27 #include <kfiledialog.h>
31 #define FILL_COLOR QColor(255, 255, 192)
32 #define LINK_COLOR Qt::red
33 #define TEXT_COLOR Qt::black
40 m_bChangesApplied =
false;
41 m_pOptionState = state;
46 setupCodeImportPage();
49 setupAutoLayoutPage();
59 void SettingsDialog::setupUIPage()
66 pageUserInterface =
new KPageWidgetItem(page, i18n(
"User Interface"));
67 pageUserInterface->setHeader(i18n(
"User Interface Settings"));
71 m_UiWidgets.colorGB =
new QGroupBox(i18nc(
"color group box",
"Color"), page);
75 uiPageLayout->
addWidget(m_UiWidgets.colorGB);
77 uiPageLayout->
addItem(
new QSpacerItem(0, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
79 m_UiWidgets.textColorCB =
new QCheckBox(i18n(
"Custom text color:"), m_UiWidgets.colorGB);
80 colorLayout->
addWidget(m_UiWidgets.textColorCB, 0, 0);
82 m_UiWidgets.textColorB =
new KColorButton(m_pOptionState->
uiState.
textColor, m_UiWidgets.colorGB);
84 colorLayout->
addWidget(m_UiWidgets.textColorB, 0, 1);
86 m_UiWidgets.lineColorCB =
new QCheckBox(i18n(
"Custom line color:"), m_UiWidgets.colorGB);
87 colorLayout->
addWidget(m_UiWidgets.lineColorCB, 1, 0);
89 m_UiWidgets.lineColorB =
new KColorButton(m_pOptionState->
uiState.
lineColor, m_UiWidgets.colorGB);
91 colorLayout->
addWidget(m_UiWidgets.lineColorB, 1, 1);
96 m_UiWidgets.fillColorCB =
new QCheckBox(i18n(
"Custom fill color:"), m_UiWidgets.colorGB);
97 colorLayout->
addWidget(m_UiWidgets.fillColorCB, 2, 0);
99 m_UiWidgets.fillColorB =
new KColorButton(m_pOptionState->
uiState.
fillColor, m_UiWidgets.colorGB);
100 colorLayout->
addWidget(m_UiWidgets.fillColorB, 2, 1);
102 m_UiWidgets.gridColorCB =
new QCheckBox(i18n(
"Custom grid color:"), m_UiWidgets.colorGB);
103 colorLayout->
addWidget(m_UiWidgets.gridColorCB, 3, 0);
105 m_UiWidgets.gridColorB =
new KColorButton(m_pOptionState->
uiState.
gridDotColor, m_UiWidgets.colorGB);
106 colorLayout->
addWidget(m_UiWidgets.gridColorB, 3, 1);
108 m_UiWidgets.bgColorCB =
new QCheckBox(i18n(
"Custom background color:"), m_UiWidgets.colorGB);
109 colorLayout->
addWidget(m_UiWidgets.bgColorCB, 4, 0);
112 colorLayout->
addWidget(m_UiWidgets.bgColorB, 4, 1);
114 m_UiWidgets.lineWidthCB =
new QCheckBox(i18n(
"Custom line width:"), m_UiWidgets.colorGB);
115 colorLayout->
addWidget(m_UiWidgets.lineWidthCB, 5, 0);
117 m_UiWidgets.lineWidthB =
new KIntSpinBox(0, 10, 1, m_pOptionState->
uiState.
lineWidth, m_UiWidgets.colorGB);
118 colorLayout->
addWidget(m_UiWidgets.lineWidthB, 5, 1);
120 m_UiWidgets.useFillColorCB =
new QCheckBox(i18n(
"&Use fill color"), m_UiWidgets.colorGB);
122 colorLayout->
addWidget(m_UiWidgets.useFillColorCB, 6, 0);
126 connect(m_UiWidgets.textColorCB, SIGNAL(toggled(
bool)),
this, SLOT(slotTextCBChecked(
bool)));
127 connect(m_UiWidgets.lineColorCB, SIGNAL(toggled(
bool)),
this, SLOT(slotLineCBChecked(
bool)));
128 connect(m_UiWidgets.fillColorCB, SIGNAL(toggled(
bool)),
this, SLOT(slotFillCBChecked(
bool)));
129 connect(m_UiWidgets.gridColorCB, SIGNAL(toggled(
bool)),
this, SLOT(slotGridCBChecked(
bool)));
130 connect(m_UiWidgets.bgColorCB, SIGNAL(toggled(
bool)),
this, SLOT(slotBgCBChecked(
bool)));
131 connect(m_UiWidgets.lineWidthCB, SIGNAL(toggled(
bool)),
this, SLOT(slotLineWidthCBChecked(
bool)));
134 if (m_UiWidgets.textColorB->color() ==
TEXT_COLOR) {
135 m_UiWidgets.textColorCB->setChecked(
false);
136 m_UiWidgets.textColorB->setDisabled(
true);
139 m_UiWidgets.textColorCB->setChecked(
true);
142 if (m_UiWidgets.fillColorB->color() ==
FILL_COLOR) {
143 m_UiWidgets.fillColorCB->setChecked(
false);
144 m_UiWidgets.fillColorB->setDisabled(
true);
147 m_UiWidgets.fillColorCB->setChecked(
true);
150 if (m_UiWidgets.lineColorB->color() ==
LINK_COLOR) {
151 m_UiWidgets.lineColorCB->setChecked(
false);
152 m_UiWidgets.lineColorB->setDisabled(
true);
155 m_UiWidgets.lineColorCB->setChecked(
true);
158 if (m_UiWidgets.lineWidthB->value() == 0) {
159 m_UiWidgets.lineWidthCB->setChecked(
false);
160 m_UiWidgets.lineWidthB->setDisabled(
true);
163 m_UiWidgets.lineWidthCB->setChecked(
true);
164 m_UiWidgets.lineWidthB->setDisabled(
false);
168 void SettingsDialog::setupGeneralPage()
171 KVBox * page =
new KVBox();
172 pageGeneral =
new KPageWidgetItem(page, i18nc(
"general settings page",
"General"));
173 pageGeneral->setHeader(i18n(
"General Settings"));
179 void SettingsDialog::setupClassPage()
182 KVBox * page =
new KVBox();
183 pageClass =
new KPageWidgetItem(page, i18nc(
"class settings page",
"Class"));
184 pageClass->setHeader(i18n(
"Class Settings"));
190 void SettingsDialog::setupCodeImportPage()
193 KVBox * page =
new KVBox();
194 pageCodeImport =
new KPageWidgetItem(page, i18n(
"Code Importer"));
195 pageCodeImport->setHeader(i18n(
"Code Import Settings"));
201 void SettingsDialog::setupCodeGenPage()
204 KVBox * page =
new KVBox();
205 pageCodeGen =
new KPageWidgetItem(page, i18n(
"Code Generation"));
206 pageCodeGen->setHeader(i18n(
"Code Generation Settings"));
210 connect(m_pCodeGenPage, SIGNAL(languageChanged()),
this, SLOT(slotApply()));
216 KVBox * page =
new KVBox();
217 pageCodeViewer =
new KPageWidgetItem(page, i18n(
"Code Viewer"));
218 pageCodeViewer->setHeader(i18n(
"Code Viewer Settings"));
224 void SettingsDialog::setupFontPage()
226 KVBox * page =
new KVBox();
227 pageFont =
new KPageWidgetItem(page, i18n(
"Font"));
228 pageFont->setHeader(i18n(
"Font Settings"));
231 m_FontWidgets.chooser =
new KFontChooser(page, KFontChooser::NoDisplayFlags,
QStringList(), 0);
232 m_FontWidgets.chooser->setFont(m_pOptionState->
uiState.
font);
235 void SettingsDialog::setupAutoLayoutPage()
237 KVBox * page =
new KVBox();
238 pageAutoLayout =
new KPageWidgetItem(page, i18n(
"Auto Layout"));
239 pageAutoLayout->setHeader(i18n(
"Auto Layout Settings"));
245 void SettingsDialog::slotApply()
252 void SettingsDialog::slotOk()
254 applyPage(pageClass);
255 applyPage(pageGeneral);
256 applyPage(pageUserInterface);
257 applyPage(pageCodeViewer);
258 applyPage(pageCodeImport);
259 applyPage(pageCodeGen);
261 applyPage(pageAutoLayout);
265 void SettingsDialog::slotDefault()
270 if (current == pageGeneral)
274 else if (current == pageFont)
278 else if (current == pageUserInterface)
280 m_UiWidgets.useFillColorCB->setChecked(
true);
284 m_UiWidgets.lineWidthB->setValue(0);
286 else if (current == pageClass)
290 else if (current == pageCodeImport)
294 else if (current == pageCodeGen)
297 else if (current == pageCodeViewer)
300 else if (current == pageAutoLayout)
306 void SettingsDialog::applyPage(KPageWidgetItem*item)
308 m_bChangesApplied =
true;
309 if (item == pageGeneral)
311 m_pGeneralPage->
apply();
313 else if (item == pageFont)
315 m_pOptionState->
uiState.
font = m_FontWidgets.chooser->font();
317 else if (item == pageUserInterface)
327 else if (item == pageClass)
329 m_pClassPage->
apply();
331 else if (item == pageCodeImport)
333 m_pCodeImportPage->
apply();
335 else if (item == pageCodeGen)
337 m_pCodeGenPage->
apply();
339 else if (item == pageCodeViewer)
341 m_pCodeViewerPage->
apply();
344 else if (item == pageAutoLayout)
346 m_pAutoLayoutPage->
apply();
350 void SettingsDialog::slotTextCBChecked(
bool value)
352 if (value ==
false) {
354 m_UiWidgets.textColorB->setDisabled(
true);
357 m_UiWidgets.textColorB->setDisabled(
false);
361 void SettingsDialog::slotLineCBChecked(
bool value)
363 if (value ==
false) {
365 m_UiWidgets.lineColorB->setDisabled(
true);
368 m_UiWidgets.lineColorB->setDisabled(
false);
372 void SettingsDialog::slotFillCBChecked(
bool value)
374 if (value ==
false) {
376 m_UiWidgets.fillColorB->setDisabled(
true);
379 m_UiWidgets.fillColorB->setDisabled(
false);
383 void SettingsDialog::slotGridCBChecked(
bool value)
385 if (value ==
false) {
388 m_UiWidgets.gridColorB->setDisabled(
true);
391 m_UiWidgets.gridColorB->setDisabled(
false);
395 void SettingsDialog::slotBgCBChecked(
bool value)
397 if (value ==
false) {
399 m_UiWidgets.bgColorB->setColor(palette.
base().
color());
400 m_UiWidgets.bgColorB->setDisabled(
true);
403 m_UiWidgets.bgColorB->setDisabled(
false);
407 void SettingsDialog::slotLineWidthCBChecked(
bool value)
409 if (value ==
false) {
410 m_UiWidgets.lineWidthB->setValue(0);
411 m_UiWidgets.lineWidthB->setDisabled(
true);
414 m_UiWidgets.lineWidthB->setDisabled(
false);
423 #include "settingsdialog.moc"
A dialog page to display options for class related options.
QString getCodeGenerationLanguage()
void setCaption(const QString &caption)
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 setSpacing(int spacing)
void apply()
apply changes
void setDefaults()
sets default values
const QColor & color() const
Settings::CodeViewerState getOptions()
void apply()
Reads the set values from their corresponding widgets, writes them back to the data structure...
SettingsDialog(QWidget *parent, Settings::OptionState *state)
KPageWidgetItem * currentPage()
virtual void addItem(QLayoutItem *item)
void setMargin(int margin)
const QBrush & alternateBase() const
void setDefaults()
Sets default values.
This class is used in the code generation wizard and also in SettingsDialog.
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
const QBrush & base() const
void addPage(KPageWidgetItem *page)
This class is used in the code generation wizard and also in SettingsDialog.
A dialog page to display auto layouts options.
A dialog page to display auto layouts options.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Base class for property dialogs.
void apply()
Reads the set values from their corresponding widgets, writes them back to the data structure...