Enable system theme icons, add iconmapper and rename some icon names
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include <QSettings>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "iconmapper.h"
|
||||
#include "settings/appearancesettingspage.h"
|
||||
#include "iconloader.h"
|
||||
|
||||
@@ -37,12 +38,10 @@ bool IconLoader::custom_icons_ = false;
|
||||
|
||||
void IconLoader::Init() {
|
||||
|
||||
// TODO: Fix use system icons option properly.
|
||||
|
||||
//QSettings s;
|
||||
//s.beginGroup(AppearanceSettingsPage::kSettingsGroup);
|
||||
//system_icons_ = s.value("system_icons", false).toBool();
|
||||
//s.endGroup();
|
||||
QSettings s;
|
||||
s.beginGroup(AppearanceSettingsPage::kSettingsGroup);
|
||||
system_icons_ = s.value("system_icons", false).toBool();
|
||||
s.endGroup();
|
||||
|
||||
QDir dir;
|
||||
if (dir.exists(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/icons")) {
|
||||
@@ -66,7 +65,17 @@ QIcon IconLoader::Load(const QString &name, const int size) {
|
||||
else sizes << size;
|
||||
|
||||
if (system_icons_) {
|
||||
IconMapper::IconProperties icon_prop;
|
||||
if (IconMapper::iconmapper_.contains(name)) {
|
||||
icon_prop = IconMapper::iconmapper_[name];
|
||||
}
|
||||
ret = QIcon::fromTheme(name);
|
||||
if (ret.isNull()) {
|
||||
for (QString alt_name : icon_prop.names) {
|
||||
ret = QIcon::fromTheme(alt_name);
|
||||
if (!ret.isNull()) break;
|
||||
}
|
||||
}
|
||||
if (!ret.isNull()) return ret;
|
||||
qLog(Warning) << "Couldn't load icon" << name << "from system theme icons.";
|
||||
}
|
||||
|
||||
135
src/core/iconmapper.h
Normal file
135
src/core/iconmapper.h
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2019, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QMap>
|
||||
|
||||
namespace IconMapper {
|
||||
|
||||
struct IconProperties {
|
||||
IconProperties() : min_size(0), max_size(0) {}
|
||||
IconProperties(const QStringList &_names, const int _min_size, const int _max_size) : names(_names), min_size(_min_size), max_size(_max_size) {}
|
||||
QStringList names;
|
||||
int min_size;
|
||||
int max_size;
|
||||
};
|
||||
|
||||
static const QMap<QString, IconProperties> iconmapper_ = {
|
||||
|
||||
{ "albums", { {"media-optical"}, 0, 0 } },
|
||||
{ "alsa", { {}, 0, 0 } },
|
||||
{ "application-exit", { {}, 0, 0 } },
|
||||
{ "applications-internet", { {}, 0, 0 } },
|
||||
{ "bluetooth", { {}, 0, 0 } },
|
||||
{ "cdcase", { {"cdcover", "media-optical"}, 0, 0 } },
|
||||
{ "media-optical", { {"cd"}, 0, 0 } },
|
||||
{ "configure", { {}, 0, 0 } },
|
||||
{ "device-ipod-nano", { {}, 0, 0 } },
|
||||
{ "device-ipod", { {}, 0, 0 } },
|
||||
{ "device-phone", { {}, 0, 0 } },
|
||||
{ "device", { {"drive-removable-media-usb-pendrive"}, 0, 0 } },
|
||||
{ "device-usb-drive", { {}, 0, 0 } },
|
||||
{ "device-usb-flash", { {}, 0, 0 } },
|
||||
{ "dialog-error", { {}, 0, 0 } },
|
||||
{ "dialog-information", { {}, 0, 0 } },
|
||||
{ "dialog-ok-apply", { {}, 0, 0 } },
|
||||
{ "dialog-password", { {}, 0, 0 } },
|
||||
{ "dialog-warning", { {}, 0, 0 } },
|
||||
{ "document-download", { {}, 0, 0 } },
|
||||
{ "document-new", { {}, 0, 0 } },
|
||||
{ "document-open-folder", { {}, 0, 0 } },
|
||||
{ "document-open", { {}, 0, 0 } },
|
||||
{ "document-save", { {}, 0, 0 } },
|
||||
{ "document-search", { {}, 0, 0 } },
|
||||
{ "download", { {}, 0, 0 } },
|
||||
{ "edit-clear-list", { {}, 0, 0 } },
|
||||
{ "edit-clear-locationbar-ltr", { {}, 0, 0 } },
|
||||
{ "edit-copy", { {}, 0, 0 } },
|
||||
{ "edit-delete", { {}, 0, 0 } },
|
||||
{ "edit-find", { {}, 0, 0 } },
|
||||
{ "edit-redo", { {}, 0, 0 } },
|
||||
{ "edit-rename", { {}, 0, 0 } },
|
||||
{ "edit-undo", { {}, 0, 0 } },
|
||||
{ "electrocompaniet", { {}, 0, 0 } },
|
||||
{ "equalizer", { {}, 0, 0 } },
|
||||
{ "folder-new", { {}, 0, 0 } },
|
||||
{ "folder", { {}, 0, 0 } },
|
||||
{ "folder-sound", { {"folder-music"}, 0, 0 } },
|
||||
{ "footsteps", { {}, 0, 0 } },
|
||||
{ "go-down", { {}, 0, 0 } },
|
||||
{ "go-home", { {}, 0, 0 } },
|
||||
{ "go-jump", { {}, 0, 0 } },
|
||||
{ "go-next", { {}, 0, 0 } },
|
||||
{ "go-previous", { {}, 0, 0 } },
|
||||
{ "go-up", { {}, 0, 0 } },
|
||||
{ "gstreamer", { {}, 0, 0 } },
|
||||
{ "headset", { {}, 0, 0 } },
|
||||
{ "help-hint", { {}, 0, 0 } },
|
||||
{ "intel", { {}, 0, 0 } },
|
||||
{ "jack", { {}, 0, 0 } },
|
||||
{ "keyboard", { {}, 0, 0 } },
|
||||
{ "list-add", { {}, 0, 0 } },
|
||||
{ "list-remove", { {}, 0, 0 } },
|
||||
{ "love", { {"heart", "emblem-favorite"}, 0, 0 } },
|
||||
{ "mcintosh-player", { {}, 0, 0 } },
|
||||
{ "mcintosh", { {}, 0, 0 } },
|
||||
{ "mcintosh-text", { {}, 0, 0 } },
|
||||
{ "media-eject", { {}, 0, 0 } },
|
||||
{ "media-playback-pause", { {"media-pause"}, 0, 0 } },
|
||||
{ "media-playlist-repeat", { {}, 0, 0 } },
|
||||
{ "media-playlist-shuffle", { {""}, 0, 0 } },
|
||||
{ "media-playback-start", { {"media-play", "media-playback-playing"}, 0, 0 } },
|
||||
{ "media-seek-backward", { {}, 0, 0 } },
|
||||
{ "media-seek-forward", { {}, 0, 0 } },
|
||||
{ "media-skip-backward", { {}, 0, 0 } },
|
||||
{ "media-skip-forward", { {}, 0, 0 } },
|
||||
{ "media-playback-stop", { {"media-stop"}, 0, 0 } },
|
||||
{ "moodbar", { {"preferences-desktop-icons"}, 0, 0 } },
|
||||
{ "nvidia", { {}, 0, 0 } },
|
||||
{ "pulseaudio", { {}, 0, 0 } },
|
||||
{ "qobuz", { {}, 0, 0 } },
|
||||
{ "realtek", { {}, 0, 0 } },
|
||||
{ "scrobble-disabled", { {}, 0, 0 } },
|
||||
{ "scrobble", { {}, 0, 0 } },
|
||||
{ "search", { {}, 0, 0 } },
|
||||
{ "soundcard", { {"audiocard", "audio-card"}, 0, 0 } },
|
||||
{ "speaker", { {}, 0, 0 } },
|
||||
{ "star-grey", { {}, 0, 0 } },
|
||||
{ "star", { {}, 0, 0 } },
|
||||
{ "strawberry", { {}, 0, 0 } },
|
||||
{ "subsonic", { {}, 0, 0 } },
|
||||
{ "tidal", { {}, 0, 0 } },
|
||||
{ "tools-wizard", { {}, 0, 0 } },
|
||||
{ "view-choose", { {}, 0, 0 } },
|
||||
{ "view-fullscreen", { {}, 0, 0 } },
|
||||
{ "view-media-lyrics", { {}, 0, 0 } },
|
||||
{ "view-media-playlist", { {}, 0, 0 } },
|
||||
{ "view-media-visualization", { {"preferences-desktop-theme"}, 0, 0 } },
|
||||
{ "view-refresh", { {}, 0, 0 } },
|
||||
{ "library-music", { {"vinyl"}, 0, 0 } },
|
||||
{ "vlc", { {}, 0, 0 } },
|
||||
{ "xine", { {}, 0, 0 } },
|
||||
{ "zoom-in", { {}, 0, 0 } },
|
||||
{ "zoom-out", { {}, 0, 0 } }
|
||||
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@@ -273,7 +273,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
||||
|
||||
// Add tabs to the fancy tab widget
|
||||
ui_->tabs->AddTab(context_view_, "context", IconLoader::Load("strawberry"), tr("Context"));
|
||||
ui_->tabs->AddTab(collection_view_, "collection", IconLoader::Load("vinyl"), tr("Collection"));
|
||||
ui_->tabs->AddTab(collection_view_, "collection", IconLoader::Load("library-music"), tr("Collection"));
|
||||
ui_->tabs->AddTab(file_view_, "files", IconLoader::Load("document-open"), tr("Files"));
|
||||
ui_->tabs->AddTab(playlist_list_, "playlists", IconLoader::Load("view-media-playlist"), tr("Playlists"));
|
||||
ui_->tabs->AddTab(queue_view_, "queue", IconLoader::Load("footsteps"), tr("Queue"));
|
||||
@@ -346,11 +346,11 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
||||
// Music menu
|
||||
|
||||
ui_->action_open_file->setIcon(IconLoader::Load("document-open"));
|
||||
ui_->action_open_cd->setIcon(IconLoader::Load("cd"));
|
||||
ui_->action_open_cd->setIcon(IconLoader::Load("media-optical"));
|
||||
ui_->action_previous_track->setIcon(IconLoader::Load("media-skip-backward"));
|
||||
ui_->action_play_pause->setIcon(IconLoader::Load("media-play"));
|
||||
ui_->action_stop->setIcon(IconLoader::Load("media-stop"));
|
||||
ui_->action_stop_after_this_track->setIcon(IconLoader::Load("media-stop"));
|
||||
ui_->action_play_pause->setIcon(IconLoader::Load("media-playback-start"));
|
||||
ui_->action_stop->setIcon(IconLoader::Load("media-playback-stop"));
|
||||
ui_->action_stop_after_this_track->setIcon(IconLoader::Load("media-playback-stop"));
|
||||
ui_->action_next_track->setIcon(IconLoader::Load("media-skip-forward"));
|
||||
ui_->action_quit->setIcon(IconLoader::Load("application-exit"));
|
||||
|
||||
@@ -594,7 +594,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
||||
connect(playlist_menu_, SIGNAL(aboutToHide()), SLOT(PlaylistMenuHidden()));
|
||||
playlist_play_pause_ = playlist_menu_->addAction(tr("Play"), this, SLOT(PlaylistPlay()));
|
||||
playlist_menu_->addAction(ui_->action_stop);
|
||||
playlist_stop_after_ = playlist_menu_->addAction(IconLoader::Load("media-stop"), tr("Stop after this track"), this, SLOT(PlaylistStopAfter()));
|
||||
playlist_stop_after_ = playlist_menu_->addAction(IconLoader::Load("media-playback-stop"), tr("Stop after this track"), this, SLOT(PlaylistStopAfter()));
|
||||
playlist_queue_ = playlist_menu_->addAction(IconLoader::Load("go-next"), tr("Toggle queue status"), this, SLOT(PlaylistQueue()));
|
||||
playlist_queue_->setShortcut(QKeySequence("Ctrl+D"));
|
||||
ui_->playlist->addAction(playlist_queue_);
|
||||
@@ -1040,7 +1040,7 @@ void MainWindow::MediaStopped() {
|
||||
|
||||
ui_->action_stop->setEnabled(false);
|
||||
ui_->action_stop_after_this_track->setEnabled(false);
|
||||
ui_->action_play_pause->setIcon(IconLoader::Load("media-play"));
|
||||
ui_->action_play_pause->setIcon(IconLoader::Load("media-playback-start"));
|
||||
ui_->action_play_pause->setText(tr("Play"));
|
||||
|
||||
ui_->action_play_pause->setEnabled(true);
|
||||
@@ -1069,7 +1069,7 @@ void MainWindow::MediaPaused() {
|
||||
|
||||
ui_->action_stop->setEnabled(true);
|
||||
ui_->action_stop_after_this_track->setEnabled(true);
|
||||
ui_->action_play_pause->setIcon(IconLoader::Load("media-play"));
|
||||
ui_->action_play_pause->setIcon(IconLoader::Load("media-playback-start"));
|
||||
ui_->action_play_pause->setText(tr("Play"));
|
||||
|
||||
ui_->action_play_pause->setEnabled(true);
|
||||
@@ -1087,7 +1087,7 @@ void MainWindow::MediaPlaying() {
|
||||
|
||||
ui_->action_stop->setEnabled(true);
|
||||
ui_->action_stop_after_this_track->setEnabled(true);
|
||||
ui_->action_play_pause->setIcon(IconLoader::Load("media-pause"));
|
||||
ui_->action_play_pause->setIcon(IconLoader::Load("media-playback-pause"));
|
||||
ui_->action_play_pause->setText(tr("Pause"));
|
||||
|
||||
bool enable_play_pause(false);
|
||||
@@ -1527,11 +1527,11 @@ void MainWindow::PlaylistRightClick(const QPoint &global_pos, const QModelIndex
|
||||
// Is this song currently playing?
|
||||
if (app_->playlist_manager()->current()->current_row() == source_index.row() && app_->player()->GetState() == Engine::Playing) {
|
||||
playlist_play_pause_->setText(tr("Pause"));
|
||||
playlist_play_pause_->setIcon(IconLoader::Load("media-pause"));
|
||||
playlist_play_pause_->setIcon(IconLoader::Load("media-playback-pause"));
|
||||
}
|
||||
else {
|
||||
playlist_play_pause_->setText(tr("Play"));
|
||||
playlist_play_pause_->setIcon(IconLoader::Load("media-play"));
|
||||
playlist_play_pause_->setIcon(IconLoader::Load("media-playback-start"));
|
||||
}
|
||||
|
||||
// Are we allowed to pause?
|
||||
@@ -1644,7 +1644,7 @@ void MainWindow::PlaylistRightClick(const QPoint &global_pos, const QModelIndex
|
||||
else playlist_queue_->setIcon(IconLoader::Load("go-next"));
|
||||
|
||||
if (in_skipped < selected) playlist_skip_->setIcon(IconLoader::Load("media-skip-forward"));
|
||||
else playlist_skip_->setIcon(IconLoader::Load("media-play"));
|
||||
else playlist_skip_->setIcon(IconLoader::Load("media-playback-start"));
|
||||
|
||||
|
||||
if (!index.isValid()) {
|
||||
|
||||
@@ -190,7 +190,7 @@ void QtSystemTrayIcon::SetPaused() {
|
||||
|
||||
action_stop_->setEnabled(true);
|
||||
action_stop_after_this_track_->setEnabled(true);
|
||||
action_play_pause_->setIcon(IconLoader::Load("media-play"));
|
||||
action_play_pause_->setIcon(IconLoader::Load("media-playback-start"));
|
||||
action_play_pause_->setText(tr("Play"));
|
||||
|
||||
action_play_pause_->setEnabled(true);
|
||||
@@ -203,7 +203,7 @@ void QtSystemTrayIcon::SetPlaying(bool enable_play_pause) {
|
||||
|
||||
action_stop_->setEnabled(true);
|
||||
action_stop_after_this_track_->setEnabled(true);
|
||||
action_play_pause_->setIcon(IconLoader::Load("media-pause"));
|
||||
action_play_pause_->setIcon(IconLoader::Load("media-playback-pause"));
|
||||
action_play_pause_->setText(tr("Pause"));
|
||||
action_play_pause_->setEnabled(enable_play_pause);
|
||||
|
||||
@@ -215,7 +215,7 @@ void QtSystemTrayIcon::SetStopped() {
|
||||
|
||||
action_stop_->setEnabled(false);
|
||||
action_stop_after_this_track_->setEnabled(false);
|
||||
action_play_pause_->setIcon(IconLoader::Load("media-play"));
|
||||
action_play_pause_->setIcon(IconLoader::Load("media-playback-start"));
|
||||
action_play_pause_->setText(tr("Play"));
|
||||
|
||||
action_play_pause_->setEnabled(true);
|
||||
|
||||
@@ -489,8 +489,8 @@ QIcon Song::IconForSource(Source source) {
|
||||
|
||||
switch (source) {
|
||||
case Song::Source_LocalFile: return IconLoader::Load("folder-sound");
|
||||
case Song::Source_Collection: return IconLoader::Load("vinyl");
|
||||
case Song::Source_CDDA: return IconLoader::Load("cd");
|
||||
case Song::Source_Collection: return IconLoader::Load("library-music");
|
||||
case Song::Source_CDDA: return IconLoader::Load("media-optical");
|
||||
case Song::Source_Device: return IconLoader::Load("device");
|
||||
case Song::Source_Stream: return IconLoader::Load("applications-internet");
|
||||
case Song::Source_Tidal: return IconLoader::Load("tidal");
|
||||
|
||||
Reference in New Issue
Block a user