aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-theme-engine/src/lthemeengine/iconthemepage.cpp
diff options
context:
space:
mode:
authorWeblate <noreply@weblate.org>2017-08-02 21:00:16 +0000
committerWeblate <noreply@weblate.org>2017-08-02 21:00:16 +0000
commit3d511a0f8285088eba24cb22b15cda039d27f6a0 (patch)
tree2eccf8b44a5e9862e6733880c37d57a9af74b41a /src-qt5/core/lumina-theme-engine/src/lthemeengine/iconthemepage.cpp
parentTranslated using Weblate (Spanish) (diff)
parentFix up the screensaver animation crashes *again*. (diff)
downloadlumina-3d511a0f8285088eba24cb22b15cda039d27f6a0.tar.gz
lumina-3d511a0f8285088eba24cb22b15cda039d27f6a0.tar.bz2
lumina-3d511a0f8285088eba24cb22b15cda039d27f6a0.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src-qt5/core/lumina-theme-engine/src/lthemeengine/iconthemepage.cpp')
-rw-r--r--src-qt5/core/lumina-theme-engine/src/lthemeengine/iconthemepage.cpp103
1 files changed, 46 insertions, 57 deletions
diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/iconthemepage.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine/iconthemepage.cpp
index cfe002aa..1a09ac0d 100644
--- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/iconthemepage.cpp
+++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/iconthemepage.cpp
@@ -22,22 +22,20 @@ IconThemePage::~IconThemePage(){
void IconThemePage::writeSettings(){
QSettings settings(lthemeengine::configFile(), QSettings::IniFormat);
QTreeWidgetItem *item = m_ui->treeWidget->currentItem();
- if(item)
- settings.setValue("Appearance/icon_theme", item->data(3, Qt::UserRole));
+ if(item){ settings.setValue("Appearance/icon_theme", item->data(3, Qt::UserRole)); }
}
void IconThemePage::readSettings(){
QSettings settings(lthemeengine::configFile(), QSettings::IniFormat);
QString name = settings.value("Appearance/icon_theme").toString();
- if(name.isEmpty())
- return;
- for(int i = 0; i < m_ui->treeWidget->topLevelItemCount(); ++i){
- QTreeWidgetItem *item = m_ui->treeWidget->topLevelItem(i);
- if(item->data(3, Qt::UserRole).toString() == name){
- m_ui->treeWidget->setCurrentItem(item);
- break;
- }
+ if(name.isEmpty()){ return; }
+ for(int i = 0; i < m_ui->treeWidget->topLevelItemCount(); ++i){
+ QTreeWidgetItem *item = m_ui->treeWidget->topLevelItem(i);
+ if(item->data(3, Qt::UserRole).toString() == name){
+ m_ui->treeWidget->setCurrentItem(item);
+ break;
}
+ }
}
void IconThemePage::loadThemes(){
@@ -61,39 +59,33 @@ void IconThemePage::loadTheme(const QString &path){
config.setIniCodec("UTF-8");
config.beginGroup("Icon Theme");
QStringList dirs = config.value("Directories").toStringList();
- if(dirs.isEmpty() || config.value("Hidden", false).toBool())
- return;
- QString name, comment;
- QString lang = QLocale::system().name();
- name = config.value(QString("Name[%1]").arg(lang)).toString();
- comment = config.value(QString("Comment[%1]").arg(lang)).toString();
- if(lang.contains("_"))
- lang = lang.split("_").first();
- if(name.isEmpty())
- name = config.value(QString("Name[%1]").arg(lang)).toString();
- if(comment.isEmpty())
- comment = config.value(QString("Comment[%1]").arg(lang)).toString();
- if(name.isEmpty())
- name = config.value("Name").toString();
- if(comment.isEmpty())
- comment = config.value("Comment").toString();
- config.endGroup();
- QIcon icon1 = findIcon(path, 24, "document-save");
- QIcon icon2 = findIcon(path, 24, "document-print");
- QIcon icon3 = findIcon(path, 24, "media-playback-stop");
- QTreeWidgetItem *item = new QTreeWidgetItem();
- item->setIcon(0, icon1);
- item->setIcon(1, icon2);
- item->setIcon(2, icon3);
- item->setText(3, name);
- item->setData(3, Qt::UserRole, QFileInfo(path).path().section("/", -1));
- item->setToolTip(3, comment);
- item->setSizeHint(0, QSize(24,24));
- m_ui->treeWidget->addTopLevelItem(item);
- m_ui->treeWidget->resizeColumnToContents(0);
- m_ui->treeWidget->resizeColumnToContents(1);
- m_ui->treeWidget->resizeColumnToContents(2);
- m_ui->treeWidget->resizeColumnToContents(3);
+ if(dirs.isEmpty() || config.value("Hidden", false).toBool()){ return; }
+ QString name, comment;
+ QString lang = QLocale::system().name();
+ name = config.value(QString("Name[%1]").arg(lang)).toString();
+ comment = config.value(QString("Comment[%1]").arg(lang)).toString();
+ if(lang.contains("_")){ lang = lang.split("_").first(); }
+ if(name.isEmpty()){ name = config.value(QString("Name[%1]").arg(lang)).toString(); }
+ if(comment.isEmpty()){ comment = config.value(QString("Comment[%1]").arg(lang)).toString(); }
+ if(name.isEmpty()){ name = config.value("Name").toString(); }
+ if(comment.isEmpty()){ comment = config.value("Comment").toString(); }
+ config.endGroup();
+ QIcon icon1 = findIcon(path, 24, "document-save");
+ QIcon icon2 = findIcon(path, 24, "document-print");
+ QIcon icon3 = findIcon(path, 24, "media-playback-stop");
+ QTreeWidgetItem *item = new QTreeWidgetItem();
+ item->setIcon(0, icon1);
+ item->setIcon(1, icon2);
+ item->setIcon(2, icon3);
+ item->setText(3, name);
+ item->setData(3, Qt::UserRole, QFileInfo(path).path().section("/", -1));
+ item->setToolTip(3, comment);
+ item->setSizeHint(0, QSize(24,24));
+ m_ui->treeWidget->addTopLevelItem(item);
+ m_ui->treeWidget->resizeColumnToContents(0);
+ m_ui->treeWidget->resizeColumnToContents(1);
+ m_ui->treeWidget->resizeColumnToContents(2);
+ m_ui->treeWidget->resizeColumnToContents(3);
}
QIcon IconThemePage::findIcon(const QString &themePath, int size, const QString &name){
@@ -127,18 +119,15 @@ QIcon IconThemePage::findIcon(const QString &themePath, int size, const QString
}
config.endGroup();
}
- if (!haveInherits)
- return QIcon();
- parents.append("hicolor"); //add fallback themes
- parents.append("gnome");
- parents.removeDuplicates();
- foreach (QString parent, parents){
- QString parentThemePath = QDir(QFileInfo(themePath).path() + "/../" + parent).canonicalPath() + "/index.theme";
- if(!QFile::exists(parentThemePath) || parentThemePath == themePath)
- continue;
- QIcon icon = findIcon(parentThemePath, size, name);
- if(!icon.isNull())
- return icon;
- }
- return QIcon();
+ if (!haveInherits){ return QIcon(); }
+ parents.append("hicolor"); //add fallback themes
+ parents.append("gnome");
+ parents.removeDuplicates();
+ foreach (QString parent, parents){
+ QString parentThemePath = QDir(QFileInfo(themePath).path() + "/../" + parent).canonicalPath() + "/index.theme";
+ if(!QFile::exists(parentThemePath) || parentThemePath == themePath){ continue; }
+ QIcon icon = findIcon(parentThemePath, size, name);
+ if(!icon.isNull()){ return icon; }
+ }
+ return QIcon();
}
bgstack15