ui: Change screen scaling on Linux (issue #518, #523)

* Set environment variables QT_AUTO_SCREEN_SCALE_FACTOR and QT_SCALE_FACTOR on Linux on app start
* Added ScreenAutoScaling and ScreenScaleFactor to ApplicationSettings with dropdown boxes in the preferences
  only visible on Linux
* Removed QtFontPicker and QtTextEncodingPicker
* Moved logging into preferences category "output"

fortune cookie message = You will have a peace of mind when you talk to an old friend
This commit is contained in:
Eberhard Graether
2018-01-16 11:01:32 +01:00
parent 6672127c68
commit 43c223368c
15 changed files with 375 additions and 248 deletions
+27 -2
View File
@@ -11,8 +11,35 @@
#include "utility/ResourcePaths.h"
#include "utility/UserPaths.h"
#include "settings/ApplicationSettings.h"
void setupPlatform(int argc, char *argv[])
{
std::string home = std::getenv("HOME");
UserPaths::setUserDataPath(FilePath(home + "/.config/sourcetrail/"));
// Set QT screen scaling factor
ApplicationSettings appSettings;
appSettings.load(UserPaths::getAppSettingsPath());
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR_SOURCETRAIL", qgetenv("QT_AUTO_SCREEN_SCALE_FACTOR"));
qputenv("QT_SCALE_FACTOR_SOURCETRAIL", qgetenv("QT_SCALE_FACTOR"));
int autoScaling = appSettings.getScreenAutoScaling();
if (autoScaling != -1)
{
QByteArray bytes;
bytes.setNum(autoScaling);
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", bytes);
}
float scaleFactor = appSettings.getScreenScaleFactor();
if (scaleFactor > 0.0)
{
QByteArray bytes;
bytes.setNum(scaleFactor);
qputenv("QT_SCALE_FACTOR", bytes);
}
}
void setupApp(int argc, char *argv[])
@@ -26,8 +53,6 @@ void setupApp(int argc, char *argv[])
QDir coatiDir((userdir + "/.config/coati").c_str());
userdir.append("/.config/sourcetrail/");
UserPaths::setUserDataPath(FilePath(userdir));
QString userDataPath(userdir.c_str());
QDir dataDir(userdir.c_str());
if (!dataDir.exists())
+2 -8
View File
@@ -12,10 +12,11 @@
#include "utility/ResourcePaths.h"
#include "utility/UserPaths.h"
bool appIsMacBundle = false;
void setupPlatform(int argc, char *argv[])
{
UserPaths::setUserDataPath(FilePath("./user/"));
// ----------------------------------------------------------------------------
// This makes relative paths work in C++ in Xcode by changing directory to the Resources folder inside the .app bundle
// source: http://stackoverflow.com/questions/516200/relative-paths-not-working-in-xcode-c
@@ -81,19 +82,12 @@ void setupPlatform(int argc, char *argv[])
// ----------------------------------------------------------------------------
UserPaths::setUserDataPath(FilePath(dataPath.toStdString() + "/"));
appIsMacBundle = true;
}
void setupApp(int argc, char *argv[])
{
FilePath path(QDir::currentPath().toStdString());
AppPath::setAppPath(path.getAbsolute().str() + "/");
if (!appIsMacBundle)
{
UserPaths::setUserDataPath(FilePath("./user/"));
}
}
#endif // INCLUDES_MAC_H