diff --git a/qad/application/aboutwindow.cpp b/qad/application/aboutwindow.cpp new file mode 100644 index 0000000..0f972e2 --- /dev/null +++ b/qad/application/aboutwindow.cpp @@ -0,0 +1,157 @@ +#include "aboutwindow.h" +#include "ui_aboutwindow.h" +#include "qad_types.h" +#include +#include +#include + +#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) +# define MOBILE_VIEW +#endif + +QImage AboutWindow::logo; +QVector AboutWindow::versions, AboutWindow::builds; +QString AboutWindow::comment; + + +AboutWindow::AboutWindow(QWidget * parent): QDialog(parent), ui(new Ui::AboutWindow) { +#ifdef ANDROID + setStyleSheet("font: 12pt \"DejaVu Sans\";"); +#endif + ui->setupUi(this); + QImage logo_im = logo; + if (logo_im.isNull()) + logo_im.load(":/icons/splash.png"); + setWindowTitle(QApplication::applicationName() + " - " + tr("About")); + QIcon ic = QApplication::windowIcon(); + if (ic.isNull()) { + QWidgetList tlw = QApplication::topLevelWidgets(); + foreach (QWidget * w, tlw) + if (!w->windowIcon().isNull()) { + ic = w->windowIcon(); + break; + } + } + if (ic.isNull()) + ic = QIcon(QPixmap::fromImage(logo_im)); + setWindowIcon(ic); + QFormLayout * lay = (QFormLayout*)(ui->groupVersions->layout()); + foreach (SSPair p, versions) { + lay->addRow(p.first, new QLabel(p.second)); + } + lay = (QFormLayout*)(ui->groupBuild->layout()); + foreach (SSPair p, builds) { + lay->addRow(p.first, new QLabel(p.second)); + } + ui->labelComment->setText(comment); + ui->labelComment->setHidden(comment.isEmpty()); + //ui->labelArch->setText(QSysInfo::currentCpuArchitecture()); + ui->labelAuthors->setText(authors()); + connect(ui->buttonQt, SIGNAL(clicked()), qApp, SLOT(aboutQt())); +#ifdef MOBILE_VIEW + ui->layoutMain->insertWidget(0, ui->imageView); + //ui->verticalSpacer->changeSize(1, 1, QSizePolicy::Preferred, QSizePolicy::Preferred); +#endif +#ifdef MOBILE_VIEW + ui->layoutMain->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Preferred, QSizePolicy::Expanding)); +#else + QScreen * scr = +# if QT_VERSION >= 0x050A00 + QApplication::screenAt(QCursor::pos()); +# else + QApplication::screens()[0]; +# endif + if (scr) { + QRect r; + r.setSize(scr->availableSize() / 2); + r.moveCenter(scr->availableGeometry().center()); + setGeometry(r); + } +#endif +} + + +AboutWindow::~AboutWindow() { + delete ui; +} + + +void AboutWindow::setLogo(QImage im) { + logo = im; +} + + +void AboutWindow::addVersion(QString name, QString version) { + if (!name.endsWith(":")) name.append(":"); + foreach (const SSPair & p, versions) { + if (p.first == name) return; + } + versions << SSPair(name, version); +} + + +void AboutWindow::addBuildInfo(QString name, QString value) { + if (!name.endsWith(":")) name.append(":"); + foreach (const SSPair & p, builds) { + if (p.first == name) return; + } + builds << SSPair(name, value); +} + + +void AboutWindow::setComment(QString text) { + comment = text; +} + + +void AboutWindow::show() { + AboutWindow w; + w.exec(); +} + + +int AboutWindow::exec() { +#ifdef MOBILE_VIEW + showFullScreen(); + //setWindowState(Qt::WindowFullScreen); +#endif + return QDialog::exec(); +} + + +void AboutWindow::changeEvent(QEvent *e) { + QDialog::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + case QEvent::FontChange: + case QEvent::Polish: + ui->buttonOK->setIconSize(preferredIconSize(2., this)); + ui->buttonQt->setIconSize(preferredIconSize(2., this)); + break; + default: break; + } +} + + +QString AboutWindow::authors() { + QFile f(":/authors.txt"); + if (!f.open(QIODevice::ReadOnly)) return QString(); + QString ret; + QTextStream ts(&f); + ts.readLine(); + QStringList sl; + while (!ts.atEnd()) { + QString l = ts.readLine(); + if (l.isEmpty()) continue; + QString name, mail; + sl = l.split(";"); + if (sl.size() > 0) name = sl[0].trimmed(); + if (sl.size() > 1) mail = sl[1].trimmed(); + if (!ret.isEmpty()) ret += "\n"; + ret += QString("%1 (%2)").arg(name, mail); + } + return ret; +} + diff --git a/qad/application/aboutwindow.h b/qad/application/aboutwindow.h new file mode 100644 index 0000000..d447566 --- /dev/null +++ b/qad/application/aboutwindow.h @@ -0,0 +1,48 @@ +#ifndef ABOUTWINDOW_H +#define ABOUTWINDOW_H + +#include "qad_export.h" +#include + +#define ADD_ABOUT_VERSION(lib) AboutWindow::addVersion(#lib, lib##_VERSION_NAME); +#define ADD_ABOUT_BUILD_INFO(lib) \ + AboutWindow::addBuildInfo("Arch", lib##_ARCH); \ + AboutWindow::addBuildInfo("Compiler", lib##_CXX_COMPILER); \ + AboutWindow::addBuildInfo("CMake", lib##_CMAKE_VERSION); \ + AboutWindow::addBuildInfo("Date", lib##_BUILD_DATE); + +namespace Ui { + class AboutWindow; +} + +class QAD_EXPORT AboutWindow: public QDialog +{ + Q_OBJECT + typedef QPair SSPair; + explicit AboutWindow(QWidget * parent = 0); + ~AboutWindow(); +public: + + static void setLogo(QImage im); + static void addVersion(QString name, QString version); + static void addBuildInfo(QString name, QString value); + static void setComment(QString text); + + static void show(); + +protected: + virtual void changeEvent(QEvent * e); + virtual int exec(); + + QString authors(); + +private: + Ui::AboutWindow * ui; + + static QImage logo; + static QVector versions, builds; + static QString comment; + +}; + +#endif // ABOUTWINDOW_H diff --git a/qad/application/aboutwindow.ui b/qad/application/aboutwindow.ui new file mode 100644 index 0000000..e0b0c42 --- /dev/null +++ b/qad/application/aboutwindow.ui @@ -0,0 +1,155 @@ + + + AboutWindow + + + + 0 + 0 + 724 + 502 + + + + - About + + + + + + QFrame::NoFrame + + + + + 0 + 0 + 0 + + + + + :/icons/splash.png + + + + + + + + + + + + Versions + + + + QFormLayout::AllNonFixedFieldsGrow + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + Build + + + + QFormLayout::AllNonFixedFieldsGrow + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + Authors + + + + + + + + + + + + + + + + Qt::Vertical + + + + 1 + 1 + + + + + + + + About Qt... + + + + :/icons/qt.png:/icons/qt.png + + + + + + + OK + + + + :/icons/dialog-ok-apply.png:/icons/dialog-ok-apply.png + + + + + + + + + + ImageView + QGraphicsView +
image_view.h
+
+
+ + + + + + + buttonOK + clicked() + AboutWindow + close() + + + 712 + 490 + + + 320 + 385 + + + + +
diff --git a/qad/application/qad_application.qrc b/qad/application/qad_application.qrc index 6a6c8f9..aafad3d 100644 --- a/qad/application/qad_application.qrc +++ b/qad/application/qad_application.qrc @@ -27,5 +27,6 @@ ../icons/clear-history.png ../icons/layer-visible-off.png ../icons/layer-visible-on.png + ../icons/qt.png diff --git a/qad/icons/qt.png b/qad/icons/qt.png new file mode 100644 index 0000000..d999cb3 Binary files /dev/null and b/qad/icons/qt.png differ