-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDPI_ADAPTIVE_PATCH.diff
More file actions
545 lines (500 loc) · 23.8 KB
/
Copy pathDPI_ADAPTIVE_PATCH.diff
File metadata and controls
545 lines (500 loc) · 23.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -6,6 +6,7 @@
#include <QDir>
#include <QFileInfo>
#include <QFont>
+#include <QGuiApplication>
#include <QIcon>
#include <QJsonDocument>
#include <QJsonObject>
@@ -246,6 +247,17 @@
int main(int argc, char *argv[])
{
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ // Make Qt 5 follow Windows DPI scaling. Qt 6 enables this behavior by default.
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
+#endif
+#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
+ // Preserve fractional Windows scale factors such as 125% and 150%.
+ QGuiApplication::setHighDpiScaleFactorRoundingPolicy(
+ Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
+#endif
+
QStringList rawArguments;
rawArguments.reserve(argc);
for (int index = 0; index < argc; ++index) {
--- a/src/ui/MainWindow.cpp
+++ b/src/ui/MainWindow.cpp
@@ -35,6 +35,7 @@
#include <QPalette>
#include <QPixmap>
#include <QPushButton>
+#include <QRegularExpression>
#include <QScreen>
#include <QScrollArea>
#include <QSettings>
@@ -55,6 +56,66 @@
#include <functional>
namespace {
+qreal g_uiScale = 1.0;
+
+qreal calculateUiScale()
+{
+ QScreen *screen = QGuiApplication::primaryScreen();
+ if (!screen) {
+ return 1.0;
+ }
+
+ // QScreen geometry is expressed in device-independent pixels when Qt high-DPI
+ // scaling is active. This means Windows 150%/200% scaling is already taken
+ // into account, and we only add a modest boost when a display still exposes
+ // substantially more logical workspace than a 1920x1080 reference screen.
+ const QSize available = screen->availableGeometry().size();
+ const qreal widthRatio = available.width() / 1920.0;
+ const qreal heightRatio = available.height() / 1080.0;
+ const qreal workspaceRatio = qMin(widthRatio, heightRatio);
+ if (workspaceRatio <= 1.0) {
+ return 1.0;
+ }
+
+ // Square-root growth keeps 2K comfortable without making 4K oversized:
+ // 2560x1440 -> ~1.15x, 3840x2160 -> ~1.41x (at 100% OS scaling).
+ return qBound<qreal>(1.0, std::sqrt(workspaceRatio), 1.50);
+}
+
+int sp(int value)
+{
+ if (value <= 0) {
+ return value;
+ }
+ return qMax(1, qRound(value * g_uiScale));
+}
+
+
+QString scaleStyleSheetPixels(const QString &style, qreal scale)
+{
+ if (scale <= 1.001) {
+ return style;
+ }
+
+ static const QRegularExpression pixelPattern(QStringLiteral(R"((\d+(?:\.\d+)?)px)"));
+ QString result;
+ result.reserve(style.size() + style.size() / 12);
+
+ int last = 0;
+ auto matchIt = pixelPattern.globalMatch(style);
+ while (matchIt.hasNext()) {
+ const QRegularExpressionMatch match = matchIt.next();
+ result += style.mid(last, match.capturedStart() - last);
+
+ const qreal value = match.captured(1).toDouble();
+ const int scaledValue = value <= 0.0 ? 0 : qMax(1, qRound(value * scale));
+ result += QString::number(scaledValue) + QStringLiteral("px");
+ last = match.capturedEnd();
+ }
+ result += style.mid(last);
+ return result;
+}
+
class ShareDropArea : public QFrame {
public:
std::function<void(const QStringList &)> onDropPaths;
@@ -220,8 +281,8 @@
QIcon buildSidebarIcon(UiIcon kind)
{
QIcon icon;
- const QPixmap normal = drawUiIcon(kind, QColor(QStringLiteral("#64748b")), Qt::transparent, 24);
- const QPixmap active = drawUiIcon(kind, QColor(QStringLiteral("#6d5ce7")), Qt::transparent, 24);
+ const QPixmap normal = drawUiIcon(kind, QColor(QStringLiteral("#64748b")), Qt::transparent, sp(24));
+ const QPixmap active = drawUiIcon(kind, QColor(QStringLiteral("#6d5ce7")), Qt::transparent, sp(24));
icon.addPixmap(normal, QIcon::Normal, QIcon::Off);
icon.addPixmap(active, QIcon::Normal, QIcon::On);
icon.addPixmap(active, QIcon::Active, QIcon::Off);
@@ -232,8 +293,8 @@
void applySoftShadow(QWidget *widget, int blurRadius = 24, int yOffset = 7)
{
auto *shadow = new QGraphicsDropShadowEffect(widget);
- shadow->setBlurRadius(blurRadius);
- shadow->setOffset(0, yOffset);
+ shadow->setBlurRadius(sp(blurRadius));
+ shadow->setOffset(0, sp(yOffset));
shadow->setColor(QColor(26, 38, 64, 28));
widget->setGraphicsEffect(shadow);
}
@@ -251,13 +312,13 @@
applySoftShadow(card, 22, 6);
auto *layout = new QVBoxLayout(card);
- layout->setContentsMargins(22, 20, 22, 22);
- layout->setSpacing(9);
+ layout->setContentsMargins(sp(22), sp(20), sp(22), sp(22));
+ layout->setSpacing(sp(9));
auto *icon = new QLabel(card);
icon->setObjectName(QStringLiteral("StatIcon"));
- icon->setFixedSize(48, 48);
- icon->setPixmap(drawUiIcon(iconKind, iconColor, iconBackground, 48));
+ icon->setFixedSize(sp(48), sp(48));
+ icon->setPixmap(drawUiIcon(iconKind, iconColor, iconBackground, sp(48)));
icon->setAlignment(Qt::AlignCenter);
auto *titleLabel = new QLabel(title, card);
@@ -285,9 +346,9 @@
auto *button = new QPushButton(text, parent);
button->setCheckable(true);
button->setCursor(Qt::PointingHandCursor);
- button->setMinimumHeight(50);
+ button->setMinimumHeight(sp(50));
button->setIcon(buildSidebarIcon(iconKind));
- button->setIconSize(QSize(22, 22));
+ button->setIconSize(QSize(sp(22), sp(22)));
button->setObjectName(QStringLiteral("SidebarButton"));
return button;
}
@@ -297,8 +358,8 @@
auto *label = new QLabel(text, parent);
label->setObjectName(QStringLiteral("FieldLabel"));
label->setAlignment(Qt::AlignCenter);
- label->setMinimumHeight(40);
- label->setMinimumWidth(118);
+ label->setMinimumHeight(sp(40));
+ label->setMinimumWidth(sp(118));
return label;
}
@@ -316,17 +377,17 @@
{
const bool isFolder = share.type == ShareType::Directory || share.type == ShareType::VirtualDirectory;
- QPixmap pixmap(72, 72);
+ QPixmap pixmap(sp(72), sp(72));
pixmap.fill(Qt::transparent);
QPainter painter(&pixmap);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(Qt::NoPen);
painter.setBrush(isFolder ? QColor(QStringLiteral("#ffe8a3")) : QColor(QStringLiteral("#cfe9ff")));
- painter.drawRoundedRect(pixmap.rect(), 20, 20);
+ painter.drawRoundedRect(pixmap.rect(), sp(20), sp(20));
painter.setPen(isFolder ? QColor(QStringLiteral("#cf9600")) : QColor(QStringLiteral("#148fe8")));
- painter.setFont(QFont(QStringLiteral("Microsoft JhengHei UI"), 24, QFont::Bold));
+ painter.setFont(QFont(QStringLiteral("Microsoft JhengHei UI"), sp(24), QFont::Bold));
painter.drawText(pixmap.rect(), Qt::AlignCenter, isFolder ? QStringLiteral("D") : QStringLiteral("F"));
return pixmap;
}
@@ -412,8 +473,9 @@
, m_controller(controller)
{
setWindowTitle(QStringLiteral("Easy Cloud HFS - 檔案分享伺服器"));
- resize(1180, 720);
- setMinimumSize(900, 600);
+ g_uiScale = calculateUiScale();
+ resize(sp(1180), sp(720));
+ setMinimumSize(sp(900), sp(600));
buildUi();
setupTrayIcon();
@@ -469,7 +531,7 @@
{
const AppSettings settings = m_controller->settings();
- QSize targetSize(settings.windowWidth, settings.windowHeight);
+ QSize targetSize(sp(settings.windowWidth), sp(settings.windowHeight));
if (QScreen *screen = QGuiApplication::primaryScreen()) {
const QSize available = screen->availableGeometry().size();
const int maxWidth = qMax(760, available.width() - 24);
@@ -491,8 +553,8 @@
{
AppSettings settings = m_controller->settings();
const QSize storedSize = isMaximized() ? normalGeometry().size() : size();
- settings.windowWidth = qMax(minimumWidth(), storedSize.width());
- settings.windowHeight = qMax(minimumHeight(), storedSize.height());
+ settings.windowWidth = qMax(900, qRound(storedSize.width() / g_uiScale));
+ settings.windowHeight = qMax(600, qRound(storedSize.height() / g_uiScale));
settings.windowMaximized = isMaximized();
m_controller->saveSystemSettings(settings);
}
@@ -586,21 +648,21 @@
{
auto *sidebar = new QFrame(m_central);
sidebar->setObjectName(QStringLiteral("Sidebar"));
- sidebar->setFixedWidth(278);
+ sidebar->setFixedWidth(sp(278));
auto *layout = new QVBoxLayout(sidebar);
- layout->setContentsMargins(20, 22, 20, 20);
- layout->setSpacing(10);
+ layout->setContentsMargins(sp(20), sp(22), sp(20), sp(20));
+ layout->setSpacing(sp(10));
auto *brandBox = new QFrame(sidebar);
brandBox->setObjectName(QStringLiteral("BrandBox"));
auto *brandLayout = new QVBoxLayout(brandBox);
- brandLayout->setContentsMargins(8, 8, 8, 16);
- brandLayout->setSpacing(5);
+ brandLayout->setContentsMargins(sp(8), sp(8), sp(8), sp(16));
+ brandLayout->setSpacing(sp(5));
auto *logo = new QLabel(brandBox);
- logo->setPixmap(QPixmap(QStringLiteral(":/desktop_logo.png")).scaled(104, 104, Qt::KeepAspectRatio, Qt::SmoothTransformation));
- logo->setFixedSize(104, 104);
+ logo->setPixmap(QPixmap(QStringLiteral(":/desktop_logo.png")).scaled(sp(104), sp(104), Qt::KeepAspectRatio, Qt::SmoothTransformation));
+ logo->setFixedSize(sp(104), sp(104));
logo->setAlignment(Qt::AlignCenter);
auto *brandTitle = new QLabel(QStringLiteral("Easy Cloud HFS"), brandBox);
@@ -620,7 +682,7 @@
brandLayout->addWidget(m_brandSubtitle);
brandLayout->addWidget(brandVersion);
layout->addWidget(brandBox);
- layout->addSpacing(6);
+ layout->addSpacing(sp(6));
auto *buttonGroup = new QButtonGroup(this);
buttonGroup->setExclusive(true);
@@ -654,14 +716,14 @@
footer->setObjectName(QStringLiteral("SidebarFooter"));
applySoftShadow(footer, 20, 5);
auto *footerLayout = new QVBoxLayout(footer);
- footerLayout->setContentsMargins(16, 16, 16, 16);
- footerLayout->setSpacing(9);
+ footerLayout->setContentsMargins(sp(16), sp(16), sp(16), sp(16));
+ footerLayout->setSpacing(sp(9));
auto *statusRow = new QHBoxLayout();
- statusRow->setSpacing(9);
+ statusRow->setSpacing(sp(9));
m_statusDot = new QLabel(footer);
m_statusDot->setObjectName(QStringLiteral("StatusDot"));
- m_statusDot->setFixedSize(10, 10);
+ m_statusDot->setFixedSize(sp(10), sp(10));
m_statusText = new QLabel(QStringLiteral("伺服器未啟動"), footer);
m_statusText->setObjectName(QStringLiteral("StatusText"));
@@ -715,12 +777,12 @@
auto *header = new QFrame(content);
header->setObjectName(QStringLiteral("Header"));
auto *headerLayout = new QHBoxLayout(header);
- headerLayout->setContentsMargins(34, 26, 34, 20);
- headerLayout->setSpacing(18);
+ headerLayout->setContentsMargins(sp(34), sp(26), sp(34), sp(20));
+ headerLayout->setSpacing(sp(18));
auto *titleLayout = new QVBoxLayout();
titleLayout->setContentsMargins(0, 0, 0, 0);
- titleLayout->setSpacing(5);
+ titleLayout->setSpacing(sp(5));
m_pageTitle = new QLabel(header);
m_pageTitle->setObjectName(QStringLiteral("PageTitle"));
@@ -736,8 +798,8 @@
m_startStopButton = new QPushButton(header);
m_startStopButton->setCursor(Qt::PointingHandCursor);
- m_startStopButton->setMinimumHeight(48);
- m_startStopButton->setMinimumWidth(154);
+ m_startStopButton->setMinimumHeight(sp(48));
+ m_startStopButton->setMinimumWidth(sp(154));
connect(m_startStopButton, &QPushButton::clicked, this, [this]() {
if (m_isStoppingServer) {
return;
@@ -771,12 +833,12 @@
{
auto *dashboard = new QWidget(m_pages);
auto *dashboardLayout = new QVBoxLayout(dashboard);
- dashboardLayout->setContentsMargins(34, 18, 34, 30);
- dashboardLayout->setSpacing(24);
+ dashboardLayout->setContentsMargins(sp(34), sp(18), sp(34), sp(30));
+ dashboardLayout->setSpacing(sp(24));
auto *statsGrid = new QGridLayout();
- statsGrid->setHorizontalSpacing(18);
- statsGrid->setVerticalSpacing(18);
+ statsGrid->setHorizontalSpacing(sp(18));
+ statsGrid->setVerticalSpacing(sp(18));
statsGrid->addWidget(makeCard(tx(QStringLiteral("總下載次數"), QStringLiteral("Total Downloads")), &m_totalDownloadsValue, &m_lblTotalDownloadsTitle, UiIcon::Download, QColor(QStringLiteral("#7657e8")), QColor(QStringLiteral("#f0ecff"))), 0, 0);
statsGrid->addWidget(makeCard(tx(QStringLiteral("總下載流量"), QStringLiteral("Total Data Served")), &m_totalBytesValue, &m_lblTotalBytesTitle, UiIcon::Data, QColor(QStringLiteral("#2f7df4")), QColor(QStringLiteral("#eaf3ff"))), 0, 1);
statsGrid->addWidget(makeCard(tx(QStringLiteral("目前連線"), QStringLiteral("Active Connections")), &m_activeConnectionsValue, &m_lblActiveConnectionsTitle, UiIcon::Connections, QColor(QStringLiteral("#20a96b")), QColor(QStringLiteral("#e7f8f0"))), 0, 2);
@@ -791,7 +853,7 @@
infoCard->setObjectName(QStringLiteral("InfoCard"));
applySoftShadow(infoCard, 24, 7);
auto *infoLayout = new QVBoxLayout(infoCard);
- infoLayout->setContentsMargins(26, 24, 26, 24);
+ infoLayout->setContentsMargins(sp(26), sp(24), sp(26), sp(24));
m_lblServerInfoTitle = new QLabel(tx(QStringLiteral("伺服器運作資訊"), QStringLiteral("Server Information")), infoCard);
m_lblServerInfoTitle->setObjectName(QStringLiteral("SectionTitle"));
m_serverInfoLabel = new QLabel(infoCard);
@@ -806,11 +868,11 @@
m_sharePage = new QWidget(m_pages);
auto *shareLayout = new QVBoxLayout(m_sharePage);
- shareLayout->setContentsMargins(24, 22, 24, 22);
- shareLayout->setSpacing(16);
+ shareLayout->setContentsMargins(sp(24), sp(22), sp(24), sp(22));
+ shareLayout->setSpacing(sp(16));
auto *shareHeader = new QHBoxLayout();
- shareHeader->setSpacing(10);
+ shareHeader->setSpacing(sp(10));
m_shareExternalLinkCheck = new QCheckBox(tx(QStringLiteral("啟用外部連結"), QStringLiteral("Enable External Link")), m_sharePage);
m_shareExternalInfoLabel = new QLabel(tx(QStringLiteral("使用 Cloudflare Tunnel 代理"), QStringLiteral("Use Cloudflare Tunnel Proxy")), m_sharePage);
m_shareExternalInfoLabel->setObjectName(QStringLiteral("ExternalPrefixLabel"));
@@ -818,17 +880,17 @@
m_shareExternalInfoLabel->setTextFormat(Qt::RichText);
m_shareExternalInfoLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
m_shareExternalInfoLabel->setOpenExternalLinks(false);
- m_shareExternalInfoLabel->setMinimumWidth(300);
- m_shareExternalInfoLabel->setMaximumWidth(380);
- m_shareExternalInfoLabel->setMinimumHeight(40);
+ m_shareExternalInfoLabel->setMinimumWidth(sp(300));
+ m_shareExternalInfoLabel->setMaximumWidth(sp(380));
+ m_shareExternalInfoLabel->setMinimumHeight(sp(40));
m_btnSaveShares = new QPushButton(tx(QStringLiteral("儲存分享"), QStringLiteral("Save Shares")), m_sharePage);
m_btnSaveShares->setObjectName(QStringLiteral("SecondaryButton"));
m_btnAddShare = new QPushButton(tx(QStringLiteral("新增分享"), QStringLiteral("Add Share")), m_sharePage);
m_btnSaveShares->setCursor(Qt::PointingHandCursor);
m_btnAddShare->setCursor(Qt::PointingHandCursor);
- m_btnSaveShares->setMinimumHeight(40);
- m_btnAddShare->setMinimumHeight(42);
- m_btnAddShare->setMinimumWidth(128);
+ m_btnSaveShares->setMinimumHeight(sp(40));
+ m_btnAddShare->setMinimumHeight(sp(42));
+ m_btnAddShare->setMinimumWidth(sp(128));
m_shareExternalLinkCheck->setCursor(Qt::PointingHandCursor);
connect(m_shareExternalLinkCheck, &QCheckBox::toggled, this, [this](bool checked) {
m_controller->setExternalLinkSettings(checked);
@@ -848,10 +910,10 @@
auto *dropArea = new ShareDropArea(m_sharePage);
dropArea->setObjectName(QStringLiteral("DropArea"));
- dropArea->setMinimumHeight(120);
+ dropArea->setMinimumHeight(sp(120));
auto *dropLayout = new QVBoxLayout(dropArea);
- dropLayout->setContentsMargins(24, 24, 24, 24);
- dropLayout->setSpacing(12);
+ dropLayout->setContentsMargins(sp(24), sp(24), sp(24), sp(24));
+ dropLayout->setSpacing(sp(12));
m_dropTitle = new QLabel(tx(QStringLiteral("可直接拖曳檔案或資料夾到這裡快速連結"), QStringLiteral("Drag and drop files or folders here to share")), dropArea);
m_dropTitle->setObjectName(QStringLiteral("DropTitle"));
m_dropTitle->setAlignment(Qt::AlignCenter);
@@ -867,7 +929,7 @@
auto *listContainer = new QWidget(listScroll);
m_shareListLayout = new QVBoxLayout(listContainer);
m_shareListLayout->setContentsMargins(0, 0, 0, 0);
- m_shareListLayout->setSpacing(12);
+ m_shareListLayout->setSpacing(sp(12));
listScroll->setWidget(listContainer);
shareLayout->addWidget(listScroll, 1);
@@ -875,22 +937,22 @@
auto *systemPage = new QWidget(m_pages);
auto *systemLayout = new QVBoxLayout(systemPage);
- systemLayout->setContentsMargins(34, 28, 34, 28);
- systemLayout->setSpacing(20);
+ systemLayout->setContentsMargins(sp(34), sp(28), sp(34), sp(28));
+ systemLayout->setSpacing(sp(20));
auto *systemCard = new QFrame(systemPage);
systemCard->setObjectName(QStringLiteral("InfoCard"));
applySoftShadow(systemCard, 24, 7);
auto *systemCardLayout = new QVBoxLayout(systemCard);
- systemCardLayout->setContentsMargins(28, 26, 28, 28);
- systemCardLayout->setSpacing(22);
+ systemCardLayout->setContentsMargins(sp(28), sp(26), sp(28), sp(28));
+ systemCardLayout->setSpacing(sp(22));
m_lblSystemTitle = new QLabel(tx(QStringLiteral("系統設定"), QStringLiteral("System Settings")), systemCard);
m_lblSystemTitle->setObjectName(QStringLiteral("SectionTitle"));
systemCardLayout->addWidget(m_lblSystemTitle);
auto *logoRow = new QHBoxLayout();
m_logoPreview = new QLabel(systemCard);
- m_logoPreview->setFixedSize(112, 112);
+ m_logoPreview->setFixedSize(sp(112), sp(112));
m_btnSelectLogo = new QPushButton(tx(QStringLiteral("選擇 Logo"), QStringLiteral("Select Logo")), systemCard);
m_btnSelectLogo->setObjectName(QStringLiteral("SecondaryButton"));
m_btnClearLogo = new QPushButton(tx(QStringLiteral("移除 Logo"), QStringLiteral("Remove Logo")), systemCard);
@@ -912,7 +974,7 @@
m_controller->saveSystemSettings(settings);
});
auto *logoButtonsLayout = new QVBoxLayout();
- logoButtonsLayout->setSpacing(10);
+ logoButtonsLayout->setSpacing(sp(10));
logoButtonsLayout->addWidget(m_btnSelectLogo);
logoButtonsLayout->addWidget(m_btnClearLogo);
logoButtonsLayout->addStretch();
@@ -925,8 +987,8 @@
auto *form = new QFormLayout();
form->setLabelAlignment(Qt::AlignCenter);
form->setFormAlignment(Qt::AlignTop);
- form->setHorizontalSpacing(20);
- form->setVerticalSpacing(18);
+ form->setHorizontalSpacing(sp(20));
+ form->setVerticalSpacing(sp(18));
m_siteNameEdit = new QLineEdit(systemCard);
m_portSpin = new NoWheelSpinBox(systemCard);
@@ -969,13 +1031,13 @@
auto *aboutPage = new QWidget(m_pages);
auto *aboutLayout = new QVBoxLayout(aboutPage);
- aboutLayout->setContentsMargins(34, 28, 34, 28);
+ aboutLayout->setContentsMargins(sp(34), sp(28), sp(34), sp(28));
auto *aboutCard = new QFrame(aboutPage);
aboutCard->setObjectName(QStringLiteral("InfoCard"));
applySoftShadow(aboutCard, 24, 7);
auto *aboutCardLayout = new QVBoxLayout(aboutCard);
- aboutCardLayout->setContentsMargins(34, 30, 34, 30);
- aboutCardLayout->setSpacing(18);
+ aboutCardLayout->setContentsMargins(sp(34), sp(30), sp(34), sp(30));
+ aboutCardLayout->setSpacing(sp(18));
m_lblAboutTitle = new QLabel(tx(QStringLiteral("關於"), QStringLiteral("About")), aboutCard);
m_lblAboutTitle->setObjectName(QStringLiteral("SectionTitle"));
m_aboutLabel = new QLabel(aboutCard);
@@ -1129,7 +1191,7 @@
void MainWindow::refreshAbout()
{
- m_aboutLabel->setText(tx(
+ m_aboutLabel->setText(scaleStyleSheetPixels(tx(
QStringLiteral(
"<div style='font-size:22px; font-weight:700; line-height:1.85;'>"
"Easy Cloud HFS<br>"
@@ -1184,7 +1246,7 @@
"<div style='margin-top:24px; font-size:18px; line-height:1.9;'>"
"This is an independent tool and is not an official Cloudflare product."
"</div>")
- ));
+ ), g_uiScale));
}
void MainWindow::refreshStartStopButton()
@@ -1233,7 +1295,7 @@
m_statusText->setStyleSheet(QStringLiteral("QLabel#StatusText{font-weight:700;color:%1;}").arg(textColor));
}
if (m_statusDot) {
- m_statusDot->setStyleSheet(QStringLiteral("QLabel#StatusDot{background:%1;border:0;border-radius:5px;}").arg(dotColor));
+ m_statusDot->setStyleSheet(scaleStyleSheetPixels(QStringLiteral("QLabel#StatusDot{background:%1;border:0;border-radius:5px;}").arg(dotColor), g_uiScale));
}
}
@@ -1272,7 +1334,7 @@
? QStringLiteral("QLabel{background:#0f1726;color:#617899;border:1px solid #223452;border-radius:14px;padding:10px 14px;font-weight:600;}")
: QStringLiteral("QLabel{background:#f3f6fa;color:#b5c0cf;border:1px solid #e0e7f0;border-radius:14px;padding:10px 14px;font-weight:600;}"));
- m_shareExternalInfoLabel->setStyleSheet(style);
+ m_shareExternalInfoLabel->setStyleSheet(scaleStyleSheetPixels(style, g_uiScale));
}
void MainWindow::showShareMenu()
@@ -1323,11 +1385,11 @@
auto *card = new QFrame(m_sharePage);
card->setObjectName(QStringLiteral("ShareCard"));
auto *cardLayout = new QHBoxLayout(card);
- cardLayout->setContentsMargins(16, 12, 16, 12);
- cardLayout->setSpacing(12);
+ cardLayout->setContentsMargins(sp(16), sp(12), sp(16), sp(12));
+ cardLayout->setSpacing(sp(12));
auto *iconLabel = new QLabel(card);
- iconLabel->setFixedSize(48, 48);
+ iconLabel->setFixedSize(sp(48), sp(48));
iconLabel->setPixmap(buildShareIcon(share));
iconLabel->setScaledContents(true);
@@ -1341,12 +1403,12 @@
typeLabel->setObjectName(QStringLiteral("ShareTypeBadge"));
typeLabel->setProperty("shareKind", isDirectoryShare(share) ? QStringLiteral("folder") : QStringLiteral("file"));
typeLabel->setAlignment(Qt::AlignCenter);
- typeLabel->setMinimumWidth(104);
- typeLabel->setMinimumHeight(34);
+ typeLabel->setMinimumWidth(sp(104));
+ typeLabel->setMinimumHeight(sp(34));
auto *removeButton = new QPushButton(tx(QStringLiteral("關閉"), QStringLiteral("Close")), card);
removeButton->setObjectName(QStringLiteral("DangerButton"));
- removeButton->setMinimumHeight(34);
+ removeButton->setMinimumHeight(sp(34));
connect(removeButton, &QPushButton::clicked, this, [this, share]() {
const auto reply = QMessageBox::question(this,
@@ -1412,8 +1474,8 @@
updatedSettings.download.perIpLimitUnit = QStringLiteral("KB/s");
const QSize storedSize = isMaximized() ? normalGeometry().size() : size();
- updatedSettings.windowWidth = qMax(minimumWidth(), storedSize.width());
- updatedSettings.windowHeight = qMax(minimumHeight(), storedSize.height());
+ updatedSettings.windowWidth = qMax(900, qRound(storedSize.width() / g_uiScale));
+ updatedSettings.windowHeight = qMax(600, qRound(storedSize.height() / g_uiScale));
updatedSettings.windowMaximized = isMaximized();
updatedSettings.clearSharesOnExit = false;
@@ -1529,7 +1591,7 @@
"QScrollBar:vertical{background:transparent;width:10px;margin:3px;} QScrollBar::handle:vertical{background:#cfd5df;border-radius:5px;min-height:28px;} QScrollBar::add-line:vertical,QScrollBar::sub-line:vertical{height:0;}"
"QScrollBar:horizontal{background:transparent;height:10px;margin:3px;} QScrollBar::handle:horizontal{background:#cfd5df;border-radius:5px;min-width:28px;} QScrollBar::add-line:horizontal,QScrollBar::sub-line:horizontal{width:0;}");
- qApp->setStyleSheet(style);
+ qApp->setStyleSheet(scaleStyleSheetPixels(style, g_uiScale));
}