Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ukui/ukui-sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
liushanwen1997 committed Mar 3, 2021
2 parents 153bff9 + 1ff9997 commit ccc374f
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 19 deletions.
83 changes: 77 additions & 6 deletions src/plugins/ukui-notebook/about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
#include "ui_about.h"
#include "utils/xatom-helper.h"

#include <QGSettings>

#define UKUI_STYLE_SCHEMA "org.ukui.style"
#define STYLE_NAME "styleName"
#define STYLE_NAME_KEY_DARK "ukui-dark"
#define STYLE_NAME_KEY_DEFAULT "ukui-default"
#define STYLE_NAME_KEY_BLACK "ukui-black"
#define STYLE_NAME_KEY_LIGHT "ukui-light"
#define STYLE_NAME_KEY_WHITE "ukui-white"

#define SYSTEM_FONT_EKY "system-font-size"
#define SYSTEM_NAME_KEY "system-font"

extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);

About::About(QWidget *parent) :
Expand All @@ -28,16 +41,16 @@ About::About(QWidget *parent) :
ui->closeBtn->setProperty("isWindowButton", 0x2);
ui->closeBtn->setProperty("useIconHighlightEffect", 0x8);
ui->closeBtn->setFlat(true);

connect(ui->closeBtn, &QPushButton::clicked, this, [=](){
this->close();
});
ui->appnameLabel->setStyleSheet("QLabel{font-size: 18px; color: palette(windowText);}"
"QLabel{font-family: NotoSansCJKsc-Medium, NotoSansCJKsc;}");

ui->versionLabel->setText(tr("Version: 2020.1.0"));
ui->teamLabel->setText(tr("Service & Support: ") +
"<a href=\"mailto://[email protected]\""
"style=\"color: palette(buttonText)\">"
"[email protected]</a>");
// ui->teamLabel->setText(tr("Service & Support: ") +
// "<a href=\"mailto://[email protected]\""
// "style=\"color: palette(buttonText)\">"
// "[email protected]</a>");
ui->appiconLabel->setPixmap(QIcon::fromTheme("kylin-notebook").pixmap(96,96));
ui->appnameLabel->setText(tr("Kylin Memo"));
ui->introduceLabel->setText(tr("Kylin Memo is a self-developed sidebar application plug-in, "
Expand All @@ -49,6 +62,8 @@ About::About(QWidget *parent) :
QDesktopServices::openUrl(QUrl(url));
});
ui->teamLabel->setContextMenuPolicy(Qt::NoContextMenu);

listenToGsettings();
}

About::~About()
Expand All @@ -64,3 +79,59 @@ void About::paintEvent(QPaintEvent *event) {
rectPath.addRect(this->rect());
p.fillPath(rectPath,palette().color(QPalette::Base));
}

void About::listenToGsettings()
{
const QByteArray styleID(UKUI_STYLE_SCHEMA);
QStringList stylelist;

if (QGSettings::isSchemaInstalled(styleID)){
QGSettings *styleUKUI = new QGSettings(styleID);

stylelist << STYLE_NAME_KEY_DARK << STYLE_NAME_KEY_BLACK; //<<STYLE_NAME_KEY_DEFAULT;

if(stylelist.contains(styleUKUI->get(STYLE_NAME).toString())){
ui->teamLabel->setText(tr("Service & Support: ") +
"<a href=\"mailto://[email protected]\""
"style=\"color:white\">"
"[email protected]</a>");
}else{
ui->teamLabel->setText(tr("Service & Support: ") +
"<a href=\"mailto://[email protected]\""
"style=\"color:black\">"
"[email protected]</a>");
}

connect(styleUKUI, &QGSettings::changed, this, [=] (const QString &key){
if(key==STYLE_NAME){
if(stylelist.contains(styleUKUI->get(STYLE_NAME).toString())){
ui->teamLabel->setText(tr("Service & Support: ") +
"<a href=\"mailto://[email protected]\""
"style=\"color:white\">"
"[email protected]</a>");
}else{
ui->teamLabel->setText(tr("Service & Support: ") +
"<a href=\"mailto://[email protected]\""
"style=\"color:black\">"
"[email protected]</a>");
}
}
});

if(styleUKUI->get(SYSTEM_FONT_EKY).toInt()){
const int size = styleUKUI->get(SYSTEM_FONT_EKY).toInt();
QFont dateFont;
dateFont.setPointSize(size * 1.3);
ui->appnameLabel->setFont(dateFont);
}

connect(styleUKUI, &QGSettings::changed, this, [=](const QString &key){
if(key == "systemFontSize"){
const int size = styleUKUI->get(SYSTEM_FONT_EKY).toInt();
QFont dateFont;
dateFont.setPointSize(size * 1.3);
ui->appnameLabel->setFont(dateFont);
}
});
}
}
2 changes: 2 additions & 0 deletions src/plugins/ukui-notebook/about.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class About : public QDialog

private:
Ui::About *ui;

void listenToGsettings();
};

#endif // ABOUT_H
78 changes: 65 additions & 13 deletions src/plugins/ukui-notebook/about.ui
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<number>0</number>
</property>
<property name="bottomMargin">
<number>40</number>
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
Expand Down Expand Up @@ -159,13 +159,25 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>12</number>
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="appnameLabel">
<property name="minimumSize">
<size>
<width>0</width>
<height>36</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>36</height>
</size>
</property>
<property name="text">
<string/>
</property>
Expand All @@ -176,6 +188,18 @@
</item>
<item>
<widget class="QLabel" name="versionLabel">
<property name="minimumSize">
<size>
<width>0</width>
<height>36</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>36</height>
</size>
</property>
<property name="text">
<string/>
</property>
Expand All @@ -191,29 +215,57 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>24</number>
<number>0</number>
</property>
<property name="leftMargin">
<number>32</number>
</property>
<property name="topMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>32</number>
</property>
<item>
<widget class="QLabel" name="introduceLabel">
<property name="minimumSize">
<size>
<width>356</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>356</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="teamLabel">
<property name="minimumSize">
<size>
<width>0</width>
<height>36</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>36</height>
</size>
</property>
<property name="text">
<string/>
</property>
Expand All @@ -222,7 +274,7 @@
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
Expand Down

0 comments on commit ccc374f

Please sign in to comment.