27 #include <kfiledialog.h>
31 #define FILL_COLOR QColor(255, 255, 192)
32 #define LINK_COLOR Qt::red
33 #define TEXT_COLOR Qt::black
39 setCaption(i18n(
"Umbrello Setup"));
40 setButtons(Help | Default | Apply | Ok | Cancel);
43 showButtonSeparator(
true);
44 setFaceType(KPageDialog::List);
45 m_bChangesApplied =
false;
46 m_pOptionState = state;
47 setHelp(
"umbrello/index.html", QString());
52 setupCodeImportPage();
55 setupAutoLayoutPage();
56 connect(
this, SIGNAL(okClicked()),
this, SLOT(slotOk()));
57 connect(
this, SIGNAL(applyClicked()),
this, SLOT(slotApply()));
58 connect(
this, SIGNAL(defaultClicked()),
this, SLOT(slotDefault()));
65 void SettingsDlg::setupUIPage()
70 QVBoxLayout* uiPageLayout =
new QVBoxLayout(page);
72 pageUserInterface =
new KPageWidgetItem(page, i18n(
"User Interface"));
73 pageUserInterface->setHeader(i18n(
"User Interface Settings"));
75 addPage(pageUserInterface);
77 m_UiWidgets.colorGB =
new QGroupBox(i18nc(
"color group box",
"Color"), page);
78 QGridLayout * colorLayout =
new QGridLayout(m_UiWidgets.colorGB);
79 colorLayout->setSpacing(spacingHint());
80 colorLayout->setMargin(fontMetrics().height());
81 uiPageLayout->addWidget(m_UiWidgets.colorGB);
83 uiPageLayout->addItem(
new QSpacerItem(0, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
85 m_UiWidgets.textColorCB =
new QCheckBox(i18n(
"Custom text color:"), m_UiWidgets.colorGB);
86 colorLayout->addWidget(m_UiWidgets.textColorCB, 0, 0);
88 m_UiWidgets.textColorB =
new KColorButton(m_pOptionState->
uiState.
textColor, m_UiWidgets.colorGB);
90 colorLayout->addWidget(m_UiWidgets.textColorB, 0, 1);
92 m_UiWidgets.lineColorCB =
new QCheckBox(i18n(
"Custom line color:"), m_UiWidgets.colorGB);
93 colorLayout->addWidget(m_UiWidgets.lineColorCB, 1, 0);
95 m_UiWidgets.lineColorB =
new KColorButton(m_pOptionState->
uiState.
lineColor, m_UiWidgets.colorGB);
97 colorLayout->addWidget(m_UiWidgets.lineColorB, 1, 1);
102 m_UiWidgets.fillColorCB =
new QCheckBox(i18n(
"Custom fill color:"), m_UiWidgets.colorGB);
103 colorLayout->addWidget(m_UiWidgets.fillColorCB, 2, 0);
105 m_UiWidgets.fillColorB =
new KColorButton(m_pOptionState->
uiState.
fillColor, m_UiWidgets.colorGB);
106 colorLayout->addWidget(m_UiWidgets.fillColorB, 2, 1);
108 m_UiWidgets.gridColorCB =
new QCheckBox(i18n(
"Custom grid color:"), m_UiWidgets.colorGB);
109 colorLayout->addWidget(m_UiWidgets.gridColorCB, 3, 0);
111 m_UiWidgets.gridColorB =
new KColorButton(m_pOptionState->
uiState.
gridDotColor, m_UiWidgets.colorGB);
112 colorLayout->addWidget(m_UiWidgets.gridColorB, 3, 1);
114 m_UiWidgets.bgColorCB =
new QCheckBox(i18n(
"Custom background color:"), m_UiWidgets.colorGB);
115 colorLayout->addWidget(m_UiWidgets.bgColorCB, 4, 0);
118 colorLayout->addWidget(m_UiWidgets.bgColorB, 4, 1);
120 m_UiWidgets.lineWidthCB =
new QCheckBox(i18n(
"Custom line width:"), m_UiWidgets.colorGB);
121 colorLayout->addWidget(m_UiWidgets.lineWidthCB, 5, 0);
123 m_UiWidgets.lineWidthB =
new KIntSpinBox(0, 10, 1, m_pOptionState->
uiState.
lineWidth, m_UiWidgets.colorGB);
124 colorLayout->addWidget(m_UiWidgets.lineWidthB, 5, 1);
126 m_UiWidgets.useFillColorCB =
new QCheckBox(i18n(
"&Use fill color"), m_UiWidgets.colorGB);
128 colorLayout->addWidget(m_UiWidgets.useFillColorCB, 6, 0);
132 connect(m_UiWidgets.textColorCB, SIGNAL(toggled(
bool)),
this, SLOT(slotTextCBChecked(
bool)));
133 connect(m_UiWidgets.lineColorCB, SIGNAL(toggled(
bool)),
this, SLOT(slotLineCBChecked(
bool)));
134 connect(m_UiWidgets.fillColorCB, SIGNAL(toggled(
bool)),
this, SLOT(slotFillCBChecked(
bool)));
135 connect(m_UiWidgets.gridColorCB, SIGNAL(toggled(
bool)),
this, SLOT(slotGridCBChecked(
bool)));
136 connect(m_UiWidgets.bgColorCB, SIGNAL(toggled(
bool)),
this, SLOT(slotBgCBChecked(
bool)));
137 connect(m_UiWidgets.lineWidthCB, SIGNAL(toggled(
bool)),
this, SLOT(slotLineWidthCBChecked(
bool)));
140 if (m_UiWidgets.textColorB->color() ==
TEXT_COLOR) {
141 m_UiWidgets.textColorCB->setChecked(
false);
142 m_UiWidgets.textColorB->setDisabled(
true);
145 m_UiWidgets.textColorCB->setChecked(
true);
148 if (m_UiWidgets.fillColorB->color() ==
FILL_COLOR) {
149 m_UiWidgets.fillColorCB->setChecked(
false);
150 m_UiWidgets.fillColorB->setDisabled(
true);
153 m_UiWidgets.fillColorCB->setChecked(
true);
156 if (m_UiWidgets.lineColorB->color() ==
LINK_COLOR) {
157 m_UiWidgets.lineColorCB->setChecked(
false);
158 m_UiWidgets.lineColorB->setDisabled(
true);
161 m_UiWidgets.lineColorCB->setChecked(
true);
164 if (m_UiWidgets.lineWidthB->value() == 0) {
165 m_UiWidgets.lineWidthCB->setChecked(
false);
166 m_UiWidgets.lineWidthB->setDisabled(
true);
169 m_UiWidgets.lineWidthCB->setChecked(
true);
170 m_UiWidgets.lineWidthB->setDisabled(
false);
174 void SettingsDlg::setupGeneralPage()
177 KVBox * page =
new KVBox();
178 pageGeneral =
new KPageWidgetItem(page, i18nc(
"general settings page",
"General"));
179 pageGeneral->setHeader(i18n(
"General Settings"));
181 addPage(pageGeneral);
185 void SettingsDlg::setupClassPage()
188 KVBox * page =
new KVBox();
189 pageClass =
new KPageWidgetItem(page, i18nc(
"class settings page",
"Class"));
190 pageClass->setHeader(i18n(
"Class Settings"));
196 void SettingsDlg::setupCodeImportPage()
199 KVBox * page =
new KVBox();
200 pageCodeImport =
new KPageWidgetItem(page, i18n(
"Code Importer"));
201 pageCodeImport->setHeader(i18n(
"Code Import Settings"));
203 addPage(pageCodeImport);
207 void SettingsDlg::setupCodeGenPage()
210 KVBox * page =
new KVBox();
211 pageCodeGen =
new KPageWidgetItem(page, i18n(
"Code Generation"));
212 pageCodeGen->setHeader(i18n(
"Code Generation Settings"));
214 addPage(pageCodeGen);
216 connect(m_pCodeGenPage, SIGNAL(languageChanged()),
this, SLOT(slotApply()));
222 KVBox * page =
new KVBox();
223 pageCodeViewer =
new KPageWidgetItem(page, i18n(
"Code Viewer"));
224 pageCodeViewer->setHeader(i18n(
"Code Viewer Settings"));
226 addPage(pageCodeViewer);
230 void SettingsDlg::setupFontPage()
232 KVBox * page =
new KVBox();
233 pageFont =
new KPageWidgetItem(page, i18n(
"Font"));
234 pageFont->setHeader(i18n(
"Font Settings"));
237 m_FontWidgets.chooser =
new KFontChooser(page, KFontChooser::NoDisplayFlags, QStringList(), 0);
238 m_FontWidgets.chooser->setFont(m_pOptionState->
uiState.
font);
241 void SettingsDlg::setupAutoLayoutPage()
243 KVBox * page =
new KVBox();
244 pageAutoLayout =
new KPageWidgetItem(page, i18n(
"Auto Layout"));
245 pageAutoLayout->setHeader(i18n(
"Auto Layout Settings"));
247 addPage(pageAutoLayout);
251 void SettingsDlg::slotApply()
253 applyPage(currentPage());
258 void SettingsDlg::slotOk()
260 applyPage(pageClass);
261 applyPage(pageGeneral);
262 applyPage(pageUserInterface);
263 applyPage(pageCodeViewer);
264 applyPage(pageCodeImport);
265 applyPage(pageCodeGen);
267 applyPage(pageAutoLayout);
271 void SettingsDlg::slotDefault()
275 KPageWidgetItem *current = currentPage();
276 if (current == pageGeneral)
280 else if (current == pageFont)
282 m_FontWidgets.chooser->setFont(parentWidget()->font());
284 else if (current == pageUserInterface)
286 m_UiWidgets.useFillColorCB->setChecked(
true);
290 m_UiWidgets.lineWidthB->setValue(0);
292 else if (current == pageClass)
296 else if (current == pageCodeImport)
300 else if (current == pageCodeGen)
303 else if (current == pageCodeViewer)
306 else if (current == pageAutoLayout)
312 void SettingsDlg::applyPage(KPageWidgetItem*item)
314 m_bChangesApplied =
true;
315 if (item == pageGeneral)
317 m_pGeneralPage->
apply();
319 else if (item == pageFont)
321 m_pOptionState->
uiState.
font = m_FontWidgets.chooser->font();
323 else if (item == pageUserInterface)
333 else if (item == pageClass)
335 m_pClassPage->
apply();
337 else if (item == pageCodeImport)
339 m_pCodeImportPage->
apply();
341 else if (item == pageCodeGen)
343 m_pCodeGenPage->
apply();
345 else if (item == pageCodeViewer)
347 m_pCodeViewerPage->
apply();
350 else if (item == pageAutoLayout)
352 m_pAutoLayoutPage->
apply();
356 void SettingsDlg::slotTextCBChecked(
bool value)
358 if (value ==
false) {
360 m_UiWidgets.textColorB->setDisabled(
true);
363 m_UiWidgets.textColorB->setDisabled(
false);
367 void SettingsDlg::slotLineCBChecked(
bool value)
369 if (value ==
false) {
371 m_UiWidgets.lineColorB->setDisabled(
true);
374 m_UiWidgets.lineColorB->setDisabled(
false);
378 void SettingsDlg::slotFillCBChecked(
bool value)
380 if (value ==
false) {
382 m_UiWidgets.fillColorB->setDisabled(
true);
385 m_UiWidgets.fillColorB->setDisabled(
false);
389 void SettingsDlg::slotGridCBChecked(
bool value)
391 if (value ==
false) {
393 m_UiWidgets.gridColorB->setColor(palette.alternateBase().color());
394 m_UiWidgets.gridColorB->setDisabled(
true);
397 m_UiWidgets.gridColorB->setDisabled(
false);
401 void SettingsDlg::slotBgCBChecked(
bool value)
403 if (value ==
false) {
405 m_UiWidgets.bgColorB->setColor(palette.base().color());
406 m_UiWidgets.bgColorB->setDisabled(
true);
409 m_UiWidgets.bgColorB->setDisabled(
false);
413 void SettingsDlg::slotLineWidthCBChecked(
bool value)
415 if (value ==
false) {
416 m_UiWidgets.lineWidthB->setValue(0);
417 m_UiWidgets.lineWidthB->setDisabled(
true);
420 m_UiWidgets.lineWidthB->setDisabled(
false);
429 #include "settingsdlg.moc"
A dialog page to display options for class related options.
SettingsDlg(QWidget *parent, Settings::OptionState *state)
KIcon DesktopIcon(IconType type)
Returns the pixmap for the given type as desktop icon.
void setDefaults()
sets default values
QString getLanguage()
Returns the user selected language used for code generation.
void apply()
Reads the set values from their corresponding widgets, writes them back to the data structure...
void apply()
apply changes
void setDefaults()
sets default values
Settings::CodeViewerState getOptions()
void apply()
Reads the set values from their corresponding widgets, writes them back to the data structure...
void setDefaults()
Sets default values.
This class is used in the code generation wizard and also in SettingsDlg.
void apply()
Reads the set values from their corresponding widgets, writes them back to the data structure...
configurable params for the code viewer tool
CodeViewerState codeViewerState
QString getCodeGenerationLanguage()
This class is used in the code generation wizard and also in SettingsDlg.
A dialog page to display auto layouts options.
A dialog page to display auto layouts options.
void apply()
Reads the set values from their corresponding widgets, writes them back to the data structure...