Skip to content

Commit 1a2fe23

Browse files
committed
Tweak UI for better look on Windows
1 parent 1c0830e commit 1a2fe23

File tree

8 files changed

+70
-57
lines changed

8 files changed

+70
-57
lines changed

src/app/app.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ void Application::initAppFonts() {
154154
#ifdef Q_OS_MAC
155155
QString defaultFontName("Helvetica Neue");
156156
int defaultFontSize = 12;
157+
#elif defined(Q_OS_WINDOWS)
158+
QString defaultFontName("Segoe UI");
159+
int defaultFontSize = 11;
157160
#else
158161
QString defaultFontName("Open Sans");
159162
int defaultFontSize = 11;
@@ -162,15 +165,18 @@ void Application::initAppFonts() {
162165
QString appFont = settings.value("app/appFont", defaultFontName).toString();
163166
int appFontSize = settings.value("app/appFontSize", defaultFontSize).toInt();
164167

165-
#ifdef Q_OS_LINUX
168+
166169
if (appFont == "Open Sans") {
170+
#if defined(Q_OS_LINUX)
167171
int result = QFontDatabase::addApplicationFont("://fonts/OpenSans.ttc");
168172

169173
if (result == -1) {
170174
appFont = "Ubuntu";
171175
}
172-
}
176+
#elif defined (Q_OS_WINDOWS)
177+
appFont = defaultFontName;
173178
#endif
179+
}
174180

175181
qDebug() << "App font:" << appFont << appFontSize;
176182
QFont defaultFont(appFont, appFontSize);

src/main.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
#include <QGuiApplication>
44
#include <QScreen>
55

6+
#if defined(Q_OS_WIN) | defined(Q_OS_LINUX)
7+
#include <QProcess>
8+
#define RELAUNCH_CODE 1001
9+
#endif
10+
611
#ifdef CRASHPAD_INTEGRATION
712
#include "crashpad/handler.h"
813
#endif
@@ -13,8 +18,6 @@
1318

1419
#include "app/app.h"
1520

16-
#define RESTART_CODE 1000
17-
1821
int main(int argc, char *argv[])
1922
{
2023
int returnCode = 0;
@@ -25,41 +28,38 @@ int main(int argc, char *argv[])
2528
startCrashpad(appDir);
2629
#endif
2730

28-
bool scalingSetup = false;
29-
3031
#if defined(Q_OS_LINUX)
3132
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
3233
#endif
3334

34-
do
35-
{
36-
Application a(argc, argv);
37-
3835
#if defined(Q_OS_WIN)
39-
if (!scalingSetup) {
40-
if (QGuiApplication::primaryScreen() && QGuiApplication::primaryScreen()->availableSize().width() <= 1920
41-
&& QGuiApplication::primaryScreen()->devicePixelRatio() > 1
42-
&& !QGuiApplication::testAttribute(Qt::AA_DisableHighDpiScaling)) {
43-
QGuiApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
44-
} else {
45-
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
46-
}
47-
returnCode = RESTART_CODE;
48-
scalingSetup = true;
49-
continue;
50-
}
36+
if (QGuiApplication::primaryScreen() && QGuiApplication::primaryScreen()->availableSize().width() <= 1920
37+
&& QGuiApplication::primaryScreen()->devicePixelRatio() > 1
38+
&& !QGuiApplication::testAttribute(Qt::AA_DisableHighDpiScaling)) {
39+
QGuiApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
40+
} else {
41+
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
42+
}
5143
#endif
5244

45+
Application a(argc, argv);
46+
5347
#ifdef LINUX_SIGNALS
54-
UnixSignalWatcher sigwatch;
55-
sigwatch.watchForSignal(SIGINT);
56-
sigwatch.watchForSignal(SIGTERM);
57-
QObject::connect(&sigwatch, SIGNAL(unixSignal(int)), &a, SLOT(quit()));
48+
UnixSignalWatcher sigwatch;
49+
sigwatch.watchForSignal(SIGINT);
50+
sigwatch.watchForSignal(SIGTERM);
51+
QObject::connect(&sigwatch, SIGNAL(unixSignal(int)), &a, SLOT(quit()));
52+
#endif
53+
a.initModels();
54+
a.initQml();
55+
returnCode = a.exec();
56+
57+
#if defined(Q_OS_WIN) | defined(Q_OS_LINUX)
58+
if (returnCode == RELAUNCH_CODE) {
59+
QProcess::startDetached(a.arguments()[0], a.arguments());
60+
returnCode = 0;
61+
}
5862
#endif
59-
a.initModels();
60-
a.initQml();
61-
returnCode = a.exec();
62-
} while(returnCode == RESTART_CODE);
6363

6464
return returnCode;
6565
}

src/qml/AppToolBar.qml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ ToolBar {
100100

101101
Item { Layout.fillWidth: true }
102102

103+
BetterButton {
104+
iconSource: "qrc:/images/log.svg"
105+
text: qsTranslate("RDM","Log")
106+
107+
onClicked: logDrawer.open()
108+
}
109+
103110
BetterButton {
104111
objectName: "rdm_global_settings_btn"
105112
iconSource: "qrc:/images/settings.svg"
@@ -108,14 +115,7 @@ ToolBar {
108115
onClicked: {
109116
settingsDialog.open()
110117
}
111-
}
112-
113-
BetterButton {
114-
iconSource: "qrc:/images/log.svg"
115-
text: qsTranslate("RDM","Log")
116-
117-
onClicked: logDrawer.open()
118-
}
118+
}
119119
}
120120
}
121121

src/qml/GlobalSettings.qml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Dialog {
1818
contentItem: Rectangle {
1919
id: dialogRoot
2020
implicitWidth: 800
21-
implicitHeight: PlatformUtils.isOSX()? 500 : 600
21+
implicitHeight: PlatformUtils.isOSX()? 500 : 620
2222

2323
border.color: "#eeeeee"
2424
border.width: 1
@@ -35,7 +35,7 @@ Dialog {
3535

3636
ColumnLayout {
3737
id: innerLayout
38-
width: globalSettingsScrollView.width - 25
38+
width: PlatformUtils.isOSX()? globalSettingsScrollView.width - 25 : globalSettingsScrollView.width
3939
height: (dialogRoot.height - 50 > implicitHeight) ? dialogRoot.height - 50 : implicitHeight
4040

4141
SettingsGroupTitle {
@@ -46,7 +46,7 @@ Dialog {
4646
id: appLang
4747

4848
Layout.fillWidth: true
49-
Layout.preferredHeight: 40
49+
Layout.preferredHeight: 30
5050

5151
model: ["system", "en_US", "zh_CN", "zh_TW", "ru_RU", "es_ES", "ja_JP"]
5252
value: "system"
@@ -60,7 +60,7 @@ Dialog {
6060
id: appFont
6161

6262
Layout.fillWidth: true
63-
Layout.preferredHeight: 40
63+
Layout.preferredHeight: 30
6464

6565
value: Qt.platform.os == "osx"? "Helvetica Neue" : "Open Sans"
6666
model: Qt.fontFamilies()
@@ -74,7 +74,7 @@ Dialog {
7474
id: appFontSize
7575

7676
Layout.fillWidth: true
77-
Layout.preferredHeight: 40
77+
Layout.preferredHeight: 30
7878

7979
model: ["8", "9", "10", "11", "12"]
8080
value: Qt.platform.os == "osx"? "12" : "11"
@@ -88,7 +88,7 @@ Dialog {
8888
id: systemProxy
8989

9090
Layout.fillWidth: true
91-
Layout.preferredHeight: 40
91+
Layout.preferredHeight: 30
9292

9393
value: false
9494
label: qsTranslate("RDM","Use system proxy settings")
@@ -106,7 +106,7 @@ Dialog {
106106
id: nsReload
107107

108108
Layout.fillWidth: true
109-
Layout.preferredHeight: 40
109+
Layout.preferredHeight: 30
110110

111111
value: true
112112
label: qsTranslate("RDM","Reopen namespaces on reload")
@@ -117,7 +117,7 @@ Dialog {
117117
id: keySorting
118118

119119
Layout.fillWidth: true
120-
Layout.preferredHeight: 40
120+
Layout.preferredHeight: 30
121121

122122
value: true
123123
label: qsTranslate("RDM","Enable key sorting in tree")
@@ -128,7 +128,7 @@ Dialog {
128128
id: liveKeyLimit
129129

130130
Layout.fillWidth: true
131-
Layout.preferredHeight: 40
131+
Layout.preferredHeight: 30
132132

133133
min: 100
134134
max: 100000
@@ -141,7 +141,7 @@ Dialog {
141141
id: liveUpdateInterval
142142

143143
Layout.fillWidth: true
144-
Layout.preferredHeight: 40
144+
Layout.preferredHeight: 30
145145

146146
min: 3
147147
max: 100000
@@ -164,6 +164,7 @@ Dialog {
164164

165165
LC.TableView {
166166
visible: !PlatformUtils.isOSX()
167+
167168
Layout.fillWidth: true
168169
Layout.fillHeight: true
169170
verticalScrollBarPolicy: Qt.ScrollBarAlwaysOn
@@ -204,7 +205,7 @@ Dialog {
204205
onClicked: {
205206
if (root.restartRequired === true) {
206207
// restart app
207-
Qt.exit(1000)
208+
Qt.exit(1001)
208209
}
209210

210211
restartRequired = false
@@ -241,4 +242,8 @@ Dialog {
241242

242243
property var formatters
243244
}
245+
246+
Component.onCompleted: {
247+
restartRequired = false
248+
}
244249
}

src/qml/app.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ ApplicationWindow {
2323
title: "Redis Desktop Manager " + Qt.application.version
2424
width: 1100
2525
height: 800
26+
minimumWidth: 1100
27+
minimumHeight: 700
2628

2729
property double wRatio : (width * 1.0) / (Screen.width * 1.0)
2830
property double hRatio : (height * 1.0) / (Screen.height * 1.0)

src/qml/value-editor/Pagination.qml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ ColumnLayout {
2323
text: " of " + table.totalPages
2424
wrapMode: Text.WrapAnywhere
2525
}
26+
27+
Text {
28+
text: qsTranslate("RDM","Size: ") + keyRowsCount
29+
}
2630
}
2731

2832
RowLayout {

src/qml/value-editor/ValueTabs.qml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -702,11 +702,6 @@ Repeater {
702702
Layout.fillHeight: true
703703
}
704704

705-
Text {
706-
visible: keyTab.keyModel? isMultiRow : false
707-
text: qsTranslate("RDM","Size: ") + keyRowsCount
708-
}
709-
710705
Pagination {
711706
id: pagination
712707
Layout.fillWidth: true

src/rdm.pro

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ win32 {
7373
QMAKE_TARGET_COMPANY = redisdesktop.com
7474
QMAKE_TARGET_PRODUCT = RedisDesktopManager
7575
QMAKE_TARGET_DESCRIPTION = "Open source GUI management tool for Redis"
76-
QMAKE_TARGET_COPYRIGHT = "Igor Malinovskiy (C) 2013-2019"
76+
QMAKE_TARGET_COPYRIGHT = "Igor Malinovskiy (C) 2013-2020"
7777

7878
release: DESTDIR = ./../bin/windows/release
7979
debug: DESTDIR = ./../bin/windows/debug
@@ -129,6 +129,8 @@ unix:!macx { # ubuntu & debian
129129
deskicon.path = /usr/share/applications
130130
deskicon.files = $$PWD/resources/rdm.desktop
131131
INSTALLS += deskicon
132+
133+
RESOURCES += $$PWD/resources/fonts.qrc
132134
}
133135

134136
UI_DIR = $$DESTDIR/ui
@@ -141,8 +143,7 @@ INCLUDEPATH += $$PWD/ \
141143
$$UI_DIR/ \
142144

143145
RESOURCES += \
144-
$$PWD/resources/images.qrc \
145-
$$PWD/resources/fonts.qrc \
146+
$$PWD/resources/images.qrc \
146147
$$PWD/qml/qml.qrc \
147148
$$PWD/py/py.qrc \
148149
$$PWD/resources/commands.qrc

0 commit comments

Comments
 (0)