- Timestamp:
- Apr 30, 2010, 5:59:09 PM (15 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/mainwindow.cpp
r114 r115 36 36 settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, "TSPSG", "tspsg", this); 37 37 38 if (settings->contains("Style")) { 39 QStyle *s = QStyleFactory::create(settings->value("Style").toString()); 40 if (s != NULL) 41 QApplication::setStyle(s); 42 else 43 settings->remove("Style"); 44 } 45 38 46 loadLanguage(); 39 47 setupUi(); … … 66 74 connect(actionSettingsLanguageAutodetect, SIGNAL(triggered(bool)), SLOT(actionSettingsLanguageAutodetectTriggered(bool))); 67 75 connect(groupSettingsLanguageList, SIGNAL(triggered(QAction *)), SLOT(groupSettingsLanguageListTriggered(QAction *))); 76 connect(actionSettingsStyleSystem, SIGNAL(triggered(bool)), SLOT(actionSettingsStyleSystemTriggered(bool))); 77 connect(groupSettingsStyleList, SIGNAL(triggered(QAction*)), SLOT(groupSettingsStyleListTriggered(QAction*))); 68 78 connect(actionHelpAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); 69 79 connect(actionHelpAbout, SIGNAL(triggered()), SLOT(actionHelpAboutTriggered())); … … 337 347 if (checked) { 338 348 settings->remove("Language"); 339 QMessageBox::information(this, tr("Language change"), tr("Language will be autodetected on the next application start."));349 QMessageBox::information(this, tr("Language change"), tr("Language will be autodetected on the next %1 start.").arg(QApplication::applicationName())); 340 350 } else 341 351 settings->setValue("Language", groupSettingsLanguageList->checkedAction()->data().toString()); … … 367 377 if (!solutionText->document()->isEmpty()) 368 378 QMessageBox::information(this, tr("Settings Changed"), tr("You have changed the application language.\nTo get current solution output in the new language\nyou need to re-run the solution process.")); 379 } 380 } 381 382 void MainWindow::actionSettingsStyleSystemTriggered(bool checked) 383 { 384 if (checked) { 385 settings->remove("Style"); 386 QMessageBox::information(this, tr("Style Change"), tr("To apply the default style you need to restart %1.").arg(QApplication::applicationName())); 387 } else { 388 settings->setValue("Style", groupSettingsStyleList->checkedAction()->text()); 389 } 390 } 391 392 void MainWindow::groupSettingsStyleListTriggered(QAction *action) 393 { 394 QStyle *s = QStyleFactory::create(action->text()); 395 if (s != NULL) { 396 QApplication::setStyle(s); 397 settings->setValue("Style", action->text()); 398 actionSettingsStyleSystem->setChecked(false); 369 399 } 370 400 } … … 443 473 lblTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); 444 474 #ifndef HANDHELD 445 lblTitle->setStyleSheet(QString("QLabel {background-color: %1; border-color: %2; border-width: 1px; border-style: solid; border-radius: 3px;}").arg(palette().window().color().name(), palette().shadow().color().name()));475 lblTitle->setStyleSheet(QString("QLabel {background-color: %1; border-color: %2; border-width: 1px; border-style: solid; border-radius: 4px; padding: 1px;}").arg(palette().alternateBase().color().name(), palette().shadow().color().name())); 446 476 #endif // HANDHELD 447 477 … … 449 479 lblIcon->setAlignment(Qt::AlignVCenter); 450 480 #ifndef HANDHELD 451 lblIcon->setStyleSheet(QString("QLabel {background-color: %1; border-color: %2; border-width: 1px; border-style: solid; border-radius: 3px;}").arg(palette().window().color().name(),palette().windowText().color().name()));481 lblIcon->setStyleSheet(QString("QLabel {background-color: white; border-color: %1; border-width: 1px; border-style: solid; border-radius: 4px; padding: 1px;}").arg(palette().windowText().color().name())); 452 482 #endif // HANDHELD 453 483 … … 460 490 txtAbout->moveCursor(QTextCursor::Start); 461 491 #ifndef HANDHELD 462 txtAbout->setStyleSheet(QString("QTextBrowser {b order-color: %1; border-width: 1px; border-style: solid; border-radius: 3px;}").arg(palette().shadow().color().name()));492 txtAbout->setStyleSheet(QString("QTextBrowser {background-color: %1; border-color: %2; border-width: 1px; border-style: solid; border-radius: 4px; padding: 1px;}").arg(palette().base().color().name(), palette().shadow().color().name())); 463 493 #endif // HANDHELD 464 494 … … 471 501 lblTranslated->setOpenExternalLinks(true); 472 502 #ifndef HANDHELD 473 lblTranslated->setStyleSheet(QString("QLabel {background-color: %1; border-color: %2; border-width: 1px; border-style: solid; border-radius: 3px; }").arg(palette().window().color().name(), palette().shadow().color().name()));503 lblTranslated->setStyleSheet(QString("QLabel {background-color: %1; border-color: %2; border-width: 1px; border-style: solid; border-radius: 3px; padding: 1px;}").arg(palette().alternateBase().color().name(), palette().shadow().color().name())); 474 504 #endif // HANDHELD 475 505 hb2->addWidget(lblTranslated); … … 489 519 490 520 dlg->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); 491 dlg->setWindowTitle(tr("About TSPSG"));521 dlg->setWindowTitle(tr("About %1").arg(QApplication::applicationName())); 492 522 dlg->setLayout(vb); 493 523 … … 942 972 name = t.translate("--------", "LANGNAME", "Please, provide a native name of your translation language here."); 943 973 a = menuSettingsLanguage->addAction(name); 944 a->setStatusTip(t r("Set application language to %1").arg(name));974 a->setStatusTip(t.translate("MainWindow", "Set application language to %1", "").arg(name)); 945 975 a->setData(lang.completeBaseName().mid(6)); 946 976 a->setCheckable(true); … … 1011 1041 } 1012 1042 return true; 1043 } 1044 1045 void MainWindow::loadStyleList() 1046 { 1047 menuSettingsStyle->clear(); 1048 QStringList styles = QStyleFactory::keys(); 1049 menuSettingsStyle->insertAction(NULL, actionSettingsStyleSystem); 1050 actionSettingsStyleSystem->setChecked(!settings->contains("Style")); 1051 menuSettingsStyle->addSeparator(); 1052 QAction *a; 1053 foreach (QString style, styles) { 1054 a = menuSettingsStyle->addAction(style); 1055 a->setData(false); 1056 a->setStatusTip(tr("Set application style to %1").arg(style)); 1057 a->setCheckable(true); 1058 a->setActionGroup(groupSettingsStyleList); 1059 if ((style == settings->value("Style").toString()) 1060 || QString(QApplication::style()->metaObject()->className()).contains(QRegExp(QString("^Q?%1(Style)?$").arg(QRegExp::escape(style)), Qt::CaseInsensitive))) { 1061 a->setChecked(true); 1062 } 1063 } 1013 1064 } 1014 1065 … … 1079 1130 if (all) 1080 1131 Ui::MainWindow::retranslateUi(this); 1132 1133 loadStyleList(); 1081 1134 1082 1135 actionSettingsLanguageEnglish->setStatusTip(tr("Set application language to %1").arg("English")); … … 1197 1250 menuSettings->insertSeparator(actionSettingsPreferences); 1198 1251 1252 groupSettingsLanguageList = new QActionGroup(this); 1253 actionSettingsLanguageEnglish->setData("en"); 1254 actionSettingsLanguageEnglish->setActionGroup(groupSettingsLanguageList); 1255 loadLangList(); 1256 actionSettingsLanguageAutodetect->setChecked(settings->value("Language", "").toString().isEmpty()); 1257 1258 actionSettingsStyleSystem->setData(true); 1259 groupSettingsStyleList = new QActionGroup(this); 1260 1199 1261 #ifdef Q_OS_WIN32 1200 1262 actionHelpCheck4Updates = new QAction(this); … … 1203 1265 menuHelp->insertSeparator(actionHelpAboutQt); 1204 1266 #endif // Q_OS_WIN32 1205 1206 groupSettingsLanguageList = new QActionGroup(this);1207 actionSettingsLanguageEnglish->setData("en");1208 actionSettingsLanguageEnglish->setActionGroup(groupSettingsLanguageList);1209 loadLangList();1210 actionSettingsLanguageAutodetect->setChecked(settings->value("Language", "").toString().isEmpty());1211 1267 1212 1268 spinCities->setMaximum(MAX_NUM_CITIES); -
trunk/src/mainwindow.h
r107 r115 64 64 void actionSettingsLanguageAutodetectTriggered(bool checked); 65 65 void groupSettingsLanguageListTriggered(QAction *action); 66 void actionSettingsStyleSystemTriggered(bool checked); 67 void groupSettingsStyleListTriggered(QAction *action); 66 68 #ifdef Q_OS_WIN32 67 69 void actionHelpCheck4UpdatesTriggered(); … … 88 90 QString fileName; 89 91 QActionGroup *groupSettingsLanguageList; 92 QActionGroup *groupSettingsStyleList; 90 93 #ifndef QT_NO_PRINTER 91 94 QPrinter *printer; … … 122 125 void loadLangList(); 123 126 bool loadLanguage(const QString &lang = QString()); 127 void loadStyleList(); 124 128 bool maybeSave(); 125 129 void outputMatrix(QTextCursor &cur, const TMatrix &matrix);
Note: See TracChangeset
for help on using the changeset viewer.