mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 12:34:37 +03:00
HiDPI workaroud
This commit is contained in:
@@ -32,12 +32,13 @@ int main(int argc, char *argv[]) {
|
|||||||
Windows_SetCrashHandler();
|
Windows_SetCrashHandler();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
// pre-init QApplication
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
QApplication::setAttribute(Qt::AA_DisableWindowContextHelpButton);
|
QApplication::setAttribute(Qt::AA_DisableWindowContextHelpButton);
|
||||||
#endif
|
#endif
|
||||||
QApplication::setAttribute(Qt::AA_DontUseNativeDialogs);
|
QApplication::setAttribute(Qt::AA_DontUseNativeDialogs);
|
||||||
QApplication::setQuitOnLastWindowClosed(false);
|
QApplication::setQuitOnLastWindowClosed(false);
|
||||||
|
auto preQApp = new QApplication(argc, argv);
|
||||||
|
|
||||||
// Clean
|
// Clean
|
||||||
QDir::setCurrent(QApplication::applicationDirPath());
|
QDir::setCurrent(QApplication::applicationDirPath());
|
||||||
@@ -74,6 +75,16 @@ int main(int argc, char *argv[]) {
|
|||||||
QDir::setCurrent(wd.absoluteFilePath("config"));
|
QDir::setCurrent(wd.absoluteFilePath("config"));
|
||||||
QDir("temp").removeRecursively();
|
QDir("temp").removeRecursively();
|
||||||
|
|
||||||
|
// HiDPI workaround
|
||||||
|
if (ReadFileText("./groups/HiDPI").toInt() == 1) {
|
||||||
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
|
}
|
||||||
|
|
||||||
|
// init QApplication
|
||||||
|
delete preQApp;
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
// RunGuard
|
// RunGuard
|
||||||
RunGuard guard("nekoray" + wd.absolutePath());
|
RunGuard guard("nekoray" + wd.absolutePath());
|
||||||
quint64 guard_data_in = GetRandomUint64();
|
quint64 guard_data_in = GetRandomUint64();
|
||||||
|
|||||||
@@ -229,6 +229,10 @@
|
|||||||
<source>Password</source>
|
<source>Password</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Maybe useful for HiDPI screens.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>DialogEditGroup</name>
|
<name>DialogEditGroup</name>
|
||||||
|
|||||||
@@ -227,6 +227,10 @@
|
|||||||
<source>Password</source>
|
<source>Password</source>
|
||||||
<translation>密码</translation>
|
<translation>密码</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Maybe useful for HiDPI screens.</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>DialogEditGroup</name>
|
<name>DialogEditGroup</name>
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ public:
|
|||||||
DialogBasicSettings::DialogBasicSettings(QWidget *parent)
|
DialogBasicSettings::DialogBasicSettings(QWidget *parent)
|
||||||
: QDialog(parent), ui(new Ui::DialogBasicSettings) {
|
: QDialog(parent), ui(new Ui::DialogBasicSettings) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
ADD_ASTERISK(this);
|
||||||
|
|
||||||
// Common
|
// Common
|
||||||
|
|
||||||
@@ -142,6 +143,20 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent)
|
|||||||
mainwindow->repaint();
|
mainwindow->repaint();
|
||||||
NekoRay::dataStore->Save();
|
NekoRay::dataStore->Save();
|
||||||
});
|
});
|
||||||
|
//
|
||||||
|
ui->AA_EnableHighDpiScaling->setChecked(ReadFileText("groups/HiDPI").toInt() == 1);
|
||||||
|
connect(ui->AA_EnableHighDpiScaling, &QCheckBox::clicked, this, [=](bool checked) {
|
||||||
|
QFile file;
|
||||||
|
file.setFileName("groups/HiDPI");
|
||||||
|
file.open(QIODevice::ReadWrite | QIODevice::Truncate);
|
||||||
|
if (checked) {
|
||||||
|
file.write("1");
|
||||||
|
} else {
|
||||||
|
file.write("0");
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
MessageBoxWarning(tr("Settings changed"), tr("Restart nekoray to take effect."));
|
||||||
|
});
|
||||||
|
|
||||||
// Subscription
|
// Subscription
|
||||||
|
|
||||||
|
|||||||
@@ -443,7 +443,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_24" stretch="1,1">
|
<layout class="QHBoxLayout" name="horizontalLayout_24">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_23">
|
<layout class="QHBoxLayout" name="horizontalLayout_23">
|
||||||
@@ -455,23 +455,33 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="max_log_line"/>
|
<widget class="QLineEdit" name="max_log_line">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<widget class="QGroupBox" name="groupBox_3">
|
||||||
<property name="orientation">
|
<layout class="QHBoxLayout" name="horizontalLayout_25">
|
||||||
<enum>Qt::Horizontal</enum>
|
<item>
|
||||||
</property>
|
<widget class="QCheckBox" name="AA_EnableHighDpiScaling">
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="toolTip">
|
||||||
<size>
|
<string>Maybe useful for HiDPI screens.</string>
|
||||||
<width>0</width>
|
</property>
|
||||||
<height>0</height>
|
<property name="text">
|
||||||
</size>
|
<string notr="true">Qt::AA_EnableHighDpiScaling</string>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user