From: APTX Date: Sun, 16 Feb 2014 13:03:10 +0000 (+0100) Subject: Reimplement the config dialog. X-Git-Url: https://gitweb.tyo.aptx.org/?a=commitdiff_plain;h=3aa7c101051af954d730ec14589cbb05ab82ed55;p=aniplayer2.git Reimplement the config dialog. --- diff --git a/player/configdialog.cpp b/player/configdialog.cpp new file mode 100644 index 0000000..a08e26b --- /dev/null +++ b/player/configdialog.cpp @@ -0,0 +1,57 @@ +#include "configdialog.h" +#include "ui_configdialog.h" + +#include + +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 index 0000000..fd1a3d0 --- /dev/null +++ b/player/configdialog.h @@ -0,0 +1,34 @@ +#ifndef ANIDBCONFIGDIALOG_H +#define ANIDBCONFIGDIALOG_H + +#include + +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 index 0000000..014813c --- /dev/null +++ b/player/configdialog.ui @@ -0,0 +1,159 @@ + + + ConfigDialog + + + + 0 + 0 + 302 + 185 + + + + AniPlayer Settings + + + + + + Automark + + + + + + Automark on: + + + automark + + + + + + + Disabled + + + % + + + 0 + + + 100 + + + 0 + + + + + + + Paths: + + + paths + + + + + + + + + + + + + OP/ED skip + + + + + + Skip: + + + opSkip + + + + + + + s + + + 1 + + + 1000 + + + 5 + + + 85 + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + automark + paths + opSkip + buttonBox + + + + + buttonBox + accepted() + ConfigDialog + accept() + + + 292 + 397 + + + 426 + 274 + + + + + buttonBox + rejected() + ConfigDialog + reject() + + + 292 + 397 + + + 548 + 274 + + + + + diff --git a/player/main.cpp b/player/main.cpp index 1d54475..241dbf3 100644 --- a/player/main.cpp +++ b/player/main.cpp @@ -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(); diff --git a/player/mainwindow.cpp b/player/mainwindow.cpp index efb0cc6..2e47e8f 100644 --- a/player/mainwindow.cpp +++ b/player/mainwindow.cpp @@ -22,6 +22,7 @@ #include "seekslider.h" #include #include "versiondialog.h" +#include "configdialog.h" #include @@ -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() { /* diff --git a/player/mainwindow.h b/player/mainwindow.h index acf2e5a..f31082e 100644 --- a/player/mainwindow.h +++ b/player/mainwindow.h @@ -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; diff --git a/player/player.pro b/player/player.pro index dbbcc5a..e7894af 100644 --- a/player/player.pro +++ b/player/player.pro @@ -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)