Changeset 98 in tspsg-svn for trunk/src


Ignore:
Timestamp:
Mar 12, 2010, 8:28:42 PM (15 years ago)
Author:
laleppa
Message:

+ Translatable About dialog.

  • Improved installation rules in .pro file.
  • Disabled SVG and JPEG support. They aren't needed at this point.
  • Fixed a bug when labels were hardly visible under Windows Vista/7 whith translucency on and a dark background behind the application.
  • Fixed a bug when Main Window area was blank if the application was compiled using Qt < 4.6.0.
Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/globals.h

    r97 r98  
    3232#include <QtCore>
    3333#include <QtGui>
     34#include <limits>
    3435
    3536// Version info
     
    8990        #undef INFINITY
    9091#endif
    91 #define INFINITY 1.7E+308
     92#define INFINITY std::numeric_limits<double>::infinity()
    9293//! This string represents infinite value in the table
    9394#define INFSTR "---"
     
    104105        return (modf(x, &i) == 0.0);
    105106}
     107
     108#ifdef Q_OS_WIN32
     109/*!
     110 * \brief Enables or disables a mask for the \a widget.
     111 * \param widget A widget to toggle mask on.
     112 * \param enable Set to \c true to enable mask or \c false to disable it.
     113 *
     114 *  This function is used to enable an outlined font effect for \c QLabel with a static text.
     115 */
     116void toggleStyle(QWidget *widget, bool enable);
     117#endif // Q_OS_WIN32
    106118
    107119// Sanity checks
  • trunk/src/main.cpp

    r96 r98  
    3434
    3535#ifdef STATIC_BUILD
    36         Q_IMPORT_PLUGIN(qjpeg)
    37         Q_IMPORT_PLUGIN(qsvg)
     36//      Q_IMPORT_PLUGIN(qjpeg)
     37//      Q_IMPORT_PLUGIN(qsvg)
    3838#endif
    3939
  • trunk/src/mainwindow.cpp

    r97 r98  
    295295                if (untitled)
    296296                        setFileName();
     297#ifdef Q_OS_WIN32
     298                if (QtWin::isCompositionEnabled() && settings->value("UseTranslucency", DEF_USE_TRANSLUCENCY).toBool())  {
     299                        toggleStyle(labelVariant, true);
     300                        toggleStyle(labelCities, true);
     301                }
     302#endif
    297303                QApplication::restoreOverrideCursor();
    298304        }
     
    304310QString title;
    305311#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
    306         title += QString::fromUtf8("<b>TSPSG<br>TSP Solver and Generator</b><br>");
     312        title += QString("<b>TSPSG<br>TSP Solver and Generator</b><br>");
    307313#else
    308         title += QString::fromUtf8("<b>TSPSG: TSP Solver and Generator</b><br>");
    309 #endif // Q_OS_WINCE
    310         title += QString::fromUtf8("Version: <b>"BUILD_VERSION"</b><br>");
    311         title += QString::fromUtf8("<b>&copy; 2007-%1 Lёppa</b><br>").arg(QDate::currentDate().toString("yyyy"));
    312         title += QString::fromUtf8("<b><a href=\"http://tspsg.sourceforge.net/\">http://tspsg.sf.net/</a></b><br>");
     314        title += QString("<b>TSPSG: TSP Solver and Generator</b><br>");
     315#endif // Q_OS_WINCE || Q_OS_SYMBIAN
     316        title += QString("%1: <b>%2</b><br>").arg(tr("Version"), BUILD_VERSION);
     317#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN)
     318        title += QString("<b>&copy; 2007-%1 Oleksii \"Lёppa\" Serdiuk</b><br>").arg(QDate::currentDate().toString("yyyy"));
     319        title += QString("<b><a href=\"http://tspsg.sourceforge.net/\">http://tspsg.sourceforge.net/</a></b>");
     320#else
     321        title += QString("<b><a href=\"http://tspsg.sourceforge.net/\">http://tspsg.sf.net/</a></b>");
     322#endif // Q_OS_WINCE && Q_OS_SYMBIAN
     323
    313324QString about;
    314         about += QString::fromUtf8("Target OS (ARCH): <b>%1</b><br>").arg(OS);
     325        about += QString("%1: <b>%2</b><br>").arg(tr("Target OS (ARCH)"), OS);
    315326#ifndef STATIC_BUILD
    316         about += "Qt library (shared):<br>";
    317         about += QString::fromUtf8("&nbsp;&nbsp;&nbsp;&nbsp;Build time: <b>%1</b><br>").arg(QT_VERSION_STR);
    318         about += QString::fromUtf8("&nbsp;&nbsp;&nbsp;&nbsp;Runtime: <b>%1</b><br>").arg(qVersion());
     327        about += QString("%1 (%2):<br>").arg(tr("Qt library"), tr("shared"));
     328        about += QString("&nbsp;&nbsp;&nbsp;&nbsp;%1: <b>%2</b><br>").arg(tr("Build time"), QT_VERSION_STR);
     329        about += QString("&nbsp;&nbsp;&nbsp;&nbsp;%1: <b>%2</b><br>").arg(tr("Runtime"), qVersion());
    319330#else
    320         about += QString::fromUtf8("Qt library: <b>%1</b> (static)<br>").arg(QT_VERSION_STR);
     331        about += QString("%1: <b>%2</b> (%3)<br>").arg(tr("Qt library"), QT_VERSION_STR, tr("static"));
    321332#endif // STATIC_BUILD
    322         about += QString::fromUtf8("Built on <b>%1</b> at <b>%2</b><br>").arg(__DATE__).arg(__TIME__);
    323 //      about += "<br>";
    324 //      about += QString::fromUtf8("Id: <b>"VERSIONID"</b><br>");
    325         about += QString::fromUtf8("Algorithm: <b>%1</b><br>").arg(CTSPSolver::getVersionId());
     333        about += tr("Buid <b>%1</b>, built on <b>%2</b> at <b>%3</b>").arg(BUILD_NUMBER).arg(__DATE__).arg(__TIME__) + "<br>";
     334        about += QString("%1: <b>%2</b><br>").arg(tr("Algorithm"), CTSPSolver::getVersionId());
    326335        about += "<br>";
    327         about += "TSPSG is free software: you can redistribute it and/or modify it<br>"
     336        about += tr("TSPSG is free software: you can redistribute it and/or modify it<br>"
    328337                "under the terms of the GNU General Public License as published<br>"
    329338                "by the Free Software Foundation, either version 3 of the License,<br>"
     
    336345                "<br>"
    337346                "You should have received a copy of the GNU General Public License<br>"
    338                 "along with TSPSG.  If not, see <a href=\"http://www.gnu.org/licenses/\">http://www.gnu.org/licenses/</a>.";
     347                "along with TSPSG.  If not, see <a href=\"http://www.gnu.org/licenses/\">http://www.gnu.org/licenses/</a>.");
    339348
    340349QDialog *dlg = new QDialog(this);
    341350QLabel *lblIcon = new QLabel(dlg),
    342         *lblTitle = new QLabel(dlg);
     351        *lblTitle = new QLabel(dlg),
     352        *lblTranslated = new QLabel(dlg);
     353#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
     354QLabel *lblSubTitle = new QLabel(QString("<b>&copy; 2007-%1 Oleksii \"Lёppa\" Serdiuk</b>").arg(QDate::currentDate().toString("yyyy")), dlg);
     355#endif // Q_OS_WINCE || Q_OS_SYMBIAN
    343356QTextBrowser *txtAbout = new QTextBrowser(dlg);
    344357QVBoxLayout *vb = new QVBoxLayout();
    345 QHBoxLayout *hb = new QHBoxLayout();
     358QHBoxLayout *hb1 = new QHBoxLayout(),
     359        *hb2 = new QHBoxLayout();
    346360QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, dlg);
    347361
    348362        lblIcon->setPixmap(QPixmap(":/images/tspsg.png").scaledToWidth(logicalDpiX() * 2 / 3, Qt::SmoothTransformation));
    349363        lblIcon->setAlignment(Qt::AlignTop);
     364#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN)
     365        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()));
     366#endif
     367
    350368        lblTitle->setOpenExternalLinks(true);
    351369        lblTitle->setText(title);
    352 
    353         hb->addWidget(lblIcon);
    354         hb->addWidget(lblTitle);
    355         hb->addStretch();
    356 
    357 //      txtAbout->setTextInteractionFlags(txtAbout->textInteractionFlags() ^ Qt::TextEditable);
     370        lblTitle->setAlignment(Qt::AlignTop);
     371        lblTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
     372#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN)
     373        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()));
     374#endif
     375
     376        hb1->addWidget(lblIcon);
     377        hb1->addWidget(lblTitle);
     378
    358379        txtAbout->setWordWrapMode(QTextOption::NoWrap);
    359380        txtAbout->setOpenExternalLinks(true);
    360381        txtAbout->setHtml(about);
    361382        txtAbout->moveCursor(QTextCursor::Start);
     383#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN)
     384        txtAbout->setStyleSheet(QString("QTextBrowser {border-color: %1; border-width: 1px; border-style: solid; border-radius: 3px;}").arg(palette().shadow().color().name()));
     385#endif
    362386
    363387        bb->button(QDialogButtonBox::Ok)->setCursor(QCursor(Qt::PointingHandCursor));
    364388
    365         vb->addLayout(hb);
     389        lblTranslated->setText(QApplication::translate("--------", "TRANSLATION", "Please, provide translator credits here."));
     390        if (lblTranslated->text() == "TRANSLATION")
     391                lblTranslated->hide();
     392        else {
     393                lblTranslated->setOpenExternalLinks(true);
     394#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN)
     395                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()));
     396#endif
     397                hb2->addWidget(lblTranslated);
     398        }
     399
     400        hb2->addWidget(bb);
     401
     402#if defined(Q_OS_WINCE)
     403        vb->setMargin(3);
     404#endif
     405        vb->addLayout(hb1);
     406#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
     407        vb->addWidget(lblSubTitle);
     408#endif // Q_OS_WINCE || Q_OS_SYMBIAN
    366409        vb->addWidget(txtAbout);
    367         vb->addWidget(bb);
    368 
    369         dlg->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
     410        vb->addLayout(hb2);
     411
     412        dlg->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::MSWindowsFixedSizeDialogHint);
    370413        dlg->setWindowTitle(tr("About TSPSG"));
    371414        dlg->setLayout(vb);
     
    380423#endif // Q_OS_WIN32
    381424
    382         dlg->resize(450, 400);
     425        dlg->resize(450, 350);
     426
    383427        dlg->exec();
    384428
     
    825869        scrollArea->setWidget(tabWidget);
    826870        setCentralWidget(scrollArea);
     871#else
     872        setCentralWidget(tabWidget);
    827873#endif // Q_OS_WINCE
    828874
     
    890936{
    891937#ifdef Q_OS_WIN32
     938        toggleStyle(labelVariant, enable);
     939        toggleStyle(labelCities, enable);
     940        toggleStyle(statusBar(), enable);
    892941        tabWidget->setDocumentMode(enable);
    893942        QtWin::enableBlurBehindWindow(this, enable);
  • trunk/src/pch.h

    r97 r98  
    2727
    2828#ifdef __cplusplus
    29         // Qt Libraries
    30         #include <QtCore>
    31         #include <QtGui>
    32         #include <QtSvg>
    33 
    34         // Rarely modified parts
    35         #include "version.h"
    36         #include "os.h"
    37         #ifdef Q_OS_WIN32
    38                 #include "qtwin.h"
    39         #endif // Q_OS_WIN32
     29        #include "globals.h"
    4030#endif // __cplusplus
  • trunk/src/settingsdialog.cpp

    r96 r98  
    7171        vbox1->addWidget(bgGrey);
    7272        setLayout(vbox1);
    73 #else
     73#else // Q_OS_WINCE || Q_OS_SYMBIAN
    7474        // Layout helper elements
    7575QVBoxLayout *vbox1, *vbox2;
  • trunk/src/tspsolver.cpp

    r93 r98  
    326326                        matrix[nRow][k] -= val;
    327327}
     328
     329QDebug operator<<(QDebug dbg, const TMatrix &matrix)
     330{
     331        for (int r = 0; r < matrix.count(); r++) {
     332                for (int c = 0; c < matrix.at(r).count(); c++)
     333                        dbg.space() << matrix.at(r).at(c);
     334                dbg << endl;
     335        }
     336        return dbg;
     337}
  • trunk/src/tspsolver.h

    r90 r98  
    108108};
    109109
     110#ifdef DEBUG
     111QDebug operator<<(QDebug dbg, const TMatrix &matrix);
     112#endif
     113
    110114#endif // TSPSOLVER_H
  • trunk/src/version.h

    r97 r98  
    5858        #define BUILD_VERSION_MINOR 0
    5959#endif // BUILD_VERSION_MINOR
    60 /*!
    61  * \brief TSPSG release number
    62  *
    63  *  Release number meanings:
    64  *    - 1  --  3: <b>alpha</b> 1 to 3
    65  *    - 4  --  7: <b>beta</b> 1 to 4
    66  *    - 8  -- 10: <b>rc</b> 1 to 3
    67  *    - 11 --  x: <b>release</b> 1 to x-10
    68  */
    6960#ifndef BUILD_RELEASE
     61        //! TSPSG release number
    7062        #define BUILD_RELEASE 0
    7163#endif // BUILD_RELEASE
    7264
    73 /*!
    74  * \brief Current TSPSG build number
    75  *
    76  *  This will only change on releases and will be the same as revision number.
    77  */
    7865#ifndef BUILD_NUMBER
     66        //! Current TSPSG build number
    7967        #define BUILD_NUMBER 0
    8068#endif // BUILD_NUMBER
     
    8371 * \def BUILD_STATUS
    8472 * \brief TSPSG build status
    85  *
    86  * Determined based on BUILD_NUMBER and BUILD_RELEASE.
    8773 */
    88 #ifndef TSPSG_RELEASE_BUILD
     74#if !defined(TSPSG_RELEASE_BUILD)
    8975        #define BUILD_STATUS (dev build)
    90 #elif BUILD_RELEASE < 4
    91         #define BUILD_STATUS (alpha)
    92 #elif BUILD_RELEASE < 8
    93         #define BUILD_STATUS (beta)
    94 #elif BUILD_RELEASE < 11
    95         #define BUILD_STATUS (rc)
     76#elif !defined(BUILD_STATUS)
     77        #define BUILD_STATUS (build BUILD_NUMBER)
    9678#endif // TSPSG_RELEASE_BUILD
    9779
     
    10183#define QUOTE(x) QUOTE_X(x)
    10284
    103 /*!
    104  * \def BUILD_VERSION
    105  * \brief Full version of TSPSG in the form: \c major.minor.release.build [\c status].
    106  */
    107 #ifndef BUILD_STATUS
    108         #define BUILD_VERSION QUOTE(BUILD_VERSION_MAJOR.BUILD_VERSION_MINOR.BUILD_RELEASE.BUILD_NUMBER)
    109 #else
    110         #define BUILD_VERSION QUOTE(BUILD_VERSION_MAJOR.BUILD_VERSION_MINOR.BUILD_RELEASE.BUILD_NUMBER BUILD_STATUS)
    111 #endif
     85//! Full version of TSPSG in the form: \c major.minor.release.build \c status.
     86#define BUILD_VERSION QUOTE(BUILD_VERSION_MAJOR.BUILD_VERSION_MINOR.BUILD_RELEASE BUILD_STATUS)
    11287
    11388#endif // VERSION_H
Note: See TracChangeset for help on using the changeset viewer.