Changeset 278bc7818f in tspsg for src
- Timestamp:
- Feb 27, 2010, 2:13:50 PM (15 years ago)
- Branches:
- 0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
- Children:
- 162d5c5f94
- Parents:
- b2bf8e3b6b
- Location:
- src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/defaults.h
rb2bf8e3b6b r278bc7818f 45 45 #endif // Q_OS_WINCE 46 46 //! Default for "Save main window state and position" 47 #define DEF_SAVEPOS false47 #define DEF_SAVEPOS true 48 48 //! Default for "Use translucency effects in Vista/7" 49 49 #define DEF_USE_TRANSLUCENCY true … … 58 58 //! Default for "Fractional random values" 59 59 #define DEF_FRACTIONAL_RANDOM false 60 //! Default for "Symmetric tasks mode" 61 #define DEF_SYMMETRIC_MODE false 60 62 61 63 //////// OUTPUT … … 67 69 #define DEF_SHOW_MATRIX_LIMIT 15 68 70 //! Default for "Scroll to the end of output after solving" 69 #define DEF_SCROLL_TO_END true71 #define DEF_SCROLL_TO_END false 70 72 /*! 71 73 * \def DEF_FONT_FAMILY -
src/mainwindow.cpp
rb2bf8e3b6b r278bc7818f 71 71 72 72 #if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) 73 // Centering main window 74 QRect rect = geometry(); 75 rect.moveCenter(QApplication::desktop()->availableGeometry(this).center()); 76 setGeometry(rect); 73 77 if (settings->value("SavePos", DEF_SAVEPOS).toBool()) { 74 78 // Loading of saved window state … … 77 81 restoreState(settings->value("State").toByteArray()); 78 82 settings->endGroup(); 79 } else {80 // Centering main window81 QRect rect = geometry();82 rect.moveCenter(QApplication::desktop()->availableGeometry(this).center());83 setGeometry(rect);84 83 } 85 84 #else … … 500 499 501 500 #ifdef Q_OS_WINCE 501 void MainWindow::changeEvent(QEvent *ev) 502 { 503 if ((ev->type() == QEvent::ActivationChange) && isActiveWindow()) 504 desktopResized(0); 505 506 QWidget::changeEvent(ev); 507 } 508 502 509 void MainWindow::desktopResized(int screen) 503 510 { 504 if ( screen != 0)511 if ((screen != 0) || !isActiveWindow()) 505 512 return; 506 513 507 514 QRect availableGeometry = QApplication::desktop()->availableGeometry(0); 508 515 if (currentGeometry != availableGeometry) { 516 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); 509 517 /*! 510 518 * \hack HACK: This hack checks whether \link QDesktopWidget::availableGeometry() availableGeometry()\endlink's \c top + \c hegiht = \link QDesktopWidget::screenGeometry() screenGeometry()\endlink's \c height. … … 519 527 setGeometry(availableGeometry); 520 528 } 521 } 522 currentGeometry = availableGeometry; 529 currentGeometry = availableGeometry; 530 QApplication::restoreOverrideCursor(); 531 } 523 532 } 524 533 #endif // Q_OS_WINCE … … 557 566 return; 558 567 } 559 settings->setValue("NumCities", spinCities->value()); 560 561 // Saving Main Window state 562 if (settings->value("SavePos", DEF_SAVEPOS).toBool()) { 563 settings->beginGroup("MainWindow"); 568 if (!settings->value("SettingsReset", false).toBool()) { 569 settings->setValue("NumCities", spinCities->value()); 570 571 // Saving Main Window state 572 if (settings->value("SavePos", DEF_SAVEPOS).toBool()) { 573 settings->beginGroup("MainWindow"); 564 574 #if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) 565 settings->setValue("Geometry", saveGeometry());575 settings->setValue("Geometry", saveGeometry()); 566 576 #endif // Q_OS_WINCE 567 settings->setValue("State", saveState()); 568 settings->endGroup(); 577 settings->setValue("State", saveState()); 578 settings->endGroup(); 579 } 580 } else { 581 settings->remove("SettingsReset"); 569 582 } 570 583 -
src/mainwindow.h
rb2bf8e3b6b r278bc7818f 72 72 void dataChanged(const QModelIndex &tl, const QModelIndex &br); 73 73 #ifdef Q_OS_WINCE 74 void changeEvent(QEvent *ev); 74 75 void desktopResized(int screen); 75 76 #endif // Q_OS_WINCE -
src/settingsdialog.cpp
rb2bf8e3b6b r278bc7818f 54 54 scrollArea->setWidgetResizable(true); 55 55 scrollArea->setWidget(bgWhite); 56 #else 57 buttons->insertStretch(buttons->indexOf(buttonHelp) + 1); 56 58 #endif // Q_OS_WINCE 57 59 … … 146 148 147 149 #ifdef Q_OS_WINCE 148 currentGeometry = QApplication::desktop()->availableGeometry(0);149 150 // We need to react to SIP show/hide and resize the window appropriately 150 151 connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), SLOT(desktopResized(int))); … … 153 154 connect(buttonFont,SIGNAL(clicked()),this,SLOT(buttonFontClicked())); 154 155 connect(buttonColor,SIGNAL(clicked()),this,SLOT(buttonColorClicked())); 155 // setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);156 156 setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint); 157 157 #if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) … … 161 161 162 162 settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, "TSPSG", "tspsg", this); 163 settings->remove("SettingsReset"); 163 164 164 165 cbAutosize->setChecked(settings->value("Autosize", DEF_AUTOSIZE).toBool()); … … 173 174 174 175 settings->beginGroup("Task"); 176 cbSymmetricMode->setChecked(settings->value("SymmetricMode", DEF_SYMMETRIC_MODE).toBool()); 175 177 spinFractionalAccuracy->setValue(settings->value("FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt()); 176 178 spinRandMin->setMaximum(MAX_RAND_VALUE); … … 194 196 settings->endGroup(); 195 197 198 #ifndef Q_OS_WINCE 196 199 adjustSize(); 200 #endif // Q_OS_WINCE 197 201 } 198 202 … … 230 234 void SettingsDialog::accept() 231 235 { 236 if (QApplication::keyboardModifiers() & Qt::ShiftModifier) { 237 if (QMessageBox::question(this, tr("Settings Reset"), tr("Do you really want to <b>reset all application settings to their defaults</b>?"), QMessageBox::RestoreDefaults | QMessageBox::Cancel) == QMessageBox::RestoreDefaults) { 238 _newFont = (font != QFont(DEF_FONT_FAMILY, DEF_FONT_SIZE)); 239 _newColor = (color != DEF_FONT_COLOR); 240 settings->remove(""); 241 settings->setValue("SettingsReset", true); 242 QDialog::accept(); 243 QMessageBox::information(this, tr("Settings Reset"), tr("All settings where successfully reset to their defaults.\nIt is recommended to restart the application now.")); 244 return; 245 } else 246 return; 247 } 232 248 #if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) 233 249 settings->setValue("SavePos", cbSaveState->isChecked()); … … 246 262 247 263 settings->beginGroup("Task"); 264 settings->setValue("SymmetricMode", cbSymmetricMode->isChecked()); 248 265 settings->setValue("FractionalAccuracy", spinFractionalAccuracy->value()); 249 266 settings->setValue("RandMin", spinRandMin->value()); … … 293 310 QRect availableGeometry = QApplication::desktop()->availableGeometry(0); 294 311 if (currentGeometry != availableGeometry) { 312 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); 295 313 /*! 296 314 * \hack HACK: This hack checks whether \link QDesktopWidget::availableGeometry() availableGeometry()\endlink's \c top + \c hegiht = \link QDesktopWidget::screenGeometry() screenGeometry()\endlink's \c height. … … 305 323 setGeometry(availableGeometry); 306 324 } 307 } 308 currentGeometry = availableGeometry; 325 currentGeometry = availableGeometry; 326 QApplication::restoreOverrideCursor(); 327 } 328 } 329 330 void SettingsDialog::showEvent(QShowEvent *ev) 331 { 332 desktopResized(0); 333 334 QWidget::showEvent(ev); 309 335 } 310 336 #endif // Q_OS_WINCE -
src/settingsdialog.h
rb2bf8e3b6b r278bc7818f 76 76 #ifdef Q_OS_WINCE 77 77 void desktopResized(int screen); 78 void showEvent(QShowEvent *ev); 78 79 #endif // Q_OS_WINCE 79 80 void spinRandMinValueChanged(int val); -
src/tspmodel.cpp
rb2bf8e3b6b r278bc7818f 191 191 void CTSPModel::randomize() 192 192 { 193 int randMin = settings->value("Task/RandMin",DEF_RAND_MIN).toInt(); 194 int randMax = settings->value("Task/RandMax",DEF_RAND_MAX).toInt(); 195 for (int r = 0; r < nCities; r++) 196 for (int c = 0; c < nCities; c++) 197 if (r != c) 198 table[r][c] = rand(randMin,randMax); 199 emit dataChanged(index(0,0),index(nCities - 1,nCities - 1)); 193 int randMin = settings->value("Task/RandMin", DEF_RAND_MIN).toInt(); 194 int randMax = settings->value("Task/RandMax", DEF_RAND_MAX).toInt(); 195 if (settings->value("Task/SymmetricMode", DEF_SYMMETRIC_MODE).toBool()) { 196 for (int r = 0; r < nCities; r++) 197 for (int c = 0; c < r; c++) 198 table[c][r] = table[r][c] = rand(randMin, randMax); 199 } else { 200 for (int r = 0; r < nCities; r++) 201 for (int c = 0; c < nCities; c++) 202 if (r != c) 203 table[r][c] = rand(randMin, randMax); 204 } 205 emit dataChanged(index(0,0), index(nCities - 1, nCities - 1)); 200 206 } 201 207 … … 315 321 if (!ok || tmp < 0) 316 322 return false; 317 else 323 else { 318 324 table[index.row()][index.column()] = tmp; 325 if (settings->value("Task/SymmetricMode", DEF_SYMMETRIC_MODE).toBool()) 326 table[index.column()][index.row()] = tmp; 327 } 319 328 } 320 329 emit dataChanged(index,index);
Note: See TracChangeset
for help on using the changeset viewer.