All Classes Namespaces Functions Variables Enumerations Properties Pages
linux.cpp
1 /*
2 
3 Pencil2D - Traditional Animation Software
4 Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5 Copyright (C) 2009 Mj Mendoza IV
6 Copyright (C) 2012-2020 Matthew Chiawen Chang
7 
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; version 2 of the License.
11 
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 */
18 
19 #include "platformhandler.h"
20 
21 #include <QCoreApplication>
22 #include <QDebug>
23 #include <QSettings>
24 
25 #include "pencildef.h"
26 
27 namespace PlatformHandler
28 {
29  void configurePlatformSpecificSettings() {}
30 
31  void initialise()
32  {
33  /* If running as an AppImage, sets GStreamer environment variables to ensure
34  * the plugins contained in the AppImage are found
35  */
36  QString appDir = QString::fromLocal8Bit(qgetenv("APPDIR"));
37  if (!appDir.isEmpty())
38  {
39  bool success = qputenv("GST_PLUGIN_SYSTEM_PATH_1_0",
40  QString("%1/usr/lib/gstreamer-1.0:%2")
41  .arg(appDir, QString::fromLocal8Bit(qgetenv("GST_PLUGIN_SYSTEM_PATH_1_0")))
42  .toLocal8Bit());
43  success = qputenv("GST_PLUGIN_SCANNER_1_0",
44  QString("%1/usr/lib/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner")
45  .arg(appDir).toLocal8Bit()) && success;
46  if (!success)
47  {
48  qWarning() << "Unable to set up GStreamer environment";
49  }
50  }
51 
52  // Temporary solution for high DPI displays
53  // EnableHighDpiScaling is a just in case mechanism in the event that we
54  // want to disable this without recompiling, see #922
55  QSettings settings(PENCIL2D, PENCIL2D);
56  if (settings.value("EnableHighDpiScaling", "true").toBool())
57  {
58  // Enable auto screen scaling on high dpi display, for example, a 4k monitor
59  // This attr has to be set before the QApplication is constructed
60  // Only works on Windows & X11
62  }
63  }
64 }
void setAttribute(Qt::ApplicationAttribute attribute, bool on)
QString fromLocal8Bit(const char *str, int size)
bool isEmpty() const const
AA_EnableHighDpiScaling