QTfrontend/ui/widget/about.cpp
changeset 8404 f06227b2ea14
parent 8391 9f2527848ffd
child 8434 4821897a0f10
equal deleted inserted replaced
8402:659e043da6da 8404:f06227b2ea14
    44 About::About(QWidget * parent) :
    44 About::About(QWidget * parent) :
    45     QWidget(parent)
    45     QWidget(parent)
    46 {
    46 {
    47     QGridLayout *mainLayout = new QGridLayout(this);
    47     QGridLayout *mainLayout = new QGridLayout(this);
    48 
    48 
       
    49     QVBoxLayout * leftLayout = new QVBoxLayout();
       
    50     mainLayout->addLayout(leftLayout, 0, 0, 2, 1);
       
    51 
    49     QLabel *imageLabel = new QLabel;
    52     QLabel *imageLabel = new QLabel;
    50     QImage image(":/res/Hedgehog.png");
    53     QImage image(":/res/Hedgehog.png");
    51     imageLabel->setPixmap(QPixmap::fromImage(image));
    54     imageLabel->setPixmap(QPixmap::fromImage(image));
    52     imageLabel->setScaledContents(true);
    55     imageLabel->setScaledContents(true);
    53     imageLabel->setMinimumWidth(2.8);
    56     imageLabel->setMinimumWidth(2.8);
    54     imageLabel->setMaximumWidth(280);
    57     imageLabel->setMaximumWidth(280);
    55     imageLabel->setMinimumHeight(30);
    58     imageLabel->setMinimumHeight(30);
    56     imageLabel->setMaximumHeight(300);
    59     imageLabel->setMaximumHeight(300);
    57 
    60 
    58     mainLayout->addWidget(imageLabel, 0, 0, 2, 1);
    61     leftLayout->addWidget(imageLabel, 0, Qt::AlignHCenter);
    59 
    62 
    60     QLabel *lbl1 = new QLabel(this);
    63     QLabel *lbl1 = new QLabel(this);
    61     lbl1->setOpenExternalLinks(true);
    64     lbl1->setOpenExternalLinks(true);
    62     lbl1->setText(
    65     lbl1->setText(
    63         "<style type=\"text/css\">"
    66         "<style type=\"text/css\">"
    64         "a { color: #ffcc00; }"
    67         "a { color: #ffcc00; }"
    65 //            "a:hover { color: yellow; }"
    68 //            "a:hover { color: yellow; }"
    66         "</style>"
    69         "</style>"
    67         "<div align=\"center\"><h1>Hedgewars</h1>"
    70         "<div align=\"center\"><h1>Hedgewars</h1>"
    68         "<h3>" + QLabel::tr("Version") + " " + *cVersionString + "</h3>"
    71         "<h3>" + QLabel::tr("Version") + " " + *cVersionString + "</h3>"
    69         "<p><a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a></p><br>" +
    72         "<p><a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a></p>" +
    70         QLabel::tr("This program is distributed under the GNU General Public License v2") +
    73         QLabel::tr("This program is distributed under the GNU General Public License v2") +
    71         "</div>"
    74         "</div>"
    72     );
    75     );
    73     lbl1->setWordWrap(true);
    76     lbl1->setWordWrap(true);
    74     mainLayout->addWidget(lbl1, 0, 1);
    77     mainLayout->addWidget(lbl1, 0, 1);
    75 
    78 
    76     QString html;
    79     lbl2 = new QTextBrowser(this);
    77     QFile file(":/res/html/about.html");
    80     lbl2->setOpenExternalLinks(true);
    78     if(!file.open(QIODevice::ReadOnly))
    81     QUrl localpage = QUrl::fromLocalFile(":/res/html/about.html"); 
    79         QMessageBox::information(0, "Error loading about page", file.errorString());
    82     lbl2->setSource(localpage); //sets the source of the label from the file above
       
    83     mainLayout->addWidget(lbl2, 1, 1);
    80 
    84 
    81     QTextStream in(&file);
    85     /* Library information */
    82 
    86 
    83     while(!in.atEnd())
    87     QString libinfo = "<style type=text/css>a:link { color: #FFFF6E; }</style>";
    84         html.append(in.readLine());
       
    85 
    88 
    86     file.close();
    89 #ifdef __GNUC__
       
    90     libinfo.append(QString("Compiler: <a href=\"http://gcc.gnu.org\">GCC</a> %1<br>").arg(__VERSION__));
       
    91 #else
       
    92     libinfo.append(QString("Compiler: Unknown<br>").arg(__VERSION__));
       
    93 #endif
    87 
    94 
    88     /* Get information */
    95     libinfo.append(QString("<a href=\"http://www.libsdl.org/\">SDL</a> version: %1.%2.%3<br>")
    89 
       
    90     QString compilerText, compilerOpen, compilerClose;
       
    91     #ifdef __GNUC__
       
    92         compilerText = "GCC " + QString(__VERSION__) + "\n";
       
    93         compilerOpen = "<a href=\"http://gcc.gnu.org\">";
       
    94         compilerClose = "</a>";
       
    95     #else
       
    96         compilerText = "Unknown\n";
       
    97         compilerOpen = compilerClose = "";
       
    98     #endif
       
    99 
       
   100     /* Add information */
       
   101 
       
   102     html.replace("%COMPILER_A_OPEN%", compilerOpen);
       
   103     html.replace("%COMPILER_A_CLOSE%", compilerClose);
       
   104     html.replace("%COMPILER%", compilerText);
       
   105     html.replace("%SDL%", QString("version: %1.%2.%3")
       
   106         .arg(SDL_MAJOR_VERSION)
    96         .arg(SDL_MAJOR_VERSION)
   107         .arg(SDL_MINOR_VERSION)
    97         .arg(SDL_MINOR_VERSION)
   108         .arg(SDL_PATCHLEVEL));
    98         .arg(SDL_PATCHLEVEL));
   109     html.replace("%QT%", QT_VERSION_STR);
    99 
       
   100     libinfo.append(QString("<a href=\"http://qt-project.org/\">Qt</a> version: %1<br>").arg(QT_VERSION_STR));
       
   101 
   110 #ifdef VIDEOREC
   102 #ifdef VIDEOREC
   111     html.replace("%LIBAV%", QString("<a href=\"http://libav.org\">Libav</a> version: %1.%2.%3")
   103     libinfo.append(QString("<a href=\"http://libav.org\">Libav</a> version: %1.%2.%3<br>")
   112         .arg(LIBAVUTIL_VERSION_MAJOR)
   104         .arg(LIBAVUTIL_VERSION_MAJOR)
   113         .arg(LIBAVUTIL_VERSION_MINOR)
   105         .arg(LIBAVUTIL_VERSION_MINOR)
   114         .arg(LIBAVUTIL_VERSION_MICRO));
   106         .arg(LIBAVUTIL_VERSION_MICRO));
   115 #endif
   107 #endif
   116     html.replace("%PHYSFS%", QString("version: %1.%2.%3")
   108 
       
   109     libinfo.append(QString("<a href=\"http://icculus.org/physfs/\">PhysFS</a> version: %1.%2.%3<br>")
   117         .arg(PHYSFS_VER_MAJOR)
   110         .arg(PHYSFS_VER_MAJOR)
   118         .arg(PHYSFS_VER_MINOR)
   111         .arg(PHYSFS_VER_MINOR)
   119         .arg(PHYSFS_VER_PATCH));
   112         .arg(PHYSFS_VER_PATCH));
   120 
   113 
   121     lbl2 = new QTextBrowser(this);
   114     QLabel * lblLibInfo = new QLabel();
   122     lbl2->setOpenExternalLinks(true);
   115     lblLibInfo->setText(libinfo);
   123     lbl2->setHtml(html);
   116     lblLibInfo->setWordWrap(true);
   124     mainLayout->addWidget(lbl2, 1, 1);
   117     lblLibInfo->setMaximumWidth(280);
   125     
   118     leftLayout->addWidget(lblLibInfo, 0, Qt::AlignTop | Qt::AlignHCenter);
       
   119     leftLayout->addStretch(1);
       
   120 
   126     setAcceptDrops(true);
   121     setAcceptDrops(true);
   127 }
   122 }
   128 
   123 
   129 void About::dragEnterEvent(QDragEnterEvent * event)
   124 void About::dragEnterEvent(QDragEnterEvent * event)
   130 {
   125 {