From: APTX Date: Wed, 15 Apr 2009 00:00:52 +0000 (+0200) Subject: - Add about dialog X-Git-Url: https://gitweb.aptx.org/?a=commitdiff_plain;h=a0f876add481de735272a1b93ab5bc7ea4771b6a;p=aniplayer-old.git - Add about dialog - Add constants file containing application meta-data - Fix EpisodeVoteDialog logic --- diff --git a/src/aniplayer.h b/src/aniplayer.h index 2900499..1d4e607 100644 --- a/src/aniplayer.h +++ b/src/aniplayer.h @@ -5,8 +5,8 @@ #ifdef qApp # undef qApp -# define qApp (AniPlayer::instance()) #endif +#define qApp (AniPlayer::instance()) class AniPlayer : public QApplication { diff --git a/src/constants.h b/src/constants.h new file mode 100644 index 0000000..a6abe07 --- /dev/null +++ b/src/constants.h @@ -0,0 +1,17 @@ +#ifndef CONSTANTS_H +#define CONSTANTS_H + +#define STRINGIFY_INTERNAL(x) #x +#define STRINGIFY(x) STRINGIFY_INTERNAL(x) + +#ifdef REVISION +static const char *revisionString = STRINGIFY(REVISION); +#else +static const char *revisionString = "Unknown revision"; +#endif + +static const char *applicationName = "AniPlayer"; +static const char *applicationVersion = "1.0.0A1"; +static const char *organizationName = "APTX"; + +#endif // CONSTANTS_H diff --git a/src/episodevotedialog.cpp b/src/episodevotedialog.cpp index 07be726..986ab30 100644 --- a/src/episodevotedialog.cpp +++ b/src/episodevotedialog.cpp @@ -15,12 +15,12 @@ EpisodeVoteDialog::~EpisodeVoteDialog() int EpisodeVoteDialog::vote() const { - return qBound(1, int(m_ui->vote->value() * 10.0), 100); + return qBound(100, int(m_ui->vote->value() * 100.0), 1000); } void EpisodeVoteDialog::setVote(int value) { - m_ui->vote->setValue(double(value) / 10.0); + m_ui->vote->setValue(double(value) / 100.0); } void EpisodeVoteDialog::changeEvent(QEvent *e) diff --git a/src/main.cpp b/src/main.cpp index be24830..3ba9ec5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,7 @@ #include "aniplayer.h" #include "videowindow.h" +#include "constants.h" + #ifndef BROWSERPLUGIN_BUILD @@ -15,9 +17,9 @@ Q_IMPORT_PLUGIN(phonon_ds9) int main(int argc, char *argv[]) { - AniPlayer::setApplicationName("AniPlayer"); - AniPlayer::setOrganizationName("APTX"); - AniPlayer::setApplicationVersion("1.0.0A1"); + AniPlayer::setApplicationName(QLatin1String(applicationName)); + AniPlayer::setOrganizationName(QLatin1String(organizationName)); + AniPlayer::setApplicationVersion(QLatin1String(applicationVersion)); qsrand(QTime().msecsTo(QTime::currentTime())); diff --git a/src/src.pro b/src/src.pro index 18e32c9..a576240 100644 --- a/src/src.pro +++ b/src/src.pro @@ -2,7 +2,6 @@ # Project created by QtCreator 2009-02-11T10:09:59 # ------------------------------------------------- QT += phonon - unix { message(Using system (KDE?) Phonon) QT -= phonon @@ -21,7 +20,8 @@ SOURCES += main.cpp \ aniplayer.cpp \ directoryplaylist.cpp \ anidbconfigdialog.cpp \ - episodevotedialog.cpp + episodevotedialog.cpp \ + versiondialog.cpp HEADERS += menu.h \ videowindow.h \ videowidget.h \ @@ -29,7 +29,9 @@ HEADERS += menu.h \ abstractplaylist.h \ directoryplaylist.h \ anidbconfigdialog.h \ - episodevotedialog.h + episodevotedialog.h \ + versiondialog.h \ + constants.h FORMS += menu.ui \ anidbconfigdialog.ui \ episodevotedialog.ui @@ -60,4 +62,6 @@ static { DEFINES += STATIC_BUILD DESTDIR = ../build-static/ } +REV = $$system(git show-ref -s HEAD) +DEFINES += REVISION=\"$${REV}\" include(../lib/anidbudpclient/anidbudpclient.pri) diff --git a/src/versiondialog.cpp b/src/versiondialog.cpp new file mode 100644 index 0000000..5c82bf3 --- /dev/null +++ b/src/versiondialog.cpp @@ -0,0 +1,58 @@ +#include "versiondialog.h" + +#include +#include +#include +#include + +#include "constants.h" +#include "aniplayer.h" + +VersionDialog::VersionDialog(QWidget *parent) : QDialog(parent) +{ + setWindowTitle(tr("About %1").arg(qApp->applicationName())); + + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + + QGridLayout *layout = new QGridLayout(this); + layout->setSizeConstraint(QLayout::SetFixedSize); + + const QString description = tr( + "

%1 %2

" + "Built with Qt\t%3;running with Qt\t%4
" + "
" + "Built on " __DATE__ " at " __TIME__ " " +#ifdef REVISION + "from revision %6
" +#endif + "
" + "
" + "Copyright (C) 2009 %5. All rights reserved.
" + "
" + "The program is provided AS IS with NO WARRANTY OF ANY KIND, " + "INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A " + "PARTICULAR PURPOSE.
") + .arg(qApp->applicationName()) + .arg(qApp->applicationVersion()) + .arg(QLatin1String(QT_VERSION_STR)) + .arg(QLatin1String(qVersion())) + .arg(qApp->organizationName()) +#ifdef REVISION + .arg(QLatin1String(revisionString)) +#endif + ; // It's important! + + QLabel *copyRightLabel = new QLabel(description); + copyRightLabel->setWordWrap(true); + copyRightLabel->setOpenExternalLinks(true); + copyRightLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); + + QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); + QPushButton *closeButton = buttonBox->button(QDialogButtonBox::Close); + + buttonBox->addButton(closeButton, QDialogButtonBox::ButtonRole(QDialogButtonBox::RejectRole | QDialogButtonBox::AcceptRole)); + connect(buttonBox , SIGNAL(rejected()), this, SLOT(reject())); + + layout->addWidget(copyRightLabel, 0, 1, 4, 4); + layout->addWidget(buttonBox, 4, 0, 1, 5); +} diff --git a/src/versiondialog.h b/src/versiondialog.h new file mode 100644 index 0000000..05cbd9e --- /dev/null +++ b/src/versiondialog.h @@ -0,0 +1,12 @@ +#ifndef VERSIONDIALOG_H +#define VERSIONDIALOG_H + +#include + +class VersionDialog : public QDialog +{ +public: + VersionDialog(QWidget *parent = 0); +}; + +#endif // VERSIONDIALOG_H diff --git a/src/videowindow.cpp b/src/videowindow.cpp index ad70fa7..1478e50 100644 --- a/src/videowindow.cpp +++ b/src/videowindow.cpp @@ -17,6 +17,7 @@ #include "aniplayer.h" #include "directoryplaylist.h" #include "anidbconfigdialog.h" +#include "versiondialog.h" #include #include @@ -95,6 +96,7 @@ VideoWindow::VideoWindow(QWidget *parent) : QMainWindow(parent) #endif addAction("markWatched", "Mark Watched", QKeySequence("CTRL+M")); addAction("settings", "Settings", QKeySequence("F7")); + addAction("about", "About", QKeySequence()); menu = new Menu(this); menu->addActions(QWidget::actions()); @@ -119,6 +121,7 @@ VideoWindow::VideoWindow(QWidget *parent) : QMainWindow(parent) connect(m_actions["markWatched"], SIGNAL(triggered()), this, SLOT(markWatched())); connect(m_actions["settings"], SIGNAL(triggered()), this, SLOT(anidbSettings())); + connect(m_actions["about"], SIGNAL(triggered()), this, SLOT(about())); connect(m_actions["open"], SIGNAL(triggered()), this, SLOT(open())); connect(m_actions["play"], SIGNAL(triggered()), this, SLOT(play())); @@ -358,6 +361,12 @@ void VideoWindow::skip(int msec) mediaObject->seek(mediaObject->currentTime() + msec); } +void VideoWindow::about() +{ + VersionDialog dialog(this); + dialog.exec(); +} + void VideoWindow::handleStateChange(Phonon::State newstate, Phonon::State oldstate) { qDebug() << "Media changed state from" << oldstate << "to" << newstate; diff --git a/src/videowindow.h b/src/videowindow.h index 18d80ec..3966cd1 100644 --- a/src/videowindow.h +++ b/src/videowindow.h @@ -85,6 +85,8 @@ public slots: void skip(int msec = 85000); + void about(); + protected: virtual void mousePressEvent(QMouseEvent *event);