diff options
author | Arno <am@disconnect.de> | 2010-12-27 15:52:30 +0100 |
---|---|---|
committer | Arno <am@disconnect.de> | 2010-12-27 15:52:30 +0100 |
commit | 51f830068cb6b4847468aced1aa654932c39bf80 (patch) | |
tree | 0eff6453050a77999577310746e24f6182493cf3 | |
parent | 7bb7295a9033c0a6729b301e7c9b76393539e29a (diff) | |
download | SheMov-51f830068cb6b4847468aced1aa654932c39bf80.tar.gz SheMov-51f830068cb6b4847468aced1aa654932c39bf80.tar.bz2 SheMov-51f830068cb6b4847468aced1aa654932c39bf80.zip |
Made all icons in qresource available for UI
Every registered icon can be chosen as Qt::DecorationRole for all models
at once. Suitable icons must be added to SmGlobals::mIcons. Key is a
descriptive text, value is the icon path.
To make things easier SmTreeModel got two new member functions:
-QIcon decorationIcon() returning the current Icon
-void setDecorationIcon() to set the current Icon
The current Icon is initialized in the constructor from QSettings -
ui/iconfolder
To update the TreeViews connected to the FileSystemModel a little hack
is needed: Just set the QFileIconProvider again. This causes the Model
to update connected views.
-rw-r--r-- | archivetreeview.cpp | 10 | ||||
-rw-r--r-- | configurationdialog.cpp | 14 | ||||
-rw-r--r-- | configurationdialog.h | 2 | ||||
-rw-r--r-- | filestreemodel.cpp | 2 | ||||
-rw-r--r-- | filestreemodel.h | 1 | ||||
-rw-r--r-- | filesystemwidget.cpp | 8 | ||||
-rw-r--r-- | filesystemwidget.h | 3 | ||||
-rw-r--r-- | mappingtablewidget.cpp | 2 | ||||
-rw-r--r-- | mappingtablewidget.h | 5 | ||||
-rw-r--r-- | seriestreemodel.cpp | 2 | ||||
-rw-r--r-- | shemov.cpp | 1 | ||||
-rw-r--r-- | shemoviconprovider.cpp | 6 | ||||
-rw-r--r-- | smglobals.cpp | 16 | ||||
-rw-r--r-- | smglobals.h | 2 | ||||
-rw-r--r-- | smtreemodel.cpp | 8 | ||||
-rw-r--r-- | smtreemodel.h | 6 |
16 files changed, 75 insertions, 13 deletions
diff --git a/archivetreeview.cpp b/archivetreeview.cpp index 1a58041..16699dc 100644 --- a/archivetreeview.cpp +++ b/archivetreeview.cpp @@ -203,6 +203,16 @@ void ArchiveTreeView::readSettings(){ seriesWidget()->seriesTree()->readSettings(); filesWidget()->filesTree()->readSettings(); mFilesModel->readSettings(); + QSettings s; + QString iconName = s.value("ui/foldericon", "Dildo").toString(); + const QHash<QString, QString> icons = SmGlobals::instance()->icons(); + QIcon decorationIcon = QIcon(icons.value(iconName)); + mFilesModel->setDecorationIcon(decorationIcon); + mSeriesModel->setDecorationIcon(decorationIcon); + MappingTableItemModel *actorsModel = mActorsWidget->model(); + actorsModel->setDecorationIcon(decorationIcon); + MappingTableItemModel *genreModel = mGenresWidget->model(); + genreModel->setDecorationIcon(decorationIcon); } void ArchiveTreeView::currentChanged(const QItemSelection &selected, const QItemSelection &deselected){ diff --git a/configurationdialog.cpp b/configurationdialog.cpp index 7008e76..96c1d1b 100644 --- a/configurationdialog.cpp +++ b/configurationdialog.cpp @@ -33,9 +33,12 @@ #include <QPalette> #include <QImage> #include <QPainter> +#include <QStandardItemModel> +#include <QStandardItem> #include "configurationdialog.h" #include "programconfigurator.h" +#include "smglobals.h" ConfigurationDialog::ConfigurationDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){ //setup @@ -109,8 +112,13 @@ ConfigurationDialog::ConfigurationDialog(QWidget *parent, Qt::WindowFlags f) : Q QGroupBox *iconBox = new QGroupBox(tr("Icon for folders")); QHBoxLayout *iconLayout = new QHBoxLayout; mIconForFolder = new QComboBox; - QStringList icons = QStringList() << tr("Dildo") << tr("Normal"); - mIconForFolder->addItems(icons); + mIconModel = new QStandardItemModel; + const QHash<QString, QString> icons = SmGlobals::instance()->icons(); + for(QHash<QString, QString>::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); @@ -289,7 +297,7 @@ void ConfigurationDialog::readSettings(){ QSettings s; //read misc - QString icon = s.value("ui/foldericon", "Normal").toString(); + QString icon = s.value("ui/foldericon", "Dildo").toString(); int pos = mIconForFolder->findText(icon); if(pos != -1){ mIconForFolder->setCurrentIndex(pos); diff --git a/configurationdialog.h b/configurationdialog.h index 0f7f76e..90a2b22 100644 --- a/configurationdialog.h +++ b/configurationdialog.h @@ -18,6 +18,7 @@ class QComboBox; class QCheckBox; class QSpinBox; class QLabel; +class QStandardItemModel; class ProgramConfigurator; @@ -77,6 +78,7 @@ class ConfigurationDialog : public QDialog { QPushButton *mLocalColorButton; QCheckBox *mAlternateColors; QHash<QWidget*, QColor> mColors; + QStandardItemModel *mIconModel; }; #endif diff --git a/filestreemodel.cpp b/filestreemodel.cpp index 1a8b959..2e7ad83 100644 --- a/filestreemodel.cpp +++ b/filestreemodel.cpp @@ -185,7 +185,7 @@ QVariant FilesTreeModel::data(const QModelIndex &index, int role) const{ } if(role == Qt::DecorationRole){ if(index.column() == 0){ - return QIcon(":/dildo.png"); + return decorationIcon(); } } if(role == Qt::TextAlignmentRole){ diff --git a/filestreemodel.h b/filestreemodel.h index 23e5f75..c31b282 100644 --- a/filestreemodel.h +++ b/filestreemodel.h @@ -13,6 +13,7 @@ #include <QHash> #include <QMap> #include <QColor> +#include <QIcon> #include "smtreemodel.h" diff --git a/filesystemwidget.cpp b/filesystemwidget.cpp index 876d27d..f4a9d24 100644 --- a/filesystemwidget.cpp +++ b/filesystemwidget.cpp @@ -43,8 +43,8 @@ FilesystemWidget::FilesystemWidget(QWidget *parent) : QWidget(parent), mClipboar mModel->setRootPath("/"); mModel->setFilter(QDir::AllEntries | QDir::NoDot); mModel->setReadOnly(false); - SheMovIconProvider *p = new SheMovIconProvider; - mModel->setIconProvider(p); + mIconProvider = new SheMovIconProvider; + mModel->setIconProvider(mIconProvider); mDirProxy = new FilesystemDirProxy; mDirProxy->setSourceModel(mModel); @@ -393,6 +393,10 @@ void FilesystemWidget::writeSettings(){ s.setValue("windows/picviewer", mPicViewer->pos()); } +void FilesystemWidget::configChanged(){ + mModel->setIconProvider(mIconProvider); +} + void FilesystemWidget::dvdMount(){ QSettings s; QString mountDir = s.value("paths/dvdmount").toString(); diff --git a/filesystemwidget.h b/filesystemwidget.h index b54fdad..ed1f288 100644 --- a/filesystemwidget.h +++ b/filesystemwidget.h @@ -28,6 +28,7 @@ class PictureViewer; class QStringList; class FileSystemModel; class QSqlQuery; +class SheMovIconProvider; class FilesystemWidget : public QWidget { Q_OBJECT @@ -63,6 +64,7 @@ class FilesystemWidget : public QWidget { void playSelected(const QString &player = QString()); void readSettings(); void writeSettings(); + void configChanged(); void dvdMount(); void markSeen(); @@ -91,6 +93,7 @@ class FilesystemWidget : public QWidget { QString mTemplate; qint64 mSize; PictureViewer *mPicViewer; + SheMovIconProvider *mIconProvider; QString mLastDir; int mClipboardMode; }; diff --git a/mappingtablewidget.cpp b/mappingtablewidget.cpp index 74763b9..d36749b 100644 --- a/mappingtablewidget.cpp +++ b/mappingtablewidget.cpp @@ -116,7 +116,7 @@ MappingTableItemModel::MappingTableItemModel(QObject *parent) : QStringListModel QVariant MappingTableItemModel::data(const QModelIndex &index, int role) const{ if(role == Qt::DecorationRole){ - return QIcon(":/dildo.png"); + return decorationIcon(); } return QStringListModel::data(index, role); } diff --git a/mappingtablewidget.h b/mappingtablewidget.h index 34b877a..38c4fe1 100644 --- a/mappingtablewidget.h +++ b/mappingtablewidget.h @@ -51,10 +51,15 @@ class MappingTableItemModel : public QStringListModel { //data + flags virtual QVariant data(const QModelIndex &index, int role) const; virtual Qt::ItemFlags flags(const QModelIndex &index) const; + void setDecorationIcon(const QIcon &icon) { mDecorationIcon = icon; } + const QIcon decorationIcon() const { return mDecorationIcon; } //find int lowerBound(const QString &value) const; QModelIndex find(const QString &value) const; + + private: + QIcon mDecorationIcon; }; #endif // MAPPINGTABLEWIDGET_H diff --git a/seriestreemodel.cpp b/seriestreemodel.cpp index bd82acc..e881eb5 100644 --- a/seriestreemodel.cpp +++ b/seriestreemodel.cpp @@ -95,7 +95,7 @@ QVariant SeriesTreeModel::data(const QModelIndex &index, int role) const{ } if(role == Qt::DecorationRole){ if(index.column() == 0){ - return QIcon(":/dildo.png"); + return decorationIcon(); } } if(role == Qt::EditRole){ @@ -60,6 +60,7 @@ SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, fla setWindowTitle(mFSWidget->windowTitle()); mTab = new QTabWidget; mTab->addTab(mFSWidget, tr("Filemanager")); + connect(this, SIGNAL(configChanged()), mFSWidget, SLOT(configChanged())); //ArchiveTreeView mATree = new ArchiveTreeView; diff --git a/shemoviconprovider.cpp b/shemoviconprovider.cpp index 569956c..c46fa13 100644 --- a/shemoviconprovider.cpp +++ b/shemoviconprovider.cpp @@ -11,6 +11,7 @@ #include "shemoviconprovider.h" #include "helper.h" +#include "smglobals.h" SheMovIconProvider::SheMovIconProvider() {}; @@ -18,9 +19,8 @@ QIcon SheMovIconProvider::icon(const QFileInfo &info) const { if(info.isDir()){ QSettings s; QString fi(s.value("ui/foldericon").toString()); - if(fi == "Dildo"){ - return QIcon(":/dildo.png"); - } + const QHash<QString, QString> icons = SmGlobals::instance()->icons(); + return QIcon(icons.value(fi)); } QString type = Helper::mimeType(info.absoluteFilePath()); if(type.toLower().startsWith("video")){ diff --git a/smglobals.cpp b/smglobals.cpp index f163ac1..f0906f1 100644 --- a/smglobals.cpp +++ b/smglobals.cpp @@ -107,7 +107,21 @@ QSize SmGlobals::cursorSize() { return mCursorSize; } -SmGlobals::SmGlobals() : mPictureViewer(0), mFrameCache(0) {} +SmGlobals::SmGlobals() : mPictureViewer(0), mFrameCache(0){ + mIcons.insert("Dildo", ":/dildo.png"); + mIcons.insert("Dick to left", ":/back_dick.png"); + mIcons.insert("Dick pointing up", ":/up_dick.png"); + mIcons.insert("Chastity belt", ":/chastity_belt.png"); + mIcons.insert("Clitoris", ":/clitoris.png"); + mIcons.insert("Gaping ass", ":/gaping_ass.png"); + mIcons.insert("Nipple pointing up", ":/nipple_up.png"); + mIcons.insert("Bald pussy", ":/bald_pussy.png"); + mIcons.insert("Prince Albert", ":/prince_albert.png"); + mIcons.insert("Diaper", ":/diaper.png"); + mIcons.insert("High heels", ":/higheels.png"); + mIcons.insert("Ball gag", ":/ball_gag.png"); + mIcons.insert("French Maid Dress", ":/french_maid_dress.png"); +} //FrameCache SmGlobals::FrameCache::FrameCache(QObject *parent) : QObject(parent), mMagic(0xDEADBEEF), mCacheSubDir(".frameCache"), mCacheFileName("cache") { diff --git a/smglobals.h b/smglobals.h index b994b53..e86493c 100644 --- a/smglobals.h +++ b/smglobals.h @@ -46,6 +46,7 @@ class SmGlobals : public QObject { PictureViewer *pictureViewer(); FrameCache *frameCache(); QSize cursorSize(); + const QHash<QString, QString> & icons() const { return mIcons; } private: SmGlobals(); @@ -56,6 +57,7 @@ class SmGlobals : public QObject { PictureViewer *mPictureViewer; SmGlobals::FrameCache *mFrameCache; QSize mCursorSize; + QHash<QString, QString> mIcons; }; #endif diff --git a/smtreemodel.cpp b/smtreemodel.cpp index 2712cef..8b51bab 100644 --- a/smtreemodel.cpp +++ b/smtreemodel.cpp @@ -6,9 +6,11 @@ */ #include <QIcon> +#include <QSettings> #include "smtreemodel.h" #include "smtreeitem.h" +#include "smglobals.h" SmTreeModel::SmTreeModel(const QStringList &headers, QObject *parent) : QAbstractItemModel(parent), mRootItem(0){ mHeaders = headers; @@ -16,6 +18,10 @@ SmTreeModel::SmTreeModel(const QStringList &headers, QObject *parent) : QAbstrac mHeaderData.insert(mHeaders.at(i), i); } mRootItem = new SmTreeItem(headers.count()); + QSettings s; + QString iconName = s.value("ui/foldericon", "Dildo").toString(); + const QHash<QString, QString> icons = SmGlobals::instance()->icons(); + mDecorationIcon = QIcon(icons.value(iconName)); } SmTreeModel::~SmTreeModel(){ @@ -98,7 +104,7 @@ QVariant SmTreeModel::data(const QModelIndex &index, int role) const{ } if(role == Qt::DecorationRole){ if(index.column() == 0){ - return QIcon(":/dildo.png"); + return mDecorationIcon; } } return QVariant(); diff --git a/smtreemodel.h b/smtreemodel.h index 73abe64..f23e767 100644 --- a/smtreemodel.h +++ b/smtreemodel.h @@ -11,6 +11,7 @@ #include <QAbstractItemModel> #include <QStringList> #include <QHash> +#include <QIcon> class SmTreeItem; @@ -48,6 +49,10 @@ class SmTreeModel : public QAbstractItemModel { virtual bool removeRows(int row, int count, const QModelIndex &parent); bool addRow(const QList<QVariant> &data, const QModelIndex &parent); + //misc + void setDecorationIcon(const QIcon &icon) { mDecorationIcon = icon; } + const QIcon decorationIcon() const { return mDecorationIcon; } + protected: SmTreeItem *itemAt(const QModelIndex &index) const; @@ -55,6 +60,7 @@ class SmTreeModel : public QAbstractItemModel { QStringList mHeaders; SmTreeItem *mRootItem; QHash<QString, int> mHeaderData; + QIcon mDecorationIcon; }; #endif |