diff --git a/CMakeLists.txt b/CMakeLists.txt index a790893c6..18928f8e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -320,14 +320,14 @@ elseif(OS2) elseif(UNIX) message(STATUS "[${APP_LOW_NAME}] You will probably install on Linux.") install(TARGETS ${EXE_NAME} RUNTIME DESTINATION bin) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/resources/desktop/qonverter.desktop DESTINATION share/applications) - install(FILES resources/graphics/qonverter.png DESTINATION share/icons/hicolor/256x256/apps/) - install(FILES ${APP_QM} DESTINATION share/qonverter/l10n) - install(FILES ${APP_SKIN_PLAIN} DESTINATION share/qonverter/skins/base) - install(FILES ${APP_SKIN_MODERN} DESTINATION share/qonverter/skins/base) - install(FILES ${APP_SKIN_DARK} DESTINATION share/qonverter/skins/fancy) - install(FILES ${APP_SKIN_DARK_IMAGES} DESTINATION share/qonverter/skins/fancy/images) - install(FILES ${APP_MISC} DESTINATION share/qonverter/information) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/resources/desktop/${APP_LOW_NAME}.desktop DESTINATION share/applications) + install(FILES resources/graphics/${APP_LOW_NAME}.png DESTINATION share/icons/hicolor/256x256/apps/) + install(FILES ${APP_QM} DESTINATION share/${APP_LOW_NAME}/l10n) + install(FILES ${APP_SKIN_PLAIN} DESTINATION share/${APP_LOW_NAME}/skins/base) + install(FILES ${APP_SKIN_MODERN} DESTINATION share/${APP_LOW_NAME}/skins/base) + install(FILES ${APP_SKIN_DARK} DESTINATION share/${APP_LOW_NAME}/skins/fancy) + install(FILES ${APP_SKIN_DARK_IMAGES} DESTINATION share/${APP_LOW_NAME}/skins/fancy/images) + install(FILES ${APP_MISC} DESTINATION share/${APP_LOW_NAME}/information) endif(WIN32) # Custom target for packaging. diff --git a/src/core/defs.h.in b/src/core/defs.h.in index 3d7cfc39c..823a8a344 100644 --- a/src/core/defs.h.in +++ b/src/core/defs.h.in @@ -14,7 +14,7 @@ #define APP_CFG_PATH "data/config/config.ini" #define APP_CFG_GUI "gui" -#define APP_CFG_GEN "general" +#define APP_CFG_GEN "main" #define APP_CFG_LANG "localization" #define APP_DB_PATH "data/storage/database.db" @@ -25,10 +25,10 @@ // TODO: OS/2 support missing. No way to test this w/o OS/2 machine. #if defined(Q_OS_LINUX) -#define APP_LANG_PATH APP_PREFIX + QString("/share/qonverter/l10n") -#define APP_SKIN_PATH APP_PREFIX + QString("/share/qonverter/skins") -#define APP_INFO_PATH APP_PREFIX + QString("/share/qonverter/information") -#define APP_THEME_PATH APP_PREFIX + QString("/share/qonverter/themes") +#define APP_LANG_PATH APP_PREFIX + QString("/share/rssguard/l10n") +#define APP_SKIN_PATH APP_PREFIX + QString("/share/rssguard/skins") +#define APP_INFO_PATH APP_PREFIX + QString("/share/rssguard/information") +#define APP_THEME_PATH APP_PREFIX + QString("/share/rssguard/themes") #elif defined(Q_OS_MAC) #define APP_LANG_PATH QApplication::applicationDirPath() + "/../Resources/l10n" #define APP_SKIN_PATH QApplication::applicationDirPath() + "/../Resources/skins" diff --git a/src/gui/formmain.cpp b/src/gui/formmain.cpp index cc7432b9f..39a759379 100644 --- a/src/gui/formmain.cpp +++ b/src/gui/formmain.cpp @@ -6,6 +6,9 @@ FormMain::FormMain(QWidget *parent) : QMainWindow(parent), m_ui(new Ui::FormMain) { m_ui->setupUi(this); + // for testing purposes + m_ui->toolButton->setIcon(QIcon::fromTheme("application-exit")); + createConnections(); } diff --git a/src/gui/formmain.ui b/src/gui/formmain.ui index 3219ab240..84d684627 100644 --- a/src/gui/formmain.ui +++ b/src/gui/formmain.ui @@ -13,7 +13,27 @@ MainWindow - + + + + + 230 + 150 + 61 + 51 + + + + ... + + + + 32 + 32 + + + + diff --git a/src/gui/themefactory.cpp b/src/gui/themefactory.cpp index 83b890143..324facff0 100644 --- a/src/gui/themefactory.cpp +++ b/src/gui/themefactory.cpp @@ -1,7 +1,10 @@ #include +#include +#include #include #include "gui/themefactory.h" +#include "core/settings.h" #include "core/defs.h" @@ -10,7 +13,77 @@ ThemeFactory::ThemeFactory() { void ThemeFactory::setupSearchPaths() { QIcon::setThemeSearchPaths(QIcon::themeSearchPaths() << APP_THEME_PATH); - qDebug("Available icon theme paths: %s.", qPrintable(QIcon::themeSearchPaths().join(", "))); } + +// TODO: Load currently selected "real" icon theme name instead of +// Qt default "", which stands for currently active system icon theme name. +QString ThemeFactory::getSystemIconTheme() { + return QString(); +} + +QString ThemeFactory::getCurrentIconTheme() { + QString current_theme_name = Settings::getInstance().value(APP_CFG_GUI, + "icon_theme", + getSystemIconTheme()).toString(); + return current_theme_name; +} + +void ThemeFactory::setCurrentIconTheme(const QString &theme_name) { + Settings::getInstance().setValue(APP_CFG_GUI, + "icon_theme", + theme_name); + loadCurrentIconTheme(); +} + +void ThemeFactory::loadCurrentIconTheme() { + QString theme_name = getCurrentIconTheme(); + QStringList installed_themes = getInstalledIconThemes(); + + qDebug("Installed icon themes are: %s.", + qPrintable(installed_themes.join(", "))); + + if (!installed_themes.contains(theme_name)) { + qDebug("Icon theme '%s' cannot be loaded because it is not installed.", + qPrintable(theme_name)); + return; + } + else { + qDebug("Loading theme '%s'.", qPrintable(theme_name)); + QIcon::setThemeName(theme_name); + } +} + +QStringList ThemeFactory::getInstalledIconThemes() { + QStringList icon_theme_names; + + // Add system theme. + icon_theme_names << getSystemIconTheme(); + + // Iterate all directories with icon themes. + QStringList icon_themes_paths = QIcon::themeSearchPaths(); + icon_themes_paths.removeDuplicates(); + + foreach (QString icon_path, icon_themes_paths) { + QDir icon_dir(icon_path); + + // Iterate all icon themes in this directory. + foreach (QString icon_theme_path, icon_dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | + QDir::Readable | QDir::CaseSensitive | + QDir::NoSymLinks, + QDir::Time)) { + // Check if index.theme file in this path exists. + if (QFile::exists(icon_dir.path() + "/" + icon_theme_path + "/index.theme")) { + icon_theme_names << icon_theme_path; + } + } + } + + icon_theme_names.removeDuplicates(); + return icon_theme_names; +} + +// zjištění názvů témat dle d:\Programovani\Materiály\Qt\qt5\qtbase\src\gui\image\qiconloader.cpp, +// řádek 172, jak se prochází ty složky +// http://doublecmd.svn.sourceforge.net/viewvc/doublecmd/trunk/src/platform/unix/uunixicontheme.pas diff --git a/src/gui/themefactory.h b/src/gui/themefactory.h index db74618d3..12a66735d 100644 --- a/src/gui/themefactory.h +++ b/src/gui/themefactory.h @@ -1,13 +1,34 @@ #ifndef THEMEFACTORY_H #define THEMEFACTORY_H +#include + class ThemeFactory { private: ThemeFactory(); public: + // Adds custom application path to be search for icons. static void setupSearchPaths(); + + // Returns name of icon theme, which is selected as active for + // system. + static QString getSystemIconTheme(); + + // Returns list of installed themes, this includes: + // a) system-wide themes, + // b) application-wide themes. + static QStringList getInstalledIconThemes(); + + // Loads name of selected icon theme for the application and activates it. + static void loadCurrentIconTheme(); + + // Returns name of currently activated theme for the application. + static QString getCurrentIconTheme(); + + // Sets icon theme with given name as the active one. + static void setCurrentIconTheme(const QString &theme_name); }; #endif // THEMEFACTORY_H diff --git a/src/main.cpp b/src/main.cpp index 42cb02682..b51b8cf0c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -55,6 +55,9 @@ int main(int argc, char *argv[]) { // Add an extra path for non-system icon themes. ThemeFactory::setupSearchPaths(); + // Load icon theme from settings. + ThemeFactory::loadCurrentIconTheme(); + // These settings needs to be set before any QSettings object. QtSingleApplication::setApplicationName(APP_NAME); QtSingleApplication::setApplicationVersion(APP_VERSION);