]> Some of my projects - aniplayer-old.git/commitdiff
- Add about dialog
authorAPTX <APTX@.(none)>
Wed, 15 Apr 2009 00:00:52 +0000 (02:00 +0200)
committerAPTX <APTX@.(none)>
Wed, 15 Apr 2009 00:00:52 +0000 (02:00 +0200)
- Add constants file containing application meta-data
- Fix EpisodeVoteDialog logic

src/aniplayer.h
src/constants.h [new file with mode: 0644]
src/episodevotedialog.cpp
src/main.cpp
src/src.pro
src/versiondialog.cpp [new file with mode: 0644]
src/versiondialog.h [new file with mode: 0644]
src/videowindow.cpp
src/videowindow.h

index 2900499e05dff5c6452965a572aa861b41510db8..1d4e6078f347c7475832c3da4ab6d3d14d5061d2 100644 (file)
@@ -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 (file)
index 0000000..a6abe07
--- /dev/null
@@ -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
index 07be7268bc630c4a79ae66996eb817f09f9eb0ed..986ab30d90106e4c71dbfc9cadd14acdf362c7ee 100644 (file)
@@ -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)
index be24830b59d7c5c806cd2abbf3c9a94c9d6557b2..3ba9ec56a782b7d8fdcb97fd2e12868579316467 100644 (file)
@@ -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()));
 
index 18e32c9a25c7c7ec41c7e068e5fccbc6b45494b0..a5762408ea45ca30bbaf6dd29c28ef30ef8e3696 100644 (file)
@@ -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 (file)
index 0000000..5c82bf3
--- /dev/null
@@ -0,0 +1,58 @@
+#include "versiondialog.h"
+
+#include <QGridLayout>
+#include <QLabel>
+#include <QDialogButtonBox>
+#include <QPushButton>
+
+#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(
+               "<h3>%1 %2</h3>"
+               "Built with Qt\t%3;running with Qt\t%4<br/>"
+               "<br/>"
+               "Built on " __DATE__ " at " __TIME__ " "
+#ifdef REVISION
+               "from revision %6<br/>"
+#endif
+               "<br/>"
+               "<br/>"
+               "Copyright (C) 2009 %5. All rights reserved.<br/>"
+               "<br/>"
+               "The program is provided AS IS with NO WARRANTY OF ANY KIND, "
+               "INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A "
+               "PARTICULAR PURPOSE.<br/>")
+               .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 (file)
index 0000000..05cbd9e
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef VERSIONDIALOG_H
+#define VERSIONDIALOG_H
+
+#include <QDialog>
+
+class VersionDialog : public QDialog
+{
+public:
+       VersionDialog(QWidget *parent = 0);
+};
+
+#endif // VERSIONDIALOG_H
index ad70fa74ab3b534dcf26d39f11cfa7ec1dc81348..1478e509c7ca0722053cc94854b4adb74b8aefda 100644 (file)
@@ -17,6 +17,7 @@
 #include "aniplayer.h"
 #include "directoryplaylist.h"
 #include "anidbconfigdialog.h"
+#include "versiondialog.h"
 
 #include <anidbudpclient.h>
 #include <rawcommand.h>
@@ -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;
index 18d80ec3a8573c7a6e9cc07c7497ce1665a55dba..3966cd1c9d984ffa854dece965386be07575ba29 100644 (file)
@@ -85,6 +85,8 @@ public slots:
 
        void skip(int msec = 85000);
 
+       void about();
+
 protected:
 
        virtual void mousePressEvent(QMouseEvent *event);