From ffe0b7556907bc4c6dfaed87a98e7fe68378cfa2 Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 17 Mar 2013 09:30:45 +0100 Subject: Icons for SmDirModel Made Icons for SmDirModel configurable. For now it's folders, movies, pictures and others. --- configurationdialog.cpp | 91 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 70 insertions(+), 21 deletions(-) (limited to 'configurationdialog.cpp') diff --git a/configurationdialog.cpp b/configurationdialog.cpp index ce36ee6..015a33a 100644 --- a/configurationdialog.cpp +++ b/configurationdialog.cpp @@ -98,20 +98,6 @@ ConfigurationDialog::ConfigurationDialog(QWidget *parent, Qt::WindowFlags f) : S QVBoxLayout *miscLayout = new QVBoxLayout; miscLayout->setAlignment(Qt::AlignTop); - //misc - icons - QGroupBox *iconBox = new QGroupBox(tr("Icon for folders")); - QHBoxLayout *iconLayout = new QHBoxLayout; - mIconForFolder = new QComboBox; - mIconModel = new QStandardItemModel; - const QHash icons = SmGlobals::instance()->icons(); - for(QHash::const_iterator it = icons.constBegin(); it != icons.constEnd(); ++it){ - QStandardItem *item = new QStandardItem(QIcon(it.value()), it.key()); - mIconModel->appendRow(item); - } - mIconForFolder->setModel(mIconModel); - iconLayout->addWidget(mIconForFolder); - iconBox->setLayout(iconLayout); - //misc - hover QGroupBox *hoverBox = new QGroupBox(tr("Hover options")); QVBoxLayout *hoverLayout = new QVBoxLayout; @@ -155,12 +141,56 @@ ConfigurationDialog::ConfigurationDialog(QWidget *parent, Qt::WindowFlags f) : S archiveBox->setLayout(archiveLayout); //misc - assemble - miscLayout->addWidget(iconBox); miscLayout->addWidget(hoverBox); miscLayout->addWidget(archiveBox); miscWidget->setLayout(miscLayout); mTab->addTab(miscWidget, tr("Misc. settings")); + // icons + mIconModel = new QStandardItemModel; + const QHash icons = SmGlobals::instance()->icons(); + for(QHash::const_iterator it = icons.constBegin(); it != icons.constEnd(); ++it){ + QStandardItem *item = new QStandardItem(QIcon(it.value()), it.key()); + mIconModel->appendRow(item); + } + QGroupBox *folderIconBox = new QGroupBox(tr("Icon for folders")); + QHBoxLayout *folderIconLayout = new QHBoxLayout; + mIconForFolder = new QComboBox; + mIconForFolder->setModel(mIconModel); + folderIconLayout->addWidget(mIconForFolder); + folderIconBox->setLayout(folderIconLayout); + + QGroupBox *movieIconBox = new QGroupBox(tr("Icon for movies")); + QHBoxLayout *movieIconLayout = new QHBoxLayout; + mIconForMovie = new QComboBox; + mIconForMovie->setModel(mIconModel); + movieIconLayout->addWidget(mIconForMovie); + movieIconBox->setLayout(movieIconLayout); + + QGroupBox *pictureIconBox = new QGroupBox(tr("Icon for pictures")); + QHBoxLayout *pictureIconLayout = new QHBoxLayout; + mIconForPic = new QComboBox; + mIconForPic->setModel(mIconModel); + pictureIconLayout->addWidget(mIconForPic); + pictureIconBox->setLayout(pictureIconLayout); + + QGroupBox *otherIconBox = new QGroupBox(tr("Icon for other")); + QHBoxLayout *otherIconLayout = new QHBoxLayout; + mIconForOther = new QComboBox; + mIconForOther->setModel(mIconModel); + otherIconLayout->addWidget(mIconForOther); + otherIconBox->setLayout(otherIconLayout); + + QVBoxLayout *iconWidgetLayout = new QVBoxLayout; + iconWidgetLayout->addWidget(folderIconBox); + iconWidgetLayout->addWidget(movieIconBox); + iconWidgetLayout->addWidget(pictureIconBox); + iconWidgetLayout->addWidget(otherIconBox); + iconWidgetLayout->addStretch(); + QWidget *iconWidget = new QWidget; + iconWidget->setLayout(iconWidgetLayout); + mTab->addTab(iconWidget, tr("Icons")); + // movie viewer QGroupBox *movieBox = new QGroupBox(tr("Movie viewer")); QHBoxLayout *movieBoxLayout = new QHBoxLayout; @@ -383,12 +413,25 @@ void ConfigurationDialog::setGrabFrameEnabled(bool enabled){ void ConfigurationDialog::readSettings(){ QSettings s; - //read misc - QString icon = s.value("ui/foldericon", "Dildo").toString(); - int pos = mIconForFolder->findText(icon); - if(pos != -1){ - mIconForFolder->setCurrentIndex(pos); - } + //read icons + QString iconText = s.value("ui/foldericon", "Dildo").toString(); + int pos = mIconForFolder->findText(iconText); + pos = pos > -1 ? pos : 0; + mIconForFolder->setCurrentIndex(pos); + iconText = s.value("ui/movieicon", "Dildo").toString(); + pos = mIconForMovie->findText(iconText); + pos = pos > -1 ? pos : 0; + mIconForMovie->setCurrentIndex(pos); + iconText = s.value("ui/pictureicon", "Dildo").toString(); + pos = mIconForPic->findText(iconText); + pos = pos > -1 ? pos : 0; + mIconForPic->setCurrentIndex(pos); + iconText = s.value("ui/othericon", "Dildo").toString(); + pos = mIconForOther->findText(iconText); + pos = pos > -1 ? pos : 0; + mIconForOther->setCurrentIndex(pos); + + // read misc mHoverPics->setChecked(s.value("ui/hoverpics", false).toBool()); mHoverArchive->setChecked(s.value("ui/hoverarchive", false).toBool()); mHoverMovies->setChecked(s.value("ui/hovermovies", false).toBool()); @@ -475,7 +518,13 @@ void ConfigurationDialog::writeSettings(){ s.setValue("paths/strippath", mStripPath->text()); s.setValue("paths/coverpath", mCoverPath->text()); + //write icons s.setValue("ui/foldericon", mIconForFolder->currentText()); + s.setValue("ui/movieicon", mIconForMovie->currentText()); + s.setValue("ui/pictureicon", mIconForPic->currentText()); + s.setValue("ui/othericon", mIconForOther->currentText()); + + //write misc s.setValue("ui/hoverpics", (mHoverPics->checkState() == Qt::Checked)); s.setValue("ui/hoverarchive", (mHoverArchive->checkState() == Qt::Checked)); s.setValue("ui/hoveropacity", mHoverOpacity->value()); -- cgit v1.2.3-70-g09d2