WSL/SLF GitLab Repository

Skip to content
Snippets Groups Projects
Commit 91521494 authored by Michael Reisecker's avatar Michael Reisecker
Browse files

Move one more function to 'os' - now only small tweaks are left scattered in...

Move one more function to 'os' - now only small tweaks are left scattered in the code and the core OS functionality is bundled.
parent 086719de
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,6 @@
#include <QDebug>
#include <QPalette>
#include <QSettings>
namespace colors {
......
......@@ -18,6 +18,7 @@
#include "common.h"
#include "colors.h"
#include "src/main/os.h"
#include "src/main/settings.h"
#include <QDir>
......@@ -79,34 +80,7 @@ QStringList getSearchDirs(const bool &include_user_set, const bool &include_none
/* hardcoded directories, the system specific parts are handled by Qt */
QStringList locations;
locations << "."; //the application's current directory
#if defined Q_OS_WIN
locations << "../.."; //this is useful for some out of tree builds
locations << QCoreApplication::applicationDirPath(); //directory that contains the application executable
locations << QCoreApplication::applicationDirPath() + "/..";
locations << QStandardPaths::standardLocations(QStandardPaths::DesktopLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::AppDataLocation); //location where persistent application data can be stored
#endif
#if defined Q_OS_MAC
locations << "./../../../.."; //this is useful for some out of tree builds: we must get out of the bundle
locations << QCoreApplication::applicationDirPath();
locations << QCoreApplication::applicationDirPath() + "/..";
locations << QCoreApplication::applicationDirPath() + "/../../../.."; //we must get out of the bundle
locations << QStandardPaths::standardLocations(QStandardPaths::DesktopLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
locations << QDir::homePath() + "/usr/share";
#endif
#if !defined Q_OS_WIN && !defined Q_OS_MAC
locations << QCoreApplication::applicationDirPath(); //directory that contains the application executable
locations << QCoreApplication::applicationDirPath() + "/..";
locations << QStandardPaths::standardLocations(QStandardPaths::DesktopLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); //$HOME/Documents
locations << QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::DataLocation);
locations << QDir::homePath() + "/usr/share";
#endif
os::getSystemLocations(locations); //update list with OS specific search paths
//TODO: recursive search
QStringList dirs;
......
......@@ -208,15 +208,11 @@ void setAppStylesheet(QApplication &app, const command_line_args &cmd_args)
#endif
/*
* Set the global stylesheet:
* (1) All widgets that have their on-the-fly property "mandatory" set will look like this.
* Text color is mainly set for QComboBox so that it won't turn white when the background
* color is changed (to something too light in this case).
* (2) All panels that are currently set to the default value will look like this
* (3) Panels with a faulty value (e. g. invalid arithmetic expression) will look like this
* (4) Valid values (e. g. good arithmetic expression) will look like this
* (5) - (7) The main tab bar, scroll areas, and all their (grand-) children will have these colors
* (8), (9) Except for their scroll bars
* (10) Grouping elements will have this default color
* Here we define some properties that can be set for all panels (without casting to their type),
* and the style that will be applied if the property is set (e. g. default values, faulty
* expressions, ...).
* We also try to avoid gaps and borders of different colors, hence we set backgrounds for some
* of our design elements.
*/
app.setStyleSheet(" \
* [mandatory=\"true\"] {background-color: " + colors::getQColor("mandatory").name() + "; color: " + colors::getQColor("normal").name() + "} \
......
......@@ -18,13 +18,51 @@
#include "os.h"
#include <QCoreApplication>
#include <QDir>
#include <QPalette>
#include <QSettings>
#include <QStandardPaths>
#include <QtGlobal>
namespace os {
/**
* @brief Choose a number of locations to look for applications at.
* @param[out] locations List of locations which will have the system specific ones appended.
*/
void getSystemLocations(QStringList &locations)
{
#if defined Q_OS_WIN
locations << "../.."; //this is useful for some out of tree builds
locations << QCoreApplication::applicationDirPath(); //directory that contains the application executable
locations << QCoreApplication::applicationDirPath() + "/..";
locations << QStandardPaths::standardLocations(QStandardPaths::DesktopLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::AppDataLocation); //location where persistent application data can be stored
#endif
#if defined Q_OS_MAC
locations << "./../../../.."; //this is useful for some out of tree builds: we must get out of the bundle
locations << QCoreApplication::applicationDirPath();
locations << QCoreApplication::applicationDirPath() + "/..";
locations << QCoreApplication::applicationDirPath() + "/../../../.."; //we must get out of the bundle
locations << QStandardPaths::standardLocations(QStandardPaths::DesktopLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
locations << QDir::homePath() + "/usr/share";
#endif
#if !defined Q_OS_WIN && !defined Q_OS_MAC
locations << QCoreApplication::applicationDirPath(); //directory that contains the application executable
locations << QCoreApplication::applicationDirPath() + "/..";
locations << QStandardPaths::standardLocations(QStandardPaths::DesktopLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); //$HOME/Documents
locations << QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::DataLocation);
locations << QDir::homePath() + "/usr/share";
#endif
}
/**
* @brief Check if we're running on KDE Desktop environment.
* @details On a well-tuned KDE, things should be the smoothest.
......@@ -45,7 +83,7 @@ bool isDarkTheme()
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", QSettings::NativeFormat);
return (settings.value("AppsUseLightTheme")==0);
#else
const int bg_lightness( QPalette().color(QPalette::Window).lightness() );
const int bg_lightness = QPalette().color(QPalette::Window).lightness();
if (bg_lightness < 128)
return true;
return false;
......
......@@ -25,9 +25,11 @@
#define OS_H
#include <QString>
#include <QStringList>
namespace os {
void getSystemLocations(QStringList &locations);
bool isKde();
bool isDarkTheme();
void setSystemPath(const QString& appname);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment