fix: opengl set on application before

This commit is contained in:
rankun 2020-02-28 17:47:00 +08:00
commit 3007069592
2 changed files with 31 additions and 28 deletions

View file

@ -18,6 +18,35 @@ void installTranslator();
int main(int argc, char *argv[])
{
// set env
#ifdef Q_OS_WIN32
qputenv("QTSCRCPY_ADB_PATH", "../../../../third_party/adb/win/adb.exe");
qputenv("QTSCRCPY_SERVER_PATH", "../../../../third_party/scrcpy-server");
qputenv("QTSCRCPY_KEYMAP_PATH", "../../../../keymap");
qputenv("QTSCRCPY_CONFIG_PATH", "../../../../config");
#endif
#ifdef Q_OS_OSX
qputenv("QTSCRCPY_KEYMAP_PATH", "../../../../../../keymap");
#endif
#ifdef Q_OS_LINUX
qputenv("QTSCRCPY_ADB_PATH", "../../../third_party/adb/linux/adb");
qputenv("QTSCRCPY_SERVER_PATH", "../../../third_party/scrcpy-server");
qputenv("QTSCRCPY_CONFIG_PATH", "../../../config");
qputenv("QTSCRCPY_KEYMAP_PATH", "../../../keymap");
#endif
// set on QApplication before
int opengl = Config::getInstance().getDesktopOpenGL();
if (0 == opengl) {
QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
} else if (1 == opengl){
QApplication::setAttribute(Qt::AA_UseOpenGLES);
} else if (2 == opengl) {
QApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
}
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
g_oldMessageHandler = qInstallMessageHandler(myMessageOutput);
@ -41,24 +70,6 @@ int main(int argc, char *argv[])
MouseTap::getInstance()->initMouseEventTap();
#endif
#ifdef Q_OS_WIN32
qputenv("QTSCRCPY_ADB_PATH", "../../../../third_party/adb/win/adb.exe");
qputenv("QTSCRCPY_SERVER_PATH", "../../../../third_party/scrcpy-server");
qputenv("QTSCRCPY_KEYMAP_PATH", "../../../../keymap");
qputenv("QTSCRCPY_CONFIG_PATH", "../../../../config");
#endif
#ifdef Q_OS_OSX
qputenv("QTSCRCPY_KEYMAP_PATH", "../../../../../../keymap");
#endif
#ifdef Q_OS_LINUX
qputenv("QTSCRCPY_ADB_PATH", "../../../third_party/adb/linux/adb");
qputenv("QTSCRCPY_SERVER_PATH", "../../../third_party/scrcpy-server");
qputenv("QTSCRCPY_CONFIG_PATH", "../../../config");
qputenv("QTSCRCPY_KEYMAP_PATH", "../../../keymap");
#endif
//加载样式表
QFile file(":/qss/psblack.css");
if (file.open(QFile::ReadOnly)) {
@ -69,15 +80,6 @@ int main(int argc, char *argv[])
file.close();
}
int opengl = Config::getInstance().getDesktopOpenGL();
if (0 == opengl) {
QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
} else if (1 == opengl){
QApplication::setAttribute(Qt::AA_UseOpenGLES);
} else if (2 == opengl) {
QApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
}
g_mainDlg = new Dialog;
g_mainDlg->setWindowTitle(Config::getInstance().getTitle());
g_mainDlg->show();

View file

@ -69,7 +69,8 @@ const QString& Config::getConfigPath()
s_configPath = QString::fromLocal8Bit(qgetenv("QTSCRCPY_CONFIG_PATH"));
QFileInfo fileInfo(s_configPath);
if (s_configPath.isEmpty() || !fileInfo.isDir()) {
s_configPath = QCoreApplication::applicationDirPath() + "/config";
// default application dir
s_configPath = "config";
}
}
return s_configPath;