878 lines
33 KiB
Diff
878 lines
33 KiB
Diff
From a7e4e6a9dc65a51c2027f0fe2ca5d09acaf352a9 Mon Sep 17 00:00:00 2001
|
|
From: pei-jiankang <root@localhost.localdomain>
|
|
Date: Tue, 21 Dec 2021 19:19:57 +0800
|
|
Subject: [PATCH] Fix the segmentfault without org.ukui.style
|
|
|
|
---
|
|
src/cpuballwidget.cpp | 32 +++-------------
|
|
src/cpuratewidget.cpp | 32 ++++------------
|
|
src/filesystemlistitem.cpp | 3 ++
|
|
src/filesystemlistwidget.cpp | 9 +++--
|
|
src/monitortitlewidget.cpp | 27 +++-----------
|
|
src/netcatogoryshow.cpp | 10 +++--
|
|
src/networkflow.cpp | 10 ++---
|
|
src/networkindicator.cpp | 10 +++--
|
|
src/processlistitem.cpp | 11 +++---
|
|
src/processlistwidget.cpp | 23 +++++++-----
|
|
src/resourcesindicator.cpp | 15 +++-----
|
|
src/src.pro | 10 ++---
|
|
src/systemmonitor.cpp | 5 +++
|
|
widgets/mysearchedit.cpp | 70 +++--------------------------------
|
|
widgets/myunderlinebutton.cpp | 27 ++++----------
|
|
15 files changed, 91 insertions(+), 203 deletions(-)
|
|
|
|
diff --git a/src/cpuballwidget.cpp b/src/cpuballwidget.cpp
|
|
index 2901a5c..6e3ff7c 100755
|
|
--- a/src/cpuballwidget.cpp
|
|
+++ b/src/cpuballwidget.cpp
|
|
@@ -34,6 +34,7 @@ qreal gradientDistance(qreal x)
|
|
}
|
|
|
|
CpuBallWidget::CpuBallWidget(QWidget *parent) : QWidget(parent)
|
|
+ , qtSettings(nullptr)
|
|
{
|
|
const QByteArray idd(THEME_QT_SCHEMA);
|
|
|
|
@@ -92,16 +93,16 @@ CpuBallWidget::~CpuBallWidget()
|
|
|
|
void CpuBallWidget::initThemeMode()
|
|
{
|
|
+ if (!qtSettings) {
|
|
+// qWarning() << "Failed to load the gsettings: " << THEME_QT_SCHEMA;
|
|
+ return;
|
|
+ }
|
|
//监听主题改变
|
|
connect(qtSettings, &QGSettings::changed, this, [=](const QString &key)
|
|
{
|
|
if (key == "styleName")
|
|
{
|
|
-// auto style = qtSettings->get(key).toString();
|
|
-// qApp->setStyle(new InternalStyle(style));
|
|
currentThemeMode = qtSettings->get(MODE_QT_KEY).toString();
|
|
- qDebug()<<"监听主题改变-------------------->"<<currentThemeMode<<endl;
|
|
-// qApp->setStyle(new InternalStyle(currentThemeMode));
|
|
repaint();
|
|
}
|
|
});
|
|
@@ -113,34 +114,19 @@ void CpuBallWidget::loadWaveImage()
|
|
QImageReader frontReader(m_frontImagePath);
|
|
int w = frontReader.size().width();
|
|
int h = frontReader.size().height();
|
|
-// w = w * this->width() / 100;
|
|
-// h = h * this->height() / 100;
|
|
QImage image(w, h, QImage::Format_ARGB32_Premultiplied);//QImage::Format_ARGB32
|
|
image.fill(Qt::transparent); //Qt::transparent
|
|
image.load(m_frontImagePath);
|
|
- /*QPainter painter(&image);
|
|
-// painter.setCompositionMode(QPainter::CompositionMode_Source);
|
|
-// painter.fillRect(image.rect(), Qt::transparent);
|
|
-// painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
|
- painter.drawImage(QPoint(0,0), image);
|
|
- painter.end();*/
|
|
m_frontImage = image;
|
|
|
|
QImageReader backReader(m_backimagePath);
|
|
w = backReader.size().width();
|
|
h = backReader.size().height();
|
|
-// w = w * this->width() / 100;
|
|
-// h = h * this->height() / 100;
|
|
+
|
|
QImage backImage(w, h, QImage::Format_ARGB32_Premultiplied);//QImage::Format_ARGB32
|
|
backImage = backImage.scaled(QSize(w, h), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
|
backImage.fill(Qt::transparent);
|
|
backImage.load(m_backimagePath);
|
|
- /*QPainter backPainter(&backImage);
|
|
-// backPainter.setCompositionMode(QPainter::CompositionMode_Source);
|
|
-// backPainter.fillRect(image.rect(), Qt::transparent);
|
|
-// backPainter.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
|
- backPainter.drawImage(QPoint(0,0), backImage);
|
|
- backPainter.end();*/
|
|
m_backImage = backImage;
|
|
}
|
|
|
|
@@ -161,7 +147,6 @@ void CpuBallWidget::onRepaintWaveImage()
|
|
} else {
|
|
m_waveTimer->stop();
|
|
}
|
|
-// this->update();//this->repaint();
|
|
}
|
|
|
|
//value:0 ~ 100
|
|
@@ -214,13 +199,9 @@ void CpuBallWidget::paintEvent(QPaintEvent *)
|
|
} else if (currentPercent > 55) {
|
|
m_shadowEffect->setColor(QColor(255, 193, 37));//黄
|
|
} else {
|
|
-// m_shadowEffect->setColor(QColor(232, 232, 232, 127));//灰 the last parameters stands for the degree of the background
|
|
-// m_shadowEffect->setColor(QColor(204,0,255,50));
|
|
m_shadowEffect->setColor(QColor(255,255,255,255));
|
|
-// m_shadowEffect->setColor(palette().color(QPalette::Base));
|
|
}
|
|
wavePainter.fillRect(waveRectImage.rect(), QColor(255, 255, 255, 50));
|
|
-// wavePainter.fillRect(waveRectImage.rect(),palette().color("QPalette::Base)");
|
|
|
|
//Step2:波浪区域
|
|
//CompositionMode_SourceOver保证波浪出现的时候其背景为通明的
|
|
@@ -248,7 +229,6 @@ void CpuBallWidget::paintEvent(QPaintEvent *)
|
|
QFont font = wavePainter.font();
|
|
font.setPixelSize(40);//waveSize.height() * 20 / this->height()
|
|
wavePainter.setFont(font);
|
|
-// wavePainter.setPen(Qt::white);
|
|
wavePainter.setPen(QPen(palette().color(QPalette::WindowText)));
|
|
wavePainter.drawText(QRect(rect.x(), rect.y() + rect.height()*2/3, rect.width(), rect.height()/3), Qt::AlignHCenter, m_progressText);
|
|
wavePainter.end();
|
|
diff --git a/src/cpuratewidget.cpp b/src/cpuratewidget.cpp
|
|
index 4cdf485..cace1ae 100755
|
|
--- a/src/cpuratewidget.cpp
|
|
+++ b/src/cpuratewidget.cpp
|
|
@@ -204,6 +204,7 @@ inline void readFile(const QString &fileName)
|
|
}
|
|
|
|
CpuRateWidget::CpuRateWidget(QWidget *parent) : QWidget(parent)
|
|
+, qtSettings(nullptr)
|
|
{
|
|
const QByteArray idd(THEME_QT_SCHEMA);
|
|
if(QGSettings::isSchemaInstalled(idd))
|
|
@@ -225,40 +226,23 @@ CpuRateWidget::CpuRateWidget(QWidget *parent) : QWidget(parent)
|
|
initThemeMode();
|
|
|
|
m_cpuBall->startTimer();
|
|
-
|
|
- /*unsigned long runtime;
|
|
- unsigned long idletime;
|
|
- QString rate = getIdelRate(runtime, idletime);
|
|
- qDebug() << "rate="<<rate;
|
|
- qDebug() << convertTimeToString(runtime);
|
|
- qDebug() << convertTimeToString(idletime);*/
|
|
-
|
|
-
|
|
- /*sudo dmidecode -t processor
|
|
- u32 len;
|
|
- u8 *buf;
|
|
- size_t size = len;
|
|
- buf = read_file(&size, devmem);
|
|
- len = size;
|
|
-// dmi_table_decode(buf, len, num, ver, flags);
|
|
-// dmi_decode(&h, ver);*/
|
|
}
|
|
|
|
void CpuRateWidget::initThemeMode()
|
|
{
|
|
+ if (!qtSettings) {
|
|
+// qWarning() << "Failed to load the gsettings: " << THEME_QT_SCHEMA;
|
|
+ return;
|
|
+ }
|
|
+
|
|
//监听主题改变
|
|
connect(qtSettings, &QGSettings::changed, this, [=](const QString &key)
|
|
{
|
|
-
|
|
if (key == "styleName")
|
|
{
|
|
-// auto style = qtSettings->get(key).toString();
|
|
-// qApp->setStyle(new InternalStyle(style));
|
|
currentThemeMode = qtSettings->get(MODE_QT_KEY).toString();
|
|
- qDebug()<<"监听主题改变-------------------->"<<currentThemeMode<<endl;
|
|
-// qApp->setStyle(new InternalStyle(currentThemeMode));
|
|
- //repaint();
|
|
- if(currentThemeMode == "ukui-light" || currentThemeMode == "ukui-default" || currentThemeMode =="ukui-white")
|
|
+
|
|
+ if(currentThemeMode == "ukui-light" || currentThemeMode == "ukui-default" || currentThemeMode =="ukui-white")
|
|
{
|
|
m_cpuRateTitle->setStyleSheet("QLabel{background:transparent;font-size:12px;color:rgba(0,0,0,0.57);}"); //#999999
|
|
m_cpuIdleRateTitle->setStyleSheet("QLabel{background:transparent;font-size:12px;color:rgba(0,0,0,0.57);}");
|
|
diff --git a/src/filesystemlistitem.cpp b/src/filesystemlistitem.cpp
|
|
index 72d4193..d6ee7f3 100755
|
|
--- a/src/filesystemlistitem.cpp
|
|
+++ b/src/filesystemlistitem.cpp
|
|
@@ -32,6 +32,7 @@
|
|
|
|
FileSystemListItem::FileSystemListItem(FileSystemData *info)
|
|
:fontSettings(nullptr)
|
|
+ ,qtSettings(nullptr)
|
|
{
|
|
m_data = info;
|
|
iconSize = 20;
|
|
@@ -69,8 +70,10 @@ FileSystemListItem::~FileSystemListItem()
|
|
void FileSystemListItem::initThemeMode()
|
|
{
|
|
if (!qtSettings) {
|
|
+// qWarning() << "Failed to load the gsettings: " << THEME_QT_SCHEMA;
|
|
return;
|
|
}
|
|
+
|
|
//监听主题改变
|
|
connect(qtSettings, &QGSettings::changed, this, [=](const QString &key)
|
|
{
|
|
diff --git a/src/filesystemlistwidget.cpp b/src/filesystemlistwidget.cpp
|
|
index 45eb7ea..3deb69e 100755
|
|
--- a/src/filesystemlistwidget.cpp
|
|
+++ b/src/filesystemlistwidget.cpp
|
|
@@ -44,6 +44,7 @@ FileSystemListWidget::FileSystemListWidget(QList<bool> toBeDisplayedColumns, QWi
|
|
,m_mouseAtScrollArea(false)
|
|
,m_mouseDragScrollbar(false)
|
|
,fontSettings(nullptr)
|
|
+ ,qtSettings(nullptr)
|
|
{
|
|
const QByteArray idd(THEME_QT_SCHEMA);
|
|
|
|
@@ -124,17 +125,17 @@ void FileSystemListWidget::clearItems()
|
|
|
|
void FileSystemListWidget::initThemeMode()
|
|
{
|
|
+ if (!qtSettings) {
|
|
+// qWarning() << "Failed to load the gsettings: " << THEME_QT_SCHEMA;
|
|
+ return;
|
|
+ }
|
|
//监听主题改变
|
|
connect(qtSettings, &QGSettings::changed, this, [=](const QString &key)
|
|
{
|
|
|
|
if (key == "styleName")
|
|
{
|
|
-// auto style = qtSettings->get(key).toString();
|
|
-// qApp->setStyle(new InternalStyle(style));
|
|
currentThemeMode = qtSettings->get(MODE_QT_KEY).toString();
|
|
- qDebug()<<"监听主题改变-------------------->"<<currentThemeMode<<endl;
|
|
-// qApp->setStyle(new InternalStyle(currentThemeMode));
|
|
repaint();
|
|
}
|
|
});
|
|
diff --git a/src/monitortitlewidget.cpp b/src/monitortitlewidget.cpp
|
|
index 9fbcf5f..f81f636 100755
|
|
--- a/src/monitortitlewidget.cpp
|
|
+++ b/src/monitortitlewidget.cpp
|
|
@@ -43,6 +43,7 @@ MonitorTitleWidget::MonitorTitleWidget(QSettings *settings, QWidget *parent)
|
|
:QFrame(parent)
|
|
,proSettings(settings)
|
|
,fontSettings(nullptr)
|
|
+ ,qtSettings(nullptr)
|
|
{
|
|
whichBox = new QList<int>();
|
|
const QByteArray idd(THEME_QT_SCHEMA);
|
|
@@ -81,32 +82,12 @@ MonitorTitleWidget::MonitorTitleWidget(QSettings *settings, QWidget *parent)
|
|
|
|
initThemeMode();
|
|
|
|
- this->setWindowFlags(Qt::FramelessWindowHint);//this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint | Qt::WindowCloseButtonHint);
|
|
-// this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint);//Attention: Qt::WindowCloseButtonHint make showMinimized() valid
|
|
+ this->setWindowFlags(Qt::FramelessWindowHint);
|
|
|
|
installEventFilter(this);
|
|
-// setMouseTracking(true);
|
|
setFixedHeight(MONITOR_TITLE_WIDGET_HEIGHT);
|
|
|
|
this->setAutoFillBackground(true);
|
|
-// this->setAttribute(Qt::WA_TranslucentBackground);
|
|
-
|
|
-// QPalette palette;
|
|
-// palette.setColor(QPalette::Background, QColor("#0d87ca"));
|
|
-// this->setPalette(palette);
|
|
-// this->setStyleSheet("QFrame{background:transparent;background-color:#0d87ca;border-radius:5px;border:1px solid red;}");
|
|
-// this->setStyleSheet("QFrame {padding: 5px 0;} QFrame:hover {background-color: rgba(255, 245, 250, 0.1);border-radius: 5px;}");
|
|
-
|
|
-// if(currentThemeMode == "ukui-white")
|
|
-// {
|
|
-// this->setObjectName("MonitorTitle");
|
|
-// this->setStyleSheet("QFrame#MonitorTitle{background:rgba(255,255,255,0.9);border-top-left-radius:6px;border-top-right-radius:6px;color: palette(windowText);}");
|
|
-// }
|
|
-// else
|
|
-// {
|
|
-// this->setObjectName("MonitorTitle");
|
|
-// this->setStyleSheet("QFrame#MonitorTitle{background:rgba(13,14,14,0.9);border-top-left-radius:6px;border-top-right-radius:6px;color: palette(windowText);}");
|
|
-// }
|
|
|
|
m_searchTimer = new QTimer(this);
|
|
m_searchTimer->setSingleShot(true);
|
|
@@ -118,6 +99,10 @@ MonitorTitleWidget::MonitorTitleWidget(QSettings *settings, QWidget *parent)
|
|
|
|
void MonitorTitleWidget::initThemeMode()
|
|
{
|
|
+ if (!qtSettings) {
|
|
+// qWarning() << "Failed to load the gsettings: " << THEME_QT_SCHEMA;
|
|
+ return;
|
|
+ }
|
|
//监听主题改变
|
|
connect(qtSettings, &QGSettings::changed, this, [=](const QString &key)
|
|
{
|
|
diff --git a/src/netcatogoryshow.cpp b/src/netcatogoryshow.cpp
|
|
index db59352..bbf22a1 100755
|
|
--- a/src/netcatogoryshow.cpp
|
|
+++ b/src/netcatogoryshow.cpp
|
|
@@ -35,6 +35,7 @@ NetCatogoryShow::NetCatogoryShow(QWidget *parent)
|
|
,m_rectTotalHeight(38)
|
|
,m_rectTotalWidth(58)
|
|
,m_outsideBorderColor(Qt::transparent)
|
|
+ ,qtSettings(nullptr)
|
|
{
|
|
|
|
const QByteArray idd(THEME_QT_SCHEMA);
|
|
@@ -66,16 +67,17 @@ NetCatogoryShow::NetCatogoryShow(QWidget *parent)
|
|
|
|
void NetCatogoryShow::initThemeMode()
|
|
{
|
|
+ if (!qtSettings) {
|
|
+// qWarning() << "Failed to load the gsettings: " << THEME_QT_SCHEMA;
|
|
+ return;
|
|
+ }
|
|
+
|
|
//监听主题改变
|
|
connect(qtSettings, &QGSettings::changed, this, [=](const QString &key)
|
|
{
|
|
if (key == "styleName")
|
|
{
|
|
-// auto style = qtSettings->get(key).toString();
|
|
-// qApp->setStyle(new InternalStyle(style));
|
|
currentThemeMode = qtSettings->get(MODE_QT_KEY).toString();
|
|
-// qDebug()<<"监听主题改变-------------------->"<<currentThemeMode<<endl;
|
|
-// qApp->setStyle(new InternalStyle(currentThemeMode));
|
|
updateBgColor();
|
|
repaint();
|
|
}
|
|
diff --git a/src/networkflow.cpp b/src/networkflow.cpp
|
|
index ecac95b..c139395 100755
|
|
--- a/src/networkflow.cpp
|
|
+++ b/src/networkflow.cpp
|
|
@@ -105,6 +105,7 @@ NetworkFlow::NetworkFlow(QWidget *parent) : QWidget(parent)
|
|
,m_outsideBorderColor(QColor("transparent"))
|
|
,m_downloadColor(QColor("#009944"))
|
|
,m_uploadColor(QColor("#e60012"))
|
|
+ ,qtSettings(nullptr)
|
|
{
|
|
|
|
const QByteArray idd(THEME_QT_SCHEMA);
|
|
@@ -146,20 +147,19 @@ NetworkFlow::NetworkFlow(QWidget *parent) : QWidget(parent)
|
|
|
|
void NetworkFlow::initThemeMode()
|
|
{
|
|
+ if (!qtSettings) {
|
|
+// qWarning() << "Failed to load the gsettings: " << THEME_QT_SCHEMA;
|
|
+ return;
|
|
+ }
|
|
|
|
//监听主题改变
|
|
connect(qtSettings, &QGSettings::changed, this, [=](const QString &key)
|
|
{
|
|
if (key == "styleName")
|
|
{
|
|
-// auto style = qtSettings->get(key).toString();
|
|
-// qApp->setStyle(new InternalStyle(style));
|
|
currentThemeMode = qtSettings->get(MODE_QT_KEY).toString();
|
|
- qDebug()<<"监听主题改变-------------------->"<<currentThemeMode<<endl;
|
|
-// qApp->setStyle(new InternalStyle(currentThemeMode));
|
|
}
|
|
repaint();
|
|
-// update();
|
|
});
|
|
currentThemeMode = qtSettings->get(MODE_QT_KEY).toString();
|
|
}
|
|
diff --git a/src/networkindicator.cpp b/src/networkindicator.cpp
|
|
index eb4c4f6..af12711 100755
|
|
--- a/src/networkindicator.cpp
|
|
+++ b/src/networkindicator.cpp
|
|
@@ -100,6 +100,7 @@ NetworkIndicator::NetworkIndicator(QWidget *parent)
|
|
,m_rectTotalHeight(38)
|
|
,m_rectTotalWidth(58)
|
|
,m_outsideBorderColor(Qt::transparent)
|
|
+ ,qtSettings(nullptr)
|
|
{
|
|
const QByteArray idd(THEME_QT_SCHEMA);
|
|
|
|
@@ -198,16 +199,17 @@ void NetworkIndicator::initWidgets()
|
|
|
|
void NetworkIndicator::initThemeMode()
|
|
{
|
|
+ if (!qtSettings) {
|
|
+// qWarning() << "Failed to load the gsettings: " << THEME_QT_SCHEMA;
|
|
+ return;
|
|
+ }
|
|
+
|
|
//监听主题改变
|
|
connect(qtSettings, &QGSettings::changed, this, [=](const QString &key)
|
|
{
|
|
if (key == "styleName")
|
|
{
|
|
-// auto style = qtSettings->get(key).toString();
|
|
-// qApp->setStyle(new InternalStyle(style));
|
|
currentThemeMode = qtSettings->get(MODE_QT_KEY).toString();
|
|
- qDebug()<<"监听主题改变-------------------->"<<currentThemeMode<<endl;
|
|
-// qApp->setStyle(new InternalStyle(currentThemeMode));
|
|
repaint();
|
|
updateBgColor();
|
|
}
|
|
diff --git a/src/processlistitem.cpp b/src/processlistitem.cpp
|
|
index b3b512e..d976771 100755
|
|
--- a/src/processlistitem.cpp
|
|
+++ b/src/processlistitem.cpp
|
|
@@ -49,7 +49,7 @@ ProcessListItem::ProcessListItem(ProcData info)
|
|
iconSize = 20;
|
|
padding = 14;
|
|
textPadding = 10;
|
|
- //initThemeMode();
|
|
+ initThemeMode();
|
|
}
|
|
|
|
ProcessListItem::~ProcessListItem()
|
|
@@ -66,6 +66,7 @@ ProcessListItem::~ProcessListItem()
|
|
void ProcessListItem::initThemeMode()
|
|
{
|
|
if (!qtSettings) {
|
|
+// qWarning() << "Failed to load the gsettings: " << THEME_QT_SCHEMA;
|
|
return;
|
|
}
|
|
//监听主题改变
|
|
@@ -124,12 +125,12 @@ void ProcessListItem::drawBackground(QRect rect, QPainter *painter, int index, b
|
|
if(currentThemeMode == "ukui-light" || currentThemeMode == "ukui-default" || currentThemeMode == "ukui-white")
|
|
{
|
|
painter->fillPath(path, QColor("#ffffff"));
|
|
- }
|
|
-
|
|
- if(currentThemeMode == "ukui-dark" || currentThemeMode == "ukui-black")
|
|
+ } else if (currentThemeMode == "ukui-dark" || currentThemeMode == "ukui-black")
|
|
{
|
|
painter->fillPath(path,QColor("#131414"));
|
|
- }
|
|
+ } else {
|
|
+ painter->fillPath(path, QColor("000000"));
|
|
+ }
|
|
}
|
|
}
|
|
|
|
diff --git a/src/processlistwidget.cpp b/src/processlistwidget.cpp
|
|
index c2001ae..1260c89 100755
|
|
--- a/src/processlistwidget.cpp
|
|
+++ b/src/processlistwidget.cpp
|
|
@@ -51,6 +51,8 @@ ProcessListWidget::ProcessListWidget(QList<bool> toBeDisplayedColumns, QWidget *
|
|
,m_titlePressColumn(-1)
|
|
,m_mouseAtScrollArea(false)
|
|
,m_mouseDragScrollbar(false)
|
|
+ ,fontSettings(nullptr)
|
|
+ ,qtSettings(nullptr)
|
|
{
|
|
|
|
const QByteArray idd(THEME_QT_SCHEMA);
|
|
@@ -116,17 +118,17 @@ ProcessListWidget::ProcessListWidget(QList<bool> toBeDisplayedColumns, QWidget *
|
|
|
|
void ProcessListWidget::initThemeMode()
|
|
{
|
|
+ if (!qtSettings) {
|
|
+// qWarning() << "Failed to load the gsettings: " << THEME_QT_SCHEMA;
|
|
+ return;
|
|
+ }
|
|
//监听主题改变
|
|
connect(qtSettings, &QGSettings::changed, this, [=](const QString &key)
|
|
{
|
|
|
|
if (key == "styleName")
|
|
{
|
|
-// auto style = qtSettings->get(key).toString();
|
|
-// qApp->setStyle(new InternalStyle(style));
|
|
currentThemeMode = qtSettings->get(MODE_QT_KEY).toString();
|
|
- qDebug()<<"监听主题改变-------------------->"<<currentThemeMode<<endl;
|
|
-// qApp->setStyle(new InternalStyle(currentThemeMode));
|
|
repaint();
|
|
}
|
|
});
|
|
@@ -135,6 +137,10 @@ void ProcessListWidget::initThemeMode()
|
|
|
|
void ProcessListWidget::initFontSize()
|
|
{
|
|
+ if (!fontSettings) {
|
|
+ fontSize = DEFAULT_FONT_SIZE;
|
|
+ return;
|
|
+ }
|
|
connect(fontSettings,&QGSettings::changed,[=](QString key)
|
|
{
|
|
if("systemFont" == key || "systemFontSize" == key)
|
|
@@ -839,11 +845,9 @@ void ProcessListWidget::paintEvent(QPaintEvent *)
|
|
{
|
|
if(counter == 0 || counter == 5)
|
|
{
|
|
- qDebug()<<"m_currentSortIndex------"<<m_currentSortIndex;
|
|
painter.setOpacity(1);
|
|
if (this->m_isSort)
|
|
{
|
|
- qDebug()<<"m_isSort----------"<<m_isSort;
|
|
painter.drawPixmap(QPoint(rect().x() + posX + 100, rect().y() + 20), m_downArrowPixmap);
|
|
}
|
|
else
|
|
@@ -853,11 +857,9 @@ void ProcessListWidget::paintEvent(QPaintEvent *)
|
|
}
|
|
else
|
|
{
|
|
- qDebug()<<"m_currentSortIndex------"<<m_currentSortIndex;
|
|
painter.setOpacity(1);
|
|
if (this->m_isSort)
|
|
{
|
|
- qDebug()<<"m_isSort----------"<<m_isSort;
|
|
painter.drawPixmap(QPoint(rect().x() + posX + 60, rect().y() + 20), m_downArrowPixmap);
|
|
}
|
|
else
|
|
@@ -877,10 +879,11 @@ void ProcessListWidget::paintEvent(QPaintEvent *)
|
|
{
|
|
painter.setPen(QPen(QColor("#000000")));
|
|
}
|
|
-
|
|
- if(currentThemeMode == "ukui-dark" || currentThemeMode == "ukui-black")
|
|
+ else if(currentThemeMode == "ukui-dark" || currentThemeMode == "ukui-black")
|
|
{
|
|
painter.setPen(QPen(QColor("#ffffff")));
|
|
+ } else {
|
|
+ painter.setPen(QPen(QColor("#000000")));
|
|
}
|
|
|
|
|
|
diff --git a/src/resourcesindicator.cpp b/src/resourcesindicator.cpp
|
|
index ca5db76..f04e9ca 100755
|
|
--- a/src/resourcesindicator.cpp
|
|
+++ b/src/resourcesindicator.cpp
|
|
@@ -39,6 +39,7 @@ ResourcesIndicator::ResourcesIndicator(int flag, QWidget *parent)
|
|
,m_rectTotalHeight(38)
|
|
,m_rectTotalWidth(58)
|
|
,m_outsideBorderColor(Qt::transparent)
|
|
+ ,qtSettings(nullptr)
|
|
{
|
|
typeObject = flag;
|
|
const QByteArray idd(THEME_QT_SCHEMA);
|
|
@@ -48,9 +49,6 @@ ResourcesIndicator::ResourcesIndicator(int flag, QWidget *parent)
|
|
qtSettings = new QGSettings(idd);
|
|
}
|
|
|
|
-// m_bgColor = palette().color(QPalette::Base);
|
|
-// m_bgColor = QColor("#000000");
|
|
-
|
|
this->setFixedSize(188, 56);
|
|
|
|
initThemeMode();
|
|
@@ -65,11 +63,9 @@ ResourcesIndicator::ResourcesIndicator(int flag, QWidget *parent)
|
|
}
|
|
|
|
if (flag == 0) {
|
|
-// m_borderColor = palette().color(QPalette::WindowText); //#0973b4
|
|
m_borderColor = QColor(0x09,0x73,0xb4,0xff);
|
|
}
|
|
else if (flag == 1) {
|
|
-// m_borderColor = palette().color(QPalette::WindowText); //QColor("#9528b4")
|
|
m_borderColor = QColor(0x95,0x28,0xb4,0xff);
|
|
}
|
|
else {
|
|
@@ -84,6 +80,10 @@ ResourcesIndicator::~ResourcesIndicator()
|
|
|
|
void ResourcesIndicator::initThemeMode()
|
|
{
|
|
+ if (!qtSettings) {
|
|
+// qWarning() << "Failed to load the gsettings: " << THEME_QT_SCHEMA;
|
|
+ return;
|
|
+ }
|
|
//监听主题改变
|
|
connect(qtSettings, &QGSettings::changed, this, [=](const QString &key)
|
|
{
|
|
@@ -292,16 +292,11 @@ void ResourcesIndicator::paintEvent(QPaintEvent *event)
|
|
// QPainterPath picPath;
|
|
// picPath.addRoundedRect();
|
|
|
|
- qDebug()<<"this->m_rectTotalWidth"<<"----"<<"convertPercent"<<this->m_rectTotalWidth<<"----"<<convertPercent;
|
|
-
|
|
- qDebug()<<this->width()<<"My width my height"<<this->height();
|
|
|
|
if(typeObject == 0)
|
|
{
|
|
painter.setOpacity(0.46);
|
|
painter.setBrush(QColor("#0973b4"));
|
|
-// painter.setOpacity(0.46);
|
|
-// pen.setColor(QColor("#0973b4")); //#fc7416
|
|
}
|
|
|
|
if(typeObject == 1)
|
|
diff --git a/src/src.pro b/src/src.pro
|
|
index d9efd90..83b876f 100755
|
|
--- a/src/src.pro
|
|
+++ b/src/src.pro
|
|
@@ -18,13 +18,12 @@ DESTDIR = ..
|
|
|
|
LIBS += -L/usr/lib/ -lX11 -lpcap -lm
|
|
|
|
-CONFIG += link_pkgconfig \
|
|
- C++11
|
|
+CONFIG += link_pkgconfig \
|
|
+ c++11
|
|
+
|
|
#gio-2.0
|
|
#LIBS +=-lgio-2.0 -lglib-2.0
|
|
|
|
-CONFIG += c++11\
|
|
- link_pkgconfig
|
|
PKGCONFIG += libgtop-2.0 \
|
|
libsystemd \
|
|
gsettings-qt \
|
|
@@ -175,9 +174,6 @@ SOURCES += \
|
|
OTHER_FILES += \
|
|
systemmonitor.json
|
|
|
|
-#RESOURCES += \
|
|
-# img.qrc
|
|
-
|
|
RESOURCES += \
|
|
res.qrc
|
|
|
|
diff --git a/src/systemmonitor.cpp b/src/systemmonitor.cpp
|
|
index 5698e14..e9971d2 100755
|
|
--- a/src/systemmonitor.cpp
|
|
+++ b/src/systemmonitor.cpp
|
|
@@ -109,6 +109,11 @@ SystemMonitor::SystemMonitor(QWidget *parent)
|
|
|
|
void SystemMonitor::initThemeMode()
|
|
{
|
|
+ if (!qtSettings) {
|
|
+// qWarning() << "Failed to load the gsettings: " << THEME_QT_SCHEMA;
|
|
+ return;
|
|
+ }
|
|
+
|
|
//监听主题改变
|
|
connect(qtSettings, &QGSettings::changed, this, [=](const QString &key)
|
|
{
|
|
diff --git a/widgets/mysearchedit.cpp b/widgets/mysearchedit.cpp
|
|
index 75d9fce..366eae1 100755
|
|
--- a/widgets/mysearchedit.cpp
|
|
+++ b/widgets/mysearchedit.cpp
|
|
@@ -32,6 +32,7 @@ MySearchEdit::MySearchEdit(QWidget *parent)
|
|
,m_showCurve(QEasingCurve::OutCubic)
|
|
,m_hideCurve(QEasingCurve::InCubic)
|
|
,fontSettings(nullptr)
|
|
+ ,qtSettings(nullptr)
|
|
{
|
|
const QByteArray idd(THEME_QT_SCHEMA);
|
|
|
|
@@ -53,13 +54,6 @@ MySearchEdit::MySearchEdit(QWidget *parent)
|
|
m_searchBtn->setStyleSheet("QLabel{background-color:transparent;border:none;background-image:url(:/img/search.png);}");
|
|
m_searchBtn->setFixedSize(SEARCHBUTTON, SEARCHBUTTON);
|
|
|
|
-// m_clearBtn = new MyTristateButton;
|
|
-// QPushButton *m_clearBtn = new QPushButton();
|
|
-// QIcon icon(tr(":/img/close.png"));
|
|
-// m_clearBtn->setIcon(icon);
|
|
-// m_clearBtn->setObjectName("ClearIcon");
|
|
-// m_clearBtn->hide();
|
|
-
|
|
m_pClearTextButton = new QPushButton;
|
|
m_pClearTextButton->setFixedSize(19, 21);
|
|
m_pClearTextButton->setIconSize(QSize(19, 19));
|
|
@@ -68,15 +62,9 @@ MySearchEdit::MySearchEdit(QWidget *parent)
|
|
m_edit = new QLineEdit;
|
|
|
|
QIcon ClearTextEditIcon;
|
|
-// ClearTextEditIcon.addFile(":/img/button-close-default-add-background-three.svg");
|
|
-// m_pClearTextButton->setIcon(ClearTextEditIcon);
|
|
- //m_pClearTextButton->setIcon(drawSymbolicColoredPixmap(QPixmap::fromImage(QIcon::fromTheme(":/img/button-close-default-add-background-three.svg").pixmap(24,24).toImage())));
|
|
m_pClearTextButton->setCursor(Qt::ArrowCursor);
|
|
|
|
-
|
|
-
|
|
m_edit->setAttribute(Qt::WA_Hover, true);
|
|
-// m_edit->setStyle(new InternalStyle("ukui-default"));
|
|
m_edit->setTextMargins(8,0,0,0);
|
|
|
|
connect(m_edit, &QLineEdit::textChanged, this, &MySearchEdit::textChageSlots);
|
|
@@ -108,8 +96,6 @@ MySearchEdit::MySearchEdit(QWidget *parent)
|
|
|
|
m_animation = new QPropertyAnimation(m_edit, "minimumWidth");
|
|
|
|
-// m_size = QSize(m_searchBtn->sizeHint().width() + m_edit->sizeHint().width() + m_clearBtn->sizeHint().width() + 6,
|
|
-// qMax(m_searchBtn->sizeHint().height(), m_edit->sizeHint().height()));
|
|
m_edit->setFixedWidth(0);
|
|
m_edit->installEventFilter(this);
|
|
|
|
@@ -130,20 +116,12 @@ MySearchEdit::MySearchEdit(QWidget *parent)
|
|
layout->addWidget(m_pClearTextButton);
|
|
layout->setAlignment(m_pClearTextButton,Qt::AlignCenter);
|
|
layout->addStretch();
|
|
-// layout->addWidget(m_clearBtn);
|
|
-// layout->setAlignment(m_clearBtn, Qt::AlignCenter);
|
|
-
|
|
layout->setSpacing(0);
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
setFocusPolicy(Qt::StrongFocus);
|
|
|
|
-// connect(m_edit, &QLineEdit::textChanged, [this] {m_clearBtn->setVisible(!m_edit->text().isEmpty());});
|
|
connect(m_edit, &QLineEdit::textChanged, this, &MySearchEdit::textChanged, Qt::DirectConnection);
|
|
-// connect(m_clearBtn, SIGNAL(clicked()), this, SLOT(clearAndFocusEdit()));
|
|
-// connect(m_clearBtn, &MyTristateButton::clicked, this, [=] {
|
|
-// this->clearAndFocusEdit();
|
|
-// });
|
|
}
|
|
|
|
|
|
@@ -210,7 +188,6 @@ MySearchEdit::~MySearchEdit()
|
|
delete m_edit;
|
|
delete m_searchBtn;
|
|
delete m_placeHolder;
|
|
-// delete m_clearBtn;
|
|
if(fontSettings)
|
|
{
|
|
delete fontSettings;
|
|
@@ -282,7 +259,6 @@ void MySearchEdit::setEditFocus()
|
|
m_animation->start();
|
|
m_placeHolder->hide();
|
|
m_edit->setFocus();
|
|
- //this->setStyleSheet("QFrame{background-color:rgba(19,19,20,0.2);border:1px solid #CC00FF;border-radius:4px;}");
|
|
}
|
|
|
|
void MySearchEdit::setPlaceHolder(const QString &text)
|
|
@@ -332,50 +308,18 @@ void MySearchEdit::textChageSlots(const QString &text)
|
|
}
|
|
}
|
|
|
|
-//void MySearchEdit::paintEvent(QEvent *event)
|
|
-//{
|
|
-//// QStyleOption opt;
|
|
-//// opt.init(this);
|
|
-//// QPainter p(this);
|
|
-//// p.setBrush(QBrush(QColor(0x19,0x19,0x20,0xFF)));
|
|
-//// p.setPen(Qt::NoPen);
|
|
-//// QPainterPath path;
|
|
-//// opt.rect.adjust(0,0,0,0);
|
|
-//// path.addRoundedRect(opt.rect,6,6);
|
|
-//// p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
|
|
-//// style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
|
-//// p.drawRoundedRect(opt.rect, 6, 6);
|
|
-// QStyleOption opt;
|
|
-// opt.init(this);
|
|
-// QPainter p(this);
|
|
-// p.setBrush(QBrush(QColor(0x19,0x19,0x20,0x19)));
|
|
-// //p.setPen(Qt::NoPen);
|
|
-// QPainterPath path;
|
|
-// //opt.rect.adjust(0,0,0,0);
|
|
-//// path.addRoundRect(opt.rect.topLeft(),6);
|
|
-
|
|
-// path.addPath(path);
|
|
-// path.addRoundedRect(opt.rect,6,6);
|
|
-// p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
|
|
-//// p.drawRoundedRect(opt.rect,6,6);
|
|
-// style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
|
-//// p.setPen(QPen(QColor("#e9eef0"), 0));//边框颜色
|
|
-//// p.setBrush(QColor("#0d87ca"));//背景色
|
|
-//// QRectF r(1, 1, width() - 2, height() - 2);//左边 上边 右边 下边
|
|
-// p.drawPath(path);
|
|
-//}
|
|
-
|
|
void MySearchEdit::initThemeMode()
|
|
{
|
|
+ if (!qtSettings) {
|
|
+// qWarning() << "Failed to load the gsettings: " << THEME_QT_SCHEMA;
|
|
+ return;
|
|
+ }
|
|
+
|
|
//监听主题改变
|
|
connect(qtSettings, &QGSettings::changed, this, [=](const QString &key){
|
|
|
|
if (key == "styleName") {
|
|
-// auto style = qtSettings->get(key).toString();
|
|
-// qApp->setStyle(new InternalStyle(style));
|
|
currentThemeMode = qtSettings->get(MODE_QT_KEY).toString();
|
|
-// qDebug()<<"监听主题改变-------------------->"<<currentThemeMode<<endl;
|
|
-// qApp->setStyle(new InternalStyle(currentThemeMode));
|
|
m_pClearTextButton->setIcon(drawSymbolicColoredPixmap(QPixmap::fromImage(QIcon::fromTheme(":/img/button-close-default-add-background-three.svg").pixmap(24,24).toImage())));
|
|
|
|
if(currentThemeMode == "ukui-light" || currentThemeMode == "ukui-default" || currentThemeMode == "ukui-white")
|
|
@@ -398,8 +342,6 @@ void MySearchEdit::initThemeMode()
|
|
});
|
|
//获取当前主题
|
|
currentThemeMode = qtSettings->get(MODE_QT_KEY).toString();
|
|
-// qDebug()<<"监听主题改变-------------------->"<<currentThemeMode<<endl;
|
|
-// qApp->setStyle(new InternalStyle(currentThemeMode));
|
|
m_pClearTextButton->setIcon(drawSymbolicColoredPixmap(QPixmap::fromImage(QIcon::fromTheme(":/img/button-close-default-add-background-three.svg").pixmap(24,24).toImage())));
|
|
if(currentThemeMode == "ukui-light" || currentThemeMode == "ukui-default" || currentThemeMode == "ukui-white")
|
|
{
|
|
diff --git a/widgets/myunderlinebutton.cpp b/widgets/myunderlinebutton.cpp
|
|
index 548b2cd..3da8549 100755
|
|
--- a/widgets/myunderlinebutton.cpp
|
|
+++ b/widgets/myunderlinebutton.cpp
|
|
@@ -31,6 +31,7 @@ MyUnderLineButton::MyUnderLineButton(QWidget *parent)
|
|
,m_state(Normal)
|
|
,m_isChecked(false)
|
|
,fontSettings(nullptr)
|
|
+ ,qtSettings(nullptr)
|
|
{
|
|
const QByteArray idd(THEME_QT_SCHEMA);
|
|
|
|
@@ -50,27 +51,22 @@ MyUnderLineButton::MyUnderLineButton(QWidget *parent)
|
|
|
|
this->setFixedSize(NORMALWIDTH, NORMALHEIGHT+2);
|
|
m_textLabel = new QLabel;
|
|
-// QFont ftSize;
|
|
-// ftSize.setPointSize(fontSize);
|
|
-// m_textLabel->setFont(ftSize);
|
|
|
|
initThemeMode();
|
|
initFontSize();
|
|
|
|
-// m_underlineLabel = new QLabel;
|
|
-// m_underlineLabel->setFixedSize(52, 2);
|
|
-// m_underlineLabel->setStyleSheet("QLabel{background-color:#ffffff;}");
|
|
-// m_underlineLabel->hide();
|
|
-
|
|
m_layout = new QVBoxLayout(this);
|
|
m_layout->setContentsMargins(0,0,0,0);
|
|
|
|
m_layout->addWidget(m_textLabel, 0, Qt::AlignVCenter| Qt::AlignCenter);
|
|
- //m_layout->addWidget(m_underlineLabel, 0, Qt::AlignBottom | Qt::AlignHCenter);
|
|
}
|
|
|
|
void MyUnderLineButton::initThemeMode()
|
|
{
|
|
+ if (!qtSettings) {
|
|
+// qWarning() << "Failed to load the gsettings: " << THEME_QT_SCHEMA;
|
|
+ return;
|
|
+ }
|
|
|
|
//监听主题改变
|
|
connect(qtSettings, &QGSettings::changed, this, [=](const QString &key)
|
|
@@ -78,12 +74,7 @@ void MyUnderLineButton::initThemeMode()
|
|
|
|
if (key == "styleName")
|
|
{
|
|
-// auto style = qtSettings->get(key).toString();
|
|
-// qApp->setStyle(new InternalStyle(style));
|
|
currentThemeMode = qtSettings->get(MODE_QT_KEY).toString();
|
|
- qDebug()<<"监听主题改变-------------------->"<<currentThemeMode<<endl;
|
|
-// qApp->setStyle(new InternalStyle(currentThemeMode));
|
|
- //repaint();
|
|
if (currentThemeMode == "ukui-light" || currentThemeMode == "ukui-default" || currentThemeMode == "ukui-white")
|
|
{
|
|
m_textLabel->setStyleSheet("QLabel{background-color:transparent;color:rgba(0,0,0,0.57);text-align:center;}"); //ffffff
|
|
@@ -95,8 +86,6 @@ void MyUnderLineButton::initThemeMode()
|
|
m_textLabel->setStyleSheet("QLabel{background-color:transparent;color:rgba(255,255,255,0.57); text-align:center;}"); //ffffff
|
|
}
|
|
}
|
|
-// repaint();
|
|
-// updateStyleSheet();
|
|
});
|
|
currentThemeMode = qtSettings->get(MODE_QT_KEY).toString();
|
|
if (currentThemeMode == "ukui-light" || currentThemeMode == "ukui-default" || currentThemeMode == "ukui-white")
|
|
@@ -227,11 +216,11 @@ void MyUnderLineButton::updateStyleSheet()
|
|
case Normal:
|
|
if(currentThemeMode == "ukui-light" || currentThemeMode == "ukui-default" || currentThemeMode == "ukui-white")
|
|
{
|
|
- m_textLabel->setStyleSheet("QLabel{back-color:transparent;color:rgba(0,0,0,0.57); text-align:center;}");
|
|
+ m_textLabel->setStyleSheet("QLabel{background-color:transparent;color:rgba(0,0,0,0.57); text-align:center;}");
|
|
}
|
|
else
|
|
{
|
|
- m_textLabel->setStyleSheet("QLabel{back-color:transparent;color:rgba(255,255,255,0.57); text-align:center;}");
|
|
+ m_textLabel->setStyleSheet("QLabel{background-color:transparent;color:rgba(255,255,255,0.57); text-align:center;}");
|
|
}
|
|
// case Normal:
|
|
|
|
@@ -244,7 +233,7 @@ void MyUnderLineButton::updateStyleSheet()
|
|
// //m_underlineLabel->hide();
|
|
// break;
|
|
}
|
|
-// ////////////// m_textLabel->setStyleSheet("QLabel{color:white};");
|
|
+// m_textLabel->setStyleSheet("QLabel{color:white};");
|
|
}
|
|
|
|
void MyUnderLineButton::setState(MyUnderLineButton::ButtonState state)
|
|
--
|
|
2.30.0
|
|
|