2007-12-01 10:47:15 +00:00
/*
2014-01-29 18:37:45 +00:00
Copyright 2006 - 2014 The QElectroTech Team
2007-12-01 10:47:15 +00:00
This file is part of QElectroTech .
QElectroTech is free software : you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation , either version 2 of the License , or
( at your option ) any later version .
QElectroTech is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with QElectroTech . If not , see < http : //www.gnu.org/licenses/>.
*/
2007-11-18 00:22:19 +00:00
# include "configpages.h"
2008-08-14 22:51:08 +00:00
# include "borderpropertieswidget.h"
2008-07-30 12:44:57 +00:00
# include "conductorpropertieswidget.h"
2010-12-20 02:45:36 +00:00
# include "titleblockpropertieswidget.h"
2007-11-18 00:22:19 +00:00
# include "qetapp.h"
2008-07-30 12:44:57 +00:00
# include "qetdiagrameditor.h"
2010-12-20 02:45:36 +00:00
# include "bordertitleblock.h"
2009-05-01 14:41:33 +00:00
# include "qeticons.h"
2009-08-09 12:51:02 +00:00
# include "exportpropertieswidget.h"
2014-01-18 19:04:39 +00:00
# include "ui/reportpropertiewidget.h"
2014-04-11 09:51:21 +00:00
# include "ui/xrefpropertieswidget.h"
2007-11-18 00:22:19 +00:00
/**
Constructeur
@ param parent QWidget parent
*/
NewDiagramPage : : NewDiagramPage ( QWidget * parent ) : ConfigPage ( parent ) {
2014-01-18 19:04:39 +00:00
// main tab widget
QTabWidget * tab_widget = new QTabWidget ( this ) ;
// dimensions by default for diagram
2014-07-11 16:45:18 +00:00
bpw = new BorderPropertiesWidget ( QETDiagramEditor : : defaultBorderProperties ( ) ) ;
2014-01-18 19:04:39 +00:00
// default titleblock properties
2010-12-20 02:45:36 +00:00
ipw = new TitleBlockPropertiesWidget ( QETDiagramEditor : : defaultTitleBlockProperties ( ) , true ) ;
2014-01-18 19:04:39 +00:00
QWidget * diagram_widget = new QWidget ( ) ;
QVBoxLayout * diagram_layout = new QVBoxLayout ( diagram_widget ) ;
diagram_layout - > addWidget ( bpw ) ;
diagram_layout - > addWidget ( ipw ) ;
tab_widget - > addTab ( diagram_widget , tr ( " Sch \351 ma " ) ) ;
2008-08-14 22:51:08 +00:00
2014-01-18 19:04:39 +00:00
// default conductor properties
2009-04-03 19:30:25 +00:00
cpw = new ConductorPropertiesWidget ( QETDiagramEditor : : defaultConductorProperties ( ) ) ;
2008-08-14 22:51:08 +00:00
cpw - > setContentsMargins ( 0 , 0 , 0 , 0 ) ;
2014-01-18 19:04:39 +00:00
tab_widget - > addTab ( cpw , tr ( " Conducteur " ) ) ;
// default propertie of report label
rpw = new ReportPropertieWidget ( QETDiagramEditor : : defaultReportProperties ( ) ) ;
2014-01-21 19:23:44 +00:00
tab_widget - > addTab ( rpw , tr ( " Report de folio " ) ) ;
2014-04-11 09:51:21 +00:00
// default properties of xref
xrefpw = new XRefPropertiesWidget ( QETDiagramEditor : : defaultXRefProperties ( ) , this ) ;
tab_widget - > addTab ( xrefpw , tr ( " R \351 f \351 rence crois \351 es " ) ) ;
2007-11-18 00:22:19 +00:00
QVBoxLayout * vlayout1 = new QVBoxLayout ( ) ;
2014-01-18 19:04:39 +00:00
vlayout1 - > addWidget ( tab_widget ) ;
2007-11-18 00:22:19 +00:00
setLayout ( vlayout1 ) ;
}
/// Destructeur
NewDiagramPage : : ~ NewDiagramPage ( ) {
}
/**
Applique la configuration de cette page
*/
void NewDiagramPage : : applyConf ( ) {
QSettings & settings = QETApp : : settings ( ) ;
// dimensions des nouveaux schemas
2014-07-11 16:45:18 +00:00
bpw - > properties ( ) . toSettings ( settings , " diagrameditor/default " ) ;
2007-11-18 00:22:19 +00:00
// proprietes du cartouche
2014-07-12 13:14:47 +00:00
ipw - > properties ( ) . toSettings ( settings , " diagrameditor/default " ) ;
2007-11-18 00:22:19 +00:00
// proprietes par defaut des conducteurs
2014-07-17 09:20:21 +00:00
cpw - > properties ( ) . toSettings ( settings , " diagrameditor/defaultconductor " ) ;
2014-01-18 19:04:39 +00:00
// default report propertie
rpw - > toSettings ( settings , " diagrameditor/defaultreport " ) ;
2014-04-11 09:51:21 +00:00
// default xref properties
2014-07-03 08:52:14 +00:00
QHash < QString , XRefProperties > hash_xrp = xrefpw - > properties ( ) ;
foreach ( QString key , hash_xrp . keys ( ) ) {
XRefProperties xrp = hash_xrp [ key ] ;
QString str ( " diagrameditor/defaultxref " ) ;
xrp . toSettings ( settings , str + = key ) ;
}
2007-11-18 00:22:19 +00:00
}
/// @return l'icone de cette page
QIcon NewDiagramPage : : icon ( ) const {
2009-05-01 14:41:33 +00:00
return ( QET : : Icons : : NewDiagram ) ;
2007-11-18 00:22:19 +00:00
}
/// @return le titre de cette page
QString NewDiagramPage : : title ( ) const {
2009-04-03 19:30:25 +00:00
return ( tr ( " Nouveau sch \351 ma " , " configuration page title " ) ) ;
}
/**
Constructeur
@ param parent QWidget parent
*/
GeneralConfigurationPage : : GeneralConfigurationPage ( QWidget * parent ) : ConfigPage ( parent ) {
// acces a la configuration de QElectroTech
QSettings & settings = QETApp : : settings ( ) ;
2009-05-24 17:46:44 +00:00
bool use_system_colors = settings . value ( " usesystemcolors " , " true " ) . toBool ( ) ;
2009-04-05 12:33:20 +00:00
bool tabbed = settings . value ( " diagrameditor/viewmode " , " tabbed " ) = = " tabbed " ;
2009-04-03 19:30:25 +00:00
bool integrate_elements = settings . value ( " diagrameditor/integrate-elements " , true ) . toBool ( ) ;
2012-04-29 20:29:40 +00:00
bool highlight_integrated_elements = settings . value ( " diagrameditor/highlight-integrated-elements " , true ) . toBool ( ) ;
2010-02-14 16:28:45 +00:00
QString default_element_informations = settings . value ( " elementeditor/default-informations " , " " ) . toString ( ) ;
2009-04-03 19:30:25 +00:00
2009-05-24 17:46:44 +00:00
appearance_ = new QGroupBox ( tr ( " Apparence " ) , this ) ;
use_system_colors_ = new QCheckBox ( tr ( " Utiliser les couleurs du syst \350 me " ) , appearance_ ) ;
2009-04-03 19:30:25 +00:00
projects_view_mode_ = new QGroupBox ( tr ( " Projets " ) , this ) ;
windowed_mode_ = new QRadioButton ( tr ( " Utiliser des fen \352 tres " ) , projects_view_mode_ ) ;
tabbed_mode_ = new QRadioButton ( tr ( " Utiliser des onglets " ) , projects_view_mode_ ) ;
warning_view_mode_ = new QLabel ( tr ( " Ces param \350 tres s'appliqueront d \350 s la prochaine ouverture d'un \351 diteur de sch \351 mas. " ) ) ;
elements_management_ = new QGroupBox ( tr ( " Gestion des \351 l \351 ments " ) , this ) ;
2012-04-29 20:29:40 +00:00
integrate_elements_ = new QCheckBox ( tr ( " Int \351 grer automatiquement les \351 l \351 ments dans les projets (recommand \351 ) " ) ) ;
2012-05-10 06:13:27 +00:00
highlight_integrated_elements_ = new QCheckBox ( tr ( " Mettre en valeur dans le panel les \351 l \351 ments fra \356 chement int \351 gr \351 s " , " configuration option " ) ) ;
2010-02-14 16:28:45 +00:00
default_element_infos_label_ = new QLabel (
tr (
" Chaque \351 l \351 ment embarque des informations sur ses auteurs, sa licence, ou tout autre renseignement que vous jugerez utile dans un champ libre. "
" Vous pouvez sp \351 cifier ici la valeur par d \351 faut de ce champ pour les \351 l \351 ments que vous cr \351 erez : "
)
) ;
default_element_infos_label_ - > setWordWrap ( true ) ;
default_element_infos_textfield_ = new QTextEdit ( ) ;
default_element_infos_textfield_ - > setAcceptRichText ( false ) ;
2009-04-03 19:30:25 +00:00
2009-05-24 17:46:44 +00:00
use_system_colors_ - > setChecked ( use_system_colors ) ;
2009-04-03 19:30:25 +00:00
if ( tabbed ) {
tabbed_mode_ - > setChecked ( true ) ;
} else {
windowed_mode_ - > setChecked ( true ) ;
}
integrate_elements_ - > setChecked ( integrate_elements ) ;
2012-04-29 20:29:40 +00:00
highlight_integrated_elements_ - > setChecked ( highlight_integrated_elements ) ;
2010-02-14 16:28:45 +00:00
default_element_infos_textfield_ - > setPlainText ( default_element_informations ) ;
2009-04-03 19:30:25 +00:00
2009-05-24 17:46:44 +00:00
QVBoxLayout * appearance_layout = new QVBoxLayout ( ) ;
appearance_layout - > addWidget ( use_system_colors_ ) ;
appearance_ - > setLayout ( appearance_layout ) ;
2009-04-03 19:30:25 +00:00
QVBoxLayout * projects_view_mode_layout = new QVBoxLayout ( ) ;
projects_view_mode_layout - > addWidget ( windowed_mode_ ) ;
projects_view_mode_layout - > addWidget ( tabbed_mode_ ) ;
projects_view_mode_layout - > addWidget ( warning_view_mode_ ) ;
projects_view_mode_ - > setLayout ( projects_view_mode_layout ) ;
QVBoxLayout * elements_management_layout = new QVBoxLayout ( ) ;
elements_management_layout - > addWidget ( integrate_elements_ ) ;
2012-04-29 20:29:40 +00:00
elements_management_layout - > addWidget ( highlight_integrated_elements_ ) ;
2010-02-14 16:28:45 +00:00
elements_management_layout - > addWidget ( default_element_infos_label_ ) ;
elements_management_layout - > addWidget ( default_element_infos_textfield_ ) ;
2009-04-03 19:30:25 +00:00
elements_management_ - > setLayout ( elements_management_layout ) ;
2014-01-21 19:23:44 +00:00
//setup lang combo box selection widget
lang_group_box = new QGroupBox ( tr ( " Langue " ) , this ) ;
QHBoxLayout * lang_layout = new QHBoxLayout ( lang_group_box ) ;
lang_combo_box = new QComboBox ( ) ;
lang_label = new QLabel ( tr ( " La nouvelle langue sera pris en compte au prochain lancement de QElectroTech. " ) ) ;
lang_layout - > addWidget ( lang_combo_box ) ;
lang_layout - > addWidget ( lang_label ) ;
fillLang ( settings ) ;
2009-04-03 19:30:25 +00:00
QVBoxLayout * vlayout1 = new QVBoxLayout ( ) ;
QLabel * title_label_ = new QLabel ( title ( ) ) ;
vlayout1 - > addWidget ( title_label_ ) ;
QFrame * horiz_line_ = new QFrame ( ) ;
horiz_line_ - > setFrameShape ( QFrame : : HLine ) ;
vlayout1 - > addWidget ( horiz_line_ ) ;
2009-05-24 17:46:44 +00:00
vlayout1 - > addWidget ( appearance_ ) ;
2009-04-03 19:30:25 +00:00
vlayout1 - > addWidget ( projects_view_mode_ ) ;
vlayout1 - > addWidget ( elements_management_ ) ;
2014-01-21 19:23:44 +00:00
vlayout1 - > addWidget ( lang_group_box ) ;
2009-04-03 19:30:25 +00:00
vlayout1 - > addStretch ( ) ;
setLayout ( vlayout1 ) ;
}
/// Destructeur
GeneralConfigurationPage : : ~ GeneralConfigurationPage ( ) {
}
/**
2014-01-21 19:23:44 +00:00
* @ brief GeneralConfigurationPage : : applyConf
* Write all configuration in settings file
*/
2009-04-03 19:30:25 +00:00
void GeneralConfigurationPage : : applyConf ( ) {
QSettings & settings = QETApp : : settings ( ) ;
2009-05-24 17:46:44 +00:00
bool was_using_system_colors = settings . value ( " usesystemcolors " , " true " ) . toBool ( ) ;
bool must_use_system_colors = use_system_colors_ - > isChecked ( ) ;
settings . setValue ( " usesystemcolors " , must_use_system_colors ) ;
if ( was_using_system_colors ! = must_use_system_colors ) {
QETApp : : instance ( ) - > useSystemPalette ( must_use_system_colors ) ;
}
2014-01-21 19:23:44 +00:00
settings . setValue ( " lang " , lang_combo_box - > itemData ( lang_combo_box - > currentIndex ( ) ) . toString ( ) ) ;
2009-05-24 17:46:44 +00:00
2009-04-03 19:30:25 +00:00
QString view_mode = tabbed_mode_ - > isChecked ( ) ? " tabbed " : " windowed " ;
settings . setValue ( " diagrameditor/viewmode " , view_mode ) ;
settings . setValue ( " diagrameditor/integrate-elements " , integrate_elements_ - > isChecked ( ) ) ;
2012-04-29 20:29:40 +00:00
settings . setValue ( " diagrameditor/highlight-integrated-elements " , highlight_integrated_elements_ - > isChecked ( ) ) ;
2010-02-14 16:28:45 +00:00
settings . setValue ( " elementeditor/default-informations " , default_element_infos_textfield_ - > toPlainText ( ) ) ;
2009-04-03 19:30:25 +00:00
}
/// @return l'icone de cette page
QIcon GeneralConfigurationPage : : icon ( ) const {
2009-05-01 14:41:33 +00:00
return ( QET : : Icons : : Settings ) ;
2009-04-03 19:30:25 +00:00
}
/// @return le titre de cette page
QString GeneralConfigurationPage : : title ( ) const {
return ( tr ( " G \351 n \351 ral " , " configuration page title " ) ) ;
2007-11-18 00:22:19 +00:00
}
2009-08-09 12:51:02 +00:00
2014-01-21 19:23:44 +00:00
/**
* @ brief GeneralConfigurationPage : : fillLang
* fill all available lang in @ lang_combo_box
*/
void GeneralConfigurationPage : : fillLang ( QSettings & settings ) {
2014-01-27 03:20:20 +00:00
lang_combo_box - > addItem ( QET : : Icons : : translation , tr ( " Syst \350 me " ) , " system " ) ;
2014-01-21 19:23:44 +00:00
lang_combo_box - > insertSeparator ( 1 ) ;
// all lang available on lang directory
2014-01-23 08:34:47 +00:00
lang_combo_box - > addItem ( QET : : Icons : : ar , tr ( " Arabe " ) , " ar " ) ;
2014-01-23 08:55:21 +00:00
lang_combo_box - > addItem ( QET : : Icons : : catalonia , tr ( " Catalan " ) , " ca " ) ;
2014-01-23 08:34:47 +00:00
lang_combo_box - > addItem ( QET : : Icons : : cs , tr ( " Tch \350 que " ) , " cs " ) ;
2014-01-23 08:43:20 +00:00
lang_combo_box - > addItem ( QET : : Icons : : de , tr ( " Allemand " ) , " de " ) ;
2014-01-23 08:34:47 +00:00
lang_combo_box - > addItem ( QET : : Icons : : gr , tr ( " Grec " ) , " el " ) ;
lang_combo_box - > addItem ( QET : : Icons : : en , tr ( " Anglais " ) , " en " ) ;
lang_combo_box - > addItem ( QET : : Icons : : es , tr ( " Espagnol " ) , " es " ) ;
2014-01-23 08:43:20 +00:00
lang_combo_box - > addItem ( QET : : Icons : : fr , tr ( " Fran \347 ais " ) , " fr " ) ;
2014-01-23 08:34:47 +00:00
lang_combo_box - > addItem ( QET : : Icons : : hr , tr ( " Croate " ) , " hr " ) ;
lang_combo_box - > addItem ( QET : : Icons : : it , tr ( " Italien " ) , " it " ) ;
lang_combo_box - > addItem ( QET : : Icons : : pl , tr ( " Polonais " ) , " pl " ) ;
lang_combo_box - > addItem ( QET : : Icons : : pt , tr ( " Portugais " ) , " pt " ) ;
lang_combo_box - > addItem ( QET : : Icons : : ro , tr ( " Roumains " ) , " ro " ) ;
lang_combo_box - > addItem ( QET : : Icons : : ru , tr ( " Russe " ) , " ru " ) ;
lang_combo_box - > addItem ( QET : : Icons : : sl , tr ( " Slov \350 ne " ) , " sl " ) ;
2014-04-17 14:41:45 +00:00
lang_combo_box - > addItem ( QET : : Icons : : nl , tr ( " Pays-Bas " ) , " nl " ) ;
2014-05-19 16:35:13 +00:00
lang_combo_box - > addItem ( QET : : Icons : : be , tr ( " Belgique-Flemish " ) , " be " ) ;
2014-01-21 19:23:44 +00:00
//set curent index to the lang found in setting file
//if lang doesn't exist set to system
for ( int i = 0 ; i < lang_combo_box - > count ( ) ; i + + ) {
if ( lang_combo_box - > itemData ( i ) . toString ( ) = = settings . value ( " lang " ) . toString ( ) ) {
lang_combo_box - > setCurrentIndex ( i ) ;
return ;
}
}
lang_combo_box - > setCurrentIndex ( 0 ) ;
}
2009-08-09 12:51:02 +00:00
/**
Constructeur
@ param parent QWidget parent
*/
ExportConfigPage : : ExportConfigPage ( QWidget * parent ) : ConfigPage ( parent ) {
// epw contient les options d'export
epw = new ExportPropertiesWidget ( QETDiagramEditor : : defaultExportProperties ( ) ) ;
// layout vertical contenant le titre, une ligne horizontale et epw
QVBoxLayout * vlayout1 = new QVBoxLayout ( ) ;
QLabel * title = new QLabel ( this - > title ( ) ) ;
vlayout1 - > addWidget ( title ) ;
QFrame * horiz_line = new QFrame ( ) ;
horiz_line - > setFrameShape ( QFrame : : HLine ) ;
vlayout1 - > addWidget ( horiz_line ) ;
vlayout1 - > addWidget ( epw ) ;
2009-11-22 16:12:22 +00:00
vlayout1 - > addStretch ( ) ;
2009-08-09 12:51:02 +00:00
// activation du layout
setLayout ( vlayout1 ) ;
}
/// Destructeur
ExportConfigPage : : ~ ExportConfigPage ( ) {
}
/**
Applique la configuration de cette page
*/
void ExportConfigPage : : applyConf ( ) {
QSettings & settings = QETApp : : settings ( ) ;
epw - > exportProperties ( ) . toSettings ( settings , " export/default " ) ;
}
/// @return l'icone de cette page
QIcon ExportConfigPage : : icon ( ) const {
return ( QET : : Icons : : DocumentExport ) ;
}
/// @return le titre de cette page
QString ExportConfigPage : : title ( ) const {
return ( tr ( " Export " , " configuration page title " ) ) ;
}
2009-11-22 16:12:22 +00:00
/**
Constructeur
@ param parent QWidget parent
*/
PrintConfigPage : : PrintConfigPage ( QWidget * parent ) : ConfigPage ( parent ) {
// epw contient les options d'export
epw = new ExportPropertiesWidget ( QETDiagramEditor : : defaultPrintProperties ( ) ) ;
epw - > setPrintingMode ( true ) ;
// layout vertical contenant le titre, une ligne horizontale et epw
QVBoxLayout * vlayout1 = new QVBoxLayout ( ) ;
QLabel * title = new QLabel ( this - > title ( ) ) ;
vlayout1 - > addWidget ( title ) ;
QFrame * horiz_line = new QFrame ( ) ;
horiz_line - > setFrameShape ( QFrame : : HLine ) ;
vlayout1 - > addWidget ( horiz_line ) ;
vlayout1 - > addWidget ( epw ) ;
vlayout1 - > addStretch ( ) ;
// activation du layout
setLayout ( vlayout1 ) ;
}
/// Destructeur
PrintConfigPage : : ~ PrintConfigPage ( ) {
}
/**
Applique la configuration de cette page
*/
void PrintConfigPage : : applyConf ( ) {
QString prefix = " print/default " ;
QSettings & settings = QETApp : : settings ( ) ;
epw - > exportProperties ( ) . toSettings ( settings , prefix ) ;
// annule l'enregistrement de certaines proprietes non pertinentes
settings . remove ( prefix + " path " ) ;
settings . remove ( prefix + " format " ) ;
settings . remove ( prefix + " area " ) ;
}
/// @return l'icone de cette page
QIcon PrintConfigPage : : icon ( ) const {
return ( QET : : Icons : : Printer ) ;
}
/// @return le titre de cette page
QString PrintConfigPage : : title ( ) const {
return ( tr ( " Impression " , " configuration page title " ) ) ;
}