/* * Cantata * * Copyright (c) 2011-2016 Craig Drummond * * ---- * * This program 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 2 of the License, or * (at your option) any later version. * * This program 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 this program; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "icons.h" #include "gui/settings.h" #include "support/globalstatic.h" #include "support/utils.h" #include "support/pathrequester.h" #include "support/monoicon.h" #if !defined Q_OS_WIN && !defined Q_OS_MAC && !defined ENABLE_UBUNTU #include "support/gtkstyle.h" #endif #ifdef Q_OS_MAC #include "support/osxstyle.h" #endif #include #include #include #include GLOBAL_STATIC(Icons, instance) static QList constStdSizes=QList() << 16 << 22 << 32 << 48; // << 64; static const int constDarkLimit=80; static const int constDarkValue=64; static const int constLightLimit=240; static const int constLightValue=240; static bool inline isVeryLight(const QColor &col, int limit=constLightValue) { return col.red()>=limit && col.blue()>=limit && col.green()>=limit; } static bool inline isVeryDark(const QColor &col, int limit=constDarkValue) { return col.red()monoIconColor(); QColor highlightedTexCol=OSXStyle::self()->viewPalette().highlightedText().color(); #else QColor textCol=QApplication::palette().color(QPalette::Active, QPalette::WindowText); QColor highlightedTexCol=QApplication::palette().color(QPalette::Active, QPalette::HighlightedText); #endif playqueueIcon=MonoIcon::icon(QLatin1String(":sidebar-playqueue"), textCol, highlightedTexCol); libraryIcon=MonoIcon::icon(QLatin1String(":sidebar-library"), textCol, highlightedTexCol); foldersIcon=MonoIcon::icon(QLatin1String(":sidebar-folders"), textCol, highlightedTexCol); playlistsIcon=MonoIcon::icon(QLatin1String(":sidebar-playlists"), textCol, highlightedTexCol); onlineIcon=MonoIcon::icon(QLatin1String(":sidebar-online"), textCol, highlightedTexCol); infoSidebarIcon=MonoIcon::icon(QLatin1String(":sidebar-info"), textCol, highlightedTexCol); #ifdef ENABLE_DEVICES_SUPPORT devicesIcon=MonoIcon::icon(QLatin1String(":sidebar-devices"), textCol, highlightedTexCol); #endif searchTabIcon=MonoIcon::icon(QLatin1String(":sidebar-search"), textCol, highlightedTexCol); } void Icons::initToolbarIcons(const QColor &toolbarText) { QColor stdColor=calcIconColor(); bool rtl=QApplication::isRightToLeft(); #ifdef Q_OS_LINUX if (Settings::self()->useStandardIcons()) { toolbarPrevIcon=Icon::getMediaIcon("media-skip-backward"); toolbarPlayIcon=Icon::getMediaIcon("media-playback-start"); toolbarPauseIcon=Icon::getMediaIcon("media-playback-pause"); toolbarStopIcon=Icon::getMediaIcon("media-playback-stop"); toolbarNextIcon=Icon::getMediaIcon("media-skip-forward"); infoIcon=Icon("dialog-information"); toolbarMenuIcon=Icon("applications-system"); menuIcon=MonoIcon::icon(QLatin1String(":menu-icon"), stdColor, stdColor); return; } #endif #if defined Q_OS_MAC QColor col=OSXStyle::self()->monoIconColor(); #elif defined Q_OS_WIN QColor col=QApplication::palette().color(QPalette::Active, QPalette::WindowText); #else QColor col=GtkStyle::isActive() ? GtkStyle::symbolicColor() : toolbarText; #endif toolbarPrevIcon=MonoIcon::icon(QLatin1String(rtl ? ":media-next" : ":media-prev"), col, col); toolbarPlayIcon=MonoIcon::icon(QLatin1String(rtl ? ":media-play-rtl" : ":media-play"), col, col); toolbarPauseIcon=MonoIcon::icon(QLatin1String(":media-pause"), col, col); toolbarStopIcon=MonoIcon::icon(QLatin1String(":media-stop"), col, col); toolbarNextIcon=MonoIcon::icon(QLatin1String(rtl ? ":media-prev" : ":media-next"), col, col); infoIcon=MonoIcon::icon(QLatin1String(":sidebar-info"), col, col); #ifdef USE_SYSTEM_MENU_ICON toolbarMenuIcon=MonoIcon::icon(QLatin1String(":menu-icon"), col, col); menuIcon=MonoIcon::icon(QLatin1String(":menu-icon"), stdColor, stdColor); #else if (col==stdColor) { toolbarMenuIcon=menuIcon; } else { toolbarMenuIcon=MonoIcon::icon(FontAwesome::bars, col, col); } #endif } const Icon &Icons::albumIcon(int size, bool mono) const { return !mono || albumMonoIcon.isNull() ? size<48 ? albumIconSmall : albumIconLarge : albumMonoIcon; }