]> Some of my projects - aniplayer2.git/commitdiff
Reimplement the config dialog.
authorAPTX <marek321@gmail.com>
Sun, 16 Feb 2014 13:03:10 +0000 (14:03 +0100)
committerAPTX <marek321@gmail.com>
Sun, 16 Feb 2014 13:03:10 +0000 (14:03 +0100)
player/configdialog.cpp [new file with mode: 0644]
player/configdialog.h [new file with mode: 0644]
player/configdialog.ui [new file with mode: 0644]
player/main.cpp
player/mainwindow.cpp
player/mainwindow.h
player/player.pro

diff --git a/player/configdialog.cpp b/player/configdialog.cpp
new file mode 100644 (file)
index 0000000..a08e26b
--- /dev/null
@@ -0,0 +1,57 @@
+#include "configdialog.h"
+#include "ui_configdialog.h"
+
+#include <QDir>
+
+ConfigDialog::ConfigDialog(QWidget *parent) :
+       QDialog(parent),
+       m_ui(new Ui::ConfigDialog)
+{
+       m_ui->setupUi(this);
+}
+
+int ConfigDialog::automark() const
+{
+       return m_ui->automark->value();
+}
+
+void ConfigDialog::setAutomark(int percent)
+{
+       m_ui->automark->setValue(percent);
+}
+
+QStringList ConfigDialog::paths() const
+{
+       return QDir::fromNativeSeparators(m_ui->paths->text()).split(';');
+}
+
+void ConfigDialog::setPaths(const QStringList &paths)
+{
+       m_ui->paths->setText(QDir::toNativeSeparators(paths.join(";")));
+}
+
+int ConfigDialog::opSkip() const
+{
+       return m_ui->opSkip->value();
+}
+
+void ConfigDialog::setOpSkip(int seconds)
+{
+       m_ui->opSkip->setValue(seconds);
+}
+
+ConfigDialog::~ConfigDialog()
+{
+       delete m_ui;
+}
+
+void ConfigDialog::changeEvent(QEvent *e)
+{
+       switch (e->type()) {
+       case QEvent::LanguageChange:
+               m_ui->retranslateUi(this);
+               break;
+       default:
+               break;
+       }
+}
diff --git a/player/configdialog.h b/player/configdialog.h
new file mode 100644 (file)
index 0000000..fd1a3d0
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef ANIDBCONFIGDIALOG_H
+#define ANIDBCONFIGDIALOG_H
+
+#include <QDialog>
+
+namespace Ui {
+       class ConfigDialog;
+}
+
+class ConfigDialog : public QDialog {
+       Q_OBJECT
+       Q_DISABLE_COPY(ConfigDialog)
+public:
+       explicit ConfigDialog(QWidget *parent = 0);
+       virtual ~ConfigDialog();
+
+       int automark() const;
+       void setAutomark(int percent);
+
+       QStringList paths() const;
+       void setPaths(const QStringList &paths);
+
+       int opSkip() const;
+       void setOpSkip(int seconds);
+
+protected:
+       virtual void changeEvent(QEvent *e);
+
+private:
+       Ui::ConfigDialog *m_ui;
+
+};
+
+#endif // ANIDBCONFIGDIALOG_H
diff --git a/player/configdialog.ui b/player/configdialog.ui
new file mode 100644 (file)
index 0000000..014813c
--- /dev/null
@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ConfigDialog</class>
+ <widget class="QDialog" name="ConfigDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>302</width>
+    <height>185</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>AniPlayer Settings</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QGroupBox" name="groupBox_2">
+     <property name="title">
+      <string>Automark</string>
+     </property>
+     <layout class="QFormLayout" name="formLayout">
+      <item row="0" column="0">
+       <widget class="QLabel" name="lAutomark">
+        <property name="text">
+         <string>Automark on:</string>
+        </property>
+        <property name="buddy">
+         <cstring>automark</cstring>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1">
+       <widget class="QSpinBox" name="automark">
+        <property name="specialValueText">
+         <string>Disabled</string>
+        </property>
+        <property name="suffix">
+         <string>%</string>
+        </property>
+        <property name="minimum">
+         <number>0</number>
+        </property>
+        <property name="maximum">
+         <number>100</number>
+        </property>
+        <property name="value">
+         <number>0</number>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="0">
+       <widget class="QLabel" name="lPaths">
+        <property name="text">
+         <string>Paths:</string>
+        </property>
+        <property name="buddy">
+         <cstring>paths</cstring>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1">
+       <widget class="QLineEdit" name="paths"/>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="groupBox_3">
+     <property name="title">
+      <string>OP/ED skip</string>
+     </property>
+     <layout class="QFormLayout" name="formLayout_3">
+      <item row="0" column="0">
+       <widget class="QLabel" name="lOpSkip">
+        <property name="text">
+         <string>Skip:</string>
+        </property>
+        <property name="buddy">
+         <cstring>opSkip</cstring>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1">
+       <widget class="QSpinBox" name="opSkip">
+        <property name="suffix">
+         <string>s</string>
+        </property>
+        <property name="minimum">
+         <number>1</number>
+        </property>
+        <property name="maximum">
+         <number>1000</number>
+        </property>
+        <property name="singleStep">
+         <number>5</number>
+        </property>
+        <property name="value">
+         <number>85</number>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <tabstops>
+  <tabstop>automark</tabstop>
+  <tabstop>paths</tabstop>
+  <tabstop>opSkip</tabstop>
+  <tabstop>buttonBox</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>ConfigDialog</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>292</x>
+     <y>397</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>426</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>ConfigDialog</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>292</x>
+     <y>397</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>548</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
index 1d5447538a224cd3ef4af6475ba07184b0af5690..241dbf3be2e16e53ef8a27163ddcaeb2d3a01c70 100644 (file)
@@ -9,11 +9,12 @@ int main(int argc, char *argv[])
        {
                if (a.arguments().count() > 1)
                        a.sendMessage("open " + a.arguments().at(1));
-
                return 0;
        }
 
        MainWindow w;
+       a.setActivationWindow(&w);
+
        QObject::connect(&a, SIGNAL(openFileRequested(QString)), &w, SLOT(play(QString)));
 
        w.show();
index efb0cc6b465ca63ef10263bbcc33497185c376b8..2e47e8fd661a9e6ec24bedfde9b4a4dccd9dc934 100644 (file)
@@ -22,6 +22,7 @@
 #include "seekslider.h"
 #include <volumeslider.h>
 #include "versiondialog.h"
+#include "configdialog.h"
 
 #include <QDebug>
 
@@ -73,7 +74,7 @@ MainWindow::MainWindow(QWidget *parent) :
        connect(player, SIGNAL(stateChanged(AniPlayer::State, AniPlayer::State)), this, SLOT(handleStateChange(AniPlayer::State,AniPlayer::State)));
 //     connect(videoPlayer->mediaController(), SIGNAL(availableSubtitlesChanged()), this, SLOT(updateSubtitles()));
        connect(m_actions["markWatched"], SIGNAL(triggered()), player, SLOT(markWatched()));
-//     connect(m_actions["settings"], SIGNAL(triggered()), this, SLOT(anidbSettings()));
+       connect(m_actions["settings"], SIGNAL(triggered()), this, SLOT(showConfigDialog()));
        connect(m_actions["about"], SIGNAL(triggered()), this, SLOT(about()));
 
        connect(m_actions["open"], SIGNAL(triggered()), this, SLOT(open()));
@@ -441,6 +442,24 @@ void MainWindow::updateWindowFlags()
        show();
 }
 
+void MainWindow::showConfigDialog()
+{
+       ConfigDialog dialog(this);
+
+       dialog.setAutomark(player->automark());
+       dialog.setPaths(m_automarkPaths);
+       dialog.setOpSkip(m_opSkip);
+
+       if (!dialog.exec())
+       {
+               return;
+       }
+
+       player->setAutomark(dialog.automark());
+       m_automarkPaths = dialog.paths();
+       m_opSkip = dialog.opSkip();
+}
+
 void MainWindow::chaptersChanged()
 {
 /*
index acf2e5a246c6246a44d3a90b91010cd271d60557..f31082e743b9f453bbddc63959148decf7295c1b 100644 (file)
@@ -44,6 +44,8 @@ private slots:
        void chaptersChanged();
        void streamsChanged();
 
+       void showConfigDialog();
+
 protected:
        void mousePressEvent(QMouseEvent *event);
        void mouseMoveEvent(QMouseEvent *event);
@@ -73,7 +75,6 @@ private:
 
        int m_opSkip;
 
-       int m_automark;
        QStringList m_automarkPaths;
        bool m_marked;
        bool m_automarkable;
index dbbcc5aabb537e5676fa0170bcd3380e826f9a87..e7894afd63900dea80da08627d91c83714220e21 100644 (file)
@@ -10,16 +10,19 @@ DESTDIR = ../build
 HEADERS  += mainwindow.h \
        menu.h \
        seekslider.h \
-       versiondialog.h
+       versiondialog.h \
+       configdialog.h
 
 SOURCES += main.cpp\
        mainwindow.cpp \
        menu.cpp \
        seekslider.cpp \
-       versiondialog.cpp
+       versiondialog.cpp \
+       configdialog.cpp
 
 FORMS    += mainwindow.ui \
-       menu.ui
+       menu.ui \
+       configdialog.ui
 
 include(../config.pri)
 include(../aniplayer/aniplayer.pri)