Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color and font themes #6698

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -46,6 +46,7 @@ option(WEBUI "Allows to disable the WebUI." ON)
if (WIN32)
option(STACKTRACE_WIN "")
else (WIN32)
option(PLASMA_INTEGRATION "Enable KDE/Plasma integration" OFF)
cmake_dependent_option(SYSTEMD "Install the systemd service file (headless only)" OFF
"NOT GUI" OFF)
cmake_dependent_option(DBUS "Enable use of QtDBus (GUI only)" ON "GUI" OFF)
Expand Down
28 changes: 27 additions & 1 deletion configure
Expand Up @@ -721,6 +721,7 @@ enable_gui
enable_systemd
enable_webui
enable_qt_dbus
enable_plasma_integration
with_boost
with_boost_libdir
with_boost_system
Expand Down Expand Up @@ -1387,6 +1388,8 @@ Optional Features:
--enable-systemd Install the systemd service file (headless only).
--disable-webui Disable the WebUI.
--disable-qt-dbus Disable use of QtDBus (GUI only)
--enable-plasma-integration
Enable KDE/Plasma integration

Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
Expand Down Expand Up @@ -4221,6 +4224,14 @@ else
fi


# Check whether --enable-plasma-integration was given.
if test "${enable_plasma_integration+set}" = set; then :
enableval=$enable_plasma_integration;
else
enable_plasma_integration=no
fi


# Detect OS
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether OS is FreeBSD" >&5
$as_echo_n "checking whether OS is FreeBSD... " >&6; }
Expand Down Expand Up @@ -4632,7 +4643,22 @@ $as_echo "no" >&6; }
$as_echo "$enable_qt_dbus" >&6; }
as_fn_error $? "Unknown option \"$enable_qt_dbus\". Use either \"yes\" or \"no\"." "$LINENO" 5 ;;
esac

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether KDE/Plasma integration should be enabled" >&5
$as_echo_n "checking whether KDE/Plasma integration should be enabled... " >&6; }
case "x$enable_plasma_integration" in #(
"xyes") :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
QBT_ADD_CONFIG="$QBT_ADD_CONFIG plasma_integration" ;; #(
"xno") :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG plasma_integration" ;; #(
*) :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_plasma_integration" >&5
$as_echo "$enable_plasma_integration" >&6; }
as_fn_error $? "Unknown option \"$plasma_integration\". Use either \"yes\" or \"no\"." "$LINENO" 5 ;;
esac



Expand Down
17 changes: 16 additions & 1 deletion configure.ac
Expand Up @@ -48,6 +48,12 @@ AC_ARG_ENABLE(qt-dbus,
[],
[enable_qt_dbus=yes])

AC_ARG_ENABLE(plasma-integration,
[AS_HELP_STRING([--enable-plasma-integration],
[Enable KDE/Plasma integration])],
[],
[enable_plasma_integration=no])

# Detect OS
AC_MSG_CHECKING([whether OS is FreeBSD])
AS_IF([expr "$host_os" : ".*freebsd.*" > /dev/null],
Expand Down Expand Up @@ -136,7 +142,16 @@ AS_CASE(["x$enable_qt_dbus"],
QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG dbus"],
[AC_MSG_RESULT([$enable_qt_dbus])
AC_MSG_ERROR([Unknown option "$enable_qt_dbus". Use either "yes" or "no".])])

AC_MSG_CHECKING([whether KDE/Plasma integration should be enabled])
AS_CASE(["x$enable_plasma_integration"],
["xyes"],
[AC_MSG_RESULT([yes])
QBT_ADD_CONFIG="$QBT_ADD_CONFIG plasma_integration"],
["xno"],
[AC_MSG_RESULT([no])
QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG plasma_integration"],
[AC_MSG_RESULT([$enable_plasma_integration])
AC_MSG_ERROR([Unknown option "$plasma_integration". Use either "yes" or "no".])])

AX_BOOST_BASE([1.35])
# HAVE_BOOST is set to an empty value when Boost is found. I don't know
Expand Down
6 changes: 6 additions & 0 deletions dist/CMakeLists.txt
@@ -1,3 +1,9 @@
set(ADDITIONAL_THEME_FILES
${CMAKE_CURRENT_SOURCE_DIR}/theme/Classic.colortheme
${CMAKE_CURRENT_SOURCE_DIR}/theme/AlternativeDark.colortheme
${CMAKE_CURRENT_SOURCE_DIR}/theme/AlternativeLight.colortheme
)

if (APPLE)
add_subdirectory(mac)
else (APPLE)
Expand Down
25 changes: 25 additions & 0 deletions dist/theme/AlternativeDark.colortheme
@@ -0,0 +1,25 @@
[Info]
Name=Alternative (Dark)
Description=Alternative color theme. Dark flavour.
Inherits=Default (Dark)

[TorrentState]
Uploading=RGB:#63b8ff
PausedUploading=RGB:#4f94cd
QueuedUploading=RGB:#00cdcd
StalledUploading=RGB:#63b8ff
CheckingUploading=RGB:#00cdcd
ForcedUploading=RGB:#63b8ff
Allocating=RGB:#fa8072
Downloading=RGB:#32cd32
DownloadingMetadata=RGB:#32cd32
PausedDownloading=RGB:#cccccc
QueuedDownloading=RGB:#00cdcd
StalledDownloading=RGB:#fa8072
CheckingDownloading=RGB:#00cdcd
ForcedDownloading=RGB:#32cd32
QueuedForChecking=RGB:#00cdcd
CheckingResumeData=RGB:#00cdcd
Unknown=RGB:#ff0000
Error=RGB:#ff0000
MissingFiles=RGB:#ff0000
22 changes: 22 additions & 0 deletions dist/theme/AlternativeLight.colortheme
@@ -0,0 +1,22 @@
[Info]
Name=Alternative (Light)
Description=Alternative color theme. Light flavour.
Inherits=Default (Light)

[TorrentState]
Unknown=RGB:#ff0000
Error=RGB:#ff0000
MissingFiles=RGB:#ff0000
Uploading=RGB:#4169e1
PausedUploading=RGB:#00008b
QueuedUploading=RGB:#008080
StalledUploading=RGB:#4169e1
CheckingUploading=RGB:#008080
ForcedUploading=RGB:#4169e1
Allocating=RGB:#228b22
PausedDownloading=RGB:#000000
QueuedDownloading=RGB:#008080
StalledDownloading=RGB:#228b22
CheckingDownloading=RGB:#008080
QueuedForChecking=RGB:#008080
CheckingResumeData=RGB:#008080
24 changes: 24 additions & 0 deletions dist/theme/Classic.colortheme
@@ -0,0 +1,24 @@
[Info]
Name=Classic
Description=Classic qBittorrent colors.

[TorrentState]
Unknown=RGB:#ff0000
Error=RGB:#ff0000
MissingFiles=RGB:#ff0000
Uploading=RGB:#ffa500
PausedUploading=RGB:#ff0000
QueuedUploading=RGB:#008080
StalledUploading=RGB:#808080
CheckingUploading=RGB:#808080
ForcedUploading=RGB:#ffa500
Allocating=RGB:#808080
Downloading=RGB:#008000
DownloadingMetadata=RGB:#008000
PausedDownloading=RGB:#ff0000
QueuedDownloading=RGB:#008080
StalledDownloading=RGB:#808080
CheckingDownloading=RGB:#808080
ForcedDownloading=RGB:#008000
QueuedForChecking=RGB:#808080
CheckingResumeData=RGB:#808080
11 changes: 11 additions & 0 deletions dist/unix/CMakeLists.txt
Expand Up @@ -42,4 +42,15 @@ if (GUI)
${qBittorrent_SOURCE_DIR}/src/icons/skin/qbittorrent-tray-light.svg
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/status
COMPONENT data)

install(FILES ${ADDITIONAL_THEME_FILES}
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/qBittorrent/theme/
COMPONENT data
)
endif()

if (PLASMA_INTEGRATION)
install(FILES qBittorrentPlasma.colortheme
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/qBittorrent/theme/
COMPONENT data)
endif (PLASMA_INTEGRATION)
37 changes: 37 additions & 0 deletions dist/unix/qBittorrentPlasma.colortheme
@@ -0,0 +1,37 @@
[Info]
Name=Plasma colors
Description=qBittorrent color theme which uses Plasma colors.

[TorrentState]
Unknown=Plasma:ForegroundNegative:Disabled
Error=Plasma:ForegroundNegative
MissingFiles=Plasma:ForegroundNegative
Uploading=Plasma:ForegroundNeutral
PausedUploading=Plasma:ForegroundNeutral:Disabled
QueuedUploading=Plasma:ForegroundNeutral:Inactive
StalledUploading=Plasma:ForegroundInactive
CheckingUploading=Plasma:ForegroundActive:Inactive
ForcedUploading=Plasma:ForegroundNeutral:Active:View:Intensify
Allocating=Plasma:ForegroundInactive
Downloading=Plasma:ForegroundPositive
DownloadingMetadata=Plasma:ForegroundActive:Active:View:Reduce
PausedDownloading=Plasma:ForegroundPositive:Disabled
QueuedDownloading=Plasma:ForegroundPositive:Inactive
StalledDownloading=Plasma:ForegroundInactive
CheckingDownloading=Plasma:ForegroundActive:Inactive
ForcedDownloading=Plasma:ForegroundPositive:Active:View:Intensify
QueuedForChecking=Plasma:ForegroundActive:Inactive
CheckingResumeData=Plasma:ForegroundActive:Inactive

[LogMessageType]
ALL=QPalette:Active:WindowText
NORMAL=QPalette:Active:WindowText
INFO=Plasma:ForegroundActive
WARNING=Plasma:ForegroundNeutral
CRITICAL=Plasma:ForegroundNegative

[DownloadProgressBar]
Background=Plasma:BackgroundNormal
Border=Plasma:DecorationFocus
Complete=Plasma:ForegroundActive
Incomplete=Plasma:ForegroundPositive
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Expand Up @@ -54,6 +54,11 @@ endif (NOT WEBUI)
if (STACKTRACE_WIN)
add_definitions(-DSTACKTRACE_WIN)
endif(STACKTRACE_WIN)

if (PLASMA_INTEGRATION)
add_definitions(-DPLASMA_INTEGRATION)
endif (PLASMA_INTEGRATION)

# nogui {
# TARGET = qbittorrent-nox
# } else {
Expand Down
8 changes: 8 additions & 0 deletions src/app/application.cpp
Expand Up @@ -37,6 +37,9 @@

#ifndef DISABLE_GUI
#include "gui/guiiconprovider.h"
#include "gui/theme/colorproviders.h"
#include "gui/theme/fontproviders.h"
#include "gui/theme/themeprovider.h"
#ifdef Q_OS_WIN
#include <windows.h>
#include <QSharedMemory>
Expand Down Expand Up @@ -466,9 +469,14 @@ int Application::exec(const QStringList &params)
{
Net::ProxyConfigurationManager::initInstance();
Net::DownloadManager::initInstance();

#ifdef DISABLE_GUI
IconProvider::initInstance();
#else
Theme::Serialization::registerColorProviders();
Theme::Serialization::registerFontProviders();
Theme::ThemeProvider::initInstance();

GuiIconProvider::initInstance();
#endif

Expand Down
16 changes: 14 additions & 2 deletions src/base/iconprovider.cpp
Expand Up @@ -33,9 +33,21 @@
IconProvider::IconProvider(QObject *parent)
: QObject(parent)
{
setIconDir(defaultIconDir());
}

IconProvider::~IconProvider() {}
IconProvider::~IconProvider() = default;

void IconProvider::setIconDir(const QString& path)
{
m_iconThemeDir = QDir(path);
Q_ASSERT(m_iconThemeDir.exists());
}

QString IconProvider::defaultIconDir()
{
return QLatin1String(":/icons/qbt-theme/");
}

void IconProvider::initInstance()
{
Expand All @@ -58,7 +70,7 @@ IconProvider *IconProvider::instance()

QString IconProvider::getIconPath(const QString &iconId)
{
return ":/icons/qbt-theme/" + iconId + ".png";
return m_iconThemeDir.absoluteFilePath(iconId + QLatin1String(".svg"));
}

IconProvider *IconProvider::m_instance = 0;
7 changes: 7 additions & 0 deletions src/base/iconprovider.h
Expand Up @@ -30,6 +30,7 @@
#ifndef ICONPROVIDER_H
#define ICONPROVIDER_H

#include <QDir>
#include <QObject>

class QString;
Expand All @@ -49,7 +50,13 @@ class IconProvider : public QObject
explicit IconProvider(QObject *parent = 0);
~IconProvider();

void setIconDir(const QString &path);
static QString defaultIconDir();

static IconProvider *m_instance;

private:
QDir m_iconThemeDir;
};

#endif // ICONPROVIDER_H
2 changes: 1 addition & 1 deletion src/base/logger.h
Expand Up @@ -10,7 +10,7 @@ const int MAX_LOG_MESSAGES = 20000;

namespace Log
{
enum MsgType
enum MsgType: int
{
ALL = -1,
NORMAL = 0x1,
Expand Down