Changeset 118 in tspsg-svn for trunk/src/mainwindow.cpp


Ignore:
Timestamp:
May 2, 2010, 11:59:26 PM (15 years ago)
Author:
laleppa
Message:

Finished toolbar customization feature.
It is not available on handheld devices (mainly, because the customization dialog is too big for a small screen).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mainwindow.cpp

    r117 r118  
    6868        connect(actionFilePrint, SIGNAL(triggered()), SLOT(actionFilePrintTriggered()));
    6969#endif // QT_NO_PRINTER
     70#ifndef HANDHELD
     71        connect(actionSettingsToolbarsConfigure, SIGNAL(triggered()), SLOT(actionSettingsToolbarsConfigureTriggered()));
     72#endif // HANDHELD
    7073        connect(actionSettingsPreferences, SIGNAL(triggered()), SLOT(actionSettingsPreferencesTriggered()));
    7174#ifdef Q_OS_WIN32
     
    395398}
    396399
     400#ifndef HANDHELD
     401void MainWindow::actionSettingsToolbarsConfigureTriggered()
     402{
     403QtToolBarDialog dlg(this);
     404        dlg.setToolBarManager(toolBarManager);
     405        dlg.exec();
     406QToolButton *tb = static_cast<QToolButton *>(toolBarMain->widgetForAction(actionFileSave));
     407        if (tb != NULL) {
     408                tb->setMenu(menuFileSaveAs);
     409                tb->setPopupMode(QToolButton::MenuButtonPopup);
     410                tb->resize(tb->sizeHint());
     411        }
     412
     413        loadToolbarList();
     414}
     415#endif // HANDHELD
     416
    397417#ifdef Q_OS_WIN32
    398418void MainWindow::actionHelpCheck4UpdatesTriggered()
     
    423443#else
    424444        title += QString("<b><a href=\"http://tspsg.sourceforge.net/\">http://tspsg.sf.net/</a></b>");
    425 #endif // Q_OS_WINCE_WM && Q_OS_SYMBIAN
     445#endif // HANDHELD
    426446
    427447QString about;
     
    825845
    826846                // Saving Main Window state
     847#ifndef HANDHELD
    827848                if (settings->value("SavePos", DEF_SAVEPOS).toBool()) {
    828849                        settings->beginGroup("MainWindow");
    829 #ifndef HANDHELD
    830850                        settings->setValue("Geometry", saveGeometry());
    831 #endif // HANDHELD
    832851                        settings->setValue("State", saveState());
     852                        settings->setValue("Toolbars", toolBarManager->saveState());
    833853                        settings->endGroup();
    834854                }
     855#endif // HANDHELD
    835856        } else {
    836857                settings->remove("SettingsReset");
     
    10601081}
    10611082
     1083void MainWindow::loadToolbarList()
     1084{
     1085        menuSettingsToolbars->clear();
     1086#ifndef HANDHELD
     1087        menuSettingsToolbars->insertAction(NULL, actionSettingsToolbarsConfigure);
     1088        menuSettingsToolbars->addSeparator();
     1089QList<QToolBar *> list = toolBarManager->toolBars();
     1090        foreach (QToolBar *t, list) {
     1091                menuSettingsToolbars->insertAction(NULL, t->toggleViewAction());
     1092        }
     1093#else // HANDHELD
     1094        menuSettingsToolbars->insertAction(NULL, toolBarMain->toggleViewAction());
     1095#endif // HANDHELD
     1096}
     1097
    10621098bool MainWindow::maybeSave()
    10631099{
     
    11281164
    11291165        loadStyleList();
    1130 
    1131         actionSettingsLanguageEnglish->setStatusTip(tr("Set application language to %1").arg("English"));
     1166        loadToolbarList();
     1167
     1168#ifndef HANDHELD
     1169        actionSettingsToolbarsConfigure->setText(tr("Configure..."));
     1170        actionSettingsToolbarsConfigure->setToolTip(tr("Customize toolbars"));
     1171#endif // HANDHELD
    11321172
    11331173#ifndef QT_NO_PRINTER
    1134         actionFilePrintPreview->setText(QApplication::translate("MainWindow", "P&rint Preview...", 0, QApplication::UnicodeUTF8));
     1174        actionFilePrintPreview->setText(tr("P&rint Preview..."));
    11351175#ifndef QT_NO_TOOLTIP
    1136         actionFilePrintPreview->setToolTip(QApplication::translate("MainWindow", "Preview solution results", 0, QApplication::UnicodeUTF8));
     1176        actionFilePrintPreview->setToolTip(tr("Preview solution results"));
    11371177#endif // QT_NO_TOOLTIP
    11381178#ifndef QT_NO_STATUSTIP
    1139         actionFilePrintPreview->setStatusTip(QApplication::translate("MainWindow", "Preview current solution results before printing", 0, QApplication::UnicodeUTF8));
     1179        actionFilePrintPreview->setStatusTip(tr("Preview current solution results before printing"));
    11401180#endif // QT_NO_STATUSTIP
    11411181
    1142         actionFilePrint->setText(QApplication::translate("MainWindow", "&Print...", 0, QApplication::UnicodeUTF8));
     1182        actionFilePrint->setText(tr("&Print..."));
    11431183#ifndef QT_NO_TOOLTIP
    1144         actionFilePrint->setToolTip(QApplication::translate("MainWindow", "Print solution", 0, QApplication::UnicodeUTF8));
     1184        actionFilePrint->setToolTip(tr("Print solution"));
    11451185#endif // QT_NO_TOOLTIP
    11461186#ifndef QT_NO_STATUSTIP
    1147         actionFilePrint->setStatusTip(QApplication::translate("MainWindow", "Print current solution results", 0, QApplication::UnicodeUTF8));
     1187        actionFilePrint->setStatusTip(tr("Print current solution results"));
    11481188#endif // QT_NO_STATUSTIP
    1149         actionFilePrint->setShortcut(QApplication::translate("MainWindow", "Ctrl+P", 0, QApplication::UnicodeUTF8));
     1189        actionFilePrint->setShortcut(tr("Ctrl+P"));
    11501190#endif // QT_NO_PRINTER
    11511191#ifdef Q_OS_WIN32
     
    12171257        //! \hack HACK: A little hack for toolbar icons to have a sane size.
    12181258#ifdef HANDHELD
    1219         toolBar->setIconSize(QSize(logicalDpiX() / 4, logicalDpiY() / 4));
    1220 #endif // HANDHELD
    1221         static_cast<QToolButton *>(toolBar->widgetForAction(actionFileSave))->setMenu(menuFileSaveAs);
    1222         static_cast<QToolButton *>(toolBar->widgetForAction(actionFileSave))->setPopupMode(QToolButton::MenuButtonPopup);
     1259        toolBarMain->setIconSize(QSize(logicalDpiX() / 4, logicalDpiY() / 4));
     1260#endif // HANDHELD
     1261QToolButton *tb = static_cast<QToolButton *>(toolBarMain->widgetForAction(actionFileSave));
     1262        if (tb != NULL)  {
     1263                tb->setMenu(menuFileSaveAs);
     1264                tb->setPopupMode(QToolButton::MenuButtonPopup);
     1265        }
    12231266
    12241267        solutionText->document()->setDefaultFont(settings->value("Output/Font", QFont(DEF_FONT_FAMILY, DEF_FONT_SIZE)).value<QFont>());
     
    12401283        menuFile->insertSeparator(actionFileExit);
    12411284
    1242         toolBar->insertAction(actionSettingsPreferences,actionFilePrint);
     1285        toolBarMain->insertAction(actionSettingsPreferences, actionFilePrint);
    12431286#endif // QT_NO_PRINTER
    1244 
    1245         menuSettings->insertAction(actionSettingsPreferences, toolBar->toggleViewAction());
    1246         menuSettings->insertSeparator(actionSettingsPreferences);
    12471287
    12481288        groupSettingsLanguageList = new QActionGroup(this);
     
    12541294        actionSettingsStyleSystem->setData(true);
    12551295        groupSettingsStyleList = new QActionGroup(this);
     1296
     1297#ifndef HANDHELD
     1298        actionSettingsToolbarsConfigure = new QAction(this);
     1299        actionSettingsToolbarsConfigure->setIcon(QIcon(":/images/icons/configure-toolbars.png"));
     1300#endif // HANDHELD
    12561301
    12571302#ifdef Q_OS_WIN32
     
    12651310        spinCities->setMaximum(MAX_NUM_CITIES);
    12661311
    1267         retranslateUi(false);
    1268 
    1269 #ifdef Q_OS_WIN32
    1270         // Adding some eyecandy in Vista and 7 :-)
    1271         if (QtWin::isCompositionEnabled() && settings->value("UseTranslucency", DEF_USE_TRANSLUCENCY).toBool())  {
    1272                 toggleTranclucency(true);
    1273         }
    1274 #endif // Q_OS_WIN32
    1275 
    12761312#ifndef HANDHELD
    12771313        toolBarManager = new QtToolBarManager;
    12781314        toolBarManager->setMainWindow(this);
    1279 QString cat = toolBar->windowTitle();
    1280         toolBarManager->addToolBar(toolBar, cat);
     1315QString cat = toolBarMain->windowTitle();
     1316        toolBarManager->addToolBar(toolBarMain, cat);
    12811317#ifndef QT_NO_PRINTER
    12821318        toolBarManager->addAction(actionFilePrintPreview, cat);
     
    12851321        toolBarManager->addAction(actionHelpContextual, cat);
    12861322//      toolBarManager->addAction(action, cat);
    1287 #endif // HANDHELD
     1323        toolBarManager->restoreState(settings->value("MainWindow/Toolbars").toByteArray());
     1324#endif // HANDHELD
     1325
     1326        retranslateUi(false);
     1327
     1328#ifdef Q_OS_WIN32
     1329        // Adding some eyecandy in Vista and 7 :-)
     1330        if (QtWin::isCompositionEnabled() && settings->value("UseTranslucency", DEF_USE_TRANSLUCENCY).toBool())  {
     1331                toggleTranclucency(true);
     1332        }
     1333#endif // Q_OS_WIN32
    12881334}
    12891335
     
    13111357#endif // Q_OS_WIN32
    13121358}
    1313 
    1314 #ifndef HANDHELD
    1315 void MainWindow::on_actionSettingsToolbars_triggered()
    1316 {
    1317 QtToolBarDialog dlg(this);
    1318         dlg.setToolBarManager(toolBarManager);
    1319         dlg.exec();
    1320 }
    1321 #endif // HANDHELD
Note: See TracChangeset for help on using the changeset viewer.