diff options
author | am <am@f440f766-f032-0410-8965-dc7d17de2ca0> | 2009-07-12 16:04:04 +0000 |
---|---|---|
committer | am <am@f440f766-f032-0410-8965-dc7d17de2ca0> | 2009-07-12 16:04:04 +0000 |
commit | a3dd54389f7b28431fc9853cd57af231bd6a3c9c (patch) | |
tree | 3fc25acead59266867f057e862e722ac7dbe2180 /configurationdialog.cpp | |
parent | b6fbec29ad08a0607adf4b5d3fe5d8a237d1a970 (diff) | |
download | SheMov-a3dd54389f7b28431fc9853cd57af231bd6a3c9c.tar.gz SheMov-a3dd54389f7b28431fc9853cd57af231bd6a3c9c.tar.bz2 SheMov-a3dd54389f7b28431fc9853cd57af231bd6a3c9c.zip |
-implemented cover rename and templates
-started on configurationdialog
git-svn-id: file:///var/svn/repos2/shemov/trunk@385 f440f766-f032-0410-8965-dc7d17de2ca0
Diffstat (limited to 'configurationdialog.cpp')
-rw-r--r-- | configurationdialog.cpp | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/configurationdialog.cpp b/configurationdialog.cpp new file mode 100644 index 0000000..d10050a --- /dev/null +++ b/configurationdialog.cpp @@ -0,0 +1,131 @@ +/* + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version + 2 of the License, or (at your option) any later version. +*/ + +#include <QPushButton> +#include <QTabWidget> +#include <QHBoxLayout> +#include <QVBoxLayout> +#include <QGridLayout> +#include <QLineEdit> +#include <QLabel> +#include <QComboBox> +#include <QDirModel> +#include <QCompleter> +#include <QApplication> +#include <QSettings> +#include <QRegExp> + +#include "configurationdialog.h" + +ConfigurationDialog::ConfigurationDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){ + //paths tab + QWidget *pathWidget = new QWidget; + QGridLayout *pathGrid = new QGridLayout; + QDirModel *model = new QDirModel(this); + QCompleter *fsCompleter = new QCompleter(this); + fsCompleter->setModel(model); + fsCompleter->setCompletionMode(QCompleter::PopupCompletion); + QLabel *l1 = new QLabel(tr("Path to &picture viewer")); + mPictureViewer = new QLineEdit; + mPictureViewer->setCompleter(fsCompleter); + l1->setBuddy(mPictureViewer); + pathGrid->addWidget(l1, 0, 0); + pathGrid->addWidget(mPictureViewer, 0, 1); + QLabel *l2 = new QLabel(tr("Arguments for picture viewer")); + mPictureViewerArgs = new QLineEdit; + pathGrid->addWidget(l2, 1, 0); + pathGrid->addWidget(mPictureViewerArgs, 1, 1); + QLabel *l3 = new QLabel(tr("Path to &movie viewer")); + mMovieViewer = new QLineEdit; + mMovieViewer->setCompleter(fsCompleter); + l2->setBuddy(mMovieViewer); + pathGrid->addWidget(l3, 2, 0); + pathGrid->addWidget(mMovieViewer, 2, 1); + QLabel *l4 = new QLabel(tr("Arguments for movie viewer")); + mMovieViewerArgs = new QLineEdit; + pathGrid->addWidget(l4, 3, 0); + pathGrid->addWidget(mMovieViewerArgs, 3, 1); + QLabel *l5 = new QLabel(tr("Path to &archive program")); + mArchiver = new QLineEdit; + mArchiver->setCompleter(fsCompleter); + l5->setBuddy(mArchiver); + pathGrid->addWidget(l5, 4, 0); + pathGrid->addWidget(mArchiver, 4, 1); + QLabel *l6 = new QLabel(tr("Arguments for archive program")); + mArchiverArgs = new QLineEdit; + l6->setBuddy(mArchiverArgs); + pathGrid->addWidget(l6, 5, 0); + pathGrid->addWidget(mArchiverArgs, 5, 1); + QLabel *l7 = new QLabel(tr("Extraction paths")); + mArchivePaths = new QComboBox; + pathGrid->addWidget(l7, 6, 0); + pathGrid->addWidget(mArchivePaths); + QLabel *l8 = new QLabel(tr("Enter new &extraction path")); + mExtractPath = new QLineEdit; + l8->setBuddy(mExtractPath); + pathGrid->addWidget(l8, 7, 0); + pathGrid->addWidget(mExtractPath, 7, 1); + mAddPath = new QPushButton(tr("Add path")); + connect(mAddPath, SIGNAL(clicked()), this, SLOT(addPath())); + mRemovePath = new QPushButton(tr("Remove path")); + connect(mRemovePath, SIGNAL(clicked()), this, SLOT(removePath())); + QHBoxLayout *pathButtonLayout = new QHBoxLayout; + pathButtonLayout->addStretch(); + pathButtonLayout->addWidget(mAddPath); + pathButtonLayout->addWidget(mRemovePath); + pathGrid->addLayout(pathButtonLayout, 8, 1); + pathWidget->setLayout(pathGrid); + mTab->addTab(pathWidget, tr("Paths")); + + //main layout + mOk = new QPushButton(tr("Ok")); + connect(mOk, SIGNAL(clicked()), this, SLOT(accpet())); + mCancel = new QPushButton(tr("Cancel")); + connect(mCancel, SIGNAL(clicked()), this, SLOT(reject())); + QHBoxLayout *mainButtonLayout = new QHBoxLayout; + mainButtonLayout->addStretch(); + mainButtonLayout->addWidget(mOk); + mainButtonLayout->addWidget(mCancel); + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(mTab); + mainLayout->addLayout(mainButtonLayout); + setLayout(mainLayout); + QString winTitle = QString(tr("%1 - Configure")).arg(qApp->applicationName()); + setWindowTitle(winTitle); + readSettings(); +} + +void ConfigurationDialog::readSettings(){ + QSettings s; + mPictureViewer->setText(s.value("paths/pictureviewer", "/usr/bin/gwenview").toString()); + QStringList pvArgs = s.value("paths/pictureviewerargs").toStringList(); + mPictureViewerArgs->setText(pvArgs.join(" ")); + mMovieViewer->setText(s.value("paths/movieviewer", "/usr/bin/mplayer").toString()); + QStringList mvArgs = s.value("paths/movieviewerargs").toStringList(); + mMovieViewerArgs->setText(mvArgs.join(" ")); + mArchiver->setText(s.value("paths/archiver", "/usr/bin/7z").toString()); + QStringList arArgs = s.value("paths/archiveargs").toStringList(); + mArchiverArgs->setText(arArgs.join(" ")); + QStringList extractPaths = s.value("paths/extractpaths").toStringList(); + mArchivePaths->addItems(extractPaths); + mPaths = extractPaths; +} + +void ConfigurationDialog::writeSettings(){ + QSettings s; + QRegExp splitAt("\\s+"); + s.setValue("paths/pictureviewer", mPictureViewer->text()); + QStringList pvArgs = mPictureViewerArgs->text().split(splitAt, QString::SkipEmptyParts); + s.setValue("paths/pictureviewerargs", pvArgs); + s.setValue("paths/movieviewer", mMovieViewer->text()); + QStringList mvArgs = mMovieViewerArgs->text().split(splitAt, QString::SkipEmptyParts); + s.setValue("paths/movievieverargs", mvArgs); + s.setValue("paths/archiver", mArchiver->text()); + QStringList aArgs = mArchiverArgs->text().split(splitAt, QString::SkipEmptyParts); + s.setValue("paths/archiverargs", aArgs); + s.setValue("paths/extractpaths", mPaths); +} |