Skip to content

Commit 1ff9997

Browse files
author
datyuesh
committed
Optimize interface layout
Signed-off-by: datyuesh <[email protected]>
1 parent 4e64501 commit 1ff9997

File tree

3 files changed

+144
-19
lines changed

3 files changed

+144
-19
lines changed

Diff for: src/plugins/ukui-notebook/about.cpp

+77-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22
#include "ui_about.h"
33
#include "utils/xatom-helper.h"
44

5+
#include <QGSettings>
6+
7+
#define UKUI_STYLE_SCHEMA "org.ukui.style"
8+
#define STYLE_NAME "styleName"
9+
#define STYLE_NAME_KEY_DARK "ukui-dark"
10+
#define STYLE_NAME_KEY_DEFAULT "ukui-default"
11+
#define STYLE_NAME_KEY_BLACK "ukui-black"
12+
#define STYLE_NAME_KEY_LIGHT "ukui-light"
13+
#define STYLE_NAME_KEY_WHITE "ukui-white"
14+
15+
#define SYSTEM_FONT_EKY "system-font-size"
16+
#define SYSTEM_NAME_KEY "system-font"
17+
518
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
619

720
About::About(QWidget *parent) :
@@ -28,16 +41,16 @@ About::About(QWidget *parent) :
2841
ui->closeBtn->setProperty("isWindowButton", 0x2);
2942
ui->closeBtn->setProperty("useIconHighlightEffect", 0x8);
3043
ui->closeBtn->setFlat(true);
44+
3145
connect(ui->closeBtn, &QPushButton::clicked, this, [=](){
3246
this->close();
3347
});
34-
ui->appnameLabel->setStyleSheet("QLabel{font-size: 18px; color: palette(windowText);}"
35-
"QLabel{font-family: NotoSansCJKsc-Medium, NotoSansCJKsc;}");
48+
3649
ui->versionLabel->setText(tr("Version: 2020.1.0"));
37-
ui->teamLabel->setText(tr("Service & Support: ") +
38-
"<a href=\"mailto://[email protected]\""
39-
"style=\"color: palette(buttonText)\">"
40-
50+
// ui->teamLabel->setText(tr("Service & Support: ") +
51+
// "<a href=\"mailto://[email protected]\""
52+
// "style=\"color: palette(buttonText)\">"
53+
4154
ui->appiconLabel->setPixmap(QIcon::fromTheme("kylin-notebook").pixmap(96,96));
4255
ui->appnameLabel->setText(tr("Kylin Memo"));
4356
ui->introduceLabel->setText(tr("Kylin Memo is a self-developed sidebar application plug-in, "
@@ -49,6 +62,8 @@ About::About(QWidget *parent) :
4962
QDesktopServices::openUrl(QUrl(url));
5063
});
5164
ui->teamLabel->setContextMenuPolicy(Qt::NoContextMenu);
65+
66+
listenToGsettings();
5267
}
5368

5469
About::~About()
@@ -64,3 +79,59 @@ void About::paintEvent(QPaintEvent *event) {
6479
rectPath.addRect(this->rect());
6580
p.fillPath(rectPath,palette().color(QPalette::Base));
6681
}
82+
83+
void About::listenToGsettings()
84+
{
85+
const QByteArray styleID(UKUI_STYLE_SCHEMA);
86+
QStringList stylelist;
87+
88+
if (QGSettings::isSchemaInstalled(styleID)){
89+
QGSettings *styleUKUI = new QGSettings(styleID);
90+
91+
stylelist << STYLE_NAME_KEY_DARK << STYLE_NAME_KEY_BLACK; //<<STYLE_NAME_KEY_DEFAULT;
92+
93+
if(stylelist.contains(styleUKUI->get(STYLE_NAME).toString())){
94+
ui->teamLabel->setText(tr("Service & Support: ") +
95+
"<a href=\"mailto://[email protected]\""
96+
"style=\"color:white\">"
97+
98+
}else{
99+
ui->teamLabel->setText(tr("Service & Support: ") +
100+
"<a href=\"mailto://[email protected]\""
101+
"style=\"color:black\">"
102+
103+
}
104+
105+
connect(styleUKUI, &QGSettings::changed, this, [=] (const QString &key){
106+
if(key==STYLE_NAME){
107+
if(stylelist.contains(styleUKUI->get(STYLE_NAME).toString())){
108+
ui->teamLabel->setText(tr("Service & Support: ") +
109+
"<a href=\"mailto://[email protected]\""
110+
"style=\"color:white\">"
111+
112+
}else{
113+
ui->teamLabel->setText(tr("Service & Support: ") +
114+
"<a href=\"mailto://[email protected]\""
115+
"style=\"color:black\">"
116+
117+
}
118+
}
119+
});
120+
121+
if(styleUKUI->get(SYSTEM_FONT_EKY).toInt()){
122+
const int size = styleUKUI->get(SYSTEM_FONT_EKY).toInt();
123+
QFont dateFont;
124+
dateFont.setPointSize(size * 1.3);
125+
ui->appnameLabel->setFont(dateFont);
126+
}
127+
128+
connect(styleUKUI, &QGSettings::changed, this, [=](const QString &key){
129+
if(key == "systemFontSize"){
130+
const int size = styleUKUI->get(SYSTEM_FONT_EKY).toInt();
131+
QFont dateFont;
132+
dateFont.setPointSize(size * 1.3);
133+
ui->appnameLabel->setFont(dateFont);
134+
}
135+
});
136+
}
137+
}

Diff for: src/plugins/ukui-notebook/about.h

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class About : public QDialog
2424

2525
private:
2626
Ui::About *ui;
27+
28+
void listenToGsettings();
2729
};
2830

2931
#endif // ABOUT_H

Diff for: src/plugins/ukui-notebook/about.ui

+65-13
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<number>0</number>
4040
</property>
4141
<property name="bottomMargin">
42-
<number>40</number>
42+
<number>0</number>
4343
</property>
4444
<item>
4545
<layout class="QHBoxLayout" name="horizontalLayout_3">
@@ -159,13 +159,25 @@
159159
<item>
160160
<layout class="QVBoxLayout" name="verticalLayout">
161161
<property name="spacing">
162-
<number>12</number>
162+
<number>0</number>
163163
</property>
164164
<property name="topMargin">
165165
<number>0</number>
166166
</property>
167167
<item>
168168
<widget class="QLabel" name="appnameLabel">
169+
<property name="minimumSize">
170+
<size>
171+
<width>0</width>
172+
<height>36</height>
173+
</size>
174+
</property>
175+
<property name="maximumSize">
176+
<size>
177+
<width>16777215</width>
178+
<height>36</height>
179+
</size>
180+
</property>
169181
<property name="text">
170182
<string/>
171183
</property>
@@ -176,6 +188,18 @@
176188
</item>
177189
<item>
178190
<widget class="QLabel" name="versionLabel">
191+
<property name="minimumSize">
192+
<size>
193+
<width>0</width>
194+
<height>36</height>
195+
</size>
196+
</property>
197+
<property name="maximumSize">
198+
<size>
199+
<width>16777215</width>
200+
<height>36</height>
201+
</size>
202+
</property>
179203
<property name="text">
180204
<string/>
181205
</property>
@@ -191,29 +215,57 @@
191215
<item>
192216
<layout class="QVBoxLayout" name="verticalLayout_3">
193217
<property name="spacing">
194-
<number>24</number>
218+
<number>0</number>
195219
</property>
196220
<property name="leftMargin">
197221
<number>32</number>
198222
</property>
199-
<property name="topMargin">
200-
<number>12</number>
201-
</property>
202-
<property name="rightMargin">
203-
<number>32</number>
204-
</property>
205223
<item>
206224
<widget class="QLabel" name="introduceLabel">
225+
<property name="minimumSize">
226+
<size>
227+
<width>356</width>
228+
<height>0</height>
229+
</size>
230+
</property>
231+
<property name="maximumSize">
232+
<size>
233+
<width>356</width>
234+
<height>16777215</height>
235+
</size>
236+
</property>
207237
<property name="text">
208238
<string/>
209239
</property>
210-
<property name="alignment">
211-
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
212-
</property>
213240
</widget>
214241
</item>
242+
<item>
243+
<spacer name="verticalSpacer">
244+
<property name="orientation">
245+
<enum>Qt::Vertical</enum>
246+
</property>
247+
<property name="sizeHint" stdset="0">
248+
<size>
249+
<width>20</width>
250+
<height>40</height>
251+
</size>
252+
</property>
253+
</spacer>
254+
</item>
215255
<item>
216256
<widget class="QLabel" name="teamLabel">
257+
<property name="minimumSize">
258+
<size>
259+
<width>0</width>
260+
<height>36</height>
261+
</size>
262+
</property>
263+
<property name="maximumSize">
264+
<size>
265+
<width>16777215</width>
266+
<height>36</height>
267+
</size>
268+
</property>
217269
<property name="text">
218270
<string/>
219271
</property>
@@ -222,7 +274,7 @@
222274
</layout>
223275
</item>
224276
<item>
225-
<spacer name="verticalSpacer">
277+
<spacer name="verticalSpacer_2">
226278
<property name="orientation">
227279
<enum>Qt::Vertical</enum>
228280
</property>

0 commit comments

Comments
 (0)