git-svn-id: svn://db.shs.com.ru/libs@924 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
157
qad/application/aboutwindow.cpp
Normal file
157
qad/application/aboutwindow.cpp
Normal file
@@ -0,0 +1,157 @@
|
||||
#include "aboutwindow.h"
|
||||
#include "ui_aboutwindow.h"
|
||||
#include "qad_types.h"
|
||||
#include <QApplication>
|
||||
#include <QScreen>
|
||||
#include <QFile>
|
||||
|
||||
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
||||
# define MOBILE_VIEW
|
||||
#endif
|
||||
|
||||
QImage AboutWindow::logo;
|
||||
QVector<AboutWindow::SSPair> 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;
|
||||
}
|
||||
|
||||
48
qad/application/aboutwindow.h
Normal file
48
qad/application/aboutwindow.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef ABOUTWINDOW_H
|
||||
#define ABOUTWINDOW_H
|
||||
|
||||
#include "qad_export.h"
|
||||
#include <QDialog>
|
||||
|
||||
#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<QString, QString> 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<SSPair> versions, builds;
|
||||
static QString comment;
|
||||
|
||||
};
|
||||
|
||||
#endif // ABOUTWINDOW_H
|
||||
155
qad/application/aboutwindow.ui
Normal file
155
qad/application/aboutwindow.ui
Normal file
@@ -0,0 +1,155 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AboutWindow</class>
|
||||
<widget class="QWidget" name="AboutWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>724</width>
|
||||
<height>502</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string> - About</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="ImageView" name="imageView">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="backgroundBrush">
|
||||
<brush brushstyle="NoBrush">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>:/icons/splash.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="layoutMain">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelComment"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupVersions">
|
||||
<property name="title">
|
||||
<string>Versions</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBuild">
|
||||
<property name="title">
|
||||
<string>Build</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupAuthors">
|
||||
<property name="title">
|
||||
<string>Authors</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelAuthors">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>1</width>
|
||||
<height>1</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonQt">
|
||||
<property name="text">
|
||||
<string>About Qt...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_application.qrc">
|
||||
<normaloff>:/icons/qt.png</normaloff>:/icons/qt.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonOK">
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../widgets/qad_widgets.qrc">
|
||||
<normaloff>:/icons/dialog-ok-apply.png</normaloff>:/icons/dialog-ok-apply.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ImageView</class>
|
||||
<extends>QGraphicsView</extends>
|
||||
<header>image_view.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../widgets/qad_widgets.qrc"/>
|
||||
<include location="qad_application.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonOK</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>AboutWindow</receiver>
|
||||
<slot>close()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>712</x>
|
||||
<y>490</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>320</x>
|
||||
<y>385</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -27,5 +27,6 @@
|
||||
<file>../icons/clear-history.png</file>
|
||||
<file>../icons/layer-visible-off.png</file>
|
||||
<file>../icons/layer-visible-on.png</file>
|
||||
<file>../icons/qt.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
BIN
qad/icons/qt.png
Normal file
BIN
qad/icons/qt.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
Reference in New Issue
Block a user