Changeset 78 in tspsg-svn for trunk/src/settingsdialog.cpp
- Timestamp:
- Dec 18, 2009, 1:57:39 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/settingsdialog.cpp
r67 r78 35 35 setupUi(this); 36 36 // Laying out elements 37 layoutCitiesLimit = new QHBoxLayout(); 38 layoutCitiesLimit->setMargin(0); 39 layoutCitiesLimit->setSpacing(0); 40 layoutCitiesLimit->addSpacing(10); 41 layoutCitiesLimit->addWidget(cbCitiesLimit); 42 layoutCitiesLimit->addWidget(spinCitiesLimit); 43 layoutCitiesLimit->addStretch(); 44 45 buttonBox->button(QDialogButtonBox::Save)->setIcon(QIcon(":/images/icons/button_ok.png")); 46 buttonBox->button(QDialogButtonBox::Save)->setStatusTip(trUtf8("Save new preferences")); 47 buttonBox->button(QDialogButtonBox::Save)->setCursor(QCursor(Qt::PointingHandCursor)); 48 buttonBox->button(QDialogButtonBox::Cancel)->setIcon(QIcon(":/images/icons/button_cancel.png")); 49 buttonBox->button(QDialogButtonBox::Cancel)->setStatusTip(trUtf8("Close without saving preferences")); 50 buttonBox->button(QDialogButtonBox::Cancel)->setCursor(QCursor(Qt::PointingHandCursor)); 51 37 52 #ifdef Q_OS_WINCE 38 53 // Layout helper elements 39 54 QVBoxLayout *vbox1, *vbox2; 40 55 QHBoxLayout *hbox1, *hbox2; 41 QSpacerItem *spacer;42 56 43 57 labelRandMin->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); … … 48 62 vbox2->addWidget(groupRandomSettings); 49 63 vbox2->addWidget(groupOutputSettings); 50 spacer = new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding); 51 vbox2->addItem(spacer); 64 vbox2->addStretch(); 65 vbox2->addWidget(cbShowMatrix); 66 vbox2->addLayout(layoutCitiesLimit); 52 67 vbox2->addWidget(cbAutosize); 53 68 … … 62 77 hbox2->setSpacing(6); 63 78 hbox2->addWidget(buttonHelp); 64 spacer = new QSpacerItem(0,0,QSizePolicy::Expanding); 65 hbox2->addItem(spacer); 66 hbox2->addWidget(buttonOK); 67 hbox2->addWidget(buttonCancel); 79 hbox2->addStretch(); 80 hbox2->addWidget(buttonBox); 68 81 69 82 // Central layout … … 78 91 QVBoxLayout *vbox1, *vbox2, *vbox3; 79 92 QHBoxLayout *hbox1, *hbox2, *hbox3; 80 QSpacerItem *spacer;81 93 82 94 cbSaveState = new QCheckBox(bgWhite); … … 93 105 imgIcon->setFrameShape(QFrame::Panel); 94 106 imgIcon->setLineWidth(0); 95 imgIcon->setPixmap(QPixmap( QString::fromUtf8(":/images/icons/preferences_system.png")));107 imgIcon->setPixmap(QPixmap(":/images/icons/preferences_system.png")); 96 108 imgIcon->setStyleSheet("background-color: #0080C0;"); 97 109 imgIcon->setAlignment(Qt::AlignCenter); 110 imgIcon->setMinimumWidth(150); 98 111 99 112 labelHint = new QLabel(bgGrey); … … 131 144 hbox2->addWidget(groupRandomSettings); 132 145 hbox2->addWidget(groupOutputSettings); 133 spacer = new QSpacerItem(0,0,QSizePolicy::Expanding); 134 hbox2->addItem(spacer); 146 hbox2->addStretch(); 135 147 136 148 // Top right part (with white bg) 137 149 vbox2 = new QVBoxLayout(bgWhite); 138 spacer = new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding); 139 vbox2->addItem(spacer); 150 vbox2->addStretch(); 140 151 vbox2->addLayout(hbox2); 152 vbox2->addWidget(cbShowMatrix); 153 vbox2->addLayout(layoutCitiesLimit); 141 154 vbox2->addWidget(cbAutosize); 142 155 vbox2->addWidget(cbSaveState); 143 spacer = new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding); 144 vbox2->addItem(spacer); 156 vbox2->addStretch(); 145 157 146 158 // Bottom part (with grey bg) … … 150 162 hbox3->addWidget(buttonHelp); 151 163 hbox3->addWidget(labelHint); 152 hbox3->addWidget(buttonOK); 153 hbox3->addWidget(buttonCancel); 164 hbox3->addWidget(buttonBox); 154 165 155 166 // Central layout … … 161 172 vbox1->addWidget(bgGrey); 162 173 #endif // Q_OS_WINCE 163 connect(buttonOK,SIGNAL(clicked()),this,SLOT(accept()));164 connect(buttonCancel,SIGNAL(clicked()),this,SLOT(reject()));165 174 connect(spinRandMin,SIGNAL(valueChanged(int)),this,SLOT(spinRandMinValueChanged(int))); 166 175 connect(buttonFont,SIGNAL(clicked()),this,SLOT(buttonFontClicked())); … … 169 178 setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint); 170 179 #ifndef Q_OS_WINCE 171 // Setting initial text of dialog hint label to own status tip 172 // text. 180 // Setting initial text of dialog hint label to own status tip text. 173 181 labelHint->setText(labelHint->statusTip()); 174 182 #endif // Q_OS_WINCE … … 182 190 cbSaveState->setChecked(settings->value("SavePos",false).toBool()); 183 191 #endif // Q_OS_WINCE 192 184 193 settings->beginGroup("Output"); 194 cbShowMatrix->setChecked(settings->value("ShowMatrix", DEF_SHOW_MATRIX).toBool()); 195 cbCitiesLimit->setEnabled(cbShowMatrix->isChecked()); 196 cbCitiesLimit->setChecked(settings->value("UseShowMatrixLimit", DEF_USE_SHOW_MATRIX_LIMIT && cbShowMatrix->isChecked()).toBool()); 197 spinCitiesLimit->setEnabled(cbShowMatrix->isChecked()); 198 spinCitiesLimit->setValue(settings->value("ShowMatrixCitiesLimit", DEF_SHOW_MATRIX_CITY_LIMIT).toInt()); 199 spinCitiesLimit->setMaximum(MAX_NUM_CITIES); 200 185 201 font = settings->value("Font",QFont(DEF_FONT_FAMILY,DEF_FONT_SIZE)).value<QFont>(); 186 202 color = settings->value("Color",DEF_FONT_COLOR).value<QColor>(); 187 203 settings->endGroup(); 204 205 adjustSize(); 188 206 } 189 207 … … 211 229 { 212 230 #ifndef Q_OS_WINCE 213 settings->setValue("SavePos",cbSaveState->isChecked()); 214 #endif // Q_OS_WINCE 215 settings->setValue("Autosize",cbAutosize->isChecked()); 216 settings->setValue("MinCost",spinRandMin->value()); 217 settings->setValue("MaxCost",spinRandMax->value()); 231 settings->setValue("SavePos", cbSaveState->isChecked()); 232 #endif // Q_OS_WINCE 233 settings->setValue("Autosize", cbAutosize->isChecked()); 234 settings->setValue("MinCost", spinRandMin->value()); 235 settings->setValue("MaxCost", spinRandMax->value()); 236 218 237 settings->beginGroup("Output"); 238 settings->setValue("ShowMatrix", cbShowMatrix->isChecked()); 239 settings->setValue("UseShowMatrixLimit", cbShowMatrix->isChecked() && cbCitiesLimit->isChecked()); 240 if (cbCitiesLimit->isChecked()) 241 settings->setValue("ShowMatrixCitiesLimit", spinCitiesLimit->value()); 219 242 if (newFont) 220 settings->setValue("Font", font);243 settings->setValue("Font", font); 221 244 if (newColor) 222 settings->setValue("Color", color);245 settings->setValue("Color", color); 223 246 settings->endGroup(); 224 247 QDialog::accept(); … … 261 284 labelHint->setText(labelHint->statusTip()); 262 285 return true; 263 // Making imgIcon square.264 } else if (ev->type() == QEvent::Show) {265 bool result = QDialog::event(ev);266 if (result)267 imgIcon->setMinimumWidth(imgIcon->height());268 return result;269 286 } else 270 287 return QDialog::event(ev);
Note: See TracChangeset
for help on using the changeset viewer.