ukui-menu/0007-changelog.patch
2023-05-23 10:46:37 +08:00

600 lines
28 KiB
Diff

From: lixueman <lixueman@kylinos.cn>
Date: Thu, 21 Jul 2022 14:00:38 +0800
Subject: =?utf-8?b?5L+u5pS5Y2hhbmdlbG9n5L+h5oGv?=
---
.../Button/function_classify_button.cpp | 83 +++++++++-------------
.../Button/function_classify_button.h | 3 -
.../Button/letter_classify_button.cpp | 55 ++++++++++----
src/UserInterface/Button/letter_classify_button.h | 2 +-
src/UserInterface/Widget/full_commonuse_widget.cpp | 14 ++--
src/UserInterface/Widget/full_function_widget.cpp | 14 ++--
src/UserInterface/Widget/full_letter_widget.cpp | 16 +++--
.../Widget/full_searchresult_widget.cpp | 14 ++--
.../Widget/function_button_widget.cpp | 6 +-
src/UserInterface/Widget/letter_button_widget.cpp | 6 +-
src/UserInterface/full_mainwindow.cpp | 14 ++--
src/UserInterface/mainwindow.cpp | 35 ++++-----
12 files changed, 146 insertions(+), 116 deletions(-)
diff --git a/src/UserInterface/Button/function_classify_button.cpp b/src/UserInterface/Button/function_classify_button.cpp
index 2494be4..8ddabe1 100755
--- a/src/UserInterface/Button/function_classify_button.cpp
+++ b/src/UserInterface/Button/function_classify_button.cpp
@@ -36,23 +36,11 @@ FunctionClassifyButton::FunctionClassifyButton(int width,
m_iconSize(iconSize),
m_category(category),
m_fullscreen(fullscreen),
- m_enabled(enabled),
- m_iconLabel(new QLabel),
- m_textLabel(new QLabel)
+ m_enabled(enabled)
{
this->setFlat(true);
this->setFixedSize(m_width, m_height);
this->setFocusPolicy(Qt::NoFocus);
- m_iconLabel->setFixedSize(m_iconSize, m_iconSize);
- m_textLabel->adjustSize();
- m_textLabel->setText(m_category);
- m_textLabel->setAlignment(Qt::AlignCenter);
-
- if (m_fullscreen) {
- QPalette pe = m_textLabel->palette();
- pe.setColor(QPalette::ButtonText, Qt::white);
- m_textLabel->setPalette(pe);
- }
if (m_fullscreen) {
updateIconState(Normal);
@@ -67,12 +55,6 @@ FunctionClassifyButton::FunctionClassifyButton(int width,
this->setCheckable(false);
}
- QHBoxLayout *mainlayout = new QHBoxLayout;
- mainlayout->setContentsMargins(0, 0, 0, 0);
- mainlayout->setSpacing(Style::LeftSpaceIconText);
- this->setLayout(mainlayout);
-// mainlayout->addWidget(m_iconLabel);
- mainlayout->addWidget(m_textLabel);
connect(this, &FunctionClassifyButton::toggled, this, &FunctionClassifyButton::reactToToggle);
connect(this, &FunctionClassifyButton::clicked, this, &FunctionClassifyButton::buttonClickedSlot);
}
@@ -115,6 +97,37 @@ void FunctionClassifyButton::paintEvent(QPaintEvent *e)
painter.restore();
}
+ if (!(option.state & QStyle::State_Enabled)) {
+ painter.save();
+ QColor color;
+ if (!m_fullscreen) {
+ if ( g_curStyle == "ukui-light") {
+ color = Qt::black;
+ } else {
+ color = Qt::white;
+ }
+ color.setAlphaF(0.2);
+ }
+ painter.setPen(color);
+ painter.drawText(option.rect, Qt::AlignCenter, m_category);
+ painter.restore();
+ }
+
+ if (option.state & QStyle::State_Enabled) {
+ painter.save();
+ QColor color;
+
+ if ( g_curStyle == "ukui-light") {
+ color = Qt::black;
+ } else {
+ color = Qt::white;
+ }
+ color.setAlphaF(0.9);
+ painter.setPen(color);
+ painter.drawText(option.rect, Qt::AlignCenter, m_category);
+ painter.restore();
+ }
+
if (m_fullscreen && (option.state & QStyle::State_On)) {
painter.save();
painter.setPen(Qt::NoPen);
@@ -265,37 +278,7 @@ void FunctionClassifyButton::updateIconState(const FunctionClassifyButton::State
// }
// pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
// m_iconLabel->setPixmap(pixmap);
- updateTextState(state);
+// updateTextState(state);
}
-void FunctionClassifyButton::updateTextState(const FunctionClassifyButton::State state)
-{
- // QPalette p= m_textLabel->palette();
- switch (state) {
- case Enabled:
- // p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1));
- // m_textLabel->setStyleSheet("background:transparent; color:rgba(255, 255, 255);");
- break;
-
- case Disabled:
- // p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1, 0.25));
- // m_textLabel->setStyleSheet("background:transparent; color:rgba(255, 255, 255, 25%);");
- break;
-
- case Normal:
- // p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1, 0.50));
- // m_textLabel->setStyleSheet("background:transparent; color:rgba(255, 255, 255, 50%);");
- break;
- case Checked:
- // p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1));
- // m_textLabel->setStyleSheet("background:transparent;color:rgba(255, 255, 255);");
- break;
-
- default:
- break;
- }
-
- // p.setColor(QPalette::Window,Qt::transparent);
- // m_textLabel->setPalette(p);
-}
diff --git a/src/UserInterface/Button/function_classify_button.h b/src/UserInterface/Button/function_classify_button.h
index e99f2c3..6160fb9 100755
--- a/src/UserInterface/Button/function_classify_button.h
+++ b/src/UserInterface/Button/function_classify_button.h
@@ -58,8 +58,6 @@ public:
QString m_category;
bool m_fullscreen;
bool m_enabled;
- QLabel *m_iconLabel = nullptr;
- QLabel *m_textLabel = nullptr;
State m_state = Checked;
void updateBtnState();
@@ -70,7 +68,6 @@ protected:
void leaveEvent(QEvent *e);
void paintEvent(QPaintEvent *e);
void updateIconState(const State state);
- void updateTextState(const State state);
Q_SIGNALS:
void buttonClicked();
diff --git a/src/UserInterface/Button/letter_classify_button.cpp b/src/UserInterface/Button/letter_classify_button.cpp
index 5bc882f..624c38e 100755
--- a/src/UserInterface/Button/letter_classify_button.cpp
+++ b/src/UserInterface/Button/letter_classify_button.cpp
@@ -28,17 +28,17 @@ LetterClassifyButton::LetterClassifyButton(QWidget *parent,
m_fullscreen(fullscreen)
{
this->setFlat(true);
-
- if (m_fullscreen) {
- QFont font;
- font.setPixelSize(Style::LeftLetterFontSize);
- this->setFont(font);
- QPalette pe = this->palette();
- pe.setColor(QPalette::ButtonText, Qt::white);
- this->setPalette(pe);
- }
-
- this->setText(letter);
+ m_letter = letter;
+// if (m_fullscreen) {
+// QFont font;
+// font.setPixelSize(Style::LeftLetterFontSize);
+// this->setFont(font);
+// QPalette pe = this->palette();
+// pe.setColor(QPalette::ButtonText, Qt::white);
+// this->setPalette(pe);
+// }
+
+// this->setText(letter);
this->setFocusPolicy(Qt::NoFocus);
this->setCheckable(true);
this->setStyleSheet("padding: 0px;");
@@ -82,6 +82,37 @@ void LetterClassifyButton::paintEvent(QPaintEvent *e)
painter.restore();
}
+ if (!(option.state & QStyle::State_Enabled)) {
+ painter.save();
+ QColor color;
+ if (!m_fullscreen) {
+ if ( g_curStyle == "ukui-light") {
+ color = Qt::black;
+ } else {
+ color = Qt::white;
+ }
+ color.setAlphaF(0.2);
+ }
+ painter.setPen(color);
+ painter.drawText(option.rect, Qt::AlignCenter, m_letter);
+ painter.restore();
+ }
+
+ if (option.state & QStyle::State_Enabled) {
+ painter.save();
+ QColor color;
+
+ if ( g_curStyle == "ukui-light") {
+ color = Qt::black;
+ } else {
+ color = Qt::white;
+ }
+ color.setAlphaF(0.9);
+ painter.setPen(color);
+ painter.drawText(option.rect, Qt::AlignCenter, m_letter);
+ painter.restore();
+ }
+
if (m_fullscreen && (option.state & QStyle::State_On)) {
painter.save();
painter.setPen(Qt::NoPen);
@@ -118,7 +149,7 @@ void LetterClassifyButton::enterEvent(QEvent *e)
// this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2);
tooltip = new LetterToolTip();
QPoint oPoint = this->mapToGlobal(QPoint(this->rect().x() + 35, this->rect().y() - 10));
- tooltip->setText(this->text());
+ tooltip->setText(m_letter);
tooltip->raise();
tooltip->move(oPoint);
tooltip->show();
diff --git a/src/UserInterface/Button/letter_classify_button.h b/src/UserInterface/Button/letter_classify_button.h
index b6b2a3d..7235987 100755
--- a/src/UserInterface/Button/letter_classify_button.h
+++ b/src/UserInterface/Button/letter_classify_button.h
@@ -35,7 +35,7 @@ public:
);
bool is_pressed = false;
-
+ QString m_letter = QString();
private:
bool m_fullscreen = false;
LetterToolTip *tooltip = nullptr;
diff --git a/src/UserInterface/Widget/full_commonuse_widget.cpp b/src/UserInterface/Widget/full_commonuse_widget.cpp
index c02f317..26d86b5 100755
--- a/src/UserInterface/Widget/full_commonuse_widget.cpp
+++ b/src/UserInterface/Widget/full_commonuse_widget.cpp
@@ -119,13 +119,13 @@ void FullCommonUseWidget::initVerticalScrollBar()
m_verticalScrollBar->show();
}
- m_scrollBarStyle = QString("QScrollBar:vertical{width: %2px; background: rgba(12, 12, 12, 1); "
+ m_scrollBarStyle = QString("QScrollBar:vertical{width: %2px; background: rgba(12, 12, 12, %4); "
"margin: 0px,0px,0px,0px; border-radius: %3px;}"
- "QScrollBar::handle:vertical{width: %2px; background: rgba(255, 255, 255, 1);"
+ "QScrollBar::handle:vertical{width: %2px; background: rgba(255, 255, 255, %5);"
"border-radius: %3px; min-height: %1;}"
"QScrollBar::add-line:vertical{ height: 0px; width: 0px; subcontrol-position: bottom;}"
"QScrollBar::sub-line:vertical{ height: 0px; width: 0px; subcontrol-position:top;}").arg(scrollBarSize);
- m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2));
+ m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2).arg(0.25).arg(0.6));
}
void FullCommonUseWidget::on_powerOffButton_clicked()
@@ -219,11 +219,15 @@ bool FullCommonUseWidget::eventFilter(QObject *watched, QEvent *event)
if (watched == m_verticalScrollBar) {
if (event->type() == QEvent::Enter) {
- m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4));
+ m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4).arg(0.25).arg(0.78));
}
if (event->type() == QEvent::Leave) {
- m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2));
+ m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2).arg(0.25).arg(0.6));
+ }
+
+ if(event->type() == QEvent::MouseButtonPress) {
+ m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4).arg(0.25).arg(0.9));
}
}
diff --git a/src/UserInterface/Widget/full_function_widget.cpp b/src/UserInterface/Widget/full_function_widget.cpp
index fd124e4..7cc8464 100755
--- a/src/UserInterface/Widget/full_function_widget.cpp
+++ b/src/UserInterface/Widget/full_function_widget.cpp
@@ -139,13 +139,13 @@ void FullFunctionWidget::initVerticalScrollBar()
m_verticalScrollBar->show();
}
- m_scrollBarStyle = QString("QScrollBar:vertical{width: %2px; background: rgba(12, 12, 12, 1); "
+ m_scrollBarStyle = QString("QScrollBar:vertical{width: %2px; background: rgba(12, 12, 12, %4); "
"margin: 0px,0px,0px,0px; border-radius: %3px;}"
- "QScrollBar::handle:vertical{width: %2px; background: rgba(255, 255, 255, 1);"
+ "QScrollBar::handle:vertical{width: %2px; background: rgba(255, 255, 255, %5);"
"border-radius: %3px; min-height: %1;}"
"QScrollBar::add-line:vertical{ height: 0px; width: 0px; subcontrol-position: bottom;}"
"QScrollBar::sub-line:vertical{ height: 0px; width: 0px; subcontrol-position:top;}").arg(scrollBarSize);
- m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2));
+ m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2).arg(0.25).arg(0.6));
}
void FullFunctionWidget::on_powerOffButton_clicked()
@@ -505,11 +505,15 @@ bool FullFunctionWidget::eventFilter(QObject *watched, QEvent *event)
if (watched == m_verticalScrollBar) {
if (watched == m_verticalScrollBar) {
if (event->type() == QEvent::Enter) {
- m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4));
+ m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4).arg(0.25).arg(0.78));
}
if (event->type() == QEvent::Leave) {
- m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2));
+ m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2).arg(0.25).arg(0.6));
+ }
+
+ if(event->type() == QEvent::MouseButtonPress) {
+ m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4).arg(0.25).arg(0.9));
}
}
} else {
diff --git a/src/UserInterface/Widget/full_letter_widget.cpp b/src/UserInterface/Widget/full_letter_widget.cpp
index 45fb165..1ebc2c5 100755
--- a/src/UserInterface/Widget/full_letter_widget.cpp
+++ b/src/UserInterface/Widget/full_letter_widget.cpp
@@ -133,13 +133,13 @@ void FullLetterWidget::initVerticalScrollBar()
m_verticalScrollBar->show();
}
- m_scrollBarStyle = QString("QScrollBar:vertical{width: %2px; background: rgba(12, 12, 12, 1); "
+ m_scrollBarStyle = QString("QScrollBar:vertical{width: %2px; background: rgba(12, 12, 12, %4); "
"margin: 0px,0px,0px,0px; border-radius: %3px;}"
- "QScrollBar::handle:vertical{width: %2px; background: rgba(255, 255, 255, 1);"
+ "QScrollBar::handle:vertical{width: %2px; background: rgba(255, 255, 255, %5);"
"border-radius: %3px; min-height: %1;}"
"QScrollBar::add-line:vertical{ height: 0px; width: 0px; subcontrol-position: bottom;}"
"QScrollBar::sub-line:vertical{ height: 0px; width: 0px; subcontrol-position:top;}").arg(scrollBarSize);
- m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2));
+ m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2).arg(0.25).arg(0.6));
}
void FullLetterWidget::on_powerOffButton_clicked()
@@ -379,7 +379,7 @@ void FullLetterWidget::btnGroupClickedSlot(QAbstractButton *btn)
if (m_btnGroup->id(btn) == m_buttonList.indexOf(button)) {
letterbtn->setChecked(true);
//此处需实现将被选定的字母包含的应用列表移动到applistWid界面最顶端
- QString letterstr = letterbtn->text();
+ QString letterstr = letterbtn->m_letter;
int num = m_letterList.indexOf(letterstr);
if (num != -1) {
@@ -531,11 +531,15 @@ bool FullLetterWidget::eventFilter(QObject *watched, QEvent *event)
{
if (watched == m_verticalScrollBar) {
if (event->type() == QEvent::Enter) {
- m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4));
+ m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4).arg(0.25).arg(0.78));
}
if (event->type() == QEvent::Leave) {
- m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2));
+ m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2).arg(0.25).arg(0.6));
+ }
+
+ if(event->type() == QEvent::MouseButtonPress) {
+ m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4).arg(0.25).arg(0.9));
}
} else {
if (event->type() == QEvent::KeyPress) {
diff --git a/src/UserInterface/Widget/full_searchresult_widget.cpp b/src/UserInterface/Widget/full_searchresult_widget.cpp
index be5dd6b..efdee49 100755
--- a/src/UserInterface/Widget/full_searchresult_widget.cpp
+++ b/src/UserInterface/Widget/full_searchresult_widget.cpp
@@ -108,13 +108,13 @@ void FullSearchResultWidget::initVerticalScrollBar()
m_verticalScrollBar->show();
}
- m_scrollBarStyle = QString("QScrollBar:vertical{width: %2px; background: rgba(12, 12, 12, 1); "
+ m_scrollBarStyle = QString("QScrollBar:vertical{width: %2px; background: rgba(12, 12, 12, %4); "
"margin: 0px,0px,0px,0px; border-radius: %3px;}"
- "QScrollBar::handle:vertical{width: %2px; background: rgba(255, 255, 255, 1);"
+ "QScrollBar::handle:vertical{width: %2px; background: rgba(255, 255, 255, %5);"
"border-radius: %3px; min-height: %1;}"
"QScrollBar::add-line:vertical{ height: 0px; width: 0px; subcontrol-position: bottom;}"
"QScrollBar::sub-line:vertical{ height: 0px; width: 0px; subcontrol-position:top;}").arg(scrollBarSize);
- m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2));
+ m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2).arg(0.25).arg(0.6));
}
void FullSearchResultWidget::on_powerOffButton_clicked()
@@ -204,11 +204,15 @@ bool FullSearchResultWidget::eventFilter(QObject *watched, QEvent *event)
if (watched == m_verticalScrollBar) {
if (event->type() == QEvent::Enter) {
- m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4));
+ m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4).arg(0.25).arg(0.78));
}
if (event->type() == QEvent::Leave) {
- m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2));
+ m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2).arg(0.25).arg(0.6));
+ }
+
+ if(event->type() == QEvent::MouseButtonPress) {
+ m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4).arg(0.25).arg(0.9));
}
}
diff --git a/src/UserInterface/Widget/function_button_widget.cpp b/src/UserInterface/Widget/function_button_widget.cpp
index cd7b8f8..dbb116c 100755
--- a/src/UserInterface/Widget/function_button_widget.cpp
+++ b/src/UserInterface/Widget/function_button_widget.cpp
@@ -76,7 +76,7 @@ void FunctionButtonWidget::initUi()
Q_FOREACH (QAbstractButton *btn, m_buttonList)
{
FunctionClassifyButton *fbtn = qobject_cast<FunctionClassifyButton *>(btn);
- fbtn->updateIconState();
+ fbtn->updateBtnState();
}
});
}
@@ -88,9 +88,7 @@ void FunctionButtonWidget::initUi()
void FunctionButtonWidget::functionBtnClickedSlot()
{
FunctionClassifyButton *btn = dynamic_cast<FunctionClassifyButton *>(sender());
- QWidget *wid = btn->layout()->itemAt(0)->widget();
- QLabel *label = qobject_cast<QLabel *>(wid);
- Q_EMIT sendFunctionBtnSignal(label->text());
+ Q_EMIT sendFunctionBtnSignal(btn->m_category);
}
void FunctionButtonWidget::hideEvent(QHideEvent *event)
diff --git a/src/UserInterface/Widget/letter_button_widget.cpp b/src/UserInterface/Widget/letter_button_widget.cpp
index 68e3a74..f110340 100755
--- a/src/UserInterface/Widget/letter_button_widget.cpp
+++ b/src/UserInterface/Widget/letter_button_widget.cpp
@@ -47,7 +47,7 @@ void LetterButtonWidget::initUi()
letterlist.append(QString(QChar(letter)));
}
- letterlist.append("&&");
+ letterlist.append("&");
letterlist.append("#");
for (int row = 0; row < 6; row++) {
@@ -78,7 +78,7 @@ void LetterButtonWidget::hideEvent(QHideEvent *event)
void LetterButtonWidget::letterBtnClickedSlot()
{
LetterClassifyButton *btn = dynamic_cast<LetterClassifyButton *>(QObject::sender());
- QString btnname = btn->text();
+ QString btnname = btn->m_letter;
Q_EMIT sendLetterBtnSignal(btnname);
}
@@ -93,7 +93,7 @@ void LetterButtonWidget::recvLetterBtnList(QStringList list)
for (int col = 0; col < 4; col++) {
QLayoutItem *item = gridLayout->itemAt(row * 4 + col);
LetterClassifyButton *btn = static_cast<LetterClassifyButton *>(item->widget());
- QString letterstr = btn->text();
+ QString letterstr = btn->m_letter;
if (list.indexOf(letterstr.at(0)) == -1) {
btn->setEnabled(false);
diff --git a/src/UserInterface/full_mainwindow.cpp b/src/UserInterface/full_mainwindow.cpp
index 3c77fd5..3ccb33f 100755
--- a/src/UserInterface/full_mainwindow.cpp
+++ b/src/UserInterface/full_mainwindow.cpp
@@ -3,6 +3,7 @@
#include <QAction>
#include <QTranslator>
#include "utility.h"
+#include <QPalette>
FullMainWindow::FullMainWindow(QWidget *parent) :
QMainWindow(parent)
@@ -290,12 +291,15 @@ bool FullMainWindow::eventFilter(QObject *watched, QEvent *event)
{
if (watched == m_lineEdit) {
m_isSearching = true;
- char style[200];
+ QString style;
if (event->type() == QEvent::FocusIn) {
- sprintf(style, "QLineEdit{border:2px solid %s;background-color:%s;border-radius:17px;color:#ffffff;}",
- QueryLineEditClickedBorder, QueryLineEditClickedBackground);
+ QString highLightColor = QString::number(m_lineEdit->palette().color(QPalette::Highlight).rgba(), 16);
+ QString color = highLightColor.mid(2, 6);
+ style = QString("QLineEdit{border:2px solid #%1;background-color:%2;border-radius:17px;color:#ffffff;}")
+ .arg(color).arg(QueryLineEditClickedBackground);
m_lineEdit->setStyleSheet(style);
+ myDebug() <<color << style;
if (m_lineEdit->text().isEmpty()) {
qDebug() << "bool FullMainWindow::eventFilter(QObject *watched, QEvent *event)" << m_queryWid->layout()->count();
@@ -310,8 +314,8 @@ bool FullMainWindow::eventFilter(QObject *watched, QEvent *event)
m_lineEdit->setTextMargins(26, 0, 0, 0);
}
} else if (event->type() == QEvent::FocusOut && m_lineEdit->text().isEmpty()) {
- sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:17px;color:#ffffff;}",
- QueryLineEditClickedBorderDefault, QueryLineEditClickedBackground);
+ style = QString("QLineEdit{border:1px solid %1;background-color:%2;border-radius:17px;color:#ffffff;}")
+ .arg(QueryLineEditClickedBorderDefault).arg(QueryLineEditClickedBackground);
m_lineEdit->setStyleSheet(style);
resetEditline();
}
diff --git a/src/UserInterface/mainwindow.cpp b/src/UserInterface/mainwindow.cpp
index 1f09418..cc67dcb 100755
--- a/src/UserInterface/mainwindow.cpp
+++ b/src/UserInterface/mainwindow.cpp
@@ -33,6 +33,7 @@
#include <QGroupBox>
#include <QEventLoop>
#include <QLabel>
+#include <QPalette>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
@@ -316,7 +317,10 @@ void MainWindow::initSearchUi()
m_leftTopSearchHorizontalLayout->setContentsMargins(8, 0, 8, 0);
m_lineEdit = new QLineEdit(m_minSearchPage);
m_lineEdit->setMinimumSize(QSize(30, 26));
- m_lineEdit->setStyleSheet(QString::fromUtf8("border-radius: 13px; border:1px solid rgba(5, 151, 255, 1); background: transparent;"));
+ QString highLightColor = QString::number(m_lineEdit->palette().color(QPalette::Highlight).rgba(), 16);
+ QString color = highLightColor.mid(2, 6);
+ QString searchStyle = QString("border-radius: 13px; border:1px solid #%1; background: transparent;").arg(color);
+ m_lineEdit->setStyleSheet(searchStyle);
m_lineEdit->setFrame(false);
m_lineEdit->setPlaceholderText(tr("Search"));
m_lineEdit->installEventFilter(this);
@@ -519,7 +523,7 @@ void MainWindow::windowOption()
void MainWindow::initUi()
{
qDebug() << "init UI";
- this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
+ this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::BypassWindowManagerHint);
this->setAttribute(Qt::WA_TranslucentBackground, true);
this->setAutoFillBackground(false);
this->setFocusPolicy(Qt::NoFocus);
@@ -558,11 +562,10 @@ void MainWindow::initUi()
m_dropDownMenu->addAction(m_letterAction);
m_dropDownMenu->addAction(m_funcAction);
m_allAction->setChecked(true);
- m_collectPushButton->setStyleSheet("color:#3790FA;");
- QColor textColor = this->palette().color(QPalette::Text);
- QRgb rgbDefault = qRgb(textColor.red(), textColor.green(), textColor.blue());
- QString textColorDefault = "#" + QString::number(rgbDefault, 16);
- m_recentPushButton->setStyleSheet(QString("color:%1;").arg(textColorDefault));
+ QString textColorHightLight = QString::number(this->palette().color(QPalette::Highlight).rgba(), 16).mid(2, 6);
+ m_collectPushButton->setStyleSheet(QString("color: #%1;").arg(textColorHightLight));
+ QString textColorDefault = QString::number(this->palette().color(QPalette::Text).rgba(), 16).mid(2, 6);
+ m_recentPushButton->setStyleSheet(QString("color: #%1;").arg(textColorDefault));
QAction *action = new QAction();
action->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-icon-search.svg", true));
m_lineEdit->addAction(action, QLineEdit::LeadingPosition);
@@ -1209,13 +1212,12 @@ void MainWindow::on_collectPushButton_clicked()
{
m_rightStackedWidget->setCurrentIndex(0);
- m_collectPushButton->setStyleSheet("color:#3790FA;");
+ QString textColorHightLight = QString::number(this->palette().color(QPalette::Highlight).rgba(), 16).mid(2, 6);
+ m_collectPushButton->setStyleSheet(QString("color:#%1;").arg(textColorHightLight));
QFont collectFont(QGuiApplication::font().family(), QGuiApplication::font().pointSize() + 2);
m_collectPushButton->setFont(collectFont);
- QColor textColor = this->palette().color(QPalette::Text);
- QRgb rgbDefault = qRgb(textColor.red(), textColor.green(), textColor.blue());
- QString textColorDefault = "#" + QString::number(rgbDefault, 16);
- m_recentPushButton->setStyleSheet(QString("color:%1;").arg(textColorDefault));
+ QString textColorDefault = QString::number(this->palette().color(QPalette::Text).rgba(), 16).mid(2, 6);
+ m_recentPushButton->setStyleSheet(QString("color:#%1;").arg(textColorDefault));
QFont recentFont(QGuiApplication::font().family(), QGuiApplication::font().pointSize());
m_recentPushButton->setFont(recentFont);
}
@@ -1223,13 +1225,12 @@ void MainWindow::on_collectPushButton_clicked()
void MainWindow::on_recentPushButton_clicked()
{
m_rightStackedWidget->setCurrentIndex(1);
- QColor textColor = this->palette().color(QPalette::Text);
- QRgb rgbDefault = qRgb(textColor.red(), textColor.green(), textColor.blue());
- QString textColorDefault = "#" + QString::number(rgbDefault, 16);
- m_collectPushButton->setStyleSheet(QString("color:%1").arg(textColorDefault));
+ QString textColorDefault = QString::number(this->palette().color(QPalette::Text).rgba(), 16).mid(2, 6);
+ m_collectPushButton->setStyleSheet(QString("color:#%1").arg(textColorDefault));
QFont collectFont(QGuiApplication::font().family(), QGuiApplication::font().pointSize());
m_collectPushButton->setFont(collectFont);
- m_recentPushButton->setStyleSheet("color:#3790FA");
+ QString textColorHightLight = QString::number(this->palette().color(QPalette::Highlight).rgba(), 16).mid(2, 6);
+ m_recentPushButton->setStyleSheet(QString("color:#%1").arg(textColorHightLight));
QFont recentFont(QGuiApplication::font().family(), QGuiApplication::font().pointSize() + 2);
m_recentPushButton->setFont(recentFont);