Changeset 134 in tspsg-svn for trunk/src


Ignore:
Timestamp:
Sep 6, 2010, 10:23:38 PM (14 years ago)
Author:
laleppa
Message:
  • The minimum required version of Qt is now 4.5.0.
  • Updated source code to be compatible with the minimum required version of Qt.
  • Updated documentation to reflect these changes.
Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/globals.h

    r129 r134  
    3131// INCLUDES
    3232#include <QtCore>
     33#if QT_VERSION < 0x040500
     34        #error You are using Qt version < 4.5 but minimum required version is 4.5.0. Compilation aborted.
     35#endif
     36#ifdef QT_NO_SVG
     37        #define NOSVG
     38#endif
    3339#include <QtGui>
    34 #if !defined(NOSVG) && (QT_VERSION >= 0x040500)
     40#if !defined(NOSVG)
    3541        #include <QtSvg>
    36 #endif // NOSVG && QT_VERSION >= 0x040500
     42#endif // NOSVG
    3743
    3844#if defined(Q_OS_WINCE_WM) || defined(Q_OS_SYMBIAN)
     
    119125#endif // Q_OS_WIN32
    120126
     127#if QT_VERSION >= 0x040600
     128        #define GET_ICON(x) QIcon::fromTheme(x, QIcon(":/images/icons/"x".png"))
     129#else
     130        #define GET_ICON(x) QIcon(":/images/icons/"x".png")
     131#endif
     132
    121133// Sanity checks
    122134// Check that default number of cities is sane (<= MAX_NUM_CITIES)
  • trunk/src/main.cpp

    r132 r134  
    2323
    2424#include "mainwindow.h"
    25 #if QT_VERSION < 0x040500
    26         #ifdef _MSC_VER
    27                 #pragma message("WARNING: You are using Qt version < 4.5. Application will not support some non-critical features.")
    28         #elif (defined(__GNUC__) || defined(__MINGW32__))
    29                 #warning WARNING: You are using Qt version < 4.5. Application will not support some non-critical features.
     25#if QT_VERSION < 0x040600
     26        #ifdef Q_CC_MSVC
     27                #pragma message("WARNING: You are using Qt version < 4.6. Application will not support some non-critical features.")
     28        #elif defined(Q_CC_GNU)
     29                #warning WARNING: You are using Qt version < 4.6. Application will not support some non-critical features.
    3030        #else
    31                 #error You are using Qt version < 4.5. Application will not support some non-critical features. To continue, please, comment line 31 at main.cpp.
     31                #error You are using Qt version < 4.6. Application will not support some non-critical features. To continue, please, comment line 31 at main.cpp.
    3232        #endif
    3333#endif
  • trunk/src/mainwindow.cpp

    r133 r134  
    226226#endif
    227227        filters.append(tr("HTML Files") + " (*.html *.htm)");
    228 #if QT_VERSION >= 0x040500
    229228        filters.append(tr("OpenDocument Files") + " (*.odt)");
    230 #endif // QT_VERSION >= 0x040500
    231229        filters.append(tr("All Files") + " (*)");
    232230
     
    258256QFileInfo fi(selectedFile);
    259257QString format = settings->value("Output/GraphImageFormat", DEF_GRAPH_IMAGE_FORMAT).toString();
    260 #if !defined(NOSVG) && (QT_VERSION >= 0x040500)
     258#if !defined(NOSVG)
    261259        if (!QImageWriter::supportedImageFormats().contains(format.toAscii()) && (format != "svg")) {
    262 #else // NOSVG && QT_VERSION >= 0x040500
     260#else // NOSVG
    263261        if (!QImageWriter::supportedImageFormats().contains(format.toAscii())) {
    264 #endif // NOSVG && QT_VERSION >= 0x040500
     262#endif // NOSVG
    265263                format = DEF_GRAPH_IMAGE_FORMAT;
    266264                settings->remove("Output/GraphImageFormat");
     
    277275
    278276                // Saving solution graph as SVG or PNG (depending on settings and SVG support)
    279 #if !defined(NOSVG) && (QT_VERSION >= 0x040500)
     277#if !defined(NOSVG)
    280278                if (format == "svg") {
    281279QSvgGenerator svg;
     
    290288                        p.end();
    291289                } else {
    292 #endif // NOSVG && QT_VERSION >= 0x040500
     290#endif // NOSVG
    293291QImage i(graph.width(), graph.height(), QImage::Format_ARGB32);
    294292                        i.fill(0x00FFFFFF);
     
    311309                                return;
    312310                        }
    313 #if !defined(NOSVG) && (QT_VERSION >= 0x040500)
    314                 }
    315 #endif // NOSVG && QT_VERSION >= 0x040500
    316 
    317 // Qt < 4.5 has no QTextDocumentWriter class
    318 #if QT_VERSION >= 0x040500
     311#if !defined(NOSVG)
     312                }
     313#endif // NOSVG
    319314        } else {
    320315QTextDocumentWriter dw(selectedFile);
     
    323318                if (!dw.write(solutionText->document()))
    324319                        QMessageBox::critical(this, tr("Solution Save"), tr("Unable to save the solution.\nError: %1").arg(dw.device()->errorString()));
    325 #endif // QT_VERSION >= 0x040500
    326320        }
    327321        QApplication::restoreOverrideCursor();
     
    565559
    566560        bb->button(QDialogButtonBox::Ok)->setCursor(QCursor(Qt::PointingHandCursor));
    567         bb->button(QDialogButtonBox::Ok)->setIcon(QIcon::fromTheme("dialog-ok", QIcon(":/images/icons/dialog-ok.png")));
     561        bb->button(QDialogButtonBox::Ok)->setIcon(GET_ICON("dialog-ok"));
    568562
    569563        hb2->addWidget(bb);
     
    599593        dlg->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
    600594        dlg->setWindowTitle(tr("About %1").arg(QApplication::applicationName()));
    601         dlg->setWindowIcon(QIcon::fromTheme("help-about", QIcon(":/images/icons/help-about.png")));
     595        dlg->setWindowIcon(GET_ICON("help-about"));
    602596        dlg->setLayout(vb);
    603597
     
    655649        pd.setBar(pb);
    656650QPushButton *cancel = new QPushButton(&pd);
    657         cancel->setIcon(QIcon::fromTheme("dialog-cancel", QIcon(":/images/icons/dialog-cancel.png")));
     651        cancel->setIcon(GET_ICON("dialog-cancel"));
    658652        cancel->setText(QApplication::translate("QProgressDialog", "Cancel", "No need to translate this. This translation will be taken from Qt translation files."));
    659653        pd.setCancelButton(cancel);
     
    12241218                a = menuSettingsLanguage->addAction(language.at(2));
    12251219                a->setStatusTip(language.at(3));
     1220#if QT_VERSION >= 0x040600
    12261221                a->setIcon(QIcon::fromTheme(QString("flag-%1").arg(language.at(1)), QIcon(QString(":/images/icons/l10n/flag-%1.png").arg(language.at(1)))));
     1222#else
     1223                a->setIcon(QIcon(QString(":/images/icons/l10n/flag-%1.png").arg(language.at(1))));
     1224#endif
    12271225                a->setData(language.at(0));
    12281226                a->setCheckable(true);
     
    14791477
    14801478        // File Menu
    1481         actionFileNew->setIcon(QIcon::fromTheme("document-new", QIcon(":/images/icons/document-new.png")));
    1482         actionFileOpen->setIcon(QIcon::fromTheme("document-open", QIcon(":/images/icons/document-open.png")));
    1483         actionFileSave->setIcon(QIcon::fromTheme("document-save", QIcon(":/images/icons/document-save.png")));
    1484         menuFileSaveAs->setIcon(QIcon::fromTheme("document-save-as", QIcon(":/images/icons/document-save-as.png")));
    1485         actionFileExit->setIcon(QIcon::fromTheme("application-exit", QIcon(":/images/icons/application-exit.png")));
     1479        actionFileNew->setIcon(GET_ICON("document-new"));
     1480        actionFileOpen->setIcon(GET_ICON("document-open"));
     1481        actionFileSave->setIcon(GET_ICON("document-save"));
     1482        menuFileSaveAs->setIcon(GET_ICON("document-save-as"));
     1483        actionFileExit->setIcon(GET_ICON("application-exit"));
    14861484        // Settings Menu
    1487         menuSettingsLanguage->setIcon(QIcon::fromTheme("preferences-desktop-locale", QIcon(":/images/icons/preferences-desktop-locale.png")));
    1488         actionSettingsLanguageEnglish->setIcon(QIcon::fromTheme("flag-gb", QIcon(":/images/icons/l10n/flag-gb.png")));
    1489         menuSettingsStyle->setIcon(QIcon::fromTheme("preferences-desktop-theme", QIcon(":/images/icons/preferences-desktop-theme.png")));
    1490         actionSettingsPreferences->setIcon(QIcon::fromTheme("preferences-system", QIcon(":/images/icons/preferences-system.png")));
     1485        menuSettingsLanguage->setIcon(GET_ICON("preferences-desktop-locale"));
     1486        actionSettingsLanguageEnglish->setIcon(GET_ICON("flag-gb"));
     1487        menuSettingsStyle->setIcon(GET_ICON("preferences-desktop-theme"));
     1488        actionSettingsPreferences->setIcon(GET_ICON("preferences-system"));
    14911489        // Help Menu
    1492         actionHelpContents->setIcon(QIcon::fromTheme("help-contents", QIcon(":/images/icons/help-contents.png")));
    1493         actionHelpContextual->setIcon(QIcon::fromTheme("help-contextual", QIcon(":/images/icons/help-contextual.png")));
    1494         actionHelpAbout->setIcon(QIcon::fromTheme("help-about", QIcon(":/images/icons/help-about.png")));
     1490        actionHelpContents->setIcon(GET_ICON("help-contents"));
     1491        actionHelpContextual->setIcon(GET_ICON("help-contextual"));
     1492        actionHelpAbout->setIcon(GET_ICON("help-about"));
    14951493        // Buttons
    1496         buttonRandom->setIcon(QIcon::fromTheme("roll", QIcon(":/images/icons/roll.png")));
    1497         buttonSolve->setIcon(QIcon::fromTheme("dialog-ok", QIcon(":/images/icons/dialog-ok.png")));
    1498         buttonSaveSolution->setIcon(QIcon::fromTheme("document-save-as", QIcon(":/images/icons/document-save-as.png")));
    1499         buttonBackToTask->setIcon(QIcon::fromTheme("go-previous", QIcon(":/images/icons/go-previous.png")));
    1500 
    1501 //      action->setIcon(QIcon::fromTheme("", QIcon(":/images/icons/.png")));
     1494        buttonRandom->setIcon(GET_ICON("roll"));
     1495        buttonSolve->setIcon(GET_ICON("dialog-ok"));
     1496        buttonSaveSolution->setIcon(GET_ICON("document-save-as"));
     1497        buttonBackToTask->setIcon(GET_ICON("go-previous"));
     1498
     1499//      action->setIcon(GET_ICON(""));
    15021500
    15031501#if QT_VERSION >= 0x040600
     
    15411539        actionFilePrintPreview->setObjectName("actionFilePrintPreview");
    15421540        actionFilePrintPreview->setEnabled(false);
    1543         actionFilePrintPreview->setIcon(QIcon::fromTheme("document-print-preview", QIcon(":/images/icons/document-print-preview.png")));
     1541        actionFilePrintPreview->setIcon(GET_ICON("document-print-preview"));
    15441542
    15451543        actionFilePrint = new QAction(this);
    15461544        actionFilePrint->setObjectName("actionFilePrint");
    15471545        actionFilePrint->setEnabled(false);
    1548         actionFilePrint->setIcon(QIcon::fromTheme("document-print", QIcon(":/images/icons/document-print.png")));
     1546        actionFilePrint->setIcon(GET_ICON("document-print"));
    15491547
    15501548        menuFile->insertAction(actionFileExit,actionFilePrintPreview);
     
    15661564#ifndef HANDHELD
    15671565        actionSettingsToolbarsConfigure = new QAction(this);
    1568         actionSettingsToolbarsConfigure->setIcon(QIcon::fromTheme("configure-toolbars", QIcon(":/images/icons/configure-toolbars.png")));
     1566        actionSettingsToolbarsConfigure->setIcon(GET_ICON("configure-toolbars"));
    15691567#endif // HANDHELD
    15701568
    15711569#ifdef Q_OS_WIN32
    15721570        actionHelpCheck4Updates = new QAction(this);
    1573         actionHelpCheck4Updates->setIcon(QIcon::fromTheme("system-software-update", QIcon(":/images/icons/system-software-update.png")));
     1571        actionHelpCheck4Updates->setIcon(GET_ICON("system-software-update"));
    15741572        actionHelpCheck4Updates->setEnabled(hasUpdater());
    15751573        menuHelp->insertAction(actionHelpAboutQt, actionHelpCheck4Updates);
  • trunk/src/settingsdialog.cpp

    r129 r134  
    3535        setupUi(this);
    3636
    37         setWindowIcon(QIcon::fromTheme("preferences-system", QIcon(":/images/icons/preferences-system.png")));
    38 
    39         buttonBox->button(QDialogButtonBox::Ok)->setIcon(QIcon::fromTheme("dialog-ok", QIcon(":/images/icons/dialog-ok.png")));
     37        setWindowIcon(GET_ICON("preferences-system"));
     38
     39        buttonBox->button(QDialogButtonBox::Ok)->setIcon(GET_ICON("dialog-ok"));
    4040        buttonBox->button(QDialogButtonBox::Ok)->setStatusTip(tr("Save new preferences"));
    4141        buttonBox->button(QDialogButtonBox::Ok)->setCursor(QCursor(Qt::PointingHandCursor));
    42         buttonBox->button(QDialogButtonBox::Cancel)->setIcon(QIcon::fromTheme("dialog-cancel", QIcon(":/images/icons/dialog-cancel.png")));
     42        buttonBox->button(QDialogButtonBox::Cancel)->setIcon(GET_ICON("dialog-cancel"));
    4343        buttonBox->button(QDialogButtonBox::Cancel)->setStatusTip(tr("Close without saving preferences"));
    4444        buttonBox->button(QDialogButtonBox::Cancel)->setCursor(QCursor(Qt::PointingHandCursor));
    4545
    46         buttonColor->setIcon(QIcon::fromTheme("format-text-color", QIcon(":/images/icons/format-text-color.png")));
    47         buttonFont->setIcon(QIcon::fromTheme("preferences-desktop-font", QIcon(":/images/icons/preferences-desktop-font.png")));
    48         buttonHelp->setIcon(QIcon::fromTheme("help-hint", QIcon(":/images/icons/help-hint.png")));
     46        buttonColor->setIcon(GET_ICON("format-text-color"));
     47        buttonFont->setIcon(GET_ICON("preferences-desktop-font"));
     48        buttonHelp->setIcon(GET_ICON("help-hint"));
    4949
    5050QPalette p = bgWhite->palette();
     
    131131        imgIcon->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding);
    132132        imgIcon->setFrameShape(QFrame::NoFrame);
    133         imgIcon->setPixmap(QIcon::fromTheme("preferences-system", QIcon(":/images/icons/preferences-system.png")).pixmap(128, 128));
     133        imgIcon->setPixmap(GET_ICON("preferences-system").pixmap(128, 128));
    134134        imgIcon->setStyleSheet("background-color: #0080C0; padding-top: 11px;");
    135135        imgIcon->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
Note: See TracChangeset for help on using the changeset viewer.