summaryrefslogtreecommitdiffstats
path: root/configurationdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'configurationdialog.cpp')
-rw-r--r--configurationdialog.cpp80
1 files changed, 80 insertions, 0 deletions
diff --git a/configurationdialog.cpp b/configurationdialog.cpp
index 34e5d10..32fc197 100644
--- a/configurationdialog.cpp
+++ b/configurationdialog.cpp
@@ -84,6 +84,40 @@ ConfigurationDialog::ConfigurationDialog(QWidget *parent, Qt::WindowFlags f) : Q
pathWidget->setLayout(pathGrid);
mTab->addTab(pathWidget, tr("Paths"));
+ //ui tab
+ QWidget *uiWidget = new QWidget;
+ QGridLayout *uiGrid = new QGridLayout;
+ QLabel *ui1 = new QLabel(tr("Select icon for &folders"));
+ mIconForFolder = new QComboBox;
+ ui1->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);
+ uiWidget->setLayout(uiGrid);
+ mTab->addTab(uiWidget, tr("User interface"));
+
//main layout
mOk = new QPushButton(tr("Ok"));
connect(mOk, SIGNAL(clicked()), this, SLOT(accept()));
@@ -126,8 +160,36 @@ void ConfigurationDialog::removePath(){
}
}
+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
mPictureViewer->setText(s.value("paths/pictureviewer", "/usr/bin/gwenview").toString());
QStringList pvArgs = s.value("paths/pictureviewerargs").toStringList();
mPictureViewerArgs->setText(pvArgs.join(" "));
@@ -140,10 +202,23 @@ void ConfigurationDialog::readSettings(){
QStringList extractPaths = s.value("paths/extractpaths").toStringList();
mArchivePaths->addItems(extractPaths);
mPaths = extractPaths;
+
+ //read ui
+ QStringList expandPaths = s.value("ui/expandpaths").toStringList();
+ mExpandPaths->addItems(expandPaths);
+ mEPaths = expandPaths;
+ QString icon = s.value("ui/foldericon", "Normal").toString();
+ int pos = mIconForFolder->findText(icon);
+ if(pos != -1){
+ mIconForFolder->setCurrentIndex(pos);
+ }
+
}
void ConfigurationDialog::writeSettings(){
QSettings s;
+
+ //write paths
QRegExp splitAt("\\s+");
s.setValue("paths/pictureviewer", mPictureViewer->text());
QStringList pvArgs = mPictureViewerArgs->text().split(splitAt, QString::SkipEmptyParts);
@@ -155,5 +230,10 @@ void ConfigurationDialog::writeSettings(){
QStringList aArgs = mArchiverArgs->text().split(splitAt, QString::SkipEmptyParts);
s.setValue("paths/archiverargs", aArgs);
s.setValue("paths/extractpaths", mPaths);
+
+ //write ui
+ s.setValue("ui/expandpaths", mEPaths);
+ s.setValue("ui/folderIcon", mIconForFolder->currentText());
+ s.setValue("ui/selectstartup", mSelectStartup);
}