diff options
-rw-r--r-- | configurationdialog.cpp | 171 | ||||
-rw-r--r-- | configurationdialog.h | 19 |
2 files changed, 26 insertions, 164 deletions
diff --git a/configurationdialog.cpp b/configurationdialog.cpp index e6b4e46..f453700 100644 --- a/configurationdialog.cpp +++ b/configurationdialog.cpp @@ -23,90 +23,36 @@ #include "programconfigurator.h" ConfigurationDialog::ConfigurationDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){ - //paths tab - QWidget *pathWidget = new QWidget; - QGridLayout *pathGrid = new QGridLayout; + //setup mTab = new QTabWidget; QDirModel *model = new QDirModel(this); QCompleter *fsCompleter = new QCompleter(this); fsCompleter->setModel(model); fsCompleter->setCompletionMode(QCompleter::PopupCompletion); - QLabel *l1 = new QLabel(tr("Path to &archive program")); - mArchiver = new QLineEdit; - mArchiver->setCompleter(fsCompleter); - l1->setBuddy(mArchiver); - pathGrid->addWidget(l1, 0, 0); - pathGrid->addWidget(mArchiver, 0, 1); - QLabel *l2 = new QLabel(tr("Arguments for archive program")); - mArchiverArgs = new QLineEdit; - l2->setBuddy(mArchiverArgs); - pathGrid->addWidget(l2, 1, 0); - pathGrid->addWidget(mArchiverArgs, 1, 1); - QLabel *l3 = new QLabel(tr("Archive directory")); - mArchiveDir = new QLineEdit; - mArchiveDir->setCompleter(fsCompleter); - pathGrid->addWidget(l3, 2, 0); - pathGrid->addWidget(mArchiveDir, 2, 1); - QLabel *l4 = new QLabel(tr("Extraction paths")); - mArchivePaths = new QComboBox; - pathGrid->addWidget(l4, 3, 0); - pathGrid->addWidget(mArchivePaths, 3, 1); - QLabel *l5 = new QLabel(tr("Enter new &extraction path")); - mExtractPath = new QLineEdit; - mExtractPath->setCompleter(fsCompleter); - l5->setBuddy(mExtractPath); - pathGrid->addWidget(l5, 4, 0); - pathGrid->addWidget(mExtractPath, 4, 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, 5, 1); - QLabel *l6 = new QLabel(tr("Burn Directory")); - mBurnDir = new QLineEdit; - mBurnDir->setCompleter(fsCompleter); - pathGrid->addWidget(l6, 6, 0); - pathGrid->addWidget(mBurnDir, 6, 1); - pathWidget->setLayout(pathGrid); - //ui tab - QWidget *uiWidget = new QWidget; - QGridLayout *uiGrid = new QGridLayout; - QLabel *ui1 = new QLabel(tr("Select icon for &folders")); + //misc tab + QWidget *miscWidget = new QWidget; + QGridLayout *miscGrid = new QGridLayout; + miscGrid->setAlignment(Qt::AlignTop); + QLabel *miscl1 = new QLabel(tr("Select icon for &folders")); mIconForFolder = new QComboBox; - ui1->setBuddy(mIconForFolder); + miscl1->setBuddy(mIconForFolder); QStringList icons = QStringList() << tr("Dildo") << tr("Normal"); mIconForFolder->addItems(icons); - uiGrid->addWidget(ui1, 0, 0); - uiGrid->addWidget(mIconForFolder, 0, 1); - QLabel *ui2 = new QLabel(tr("Expand paths in directory tree")); - mExpandPaths = new QComboBox; - uiGrid->addWidget(ui2, 1, 0); - uiGrid->addWidget(mExpandPaths, 1, 1); - mSelect = new QPushButton(tr("Open directory at Startup")); - connect(mSelect, SIGNAL(clicked()), this, SLOT(selectStartup())); - uiGrid->addWidget(mSelect, 2, 1); - QLabel *ui3 = new QLabel(tr("Add &new path to expand")); - mExpandPath = new QLineEdit; - mExpandPath->setCompleter(fsCompleter); - ui3->setBuddy(mExpandPath); - uiGrid->addWidget(ui3, 3, 0); - uiGrid->addWidget(mExpandPath, 3, 1); - mAddExpandPath = new QPushButton(tr("Add path")); - connect(mAddExpandPath, SIGNAL(clicked()), this, SLOT(addExpandPath())); - mRemoveExpandPath = new QPushButton(tr("Remove path")); - connect(mRemoveExpandPath, SIGNAL(clicked()), this, SLOT(removeExpandPath())); - QHBoxLayout *expandButtons = new QHBoxLayout; - expandButtons->addWidget(mAddExpandPath); - expandButtons->addWidget(mRemoveExpandPath); - uiGrid->addLayout(expandButtons, 4, 1); - uiGrid->addLayout(new QHBoxLayout, 5, 0, 2, 3); - uiWidget->setLayout(uiGrid); - mTab->addTab(uiWidget, tr("User interface")); + miscGrid->addWidget(miscl1, 0, 0); + miscGrid->addWidget(mIconForFolder, 0, 1); + QLabel *miscl2 = new QLabel(tr("Archive directory")); + mArchiveDir = new QLineEdit; + mArchiveDir->setCompleter(fsCompleter); + miscGrid->addWidget(miscl2, 1, 0); + miscGrid->addWidget(mArchiveDir, 1, 1); + miscWidget->setLayout(miscGrid); + QLabel *miscl3 = new QLabel(tr("Burn Directory")); + mBurnDir = new QLineEdit; + mBurnDir->setCompleter(fsCompleter); + miscGrid->addWidget(miscl3, 2, 0); + miscGrid->addWidget(mBurnDir, 2, 1); + mTab->addTab(miscWidget, tr("Misc. settings")); // movie viewer mMovieConfig = new ProgramConfigurator("movieviewer", "Movie viewer"); @@ -167,73 +113,17 @@ void ConfigurationDialog::accept(){ QDialog::accept(); } -void ConfigurationDialog::addPath(){ - QString newPath = mExtractPath->text(); - if(!newPath.isEmpty() && !mPaths.contains(newPath)){ - mArchivePaths->addItem(newPath); - mPaths.append(newPath); - } -} - -void ConfigurationDialog::removePath(){ - QString removePath = mArchivePaths->currentText(); - int current = mArchivePaths->currentIndex(); - if(!removePath.isEmpty()){ - if(mPaths.contains(removePath)){ - mPaths.removeOne(removePath); - mArchivePaths->removeItem(current); - } - } -} - -void ConfigurationDialog::addExpandPath(){ - QString newPath = mExpandPath->text(); - if(!newPath.isEmpty() && !mEPaths.contains(newPath)){ - mExpandPaths->addItem(newPath); - mEPaths.append(newPath); - } -} - -void ConfigurationDialog::removeExpandPath(){ - QString removePath = mExpandPaths->currentText(); - int current = mExpandPaths->currentIndex(); - if(!removePath.isEmpty()){ - if(mEPaths.contains(removePath)){ - mEPaths.removeOne(removePath); - mExpandPaths->removeItem(current); - } - } -} - -void ConfigurationDialog::selectStartup(){ - QString startup = mExpandPaths->currentText(); - if(!startup.isEmpty()){ - mSelectStartup = startup; - } -} - void ConfigurationDialog::readSettings(){ QSettings s; - //read paths - mArchiver->setText(s.value("paths/archiver", "/usr/bin/7z").toString()); - QStringList arArgs = s.value("paths/archiverargs").toStringList(); - mArchiverArgs->setText(arArgs.join(" ")); - QStringList extractPaths = s.value("paths/extractpaths").toStringList(); - mArchivePaths->addItems(extractPaths); - mPaths = extractPaths; - mArchiveDir->setText(s.value("paths/archivedir").toString()); - mBurnDir->setText(s.value("paths/burn").toString()); - - //read ui - QStringList expandPaths = s.value("ui/expandpaths").toStringList(); - mExpandPaths->addItems(expandPaths); - mEPaths = expandPaths; + //read misc QString icon = s.value("ui/foldericon", "Normal").toString(); int pos = mIconForFolder->findText(icon); if(pos != -1){ mIconForFolder->setCurrentIndex(pos); } + mArchiveDir->setText(s.value("paths/archivedir").toString()); + mBurnDir->setText(s.value("paths/burn").toString()); //read database mDatabaseHost->setText(s.value("database/hostname").toString()); @@ -246,20 +136,11 @@ void ConfigurationDialog::readSettings(){ void ConfigurationDialog::writeSettings(){ QSettings s; - //write paths - QRegExp splitAt("\\s+"); - s.setValue("paths/archiver", mArchiver->text()); - QStringList aArgs = mArchiverArgs->text().split(splitAt, QString::SkipEmptyParts); - s.setValue("paths/archiverargs", aArgs); - s.setValue("paths/extractpaths", mPaths); + //write misc + s.setValue("ui/folderIcon", mIconForFolder->currentText()); s.setValue("paths/archivedir", mArchiveDir->text()); s.setValue("paths/burn", mBurnDir->text()); - //write ui - s.setValue("ui/expandpaths", mEPaths); - s.setValue("ui/folderIcon", mIconForFolder->currentText()); - s.setValue("ui/selectstartup", mSelectStartup); - //write database s.setValue("database/hostname", mDatabaseHost->text()); s.setValue("database/dbname", mDatabaseName->text()); diff --git a/configurationdialog.h b/configurationdialog.h index b3324c5..1575f41 100644 --- a/configurationdialog.h +++ b/configurationdialog.h @@ -27,41 +27,22 @@ class ConfigurationDialog : public QDialog { void accept(); private slots: - void addPath(); - void removePath(); - void addExpandPath(); - void removeExpandPath(); - void selectStartup(); private: void readSettings(); void writeSettings(); QPushButton *mOk; QPushButton *mCancel; - QPushButton *mAddPath; - QPushButton *mRemovePath; - QPushButton *mAddExpandPath; - QPushButton *mRemoveExpandPath; - QPushButton *mSelect; QTabWidget *mTab; ProgramConfigurator *mMovieConfig; ProgramConfigurator *mPicConfig; - QLineEdit *mArchiver; - QLineEdit *mArchiverArgs; - QLineEdit *mExtractPath; - QLineEdit *mExpandPath; QLineEdit *mArchiveDir; QLineEdit *mBurnDir; QLineEdit *mDatabaseHost; QLineEdit *mDatabaseName; QLineEdit *mDatabaseUsername; QLineEdit *mDatabasePassword; - QComboBox *mArchivePaths; - QComboBox *mExpandPaths; QComboBox *mIconForFolder; - QStringList mPaths; - QStringList mEPaths; - QString mSelectStartup; }; #endif |