* sys icons tick in settings

* system icons loading support

* system icons loading, style fixes
This commit is contained in:
Yan Pashkovsky 2017-05-30 23:25:24 +03:00 committed by John Maguire
parent bdda50b28f
commit 583eb25cfc
4 changed files with 46 additions and 5 deletions

View File

@ -80,6 +80,9 @@ AppearanceSettingsPage::AppearanceSettingsPage(SettingsDialog* dialog)
SLOT(DisableBlurAndOpacitySliders(bool)));
connect(ui_->use_no_background, SIGNAL(toggled(bool)),
SLOT(DisableBlurAndOpacitySliders(bool)));
#if !defined (Q_OS_UNIX) || defined (Q_OS_MACOS)
ui_->sys_icons->setDisabled(true);
#endif
}
AppearanceSettingsPage::~AppearanceSettingsPage() { delete ui_; }
@ -105,6 +108,7 @@ void AppearanceSettingsPage::Load() {
current_background_color_ = original_background_color_;
InitColorSelectorsColors();
ui_->b_use_sys_icons->setChecked(s.value("b_use_sys_icons", false).toBool());
s.endGroup();
// Playlist settings
@ -166,6 +170,7 @@ void AppearanceSettingsPage::Save() {
} else {
dialog()->appearance()->ResetToSystemDefaultTheme();
}
s.setValue("b_use_sys_icons", ui_->b_use_sys_icons->isChecked());
s.endGroup();
// Playlist settings

View File

@ -262,6 +262,26 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Other</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="b_use_sys_icons">
<property name="text">
<string>Use system icons</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -17,15 +17,18 @@
*/
#include "iconloader.h"
#include "core/appearance.h"
#include "core/logging.h"
#include "core/utilities.h"
#include <QtDebug>
#include <QDir>
#include <QSettings>
QList<int> IconLoader::sizes_;
QString IconLoader::custom_icon_path_;
QList<QString> IconLoader::icon_sub_path_;
bool IconLoader::use_sys_icons_;
void IconLoader::Init() {
sizes_.clear();
@ -33,10 +36,12 @@ void IconLoader::Init() {
custom_icon_path_ = Utilities::GetConfigPath(Utilities::Path_Icons);
icon_sub_path_.clear();
icon_sub_path_ << "/icons" << "/providers" << "/last.fm" << "";
QSettings settings;
settings.beginGroup(Appearance::kSettingsGroup);
use_sys_icons_ = settings.value("b_use_sys_icons", false).toBool();
}
QIcon IconLoader::Load(const QString& name, const IconType& icontype) {
QIcon ret;
// If the icon name is empty
if (name.isEmpty()) {
@ -44,9 +49,17 @@ QIcon IconLoader::Load(const QString& name, const IconType& icontype) {
return ret;
}
#if QT_VERSION >= 0x040600
if (use_sys_icons_) {
ret = QIcon::fromTheme(name);
if (!ret.isNull()) return ret;
}
#endif
// Set the icon load location based on IConType
switch (icontype) {
case Base: case Provider: {
case Base:
case Provider: {
const QString custom_icon_location = custom_icon_path_
+ icon_sub_path_.at(icontype);
if (QDir(custom_icon_location).exists()) {
@ -68,9 +81,11 @@ QIcon IconLoader::Load(const QString& name, const IconType& icontype) {
if (QFile::exists(filename)) ret.addFile(filename, QSize(size, size));
}
break;
}
case Lastfm: case Other: {
case Lastfm:
case Other: {
// lastfm icons location
const QString custom_fm_other_icon_location = custom_icon_path_
+ icon_sub_path_.at(icontype);
@ -88,7 +103,7 @@ QIcon IconLoader::Load(const QString& name, const IconType& icontype) {
+ "/" + name + ".png");
if (QFile::exists(path_file)) ret.addFile(path_file);
if (ret.isNull()) qLog(Warning) << "Couldn't load icon" << name;
break;
}
default:
@ -102,8 +117,8 @@ QIcon IconLoader::Load(const QString& name, const IconType& icontype) {
ret = QIcon::fromTheme(name);
if (!ret.isNull()) return ret;
#endif
qLog(Warning) << "Couldn't load icon" << name;
}
else qLog(Warning) << "Couldn't load icon" << name;
return ret;
}

View File

@ -39,6 +39,7 @@ class IconLoader {
static QList<int> sizes_;
static QString custom_icon_path_;
static QList<QString> icon_sub_path_;
static bool use_sys_icons_;
};
#endif // ICONLOADER_H