mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-27 12:46:14 +00:00
fix: opengl set on application before
This commit is contained in:
parent
89f9c4d3bf
commit
3007069592
2 changed files with 31 additions and 28 deletions
|
@ -18,6 +18,35 @@ void installTranslator();
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
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);
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
|
||||||
g_oldMessageHandler = qInstallMessageHandler(myMessageOutput);
|
g_oldMessageHandler = qInstallMessageHandler(myMessageOutput);
|
||||||
|
@ -41,24 +70,6 @@ int main(int argc, char *argv[])
|
||||||
MouseTap::getInstance()->initMouseEventTap();
|
MouseTap::getInstance()->initMouseEventTap();
|
||||||
#endif
|
#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");
|
QFile file(":/qss/psblack.css");
|
||||||
if (file.open(QFile::ReadOnly)) {
|
if (file.open(QFile::ReadOnly)) {
|
||||||
|
@ -69,15 +80,6 @@ int main(int argc, char *argv[])
|
||||||
file.close();
|
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 = new Dialog;
|
||||||
g_mainDlg->setWindowTitle(Config::getInstance().getTitle());
|
g_mainDlg->setWindowTitle(Config::getInstance().getTitle());
|
||||||
g_mainDlg->show();
|
g_mainDlg->show();
|
||||||
|
|
|
@ -69,7 +69,8 @@ const QString& Config::getConfigPath()
|
||||||
s_configPath = QString::fromLocal8Bit(qgetenv("QTSCRCPY_CONFIG_PATH"));
|
s_configPath = QString::fromLocal8Bit(qgetenv("QTSCRCPY_CONFIG_PATH"));
|
||||||
QFileInfo fileInfo(s_configPath);
|
QFileInfo fileInfo(s_configPath);
|
||||||
if (s_configPath.isEmpty() || !fileInfo.isDir()) {
|
if (s_configPath.isEmpty() || !fileInfo.isDir()) {
|
||||||
s_configPath = QCoreApplication::applicationDirPath() + "/config";
|
// default application dir
|
||||||
|
s_configPath = "config";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return s_configPath;
|
return s_configPath;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue