Changeset 430bd7f7e9 in tspsg for src/settingsdialog.cpp
- Timestamp:
- Jul 31, 2009, 8:23:07 PM (15 years ago)
- Branches:
- 0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
- Children:
- ec54b4490b
- Parents:
- b5c9bcb585
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/settingsdialog.cpp
rb5c9bcb585 r430bd7f7e9 1 1 /* 2 * TSPSG -TSP Solver and Generator2 * TSPSG: TSP Solver and Generator 3 3 * Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name> 4 4 * … … 25 25 26 26 SettingsDialog::SettingsDialog(QWidget *parent) 27 : QDialog(parent) 27 : QDialog(parent), newFont(false), newColor(false) 28 28 { 29 29 setupUi(this); … … 35 35 // setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint); 36 36 setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint); 37 layout()->setSizeConstraint(layout()->SetFixedSize);38 37 #ifndef Q_OS_WINCE 39 38 // Setting initial text of dialog hint label to own status tip 40 39 // text. 41 40 labelHint->setText(labelHint->statusTip()); 42 // HACK: Do not resize label hint (and dialog) when text changes43 // from one-line to two-line and vice versa. Any better solution?44 labelHint->setMaximumHeight(labelHint->height());45 labelHint->setMinimumHeight(labelHint->height());46 41 #endif // Q_OS_WINCE 47 42 settings = new QSettings(QSettings::IniFormat,QSettings::UserScope,"TSPSG","tspsg"); … … 51 46 cbSaveState->setChecked(settings->value("SavePos",false).toBool()); 52 47 #endif // Q_OS_WINCE 53 settings->beginGroup(" Print");48 settings->beginGroup("Output"); 54 49 font = settings->value("Font",QFont(DEF_FONT_FAMILY,DEF_FONT_SIZE)).value<QFont>(); 55 50 color = settings->value("Color",DEF_FONT_COLOR).value<QColor>(); 51 settings->endGroup(); 52 } 53 54 void SettingsDialog::accept() 55 { 56 56 #ifndef Q_OS_WINCE 57 s pinLeftMargin->setValue(settings->value("Offset",DEF_OFFSET).toInt());57 settings->setValue("SavePos",cbSaveState->isChecked()); 58 58 #endif // Q_OS_WINCE 59 settings->setValue("MinCost",spinRandMin->value()); 60 settings->setValue("MaxCost",spinRandMax->value()); 61 settings->beginGroup("Output"); 62 if (newFont) 63 settings->setValue("Font",font); 64 if (newColor) 65 settings->setValue("Color",color); 59 66 settings->endGroup(); 67 QDialog::accept(); 68 } 69 70 void SettingsDialog::buttonFontClicked() 71 { 72 bool ok; 73 QFont font = QFontDialog::getFont(&ok,this->font,this); 74 if (ok && (this->font != font)) { 75 this->font = font; 76 newFont = true; 77 } 78 } 79 80 void SettingsDialog::buttonColorClicked() 81 { 82 QColor color = QColorDialog::getColor(this->color,this); 83 if (color.isValid() && (this->color != color)) { 84 this->color = color; 85 newColor = true; 86 } 87 } 88 89 bool SettingsDialog::colorChanged() const 90 { 91 return newColor; 92 } 93 94 bool SettingsDialog::fontChanged() const 95 { 96 return newFont; 60 97 } 61 98 … … 77 114 } 78 115 #endif // Q_OS_WINCE 79 80 void SettingsDialog::buttonFontClicked()81 {82 bool ok;83 QFont font = QFontDialog::getFont(&ok,this->font,this);84 if (ok)85 this->font = font;86 }87 88 void SettingsDialog::buttonColorClicked()89 {90 QColor color = QColorDialog::getColor(this->color,this);91 if (color.isValid())92 this->color = color;93 }94 95 void SettingsDialog::accept()96 {97 #ifndef Q_OS_WINCE98 settings->setValue("SavePos",cbSaveState->isChecked());99 #endif // Q_OS_WINCE100 settings->setValue("MinCost",spinRandMin->value());101 settings->setValue("MaxCost",spinRandMax->value());102 settings->beginGroup("Print");103 settings->setValue("Font",font);104 settings->setValue("Color",color);105 #ifndef Q_OS_WINCE106 settings->setValue("Offset",spinLeftMargin->value());107 #endif // Q_OS_WINCE108 settings->endGroup();109 QDialog::accept();110 }
Note: See TracChangeset
for help on using the changeset viewer.