From 21e4c0bc7c47d5ee6b63d647410184b7f516b406 Mon Sep 17 00:00:00 2001 From: liuhao-startmenu Date: Tue, 10 Nov 2020 15:00:15 +0800 Subject: [PATCH 262/262] Adapt the light color theme --- main.cpp | 79 +-- src/CommonUseWidget/commonusewidget.cpp | 11 +- src/CommonUseWidget/fullcommonusewidget.cpp | 6 +- src/FunctionWidget/fullfunctionwidget.cpp | 181 ++----- src/FunctionWidget/fullfunctionwidget.h | 13 +- src/FunctionWidget/functionbuttonwidget.cpp | 13 +- src/FunctionWidget/functionbuttonwidget.h | 1 + src/FunctionWidget/functionwidget.cpp | 13 +- src/Interface/ukuimenuinterface.cpp | 2 +- src/Interface/ukuimenuinterface.h | 6 +- src/LetterWidget/fullletterwidget.cpp | 30 +- src/LetterWidget/fullletterwidget.h | 11 +- src/LetterWidget/letterbuttonwidget.cpp | 21 +- src/LetterWidget/letterbuttonwidget.h | 2 +- src/LetterWidget/letterwidget.cpp | 13 +- src/MainViewWidget/mainviewwidget.cpp | 458 ++++++++++-------- src/MainViewWidget/mainviewwidget.h | 6 +- src/MainWindow/mainwindow.cpp | 355 +++++++------- src/MainWindow/mainwindow.h | 4 +- src/RightClickMenu/rightclickmenu.cpp | 50 +- src/RightClickMenu/rightclickmenu.h | 6 - .../fullsearchresultwidget.cpp | 5 +- src/SearchResultWidget/searchresultwidget.cpp | 7 +- src/SideBarWidget/sidebarwidget.cpp | 235 ++++++--- src/SideBarWidget/sidebarwidget.h | 8 +- src/Style/style.h | 11 +- src/UtilityFunction/classifybtnscrollarea.cpp | 95 ++++ ...fyscrollarea.h => classifybtnscrollarea.h} | 14 +- src/UtilityFunction/classifyscrollarea.cpp | 36 -- src/UtilityFunction/fullitemdelegate.cpp | 72 +-- src/UtilityFunction/fulllistview.cpp | 68 ++- src/UtilityFunction/fulllistview.h | 1 + .../functionclassifybutton.cpp | 120 ++++- src/UtilityFunction/functionclassifybutton.h | 2 + src/UtilityFunction/itemdelegate.cpp | 43 +- src/UtilityFunction/letterclassifybutton.cpp | 113 +++-- src/UtilityFunction/letterclassifybutton.h | 11 +- src/UtilityFunction/listview.cpp | 27 +- src/UtilityFunction/listview.h | 1 + src/UtilityFunction/proxystyle.cpp | 50 ++ src/UtilityFunction/proxystyle.h | 28 ++ src/UtilityFunction/scrollarea.cpp | 86 +++- src/UtilityFunction/scrollarea.h | 16 +- .../{pushbutton.cpp => splitbarframe.cpp} | 44 +- .../{pushbutton.h => splitbarframe.h} | 7 +- src/UtilityFunction/toolbutton.cpp | 30 +- src/UtilityFunction/utility.cpp | 51 ++ src/UtilityFunction/utility.h | 7 + translations/ukui-menu_bo.ts | 326 ++++--------- translations/ukui-menu_tr.ts | 194 +++++--- translations/ukui-menu_zh_CN.ts | 194 +++++--- ukui-menu.pro | 12 +- 52 files changed, 1808 insertions(+), 1387 deletions(-) create mode 100644 src/UtilityFunction/classifybtnscrollarea.cpp rename src/UtilityFunction/{classifyscrollarea.h => classifybtnscrollarea.h} (76%) delete mode 100644 src/UtilityFunction/classifyscrollarea.cpp create mode 100644 src/UtilityFunction/proxystyle.cpp create mode 100644 src/UtilityFunction/proxystyle.h rename src/UtilityFunction/{pushbutton.cpp => splitbarframe.cpp} (72%) rename src/UtilityFunction/{pushbutton.h => splitbarframe.h} (91%) diff --git a/main.cpp b/main.cpp index a710cd3..f42f8dc 100644 --- a/main.cpp +++ b/main.cpp @@ -23,9 +23,9 @@ #include #include #include -#include #include #include +#include "src/UtilityFunction/proxystyle.h" int main(int argc, char *argv[]) { @@ -44,6 +44,9 @@ int main(int argc, char *argv[]) return EXIT_SUCCESS; } +// auto Style=new ProxyStyle; +// app.setStyle(Style); + QTranslator translator; if (translator.load(QLocale(), "ukui-menu", "_", QM_FILES_INSTALL_PATH)) app.installTranslator(&translator); @@ -52,44 +55,48 @@ int main(int argc, char *argv[]) MainWindow w; app.setActivationWindow(&w); - KWindowEffects::enableBlurBehind(w.winId(),true); - -// int position=0; -// int panelSize=0; -// if(QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) -// { -// QGSettings* gsetting=new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit()); -// if(gsetting->keys().contains(QString("panelposition"))) -// position=gsetting->get("panelposition").toInt(); -// else -// position=0; -// if(gsetting->keys().contains(QString("panelsize"))) -// panelSize=gsetting->get("panelsize").toInt(); -// else -// panelSize=46; -// } -// else -// { -// position=0; -// panelSize=46; -// } + w.setProperty("useSystemStyleBlur", true); -// int x=QApplication::primaryScreen()->geometry().x(); -// int y=QApplication::primaryScreen()->geometry().y(); + //测试 + int position=0; + int panelSize=0; + if(QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) + { + QGSettings* gsetting=new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit()); + if(gsetting->keys().contains(QString("panelposition"))) + position=gsetting->get("panelposition").toInt(); + else + position=0; + if(gsetting->keys().contains(QString("panelsize"))) + panelSize=gsetting->get("panelsize").toInt(); + else + panelSize=46; + } + else + { + position=0; + panelSize=46; + } -// if(position==0) -// w.setGeometry(QRect(x,y+QApplication::primaryScreen()->geometry().height()-panelSize-Style::minh,Style::minw,Style::minh)); -// else if(position==1) -// w.setGeometry(QRect(x,y+panelSize,Style::minw,Style::minh)); -// else if(position==2) -// w.setGeometry(QRect(x+panelSize,y,Style::minw,Style::minh)); -// else -// w.setGeometry(QRect(x+QApplication::primaryScreen()->geometry().width()-panelSize-Style::minw,y,Style::minw,Style::minh)); + int x=QApplication::primaryScreen()->geometry().x(); + int y=QApplication::primaryScreen()->geometry().y(); -// w.setFrameStyle(); -// w.show(); -// w.raise(); -// w.activateWindow(); + if(position==0) + w.setGeometry(QRect(x,y+QApplication::primaryScreen()->geometry().height()-panelSize-Style::minh, + Style::minw,Style::minh)); + else if(position==1) + w.setGeometry(QRect(x,y+panelSize,Style::minw,Style::minh)); + else if(position==2) + w.setGeometry(QRect(x+panelSize,y,Style::minw,Style::minh)); + else + w.setGeometry(QRect(x+QApplication::primaryScreen()->geometry().width()-panelSize-Style::minw,y, + Style::minw,Style::minh)); + w.show(); + w.raise(); + w.update(); + w.activateWindow(); + w.hide(); + //测试 return app.exec(); } diff --git a/src/CommonUseWidget/commonusewidget.cpp b/src/CommonUseWidget/commonusewidget.cpp index 1b9f98d..25bb31f 100644 --- a/src/CommonUseWidget/commonusewidget.cpp +++ b/src/CommonUseWidget/commonusewidget.cpp @@ -38,9 +38,8 @@ CommonUseWidget::~CommonUseWidget() void CommonUseWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + this->setAttribute(Qt::WA_TranslucentBackground); this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); m_ukuiMenuInterface=new UkuiMenuInterface; @@ -54,8 +53,8 @@ void CommonUseWidget::initUi() */ void CommonUseWidget::initAppListWidget() { - m_listView=new ListView(this,this->width()-4,this->height(),0); - m_listView->setGeometry(QRect(0,0,this->width()-4,this->height())); + m_listView=new ListView(this,this->width()-6,this->height()-6,0); + m_listView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_listView->show(); connect(m_listView,&ListView::sendItemClickedSignal,this,&CommonUseWidget::execApplication); connect(m_listView,&ListView::sendUpdateAppListSignal,this,&CommonUseWidget::updateListViewSlot); @@ -97,7 +96,7 @@ void CommonUseWidget::updateListViewSlot() void CommonUseWidget::updateListView() { m_data.clear(); - Q_FOREACH(QString desktopfp,m_ukuiMenuInterface->getAllApp()) + Q_FOREACH(QString desktopfp,m_ukuiMenuInterface->getAllClassification()) m_data.append(QStringList()<updateData(m_data); } @@ -118,6 +117,6 @@ void CommonUseWidget::moveScrollBar(int type) void CommonUseWidget::repaintWidget() { this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); - m_listView->setGeometry(QRect(0,0,this->width()-4,this->height())); + m_listView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_listView->show(); } diff --git a/src/CommonUseWidget/fullcommonusewidget.cpp b/src/CommonUseWidget/fullcommonusewidget.cpp index d394fed..d9fd0e6 100644 --- a/src/CommonUseWidget/fullcommonusewidget.cpp +++ b/src/CommonUseWidget/fullcommonusewidget.cpp @@ -36,13 +36,11 @@ void FullCommonUseWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); this->setFixedSize(Style::MainViewWidWidth, Style::AppListWidHeight); QHBoxLayout* mainLayout=new QHBoxLayout; -// mainLayout->setContentsMargins(Style::LeftWidWidth,0,0,0); mainLayout->setContentsMargins(0,0,0,0); this->setLayout(mainLayout); m_spaceItem=new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed); @@ -57,7 +55,7 @@ void FullCommonUseWidget::initUi() void FullCommonUseWidget::initAppListWidget() { m_listView=new FullListView(this,0); - m_listView->setFixedSize(this->width()-Style::LeftWidWidth,this->height()); + m_listView->setFixedSize(this->width()-Style::LeftWidWidth+1,this->height()); QHBoxLayout *mainLayout=qobject_cast(this->layout()); mainLayout->insertWidget(1,m_listView); connect(m_listView,&FullListView::sendItemClickedSignal,this,&FullCommonUseWidget::execApplication); @@ -94,7 +92,7 @@ void FullCommonUseWidget::updateListViewSlot() void FullCommonUseWidget::updateListView() { m_data.clear(); - Q_FOREACH(QString desktopfp,m_ukuiMenuInterface->getAllApp()) + Q_FOREACH(QString desktopfp,m_ukuiMenuInterface->getAllClassification()) m_data.append(desktopfp); m_listView->updateData(m_data); } diff --git a/src/FunctionWidget/fullfunctionwidget.cpp b/src/FunctionWidget/fullfunctionwidget.cpp index 92d9b17..0e43fb0 100644 --- a/src/FunctionWidget/fullfunctionwidget.cpp +++ b/src/FunctionWidget/fullfunctionwidget.cpp @@ -38,9 +38,8 @@ FullFunctionWidget::~FullFunctionWidget() void FullFunctionWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + this->setAttribute(Qt::WA_TranslucentBackground); m_applistWid=new QWidget(this); m_iconListWid=new QWidget(this); this->setFixedSize(Style::MainViewWidWidth, @@ -51,8 +50,6 @@ void FullFunctionWidget::initUi() QHBoxLayout* mainLayout=new QHBoxLayout; mainLayout->setContentsMargins(0,0,0,0); mainLayout->setSpacing(0); - m_applistWid->setStyleSheet("border:0px;background:transparent;"); - m_iconListWid->setStyleSheet("border:0px;background:transparent"); mainLayout->addWidget(m_iconListWid); mainLayout->addWidget(m_applistWid); this->setLayout(mainLayout); @@ -73,7 +70,8 @@ void FullFunctionWidget::initAppListWidget() m_applistWid->setLayout(layout); m_scrollArea=new ScrollArea; - m_scrollAreaWid=new QWidget; + m_scrollAreaWid=new ScrollAreaWid; + m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); m_scrollArea->setFixedSize(m_applistWid->width(),m_applistWid->height()); m_scrollArea->setWidget(m_scrollAreaWid); m_scrollArea->setWidgetResizable(true); @@ -168,8 +166,7 @@ void FullFunctionWidget::fillAppList() void FullFunctionWidget::insertClassificationBtn(QString category) { - PushButton* classificationbtn=new PushButton(this,category,m_scrollArea->width()-12,30,2); -// classificationbtn->setFixedSize(m_scrollArea->width()-12,25); + SplitBarFrame* classificationbtn=new SplitBarFrame(this,category,m_scrollArea->width()-12,30,2); m_scrollAreaWidLayout->addWidget(classificationbtn); m_classificationList.append(category); @@ -178,6 +175,10 @@ void FullFunctionWidget::insertClassificationBtn(QString category) void FullFunctionWidget::insertAppList(QStringList desktopfplist) { FullListView* listview=new FullListView(this,2); + //修复异常黑框问题 + connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [=](){ + listview->repaint(listview->rect()); + }); m_scrollAreaWidLayout->addWidget(listview); m_data.clear(); for(int i=0;igetRecentApp(); -// if(!recentlist.isEmpty())//最近添加非空 -// { -// if(m_classificationList.contains(tr("Recently")))//有最近添加分类 -// { -// QLayoutItem *child; -// if((child = m_scrollAreaWidLayout->itemAt(1)) != 0) -// { -// QWidget* wid=child->widget(); -// FullListView* listview=qobject_cast(wid); -// for(int i=0;igetDesktopPathByAppName(recentlist.at(i)); -// data.append(desktopfp); -// } -// listview->updateData(data); -// } -// } -// else//无最近添加分类 -// { -// PushButton* classificationbtn=new PushButton(this,tr("Recently"),scrollarea->width()-12,20); -// classificationbtn->setFixedSize(scrollarea->width()-12,20); -// m_scrollAreaWidLayout->insertWidget(0,classificationbtn); -// m_classificationList.insert(0,tr("Recently")); - -// FullListView* listview=new FullListView(this,2); -// m_scrollAreaWidLayout->insertWidget(1,listview); -// for(int i=0;igetDesktopPathByAppName(recentlist.at(i)); -// data.append(desktopfp); -// } -// listview->addData(data); -// connect(listview,SIGNAL(sendItemClickedSignal(QString)),this,SLOT(execApplication(QString))); - -// //刷新图标列表界面 -// Q_FOREACH (QAbstractButton* button, m_buttonList){ -// m_btnGroup->removeButton(button); -// } -// m_buttonList.clear(); -// QLayoutItem *child; -// while ((child = m_iconListScrollAreaWidLayout->takeAt(0)) != 0) { -// QWidget* wid=child->widget(); -// m_iconListScrollAreaWidLayout->removeWidget(wid); -// wid->setParent(nullptr); -// delete wid; -// delete child; -// } -// initIconListScrollArea(); -// } -// } -// else//最近添加为空 -// { -// if(m_classificationList.contains(tr("Recently"))) -// { -// int num=0; -// QLayoutItem *child; -// while ((child = m_scrollAreaWidLayout->takeAt(0)) != 0) { -// QWidget* wid=child->widget(); -// m_scrollAreaWidLayout->removeWidget(wid); -// wid->setParent(nullptr); -// delete wid; -// delete child; -// num++; -// if(num==2) -// break; -// } -// m_classificationList.removeAt(0); - -// //刷新图标列表界面 -// Q_FOREACH (QAbstractButton* button, m_buttonList){ -// m_btnGroup->removeButton(button); -// } -// m_buttonList.clear(); -// while ((child = m_iconListScrollAreaWidLayout->takeAt(0)) != 0) { -// QWidget* wid=child->widget(); -// m_iconListScrollAreaWidLayout->removeWidget(wid); -// wid->setParent(nullptr); -// delete wid; -// delete child; -// } -// initIconListScrollArea(); -// } -// } -// resizeScrollAreaControls(); -// setting->endGroup(); -//} - /** * 执行应用程序 */ @@ -312,6 +219,8 @@ void FullFunctionWidget::updateAppListView() m_btnGroup->removeButton(button); } m_buttonList.clear(); + m_iconListScrollAreaWidLayout->removeItem(m_topSpacerItem); + m_iconListScrollAreaWidLayout->removeItem(m_bottomSpacerItem); while ((child = m_iconListScrollAreaWidLayout->takeAt(0)) != 0) { QWidget* wid=child->widget(); m_iconListScrollAreaWidLayout->removeWidget(wid); @@ -358,14 +267,20 @@ void FullFunctionWidget::resizeScrollAreaControls() */ void FullFunctionWidget::initIconListWidget() { - m_iconListScrollArea=new ClassifyScrollArea(m_iconListWid); - m_iconListScrollAreaWid=new QWidget; + m_iconListScrollArea=new ClassifyBtnScrollArea(m_iconListWid); + m_iconListScrollArea->setFixedSize(Style::LeftBtnWidth, + m_iconListWid->height()); + m_iconListScrollAreaWid=new ClassifyBtnScrollAreaWid; + m_iconListScrollAreaWid->setFixedSize(m_iconListScrollArea->width(),m_iconListScrollArea->height()); m_iconListScrollAreaWidLayout=new QVBoxLayout; m_iconListScrollAreaWidLayout->setContentsMargins(0,0,0,0); m_iconListScrollAreaWidLayout->setSpacing(Style::LeftSpaceBetweenItem); m_iconListScrollAreaWid->setLayout(m_iconListScrollAreaWidLayout); m_iconListScrollArea->setWidget(m_iconListScrollAreaWid); + m_topSpacerItem=new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding); + m_bottomSpacerItem=new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding); + m_btnGroup=new QButtonGroup(m_iconListScrollAreaWid); m_animation = new QPropertyAnimation(m_iconListScrollArea, "geometry"); @@ -382,33 +297,28 @@ void FullFunctionWidget::initIconListWidget() */ void FullFunctionWidget::initIconListScrollArea() { + m_iconListScrollAreaWidLayout->addItem(m_topSpacerItem); for(int i=0;i vector=UkuiMenuInterface::functionalVector; -// QStringList androidlist=vector.at(0); -// for(int index=0;indexsetChecked(false); - m_buttonList.append(iconbtn); - m_iconListScrollAreaWidLayout->addWidget(iconbtn); -// } - + FunctionClassifyButton* iconbtn=new FunctionClassifyButton( + Style::LeftBtnWidth, + Style::LeftBtnHeight, + Style::LeftIconSize, + m_classificationList.at(i), + true, + true); + iconbtn->setChecked(false); + m_buttonList.append(iconbtn); + m_iconListScrollAreaWidLayout->addWidget(iconbtn); } + m_iconListScrollAreaWidLayout->addItem(m_bottomSpacerItem); int id=0; Q_FOREACH (QAbstractButton* btn, m_buttonList) { m_btnGroup->addButton(btn,id++); } connect(m_btnGroup,static_cast(&QButtonGroup::buttonClicked),this,&FullFunctionWidget::btnGroupClickedSlot); - m_iconListScrollArea->widget()->adjustSize(); +// m_iconListScrollArea->widget()->adjustSize(); m_btnGroup->button(0)->click(); } @@ -489,14 +399,13 @@ void FullFunctionWidget::valueChangedSlot(int value) void FullFunctionWidget::enterAnimation() { - int height=m_classificationList.size()*Style::LeftBtnHeight+(m_classificationList.size()-1)*Style::LeftSpaceBetweenItem; m_animation->setDuration(200);//动画总时间 - m_animation->setStartValue(QRect(0,(m_iconListWid->height()-height)/2, - 0,height)); + m_animation->setStartValue(QRect(0,0, + 0,m_iconListWid->height())); m_animation->setEndValue(QRect(Style::LeftMargin, - (m_iconListWid->height()-height)/2, + 0, Style::LeftBtnWidth, - height)); + m_iconListWid->height())); m_animation->setEasingCurve(QEasingCurve::InQuart); m_animation->start(); m_iconListScrollArea->show(); @@ -504,11 +413,11 @@ void FullFunctionWidget::enterAnimation() void FullFunctionWidget::setFunctionBtnGeometry() { - int height=m_classificationList.size()*Style::LeftBtnHeight+(m_classificationList.size()-1)*Style::LeftSpaceBetweenItem; +// int height=m_classificationList.size()*Style::LeftBtnHeight+(m_classificationList.size()-1)*Style::LeftSpaceBetweenItem; m_iconListScrollArea->setGeometry(QRect(Style::LeftMargin, - (m_iconListWid->height()-height)/2, + 0, Style::LeftBtnWidth, - height)); + m_iconListWid->height())); m_iconListScrollArea->show(); } @@ -519,22 +428,16 @@ void FullFunctionWidget::repaintWidget() Style::AppListWidHeight); m_applistWid->setFixedSize(Style::AppListWidWidth,this->height()); m_iconListWid->setFixedSize(Style::LeftWidWidth,this->height()); + m_iconListScrollArea->setFixedSize(Style::LeftBtnWidth, + m_iconListWid->height()); + m_iconListScrollAreaWid->setFixedSize(m_iconListScrollArea->width(),m_iconListScrollArea->height()); +// m_iconListScrollArea->widget()->adjustSize(); m_scrollArea->setFixedSize(m_applistWid->width(),m_applistWid->height()); updateAppListView(); } void FullFunctionWidget::widgetMakeZero() { -// Q_FOREACH (QAbstractButton* button, m_buttonList) { -// int num=m_classificationList.indexOf(functionnamelist.at(m_buttonList.indexOf(button))); -// if(num!=-1) -// { -// m_btnGroup->button(num)->setChecked(true); -// m_btnGroup->button(num)->click(); -// m_iconListScrollArea->verticalScrollBar()->setSliderPosition(0); -// break; -// } -// } m_btnGroup->button(0)->click(); m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); } diff --git a/src/FunctionWidget/fullfunctionwidget.h b/src/FunctionWidget/fullfunctionwidget.h index 8912cb8..185dd8b 100644 --- a/src/FunctionWidget/fullfunctionwidget.h +++ b/src/FunctionWidget/fullfunctionwidget.h @@ -35,9 +35,9 @@ #include #include "src/Interface/ukuimenuinterface.h" #include "src/UtilityFunction/scrollarea.h" -#include "src/UtilityFunction/pushbutton.h" +#include "src/UtilityFunction/splitbarframe.h" #include "src/UtilityFunction/fulllistview.h" -#include "src/UtilityFunction/classifyscrollarea.h" +#include "src/UtilityFunction/classifybtnscrollarea.h" #include "src/UtilityFunction/toolbutton.h" #include "src/UtilityFunction/functionclassifybutton.h" #include "src/Style/style.h" @@ -78,18 +78,20 @@ private: UkuiMenuInterface* m_ukuiMenuInterface=nullptr; QWidget* m_applistWid=nullptr; ScrollArea* m_scrollArea=nullptr; - QWidget* m_scrollAreaWid=nullptr; + ScrollAreaWid* m_scrollAreaWid=nullptr; QVBoxLayout* m_scrollAreaWidLayout=nullptr; QStringList m_classificationList;//Store the list of category buttons QStringList m_data; /*Function classification list interface*/ QWidget* m_iconListWid=nullptr; - ClassifyScrollArea* m_iconListScrollArea=nullptr; - QWidget* m_iconListScrollAreaWid=nullptr; + ClassifyBtnScrollArea* m_iconListScrollArea=nullptr; + ClassifyBtnScrollAreaWid* m_iconListScrollAreaWid=nullptr; QVBoxLayout* m_iconListScrollAreaWidLayout=nullptr; QList m_buttonList; QButtonGroup* m_btnGroup=nullptr; + QSpacerItem* m_topSpacerItem=nullptr; + QSpacerItem* m_bottomSpacerItem=nullptr; /*Animation*/ QPropertyAnimation* m_animation=nullptr;//Function category button animation @@ -107,7 +109,6 @@ protected: */ void initIconListWidget(); void initIconListScrollArea(); - /** * @brief Initialize the application list interface */ diff --git a/src/FunctionWidget/functionbuttonwidget.cpp b/src/FunctionWidget/functionbuttonwidget.cpp index 02f3738..0cde546 100644 --- a/src/FunctionWidget/functionbuttonwidget.cpp +++ b/src/FunctionWidget/functionbuttonwidget.cpp @@ -48,7 +48,6 @@ void FunctionButtonWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); this->resize(Style::LeftBtnWidth*2+5,Style::LeftBtnHeight*6+25); QGridLayout* gridLayout=new QGridLayout; @@ -67,9 +66,21 @@ void FunctionButtonWidget::initUi() false); gridLayout->addWidget(iconbtn,row,col); + m_buttonList.append(iconbtn); connect(iconbtn,&FunctionClassifyButton::buttonClicked,this, &FunctionButtonWidget::functionBtnClickedSlot); if(row*2+col==10)break; } + + if(QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) + { + QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); + connect(gsetting,&QGSettings::changed,this,[=]{ + Q_FOREACH (QAbstractButton* btn, m_buttonList) { + FunctionClassifyButton *fbtn=qobject_cast(btn); + fbtn->updateIconState(); + } + }); + } } /** diff --git a/src/FunctionWidget/functionbuttonwidget.h b/src/FunctionWidget/functionbuttonwidget.h index 2b4bb9b..e2cc5d1 100644 --- a/src/FunctionWidget/functionbuttonwidget.h +++ b/src/FunctionWidget/functionbuttonwidget.h @@ -39,6 +39,7 @@ public: private: QStringList m_categoryList; + QList m_buttonList; protected: /** diff --git a/src/FunctionWidget/functionwidget.cpp b/src/FunctionWidget/functionwidget.cpp index 0ea09a1..91303fd 100644 --- a/src/FunctionWidget/functionwidget.cpp +++ b/src/FunctionWidget/functionwidget.cpp @@ -38,7 +38,6 @@ void FunctionWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); @@ -64,8 +63,8 @@ void FunctionWidget::initUi() */ void FunctionWidget::initAppListWidget() { - m_appListView=new ListView(this,this->width()-4,this->height(),2); - m_appListView->setGeometry(QRect(0,0,this->width()-4,this->height())); + m_appListView=new ListView(this,this->width()-6,this->height()-6,2); + m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_appListView->show(); fillAppListView(0); connect(m_appListView,&ListView::sendItemClickedSignal,this,&FunctionWidget::recvItemClickedSlot); @@ -203,7 +202,7 @@ void FunctionWidget::updateAppListView() */ void FunctionWidget::appClassificationBtnClickedSlot() { - m_leaveAnimation->setStartValue(QRect(0,0,this->width()-4,this->height())); + m_leaveAnimation->setStartValue(QRect(6,0,this->width()-6,this->height()-6)); m_leaveAnimation->setEndValue(QRect(20,20,this->width()-40,this->height()-40)); m_enterAnimation->setStartValue(QRect(-40,-40,this->width()+80,this->height()+80)); m_enterAnimation->setEndValue(QRect((this->width()-Style::LeftBtnWidth*2-5)/2, @@ -240,7 +239,7 @@ void FunctionWidget::recvFunctionBtnSignal(QString btnname) Style::LeftBtnHeight*6+25)); m_leaveAnimation->setEndValue(QRect(-40,-40,this->width()+80,this->height()+80)); m_enterAnimation->setStartValue(QRect(20,20,this->width()-40,this->height()-40)); - m_enterAnimation->setEndValue(QRect(0,0,this->width()-4,this->height())); + m_enterAnimation->setEndValue(QRect(6,0,this->width()-6,this->height()-6)); m_leaveAnimation->setDuration(80); m_enterAnimation->setDuration(10); @@ -271,7 +270,7 @@ void FunctionWidget::animationFinishedSLot() void FunctionWidget::widgetMakeZero() { m_functionBtnWid->hide(); - m_appListView->setGeometry(QRect(0,0,this->width()-4,this->height())); + m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_appListView->show(); m_appListView->verticalScrollBar()->setValue(0); } @@ -287,6 +286,6 @@ void FunctionWidget::moveScrollBar(int type) void FunctionWidget::repaintWidget() { this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); - m_appListView->setGeometry(QRect(0,0,this->width()-4,this->height())); + m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_appListView->show(); } diff --git a/src/Interface/ukuimenuinterface.cpp b/src/Interface/ukuimenuinterface.cpp index 82a3d12..87489c5 100644 --- a/src/Interface/ukuimenuinterface.cpp +++ b/src/Interface/ukuimenuinterface.cpp @@ -369,7 +369,7 @@ bool UkuiMenuInterface::cmpApp(QStringList &arg_1, QStringList &arg_2) return false; } -QVector UkuiMenuInterface::getAllApp() +QVector UkuiMenuInterface::getAllClassification() { QVector allAppVector; QVector commonVector; diff --git a/src/Interface/ukuimenuinterface.h b/src/Interface/ukuimenuinterface.h index 4f2d498..e0f703c 100644 --- a/src/Interface/ukuimenuinterface.h +++ b/src/Interface/ukuimenuinterface.h @@ -63,10 +63,10 @@ public: QString getAppComment(QString desktopfp);//获取应用注释 QStringList getDesktopFilePath();//获取系统deskyop文件路径 - QVector getAlphabeticClassification();//获取字母分类 - QVector getFunctionalClassification();//获取功能分类 + QVector getAlphabeticClassification();//字母分类模块 + QVector getFunctionalClassification();//功能分类模块 QVector getCommonUseApp();//获取常用App - QVector getAllApp(); + QVector getAllClassification();//所有软件模块 void getAndroidApp();//获取安卓应用 static bool cmpApp(QStringList &arg_1,QStringList &arg_2); bool matchingAppCategories(QString desktopfp,QStringList categorylist);//匹配应用Categories diff --git a/src/LetterWidget/fullletterwidget.cpp b/src/LetterWidget/fullletterwidget.cpp index 06641b8..21b46be 100644 --- a/src/LetterWidget/fullletterwidget.cpp +++ b/src/LetterWidget/fullletterwidget.cpp @@ -37,9 +37,8 @@ FullLetterWidget::~FullLetterWidget() void FullLetterWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + this->setAttribute(Qt::WA_TranslucentBackground); m_applistWid=new QWidget(this); m_letterListWid=new QWidget(this); @@ -51,8 +50,6 @@ void FullLetterWidget::initUi() QHBoxLayout* mainLayout=new QHBoxLayout; mainLayout->setContentsMargins(0,0,0,0); mainLayout->setSpacing(0); - m_applistWid->setStyleSheet("border:0px;background: transparent;"); - m_letterListWid->setStyleSheet("border:0px;background: transparent;"); mainLayout->addWidget(m_letterListWid); mainLayout->addWidget(m_applistWid); this->setLayout(mainLayout); @@ -72,7 +69,7 @@ void FullLetterWidget::initAppListWidget() m_applistWid->setLayout(layout); m_scrollArea=new ScrollArea; - m_scrollAreaWid=new QWidget; + m_scrollAreaWid=new ScrollAreaWid; m_scrollArea->setWidget(m_scrollAreaWid); m_scrollArea->setFixedSize(m_applistWid->width(),m_applistWid->height()); m_scrollArea->setWidgetResizable(true); @@ -86,6 +83,7 @@ void FullLetterWidget::initAppListWidget() fillAppList(); + } /** @@ -109,12 +107,17 @@ void FullLetterWidget::fillAppList() letterstr="#"; m_letterList.append(letterstr);//存储分类字符 //插入字母分类按钮 - PushButton* letterbtn=new PushButton(this,letterstr,m_scrollArea->width()-12,30,1); -// letterbtn->setFixedSize(m_scrollArea->width(),20); + SplitBarFrame* letterbtn=new SplitBarFrame(this,letterstr,m_scrollArea->width()-12,30,1); m_scrollAreaWidLayout->addWidget(letterbtn); //插入应用列表 FullListView* listview=new FullListView(this,1); + + //修复异常黑框问题 + connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [=](){ + listview->repaint(listview->rect()); + }); + m_scrollAreaWidLayout->addWidget(listview); m_data.clear(); for(int i=0;isetContentsMargins(0,0,0,0); m_letterListScrollAreaWidLayout->setSpacing(0); @@ -238,19 +241,14 @@ void FullLetterWidget::initLetterListWidget() */ void FullLetterWidget::initLetterListScrollArea() { -// m_letterListScrollArea->setStyleSheet("border:1px solid #ff0000;"); -// m_letterListScrollArea->setFixedSize(Style::LeftLetterBtnHeight*2, -// (m_letterList.size()+1)*Style::LeftLetterBtnHeight); - -// m_letterListScrollArea->setStyleSheet("border:1px solid #ff0000;"); if(m_letterList.contains("&")) m_letterList.replace(m_letterList.indexOf("&"),"&&"); for(int i=0;isetFixedSize(Style::LeftLetterBtnHeight,Style::LeftLetterBtnHeight); m_buttonList.append(letterbtn); m_letterListScrollAreaWidLayout->addWidget(letterbtn); m_letterListScrollAreaWidLayout->setAlignment(letterbtn,Qt::AlignHCenter); diff --git a/src/LetterWidget/fullletterwidget.h b/src/LetterWidget/fullletterwidget.h index 8e7d9c0..dc3a4e4 100644 --- a/src/LetterWidget/fullletterwidget.h +++ b/src/LetterWidget/fullletterwidget.h @@ -43,9 +43,9 @@ #include #include "src/UtilityFunction/letterclassifybutton.h" #include "src/UtilityFunction/scrollarea.h" -#include "src/UtilityFunction/pushbutton.h" +#include "src/UtilityFunction/splitbarframe.h" #include "src/UtilityFunction/fulllistview.h" -#include "src/UtilityFunction/classifyscrollarea.h" +#include "src/UtilityFunction/classifybtnscrollarea.h" #include "src/UtilityFunction/toolbutton.h" #include "src/Style/style.h" @@ -85,15 +85,15 @@ private: UkuiMenuInterface* m_ukuiMenuInterface=nullptr; QWidget* m_applistWid=nullptr; ScrollArea* m_scrollArea=nullptr; - QWidget* m_scrollAreaWid=nullptr; + ScrollAreaWid* m_scrollAreaWid=nullptr; QVBoxLayout* m_scrollAreaWidLayout=nullptr; QStringList m_letterList;//Store the list of letter buttons QStringList m_data; /*Alphabetic classification list interface*/ QWidget* m_letterListWid=nullptr; - ClassifyScrollArea* m_letterListScrollArea=nullptr; - QWidget* m_letterListScrollAreaWid=nullptr; + ClassifyBtnScrollArea* m_letterListScrollArea=nullptr; + ClassifyBtnScrollAreaWid* m_letterListScrollAreaWid=nullptr; QVBoxLayout* m_letterListScrollAreaWidLayout=nullptr; QList m_buttonList; QButtonGroup* m_btnGroup=nullptr; @@ -110,6 +110,7 @@ protected: * @brief Initializes UI */ void initUi(); +// void paintEvent(QPaintEvent *event); /** * @brief fill application list */ diff --git a/src/LetterWidget/letterbuttonwidget.cpp b/src/LetterWidget/letterbuttonwidget.cpp index 31aa016..0af01bb 100644 --- a/src/LetterWidget/letterbuttonwidget.cpp +++ b/src/LetterWidget/letterbuttonwidget.cpp @@ -35,7 +35,6 @@ void LetterButtonWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); this->resize(235,366); QGridLayout* gridLayout=new QGridLayout; @@ -43,14 +42,6 @@ void LetterButtonWidget::initUi() gridLayout->setSpacing(5); this->setLayout(gridLayout); - char btncolor[400]; - sprintf(btncolor,"QToolButton{background:transparent;color:#ffffff;padding-left:0px;}\ - QToolButton:hover{background-color:%s;color:#ffffff;border-radius:4px;}\ - QToolButton:pressed{background-color:%s;color:#ffffff;border-radius:4px;}\ - QToolButton:disabled{color:rgba(255, 255, 255, 0.25);}", - ClassifyBtnHoverBackground, - ClassifyBtnHoverBackground); - QStringList letterlist; letterlist.clear(); for(int i=0;i<26;i++) @@ -67,12 +58,12 @@ void LetterButtonWidget::initUi() { if(row*4+colsetFlat(true); + btn->setCheckable(false); btn->setFixedSize(55,48); - btn->setStyleSheet(QString::fromLocal8Bit(btncolor)); - btn->setText(letterlist.at(row*4+col)); gridLayout->addWidget(btn,row,col); - connect(btn, &QToolButton::clicked, this, &LetterButtonWidget::letterBtnClickedSlot); + connect(btn,&LetterClassifyButton::buttonClicked,this, &LetterButtonWidget::letterBtnClickedSlot); } else { break; @@ -86,7 +77,7 @@ void LetterButtonWidget::initUi() */ void LetterButtonWidget::letterBtnClickedSlot() { - QToolButton* btn=dynamic_cast(QObject::sender()); + LetterClassifyButton* btn=dynamic_cast(QObject::sender()); QString btnname=btn->text(); Q_EMIT sendLetterBtnSignal(btnname); } @@ -102,7 +93,7 @@ void LetterButtonWidget::recvLetterBtnList(QStringList list) for(int col=0;col<4;col++) { QLayoutItem* item=gridLayout->itemAt(row*4+col); - QToolButton* btn=static_cast(item->widget()); + LetterClassifyButton* btn=static_cast(item->widget()); QString letterstr=btn->text(); if(list.indexOf(letterstr.at(0))==-1) btn->setEnabled(false); diff --git a/src/LetterWidget/letterbuttonwidget.h b/src/LetterWidget/letterbuttonwidget.h index 904166c..7c03a67 100644 --- a/src/LetterWidget/letterbuttonwidget.h +++ b/src/LetterWidget/letterbuttonwidget.h @@ -26,7 +26,7 @@ #include #include #include -#include "src/UtilityFunction/functionclassifybutton.h" +#include "src/UtilityFunction/letterclassifybutton.h" class LetterButtonWidget : public QWidget { diff --git a/src/LetterWidget/letterwidget.cpp b/src/LetterWidget/letterwidget.cpp index 3c13fca..153a2b5 100644 --- a/src/LetterWidget/letterwidget.cpp +++ b/src/LetterWidget/letterwidget.cpp @@ -47,7 +47,6 @@ void LetterWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); @@ -72,8 +71,8 @@ void LetterWidget::initUi() */ void LetterWidget::initAppListWidget() { - m_appListView=new ListView(this,this->width()-4,this->height(),1); - m_appListView->setGeometry(QRect(0,0,this->width()-4,this->height())); + m_appListView=new ListView(this,this->width()-6,this->height()-6,1); + m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_appListView->show(); fillAppListView(); connect(m_appListView,&ListView::sendItemClickedSignal,this,&LetterWidget::recvItemClickedSlot); @@ -176,7 +175,7 @@ void LetterWidget::updateAppListView() */ void LetterWidget::appClassificationBtnClickedSlot() { - m_leaveAnimation->setStartValue(QRect(0,0,this->width()-4,this->height())); + m_leaveAnimation->setStartValue(QRect(6,0,this->width()-6,this->height()-6)); m_leaveAnimation->setEndValue(QRect(20,20,this->width()-40,this->height()-40)); m_enterAnimation->setStartValue(QRect(-40,-40,this->width()+80,this->height()+80)); m_enterAnimation->setEndValue(QRect((this->width()-235)/2,(this->height()-366)/2,235,366)); @@ -208,7 +207,7 @@ void LetterWidget::recvLetterBtnSlot(QString btnname) m_leaveAnimation->setStartValue(QRect((this->width()-235)/2,(this->height()-366)/2,235,366)); m_leaveAnimation->setEndValue(QRect(-40,-40,this->width()+80,this->height()+80)); m_enterAnimation->setStartValue(QRect(20,20,this->width()-40,this->height()-40)); - m_enterAnimation->setEndValue(QRect(0,0,this->width()-4,this->height())); + m_enterAnimation->setEndValue(QRect(6,0,this->width()-6,this->height()-6)); m_leaveAnimation->setDuration(80); m_enterAnimation->setDuration(10); @@ -239,7 +238,7 @@ void LetterWidget::animationFinishedSLot() void LetterWidget::widgetMakeZero() { m_letterBtnWid->hide(); - m_appListView->setGeometry(QRect(0,0,this->width()-4,this->height())); + m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_appListView->show(); m_appListView->verticalScrollBar()->setValue(0); } @@ -255,6 +254,6 @@ void LetterWidget::moveScrollBar(int type) void LetterWidget::repaintWidget() { this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); - m_appListView->setGeometry(QRect(0,0,this->width()-4,this->height())); + m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_appListView->show(); } diff --git a/src/MainViewWidget/mainviewwidget.cpp b/src/MainViewWidget/mainviewwidget.cpp index fc5c0cc..07bb13f 100644 --- a/src/MainViewWidget/mainviewwidget.cpp +++ b/src/MainViewWidget/mainviewwidget.cpp @@ -33,15 +33,6 @@ MainViewWidget::MainViewWidget(QWidget *parent) : MainViewWidget::~MainViewWidget() { -// delete m_commonUseWid; -// delete m_fullCommonUseWid; -// delete m_letterWid; -// delete m_fullLetterWid; -// delete m_functionWid; -// delete m_fullFunctionWid; -// delete m_searchResultWid; -// delete m_fullSearchResultWid; - delete m_ukuiMenuInterface; delete m_fileWatcher; delete m_directoryChangedThread; @@ -54,29 +45,29 @@ void MainViewWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); + this->setAttribute(Qt::WA_TranslucentBackground); QVBoxLayout* mainLayout=new QVBoxLayout; mainLayout->setContentsMargins(0,0,0,0); mainLayout->setSpacing(0); m_topWidget=new QWidget; - m_topWidget->setStyleSheet("border:0px;background:transparent;"); + m_contentWid=new QWidget; - m_verticalSpacer=new QSpacerItem(20,40, QSizePolicy::Fixed, QSizePolicy::Expanding); mainLayout->addWidget(m_topWidget); - mainLayout->addItem(m_verticalSpacer); + mainLayout->addWidget(m_contentWid); this->setLayout(mainLayout); this->setFocusPolicy(Qt::NoFocus); - m_commonUseWid=new CommonUseWidget; - m_fullCommonUseWid=new FullCommonUseWidget; - m_letterWid=new LetterWidget; - m_functionWid=new FunctionWidget; - m_fullLetterWid=new FullLetterWidget; - m_fullFunctionWid=new FullFunctionWidget; - m_fullSearchResultWid=new FullSearchResultWidget; - m_searchResultWid=new SearchResultWidget; + m_commonUseWid=new CommonUseWidget(m_contentWid); + m_fullCommonUseWid=new FullCommonUseWidget(m_contentWid); + m_letterWid=new LetterWidget(m_contentWid); + m_functionWid=new FunctionWidget(m_contentWid); + m_fullLetterWid=new FullLetterWidget(m_contentWid); + m_fullFunctionWid=new FullFunctionWidget(m_contentWid); + m_fullSearchResultWid=new FullSearchResultWidget(m_contentWid); + m_searchResultWid=new SearchResultWidget(m_contentWid); + hideWidget(); m_ukuiMenuInterface=new UkuiMenuInterface; @@ -105,8 +96,9 @@ void MainViewWidget::initUi() addTopControl(); //加载默认视图 + //搜索区 this->setFixedSize(Style::defaultMainViewWidWidth,Style::minh); - m_topWidget->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultTopWidHeight); + m_topWidget->setFixedSize(this->width(),Style::defaultTopWidHeight); m_topLayout->setContentsMargins(0,0,0,0); m_topLayout->setAlignment(m_queryLineEdit,Qt::AlignCenter); m_queryLineEdit->setFixedSize(Style::defaultQueryLineEditWidth,Style::defaultQueryLineEditHeight); @@ -114,7 +106,10 @@ void MainViewWidget::initUi() m_queryWid->setGeometry(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0, m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight)); m_queryWid->show(); - mainLayout->insertWidget(1,m_commonUseWid); + //内容区 + m_contentWid->setFixedSize(this->width(),this->height()-m_topWidget->height()); + m_commonUseWid->setGeometry(0,0,Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); + m_commonUseWid->show(); m_widgetState=1; m_saveCurrentWidState=1; @@ -143,11 +138,17 @@ void MainViewWidget::addTopControl() m_topLayout=new QHBoxLayout; m_topLayout->setSpacing(0); m_queryLineEdit=new QLineEdit; - char style[100]; - sprintf(style, "QLineEdit{border:0px;background-color:%s;border-radius:4px;}",QueryLineEditBackground); - m_queryLineEdit->setStyleSheet(style); m_topLayout->addWidget(m_queryLineEdit); m_topWidget->setLayout(m_topLayout); + char style[200]; + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + if(gsetting.get("style-name").toString()=="ukui-light") + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedBorderDefault,QueryLineEditDefaultBackground); + else + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder,QueryLineEditBackground); + m_queryLineEdit->setStyleSheet(style); initQueryLineEdit(); @@ -161,22 +162,27 @@ void MainViewWidget::initQueryLineEdit() m_queryWid=new QWidget; m_queryWid->setParent(m_queryLineEdit); m_queryWid->setFocusPolicy(Qt::NoFocus); - m_queryWid->setStyleSheet("border:0px;background:transparent"); QHBoxLayout* queryWidLayout=new QHBoxLayout; - queryWidLayout->setContentsMargins(5,0,0,0); + queryWidLayout->setContentsMargins(0,0,0,0); queryWidLayout->setSpacing(5); m_queryWid->setLayout(queryWidLayout); QPixmap pixmap=loadSvg(QString(":/data/img/mainviewwidget/search.svg"),16); + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + if(gsetting.get("style-name").toString()=="ukui-light")//反黑 + pixmap=drawSymbolicBlackColoredPixmap(pixmap); + else + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); m_queryIcon=new QLabel; - m_queryIcon->setStyleSheet("background:transparent"); m_queryIcon->setFixedSize(pixmap.size()); m_queryIcon->setPixmap(pixmap); m_queryText=new QLabel; m_queryText->setText(tr("Search")); - m_queryText->setStyleSheet("background:transparent;color:#626c6e;"); m_queryText->adjustSize(); queryWidLayout->addWidget(m_queryIcon); queryWidLayout->addWidget(m_queryText); + queryWidLayout->setAlignment(m_queryIcon,Qt::AlignVCenter); + queryWidLayout->setAlignment(m_queryText,Qt::AlignVCenter); m_queryLineEdit->setFocusPolicy(Qt::ClickFocus); m_queryLineEdit->installEventFilter(this); m_queryLineEdit->setContextMenuPolicy(Qt::NoContextMenu); @@ -197,12 +203,23 @@ bool MainViewWidget::eventFilter(QObject *watched, QEvent *event) { if(watched==m_queryLineEdit) { + char style[200]; if(event->type()==QEvent::FocusIn) { - char style[200]; - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder,QueryLineEditClickedBackground); - m_queryLineEdit->setStyleSheet(style); + if(!m_isFullScreen) + { + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + if(gsetting.get("style-name").toString()=="ukui-light") + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedBorderDefault,QueryLineEditClickedDefaultBackground); + else + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder,QueryLineEditClickedBackground); + } + else + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder,QueryLineEditClickedBackground); + m_queryLineEdit->setStyleSheet(style); if(!m_queryLineEdit->text().isEmpty()) { if(m_searchKeyWords.isEmpty()) @@ -210,6 +227,8 @@ bool MainViewWidget::eventFilter(QObject *watched, QEvent *event) } else { + m_queryWid->layout()->removeWidget(m_queryText); + m_queryText->setParent(nullptr); m_animation->stop(); m_animation->setStartValue(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0, m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight)); @@ -217,7 +236,6 @@ bool MainViewWidget::eventFilter(QObject *watched, QEvent *event) m_queryIcon->width()+5,Style::QueryLineEditHeight)); m_animation->setEasingCurve(QEasingCurve::OutQuad); m_animation->start(); -// m_queryLineEdit->setReadOnly(true); m_queryLineEdit->setTextMargins(-5,1,0,1); } m_isSearching=true; @@ -229,10 +247,21 @@ bool MainViewWidget::eventFilter(QObject *watched, QEvent *event) { if(m_isSearching) { - char style[100]; - sprintf(style, "QLineEdit{border:0px;background-color:%s;border-radius:4px;}",QueryLineEditBackground); - m_animation->stop(); + if(!m_isFullScreen) + { + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + if(gsetting.get("style-name").toString()=="ukui-light") + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedBorderDefault,QueryLineEditDefaultBackground); + else + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder,QueryLineEditBackground); + } + else + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder,QueryLineEditBackground); m_queryLineEdit->setStyleSheet(style); + m_animation->stop(); m_queryText->adjustSize(); m_animation->setStartValue(QRect(0,0, m_queryIcon->width()+5,Style::QueryLineEditHeight)); @@ -242,10 +271,21 @@ bool MainViewWidget::eventFilter(QObject *watched, QEvent *event) m_animation->start(); } } - else { - char style[100]; - sprintf(style, "QLineEdit{border:0px;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditBackground); + else + { + if(!m_isFullScreen) + { + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + if(gsetting.get("style-name").toString()=="ukui-light") + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedDefaultBackground,QueryLineEditDefaultBackground); + else + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder,QueryLineEditBackground); + } + else + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder,QueryLineEditBackground); m_queryLineEdit->setStyleSheet(style); } m_isSearching=false; @@ -271,73 +311,57 @@ void MainViewWidget::setLineEditFocus(QString arg) */ void MainViewWidget::searchAppSlot(QString arg) { -// if(!m_isHiden) -// { - if(!arg.isEmpty())//切换至搜索模块 + if(!arg.isEmpty())//切换至搜索模块 + { + if(m_widgetState!=0) { - if(m_widgetState!=0) - { - QLayoutItem* child; - if((child=this->layout()->takeAt(1))!=nullptr) - { - QWidget* childWid=child->widget(); - if(childWid!=nullptr) - { - this->layout()->removeWidget(childWid); - childWid->setParent(nullptr); - } - } - m_widgetState=0; - QVBoxLayout *layout=qobject_cast(this->layout()); - if(!m_isFullScreen) - layout->insertWidget(1,m_searchResultWid); - else - layout->insertWidget(1,m_fullSearchResultWid); - } - Q_EMIT sendSearchKeyword(arg); - m_searchAppThread->start(); + m_widgetState=0; + if(!m_isFullScreen) + loadSearchResultWidget(); + else + loadFullSearchResultWidget(); } - else{//切换至分类模块 - if(m_isFullScreen) - { - switch (m_saveCurrentWidState) { - case 1: - loadFullCommonUseWidget(); - break; - case 2: - loadFullLetterWidget(); - break; - case 3: - loadFullFunctionWidget(); - default: - break; - } + Q_EMIT sendSearchKeyword(arg); + m_searchAppThread->start(); + } + else{//搜索模块显示所有的软件 + if(m_isFullScreen) + { + switch (m_saveCurrentWidState) { + case 1: + loadFullCommonUseWidget(); + break; + case 2: + loadFullLetterWidget(); + break; + case 3: + loadFullFunctionWidget(); + default: + break; } - else { - switch (m_saveCurrentWidState) { - case 1: - loadCommonUseWidget(); - break; - case 2: - loadLetterWidget(); - break; - case 3: - loadFunctionWidget(); - break; - default: - break; - } + } + else { + switch (m_saveCurrentWidState) { + case 1: + loadCommonUseWidget(); + break; + case 2: + loadLetterWidget(); + break; + case 3: + loadFunctionWidget(); + break; + default: + break; } } - -// } -// else -// m_widgetState=m_saveCurrentWidState; + } } void MainViewWidget::recvSearchResult(QVector arg) { m_searchAppThread->quit(); + m_searchAppThread->wait(); m_fullSearchResultWid->updateAppListView(arg); m_searchResultWid->updateAppListView(arg); } @@ -346,8 +370,8 @@ void MainViewWidget::animationFinishedSlot() { if(m_isSearching)//进入搜索状态 { - m_queryWid->layout()->removeWidget(m_queryText); - m_queryText->setParent(nullptr); +// m_queryWid->layout()->removeWidget(m_queryText); +// m_queryText->setParent(nullptr); m_queryLineEdit->setTextMargins(20,1,0,1); if(!m_searchKeyWords.isEmpty()) { @@ -356,7 +380,28 @@ void MainViewWidget::animationFinishedSlot() } } else//退出搜索状态 + { m_queryWid->layout()->addWidget(m_queryText); + m_queryWid->layout()->setAlignment(m_queryIcon,Qt::AlignVCenter); + m_queryWid->layout()->setAlignment(m_queryText,Qt::AlignVCenter); + QPalette pe = m_queryText->palette(); + if(!m_isFullScreen) + { + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + if(gsetting.get("style-name").toString()=="ukui-light")//反黑 + { + pe.setColor(QPalette::Text,QColor(Qt::black)); + } + else + { + pe.setColor(QPalette::Text,QColor(Qt::white)); + } + } + else + pe.setColor(QPalette::Text,QColor(Qt::white)); + + m_queryText->setPalette(pe); + } } /** @@ -365,34 +410,53 @@ void MainViewWidget::animationFinishedSlot() void MainViewWidget::loadMinMainView() { this->setFixedSize(Style::defaultMainViewWidWidth,Style::minh); - m_topWidget->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultTopWidHeight); + //搜索区 + m_topWidget->setFixedSize(this->width(),Style::defaultTopWidHeight); m_topLayout->setContentsMargins(0,0,0,0); m_topLayout->setAlignment(m_queryLineEdit,Qt::AlignCenter); m_queryLineEdit->setFixedSize(Style::defaultQueryLineEditWidth,Style::defaultQueryLineEditHeight); if(m_queryLineEdit->text().isEmpty()) { if(m_queryWid->layout()->count()==1) + { m_queryWid->layout()->addWidget(m_queryText); + m_queryWid->layout()->setAlignment(m_queryIcon,Qt::AlignVCenter); + m_queryWid->layout()->setAlignment(m_queryText,Qt::AlignVCenter); + } m_queryText->adjustSize(); m_queryWid->setGeometry(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0, m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight)); m_queryWid->show(); } + char style[200]; + QPalette pe = m_queryText->palette(); + QPixmap pixmap=loadSvg(QString(":/data/img/mainviewwidget/search.svg"),16); + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + if(gsetting.get("style-name").toString()=="ukui-light") + { + pixmap=drawSymbolicBlackColoredPixmap(pixmap);//反黑 + pe.setColor(QPalette::Text,QColor(Qt::black)); + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedBorderDefault,QueryLineEditDefaultBackground); + } + else + { + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 + pe.setColor(QPalette::Text,QColor(Qt::white)); + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder,QueryLineEditBackground); + } + m_queryLineEdit->setStyleSheet(style); + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + m_queryIcon->setPixmap(pixmap); + m_queryText->setPalette(pe); + + //内容区 + m_contentWid->setFixedSize(this->width(),this->height()-m_topWidget->height()); if(m_widgetState==0) { - QLayoutItem* child; - if((child=this->layout()->takeAt(1))!=nullptr) - { - QWidget* childWid=child->widget(); - if(childWid!=nullptr) - { - this->layout()->removeWidget(childWid); - childWid->setParent(nullptr); - } - } - QVBoxLayout *layout=qobject_cast(this->layout()); - layout->insertWidget(1,m_searchResultWid); + loadSearchResultWidget(); } else if(m_widgetState==1) loadCommonUseWidget(); @@ -401,7 +465,6 @@ void MainViewWidget::loadMinMainView() else if(m_widgetState==3) loadFunctionWidget(); m_isFullScreen=false; -// m_isHiden=false; } /** @@ -411,6 +474,7 @@ void MainViewWidget::loadMaxMainView() { this->setFixedSize(Style::MainViewWidWidth, Style::heightavailable); + //搜索区 m_topWidget->setFixedSize(this->width(),Style::TopWidgetHeight); m_queryLineEdit->setFixedSize(Style::QueryLineEditWidth,Style::QueryLineEditHeight); @@ -422,27 +486,36 @@ void MainViewWidget::loadMaxMainView() if(m_queryLineEdit->text().isEmpty()) { if(m_queryWid->layout()->count()==1) + { m_queryWid->layout()->addWidget(m_queryText); + m_queryWid->layout()->setAlignment(m_queryIcon,Qt::AlignVCenter); + m_queryWid->layout()->setAlignment(m_queryText,Qt::AlignVCenter); + } m_queryText->adjustSize(); m_queryWid->setGeometry(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0, m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight)); m_queryWid->show(); } + char style[200]; + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder,QueryLineEditBackground); + m_queryLineEdit->setStyleSheet(style); + + QPixmap pixmap=loadSvg(QString(":/data/img/mainviewwidget/search.svg"),16); + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 + QPalette pe = m_queryText->palette(); + pe.setColor(QPalette::Text,QColor(Qt::white)); + m_queryText->setPalette(pe); + + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + m_queryIcon->setPixmap(pixmap); + + //内容区 + m_contentWid->setFixedSize(this->width(),this->height()-m_topWidget->height()); if(m_widgetState==0) { - QLayoutItem* child; - if((child=this->layout()->takeAt(1))!=nullptr) - { - QWidget* childWid=child->widget(); - if(childWid!=nullptr) - { - this->layout()->removeWidget(childWid); - childWid->setParent(nullptr); - } - } - QVBoxLayout *layout=qobject_cast(this->layout()); - layout->insertWidget(1,m_fullSearchResultWid); + loadFullSearchResultWidget(); } else if(m_widgetState==1) loadFullCommonUseWidget(); @@ -451,7 +524,6 @@ void MainViewWidget::loadMaxMainView() else if(m_widgetState==3) loadFullFunctionWidget(); m_isFullScreen=true; -// m_isHiden=false; } void MainViewWidget::resizeControl() @@ -472,6 +544,7 @@ void MainViewWidget::resizeControl() 0, (m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2, 0); + m_contentWid->setFixedSize(this->width(),this->height()-m_topWidget->height()); } else { @@ -479,6 +552,7 @@ void MainViewWidget::resizeControl() m_topWidget->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultTopWidHeight); m_topLayout->setContentsMargins(0,0,0,0); m_topLayout->setAlignment(m_queryLineEdit,Qt::AlignCenter); + m_contentWid->setFixedSize(this->width(),this->height()-m_topWidget->height()); } } @@ -493,19 +567,11 @@ void MainViewWidget::loadCommonUseWidget() m_fullLetterWid->widgetMakeZero(); m_functionWid->widgetMakeZero(); m_fullFunctionWid->widgetMakeZero(); - QLayoutItem *child; - if((child = this->layout()->takeAt(1)) != nullptr) { - QWidget* childwid=child->widget(); - if(childwid!=nullptr) - { - this->layout()->removeWidget(childwid); - childwid->setParent(nullptr); - } - - } - QVBoxLayout *layout=qobject_cast(this->layout()); - layout->insertWidget(1,m_commonUseWid); + hideWidget(); + m_commonUseWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); + m_commonUseWid->show(); m_commonUseWid->updateListView(); + this->layout()->update(); m_widgetState=1; m_saveCurrentWidState=1; } @@ -520,18 +586,9 @@ void MainViewWidget::loadLetterWidget() m_fullLetterWid->widgetMakeZero(); m_functionWid->widgetMakeZero(); m_fullFunctionWid->widgetMakeZero(); - QLayoutItem *child; - if((child = this->layout()->takeAt(1)) != nullptr) { - QWidget* childwid=child->widget(); - if(childwid!=nullptr) - { - this->layout()->removeWidget(childwid); - childwid->setParent(nullptr); - } - - } - QVBoxLayout *layout=qobject_cast(this->layout()); - layout->insertWidget(1,m_letterWid); + hideWidget(); + m_letterWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); + m_letterWid->show(); m_widgetState=2; m_saveCurrentWidState=2; } @@ -546,18 +603,9 @@ void MainViewWidget::loadFunctionWidget() m_letterWid->widgetMakeZero(); m_fullLetterWid->widgetMakeZero(); m_fullFunctionWid->widgetMakeZero(); - QLayoutItem *child; - if((child = this->layout()->takeAt(1)) != nullptr) { - QWidget* childwid=child->widget(); - if(childwid!=nullptr) - { - this->layout()->removeWidget(childwid); - childwid->setParent(nullptr); - } - - } - QVBoxLayout *layout=qobject_cast(this->layout()); - layout->insertWidget(1,m_functionWid); + hideWidget(); + m_functionWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); + m_functionWid->show(); m_widgetState=3; m_saveCurrentWidState=3; } @@ -573,18 +621,9 @@ void MainViewWidget::loadFullCommonUseWidget() m_fullLetterWid->widgetMakeZero(); m_functionWid->widgetMakeZero(); m_fullFunctionWid->widgetMakeZero(); - QLayoutItem *child; - if((child = this->layout()->takeAt(1)) != nullptr) { - QWidget* childwid=child->widget(); - if(childwid!=nullptr) - { - this->layout()->removeWidget(childwid); - childwid->setParent(nullptr); - } - - } - QVBoxLayout *layout=qobject_cast(this->layout()); - layout->insertWidget(1,m_fullCommonUseWid); + hideWidget(); + m_fullCommonUseWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); + m_fullCommonUseWid->show(); m_fullCommonUseWid->updateListView(); m_widgetState=1; m_saveCurrentWidState=1; @@ -600,19 +639,11 @@ void MainViewWidget::loadFullLetterWidget() m_letterWid->widgetMakeZero(); m_functionWid->widgetMakeZero(); m_fullFunctionWid->widgetMakeZero(); - QLayoutItem *child; - if((child = this->layout()->takeAt(1)) != nullptr) { - QWidget* childwid=child->widget(); - if(childwid!=nullptr) - { - this->layout()->removeWidget(childwid); - childwid->setParent(nullptr); - } - } - QVBoxLayout *layout=qobject_cast(this->layout()); - layout->insertWidget(1,m_fullLetterWid); - if(!m_isFullScreen || (m_isFullScreen && m_saveCurrentWidState!=2)) - m_fullLetterWid->enterAnimation(); + hideWidget(); + m_fullLetterWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); + m_fullLetterWid->show(); +// if(!m_isFullScreen || (m_isFullScreen && m_saveCurrentWidState!=2)) + m_fullLetterWid->enterAnimation(); m_widgetState=2; m_saveCurrentWidState=2; } @@ -627,24 +658,41 @@ void MainViewWidget::loadFullFunctionWidget() m_letterWid->widgetMakeZero(); m_fullLetterWid->widgetMakeZero(); m_functionWid->widgetMakeZero(); - QLayoutItem *child; - if((child = this->layout()->takeAt(1)) != nullptr) { - QWidget* childwid=child->widget(); - if(childwid!=nullptr) - { - this->layout()->removeWidget(childwid); - childwid->setParent(nullptr); - } - - } - QVBoxLayout *layout=qobject_cast(this->layout()); - layout->insertWidget(1,m_fullFunctionWid); - if(!m_isFullScreen || (m_isFullScreen && m_saveCurrentWidState!=3)) - m_fullFunctionWid->enterAnimation(); + hideWidget(); + m_fullFunctionWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); + m_fullFunctionWid->show(); +// if(!m_isFullScreen || (m_isFullScreen && m_saveCurrentWidState!=3)) + m_fullFunctionWid->enterAnimation(); m_widgetState=3; m_saveCurrentWidState=3; } +void MainViewWidget::loadSearchResultWidget() +{ + hideWidget(); + m_searchResultWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); + m_searchResultWid->show(); +} + +void MainViewWidget::loadFullSearchResultWidget() +{ + hideWidget(); + m_fullSearchResultWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); + m_fullSearchResultWid->show(); +} + +void MainViewWidget::hideWidget() +{ + m_commonUseWid->hide(); + m_fullCommonUseWid->hide(); + m_letterWid->hide(); + m_fullLetterWid->hide(); + m_functionWid->hide(); + m_fullFunctionWid->hide(); + m_searchResultWid->hide(); + m_fullSearchResultWid->hide(); +} + /** * 进程开启监控槽函数 */ @@ -730,7 +778,6 @@ void MainViewWidget::repaintWidget() void MainViewWidget::widgetMakeZero() { -// m_isHiden=true; m_isSearching=false; m_widgetState=m_saveCurrentWidState; m_commonUseWid->widgetMakeZero(); @@ -743,9 +790,6 @@ void MainViewWidget::widgetMakeZero() m_queryLineEdit->clear(); m_queryLineEdit->clearFocus(); m_queryLineEdit->blockSignals(false); - char style[100]; - sprintf(style, "QLineEdit{border:0px;background-color:%s;border-radius:2px;}",QueryLineEditBackground); - m_queryLineEdit->setStyleSheet(style); m_queryLineEdit->setTextMargins(0,1,0,1); } diff --git a/src/MainViewWidget/mainviewwidget.h b/src/MainViewWidget/mainviewwidget.h index 0df64b7..eb0a63a 100644 --- a/src/MainViewWidget/mainviewwidget.h +++ b/src/MainViewWidget/mainviewwidget.h @@ -88,7 +88,7 @@ private: QWidget *m_topWidget=nullptr; QHBoxLayout *m_topLayout=nullptr; - QSpacerItem *m_verticalSpacer=nullptr; + QWidget *m_contentWid=nullptr; QLineEdit *m_queryLineEdit=nullptr; QWidget *m_queryWid=nullptr; @@ -134,6 +134,10 @@ protected: * @brief Initializes the query box */ void initQueryLineEdit(); +// void paintEvent(QPaintEvent* event); + void loadSearchResultWidget(); + void loadFullSearchResultWidget(); + void hideWidget(); public Q_SLOTS: /** diff --git a/src/MainWindow/mainwindow.cpp b/src/MainWindow/mainwindow.cpp index 0329518..7f72fcc 100644 --- a/src/MainWindow/mainwindow.cpp +++ b/src/MainWindow/mainwindow.cpp @@ -25,6 +25,7 @@ #include #include "src/XEventMonitor/xeventmonitor.h" #include "src/Style/style.h" +#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) @@ -33,7 +34,7 @@ MainWindow::MainWindow(QWidget *parent) : UkuiMenuInterface::appInfoVector=m_ukuiMenuInterface->createAppInfoVector(); UkuiMenuInterface::alphabeticVector=m_ukuiMenuInterface->getAlphabeticClassification(); UkuiMenuInterface::functionalVector=m_ukuiMenuInterface->getFunctionalClassification(); - UkuiMenuInterface::allAppVector=m_ukuiMenuInterface->getAllApp(); + UkuiMenuInterface::allAppVector=m_ukuiMenuInterface->getAllClassification(); Style::initWidStyle(); QString path=QDir::homePath()+"/.config/ukui/ukui-menu.ini"; m_setting=new QSettings(path,QSettings::IniFormat); @@ -71,10 +72,8 @@ void MainWindow::initUi() m_line=new QFrame; m_line->setFrameShape(QFrame::VLine); m_line->setFixedSize(1,this->height()); + m_line->setEnabled(false); mainlayout->addWidget(m_line); - char linestyle[100]; - sprintf(linestyle, "background-color:%s;",LineBackground); - m_line->setStyleSheet(linestyle); mainlayout->addWidget(m_sideBarWid); m_animation = new QPropertyAnimation(this, "geometry"); @@ -125,6 +124,93 @@ void MainWindow::initUi() // QString("sendStartMenuSignal"),this,SLOT(recvStartMenuSlot())); } +void MainWindow::paintEvent(QPaintEvent *event) +{ + QGSettings* gsetting=new QGSettings(QString("org.ukui.control-center.personalise").toLocal8Bit()); + double transparency=gsetting->get("transparency").toDouble(); + qreal radius = 0; + QRect rect = this->rect(); + rect.setWidth(rect.width()); + rect.setHeight(rect.height()); + rect.setX(this->rect().x()); + rect.setY(this->rect().y()); + rect.setWidth(this->rect().width()); + rect.setHeight(this->rect().height()); + if(!m_isFullScreen) + { + radius=6; + } + else + { + radius=0; + } + QPainterPath path; + path.moveTo(rect.topRight() - QPointF(radius, 0)); + path.lineTo(rect.topLeft() + QPointF(radius, 0)); + path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); + path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); + path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); + path.lineTo(rect.bottomRight() - QPointF(radius, 0)); + path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); + path.lineTo(rect.topRight() + QPointF(0, radius)); + path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); + + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setPen(Qt::transparent); + if(!m_isFullScreen) + { + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawPath(path); + setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); + } + else//全屏固定背景色(黑底白字) + { +// QGSettings gsetting(QString("org.mate.background").toLocal8Bit()); +// QString iconPath =gsetting.get("picture-filename").toString(); +// painter.drawPixmap(0,0,this->width(),this->height(),QPixmap(iconPath)); + + if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) + { + QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); + if(gsetting.keys().contains(QString("effect"))) + { + if(gsetting.get("effect").toBool()) + { + painter.setBrush(Qt::black); + painter.setPen(Qt::transparent); + painter.setOpacity(0.25); + painter.drawRect(this->rect()); + } + else + { + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); + } + } + else + { + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); + } + } + else + { + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); + } + } + QMainWindow::paintEvent(event); +} + /** * 显示全屏窗口 */ @@ -282,7 +368,7 @@ void MainWindow::animationValueFinishedSlot() m_sideBarWid->loadMinSidebar(); m_mainViewWid->loadMinMainView(); } - setFrameStyle(); +// setFrameStyle(); } /** @@ -447,20 +533,42 @@ void MainWindow::loadMainWindow() int y=QApplication::primaryScreen()->geometry().y(); if(m_isFullScreen) { + //修复界面黑框问题 + QRect startRect; + QRect endRect; if(position==0) - this->setGeometry(QRect(x,y,QApplication::primaryScreen()->geometry().width(),QApplication::primaryScreen()->geometry().height()-panelSize)); + { + startRect.setRect(x,y+QApplication::primaryScreen()->geometry().height()-panelSize-Style::minh,Style::minw,Style::minh); + endRect.setRect(x,y,QApplication::primaryScreen()->geometry().width(),QApplication::primaryScreen()->geometry().height()-panelSize); + } else if(position==1) - this->setGeometry(QRect(x,y+panelSize,QApplication::primaryScreen()->geometry().width(),QApplication::primaryScreen()->geometry().height()-panelSize)); + { + startRect.setRect(x,y+panelSize,Style::minw,Style::minh); + endRect.setRect(x,y+panelSize,QApplication::primaryScreen()->geometry().width(),QApplication::primaryScreen()->geometry().height()-panelSize); + } else if(position==2) - this->setGeometry(QRect(x+panelSize,y,QApplication::primaryScreen()->geometry().width()-panelSize,QApplication::primaryScreen()->geometry().height())); + { + startRect.setRect(x+panelSize,y,Style::minw,Style::minh); + endRect.setRect(x+panelSize,y,QApplication::primaryScreen()->geometry().width()-panelSize,QApplication::primaryScreen()->geometry().height()); + } else - this->setGeometry(QRect(x,y,QApplication::primaryScreen()->geometry().width()-panelSize,QApplication::primaryScreen()->geometry().height())); - m_sideBarWid->loadMaxSidebar(); - m_sideBarWid->setSideBarBtnGeometry(); - m_mainViewWid->loadMaxMainView(); - QPainterPath path; - path.addRect(this->rect()); - setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); + { + startRect.setRect(x+QApplication::primaryScreen()->geometry().width()-panelSize-Style::minw,y,Style::minw,Style::minh); + endRect.setRect(x,y,QApplication::primaryScreen()->geometry().width()-panelSize,QApplication::primaryScreen()->geometry().height()); + } + + this->centralWidget()->layout()->removeWidget(m_mainViewWid); + m_mainViewWid->setParent(nullptr); + this->centralWidget()->layout()->removeWidget(m_line); + m_line->setParent(nullptr); + this->centralWidget()->layout()->removeWidget(m_sideBarWid); + m_sideBarWid->setParent(nullptr); + + m_animation->setDuration(1);//动画总时间 + m_animation->setStartValue(startRect); + m_animation->setEndValue(endRect); + m_animation->setEasingCurve(QEasingCurve::Linear); + m_animation->start(); } else { @@ -478,75 +586,6 @@ void MainWindow::loadMainWindow() m_sideBarWid->loadMinSidebar(); m_mainViewWid->loadMinMainView(); } - setFrameStyle(); - - //默认开启默认态 -// if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.desktop").toLocal8Bit())) -// { -// QGSettings* gsetting=new QGSettings(QString("org.ukui.control-center.desktop").toLocal8Bit()); -// bool ret=false; -// if(gsetting->keys().contains(QString("menufullScreen"))) -// ret=gsetting->get("menufull-screen").toBool(); -// if(ret) -// { -// if(position==0) -// this->setGeometry(QRect(x,y,QApplication::primaryScreen()->geometry().width(),QApplication::primaryScreen()->geometry().height()-panelSize)); -// else if(position==1) -// this->setGeometry(QRect(x,y+panelSize,QApplication::primaryScreen()->geometry().width(),QApplication::primaryScreen()->geometry().height()-panelSize)); -// else if(position==2) -// this->setGeometry(QRect(x+panelSize,y,QApplication::primaryScreen()->geometry().width()-panelSize,QApplication::primaryScreen()->geometry().height())); -// else -// this->setGeometry(QRect(x,y,QApplication::primaryScreen()->geometry().width()-panelSize,QApplication::primaryScreen()->geometry().height())); -// this->centralWidget()->layout()->removeWidget(m_line); -// m_line->setParent(nullptr); -// m_sideBarWid->loadMaxSidebar(); -// m_mainViewWid->loadMaxMainView(); -// m_sideBarWid->enterAnimation(); -// QPainterPath path; -// path.addRect(this->rect()); -// setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); -// m_isFullScreen=true; -// } -// else -// { -// if(position==0) -// this->setGeometry(QRect(x,y+QApplication::primaryScreen()->geometry().height()-panelSize-Style::minh, -// Style::minw,Style::minh)); -// else if(position==1) -// this->setGeometry(QRect(x,y+panelSize,Style::minw,Style::minh)); -// else if(position==2) -// this->setGeometry(QRect(x+panelSize,y,Style::minw,Style::minh)); -// else -// this->setGeometry(QRect(x+QApplication::primaryScreen()->geometry().width()-panelSize-Style::minw,y, -// Style::minw,Style::minh)); -// QHBoxLayout* mainLayout=qobject_cast(this->centralWidget()->layout()); -// mainLayout->insertWidget(1,m_line); -// m_sideBarWid->loadMinSidebar(); -// m_mainViewWid->loadMinMainView(); -// m_isFullScreen=false; -// } -// } -// else -// { -// if(position==0) -// this->setGeometry(QRect(x,y+QApplication::primaryScreen()->geometry().height()-panelSize-Style::minh, -// Style::minw,Style::minh)); -// else if(position==1) -// this->setGeometry(QRect(x,y+panelSize,Style::minw,Style::minh)); -// else if(position==2) -// this->setGeometry(QRect(x+panelSize,y,Style::minw,Style::minh)); -// else -// this->setGeometry(QRect(x+QApplication::primaryScreen()->geometry().width()-panelSize-Style::minw,y, -// Style::minw,Style::minh)); - -// QHBoxLayout *mainLayout=qobject_cast(this->centralWidget()->layout()); -// mainLayout->insertWidget(1,m_line); -// m_sideBarWid->loadMinSidebar(); -// m_mainViewWid->loadMinMainView(); -// m_isFullScreen=false; -// } - -// setFrameStyle(); } void MainWindow::monitorResolutionChange(QRect rect) @@ -628,114 +667,62 @@ void MainWindow::repaintWidget() this->setGeometry(QRect(x+QApplication::primaryScreen()->geometry().width()-panelSize-Style::minw,y, Style::minw,Style::minh)); -// QHBoxLayout *mainLayout=qobject_cast(this->centralWidget()->layout()); -// mainLayout->insertWidget(1,m_line); m_sideBarWid->loadMinSidebar(); m_mainViewWid->resizeControl(); } - setFrameStyle(); } } -void MainWindow::setFrameStyle() -{ - int position=0; - int panelSize=0; - if(QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) - { - QGSettings* gsetting=new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit()); - if(gsetting->keys().contains(QString("panelposition"))) - position=gsetting->get("panelposition").toInt(); - else - position=0; - if(gsetting->keys().contains(QString("panelsize"))) - panelSize=gsetting->get("panelsize").toInt(); - else - panelSize=46; - } - else - { - position=0; - panelSize=46; - } - char style[100]; - - QString m_defaultBackground; - if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) - { - QGSettings* gsetting=new QGSettings(QString("org.ukui.control-center.personalise").toLocal8Bit()); - if(gsetting->keys().contains(QString("transparency"))) - { - double transparency=gsetting->get("transparency").toDouble(); - m_defaultBackground=QString("rgba(19, 19, 20,"+QString::number(transparency)+")"); - } - else - m_defaultBackground=QString("rgba(19, 19, 20, 0.7)"); - } - else - m_defaultBackground=QString("rgba(19, 19, 20, 0.7)"); +//void MainWindow::setFrameStyle() +//{ +// int position=0; +// int panelSize=0; +// if(QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) +// { +// QGSettings* gsetting=new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit()); +// if(gsetting->keys().contains(QString("panelposition"))) +// position=gsetting->get("panelposition").toInt(); +// else +// position=0; +// if(gsetting->keys().contains(QString("panelsize"))) +// panelSize=gsetting->get("panelsize").toInt(); +// else +// panelSize=46; +// } +// else +// { +// position=0; +// panelSize=46; +// } - if(!m_isFullScreen) - { - QRectF rect; - rect.setX(this->rect().x()+1); - rect.setY(this->rect().y()+1); - rect.setWidth(this->rect().width()-2); - rect.setHeight(this->rect().height()-2); - const qreal radius = 6; - QPainterPath path; +// QRectF rect; +// rect.setX(this->rect().x()+1); +// rect.setY(this->rect().y()+1); +// rect.setWidth(this->rect().width()-2); +// rect.setHeight(this->rect().height()-2); +// qreal radius = 0; +// QPainterPath path; +// if(!m_isFullScreen) +// { +// radius=12; +// } +// else +// { +// radius=0; +// } - if(position==0) - { - //右上角 - sprintf(style, "border:0px;background-color:%s;border-top-right-radius:6px;",m_defaultBackground.toLocal8Bit().data()); - path.moveTo(rect.topRight() - QPointF(radius, 0)); - path.lineTo(rect.topLeft()); - path.lineTo(rect.bottomLeft()); - path.lineTo(rect.bottomRight()); - path.lineTo(rect.topRight() + QPointF(0, radius)); - path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); - } - else if(position==1) - { - //右下角 - sprintf(style, "border:0px;background-color:%s;border-bottom-right-radius:6px;",m_defaultBackground.toLocal8Bit().data()); - path.moveTo(rect.topRight()); - path.lineTo(rect.topLeft()); - path.lineTo(rect.bottomLeft()); - path.lineTo(rect.bottomRight() - QPointF(radius, 0)); - path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); - path.lineTo(rect.topRight()); - } - else if(position==2) - { - //右下角 - sprintf(style, "border:0px;background-color:%s;border-bottom-right-radius:6px;",m_defaultBackground.toLocal8Bit().data()); - path.moveTo(rect.topRight()); - path.lineTo(rect.topLeft()); - path.lineTo(rect.bottomLeft()); - path.lineTo(rect.bottomRight() - QPointF(radius, 0)); - path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); - path.lineTo(rect.topRight()); - } - else - { - //左下角 - sprintf(style, "border:0px;background-color:%s;border-bottom-left-radius:6px;",m_defaultBackground.toLocal8Bit().data()); - path.moveTo(rect.topRight()); - path.lineTo(rect.topLeft()); - path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); - path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); - path.lineTo(rect.bottomRight()); - path.lineTo(rect.topRight()); - } - setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - } - else { - sprintf(style, "border:0px;background-color:%s;border-radius:0px;",m_defaultBackground.toLocal8Bit().data()); - } - m_frame->setStyleSheet(style); -} +// path.moveTo(rect.topRight() - QPointF(radius, 0)); +// path.lineTo(rect.topLeft() + QPointF(radius, 0)); +// path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); +// path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); +// path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); +// path.lineTo(rect.bottomRight() - QPointF(radius, 0)); +// path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); +// path.lineTo(rect.topRight() + QPointF(0, radius)); +// path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); + +// setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); +//} void MainWindow::keyPressEvent(QKeyEvent *e) { diff --git a/src/MainWindow/mainwindow.h b/src/MainWindow/mainwindow.h index 67c1b0c..826092f 100644 --- a/src/MainWindow/mainwindow.h +++ b/src/MainWindow/mainwindow.h @@ -48,7 +48,7 @@ public: /** * @brief Set the QFrame style */ - void setFrameStyle(); +// void setFrameStyle(); /** * @brief Load the main window */ @@ -74,7 +74,7 @@ protected: * @brief Handle events clicking on the outside of the window */ bool event(QEvent *event); -// void paintEvent(QPaintEvent*); + void paintEvent(QPaintEvent* event); /** * @brief The query box responds to keyboard events */ diff --git a/src/RightClickMenu/rightclickmenu.cpp b/src/RightClickMenu/rightclickmenu.cpp index 657842b..7767b2a 100644 --- a/src/RightClickMenu/rightclickmenu.cpp +++ b/src/RightClickMenu/rightclickmenu.cpp @@ -56,38 +56,6 @@ QPixmap RightClickMenu::getIconPixmap(QString iconstr, int type) return pixmap; } -QPixmap RightClickMenu::drawSymbolicColoredPixmap(const QPixmap &source) -{ - QColor gray(128,128,128); - QColor standard (31,32,34); - QImage img = source.toImage(); - for (int x = 0; x < img.width(); x++) { - for (int y = 0; y < img.height(); y++) { - auto color = img.pixelColor(x, y); - if (color.alpha() > 0) { - if (qAbs(color.red()-gray.red())<20 && qAbs(color.green()-gray.green())<20 && qAbs(color.blue()-gray.blue())<20) { - color.setRed(255); - color.setGreen(255); - color.setBlue(255); - img.setPixelColor(x, y, color); - } - else if(qAbs(color.red()-standard.red())<20 && qAbs(color.green()-standard.green())<20 && qAbs(color.blue()-standard.blue())<20) - { - color.setRed(255); - color.setGreen(255); - color.setBlue(255); - img.setPixelColor(x, y, color); - } - else - { - img.setPixelColor(x, y, color); - } - } - } - } - return QPixmap::fromImage(img); -} - void RightClickMenu::fixToAllActionTriggerSlot() { m_actionNumber=1; @@ -289,24 +257,8 @@ int RightClickMenu::showShutdownMenu() { m_actionNumber=0; QMenu menu; -// menu.addAction(QIcon(getIconPixmap("stock-people-symbolic",1)),tr("Switch User"), -// this,SLOT(switchUserActionTriggerSlot())); -//#if (QT_VERSION < QT_VERSION_CHECK(5,12,0)) -// if(QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit())) -// { -// QGSettings* gsetting=new QGSettings(QString("org.ukui.session").toLocal8Bit()); -// if(gsetting->keys().contains(QString("canhibernate"))) -// { -// if(gsetting->get("canhibernate").toBool()) -// menu.addAction(QIcon(getIconPixmap("kylin-hebernate-symbolic",1)),tr("Hibernate"), -// this,SLOT(hibernateActionTriggerSlot())); -// } -// } -//#endif menu.addAction(QIcon(getIconPixmap("kylin-sleep-symbolic",1)),tr("Sleep"), - this,SLOT(sleepActionTriggerSlot())); -// menu.addAction(QIcon(getIconPixmap("system-lock-screen-symbolic",1)),tr("Lock Screen"), -// this,SLOT(lockScreenActionTriggerSlot())); + this,SLOT(hibernateActionTriggerSlot()));//休眠睡眠相同 menu.addAction(QIcon(getIconPixmap("system-logout-symbolic",1)),tr("Log Out"), this,SLOT(logoutActionTriggerSlot())); menu.addAction(QIcon(getIconPixmap("system-restart-symbolic",1)),tr("Restart"), diff --git a/src/RightClickMenu/rightclickmenu.h b/src/RightClickMenu/rightclickmenu.h index 34d1526..9dd6f5a 100644 --- a/src/RightClickMenu/rightclickmenu.h +++ b/src/RightClickMenu/rightclickmenu.h @@ -85,12 +85,6 @@ protected: * @return */ QPixmap getIconPixmap(QString iconstr, int type); - /** - * @brief Process image color - * @param source: QPixmap icon - * @return return QPixmap icon - */ - QPixmap drawSymbolicColoredPixmap(const QPixmap &source); private Q_SLOTS: /** diff --git a/src/SearchResultWidget/fullsearchresultwidget.cpp b/src/SearchResultWidget/fullsearchresultwidget.cpp index 83e4aa5..ddbc7e6 100644 --- a/src/SearchResultWidget/fullsearchresultwidget.cpp +++ b/src/SearchResultWidget/fullsearchresultwidget.cpp @@ -36,7 +36,6 @@ void FullSearchResultWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); this->setFixedSize(Style::MainViewWidWidth, Style::AppListWidHeight); @@ -46,7 +45,7 @@ void FullSearchResultWidget::initUi() m_spaceItem=new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed); mainLayout->addItem(m_spaceItem); m_listView=new FullListView(this,3); - m_listView->setFixedSize(this->width()-Style::LeftWidWidth,this->height()); + m_listView->setFixedSize(this->width()-Style::LeftWidWidth+1,this->height()); mainLayout->addWidget(m_listView); this->setLayout(mainLayout); @@ -86,7 +85,7 @@ void FullSearchResultWidget::repaintWidget() m_listView->setParent(nullptr); delete m_listView; m_listView=new FullListView(this,3); - m_listView->setFixedSize(this->width()-Style::LeftWidWidth,this->height()); + m_listView->setFixedSize(this->width()-Style::LeftWidWidth+1,this->height()); QHBoxLayout *mainLayout=qobject_cast(this->layout()); mainLayout->insertWidget(1,m_listView); m_data.clear(); diff --git a/src/SearchResultWidget/searchresultwidget.cpp b/src/SearchResultWidget/searchresultwidget.cpp index 43e3336..57dd2a9 100644 --- a/src/SearchResultWidget/searchresultwidget.cpp +++ b/src/SearchResultWidget/searchresultwidget.cpp @@ -36,12 +36,11 @@ void SearchResultWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); - m_listView=new ListView(this,this->width()-4,this->height(),3); - m_listView->setGeometry(QRect(0,0,this->width()-4,this->height())); + m_listView=new ListView(this,this->width()-6,this->height()-6,3); + m_listView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_listView->show(); m_data.clear(); @@ -83,6 +82,6 @@ void SearchResultWidget::moveScrollBar(int type) void SearchResultWidget::repaintWidget() { this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); - m_listView->setGeometry(QRect(0,0,this->width()-4,this->height())); + m_listView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_listView->show(); } diff --git a/src/SideBarWidget/sidebarwidget.cpp b/src/SideBarWidget/sidebarwidget.cpp index 7a75ac7..8435651 100644 --- a/src/SideBarWidget/sidebarwidget.cpp +++ b/src/SideBarWidget/sidebarwidget.cpp @@ -46,7 +46,6 @@ void SideBarWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_StyledBackground,true); - this->setStyleSheet("border:0px;background:transparent;"); this->setFocusPolicy(Qt::NoFocus); addSidebarBtn(); @@ -65,31 +64,23 @@ void SideBarWidget::addSidebarBtn() m_mainWidget=new QWidget; m_mainWidget->setParent(this); m_mainWidgetLayout=new QVBoxLayout; - m_mainWidgetLayout->setContentsMargins(0,0,0,0); + m_mainWidgetLayout->setContentsMargins(0,0,0,6); m_mainWidgetLayout->setSpacing(10); m_mainWidget->setLayout(m_mainWidgetLayout); - m_mainWidget->setStyleSheet("background:transparent;"); //放大缩小按钮界面 m_minMaxWidget=new QWidget; - m_minMaxWidget->setStyleSheet("QWidget{background:transparent;border:0px;}"); m_minMaxLayout=new QHBoxLayout; - m_minMaxBtn=new QToolButton; + m_minMaxBtn=new QPushButton; + m_minMaxBtn->setFlat(true); // m_minMaxBtn->setShortcut(QKeySequence::InsertParagraphSeparator); // m_minMaxBtn->setShortcut(Qt::Key_Enter); m_minMaxBtn->setShortcut(Qt::Key_Return); m_minMaxLayout->addWidget(m_minMaxBtn); m_minMaxWidget->setLayout(m_minMaxLayout); - char btncolor[300]; - sprintf(btncolor,"QToolButton{background:transparent;border:0px;padding-left:0px;border-radius:4px;}\ - QToolButton:hover{background-color:%s;border:0px;border-radius:4px;}\ - QToolButton:pressed{background-color:%s;border:0px;border-radius:4px;}", - MMBtnHoverBackground,MMBtnHoverBackground); - m_minMaxBtn->setStyleSheet(QString::fromLocal8Bit(btncolor)); //分类按钮 m_buttonList.clear(); -// m_buttonTextList.clear(); m_btnGroup=new QButtonGroup(m_mainWidget); m_allBtn=new QPushButton; initBtn(m_allBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/commonuse.svg"),tr("All"),0); @@ -100,6 +91,7 @@ void SideBarWidget::addSidebarBtn() int id=0; Q_FOREACH (QAbstractButton* btn, m_buttonList) { m_btnGroup->addButton(btn,id++); + btn->setCheckable(true); } QString usericon=m_ukuiMenuInterface->getUserIcon(); @@ -109,7 +101,7 @@ void SideBarWidget::addSidebarBtn() m_personalBtn=new QPushButton; initBtn(m_personalBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/personal.svg"),tr("Personal"),4); m_trashBtn=new QPushButton; - initBtn(m_trashBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/trash.svg"),tr("Recycle Bin"),5); + initBtn(m_trashBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/trash.svg"),tr("Trash"),5); m_computerBtn=new QPushButton; initBtn(m_computerBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/computer.svg"),tr("Computer"),6); m_controlBtn=new QPushButton; @@ -128,7 +120,10 @@ void SideBarWidget::addSidebarBtn() { QPushButton* btn=qobject_cast(button); if(m_buttonList.indexOf(button)>3 && m_buttonList.indexOf(button)setCheckable(false); addRightClickMenu(btn); + } } m_shutDownBtn->setContextMenuPolicy(Qt::CustomContextMenu); connect(m_shutDownBtn,&QPushButton::customContextMenuRequested,this, @@ -169,6 +164,12 @@ void SideBarWidget::addSidebarBtn() } m_mainWidgetLayout->addWidget(m_buttonList.at(8)); + if(QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) + { + QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); + connect(gsetting,&QGSettings::changed,this,&SideBarWidget::themeModeChangeSlot); + } + m_animation = new QPropertyAnimation(m_mainWidget, "geometry"); } @@ -201,20 +202,19 @@ void SideBarWidget::resetSidebarBtnSlot() */ void SideBarWidget::initBtn(QPushButton *btn, QString btnicon, QString text, int num) { - char btncolor[300]; - sprintf(btncolor,"QPushButton{background:transparent;border:0px;padding-left:0;border-radius:4px;}\ - QPushButton:hover{background-color:%s;border:0px;border-radius:4px;}\ - QPushButton:pressed{background-color:%s;border:0px;border-radius:4px;}", - SBFunBtnHoverBackground,SBFunBtnHoverBackground); - btn->setStyleSheet(QString::fromLocal8Bit(btncolor)); + btn->setFlat(true); QHBoxLayout* btnLayout=new QHBoxLayout; QLabel* labelicon=new QLabel; labelicon->setAlignment(Qt::AlignCenter); - labelicon->setStyleSheet("background:transparent;border:0px;"); const auto ratio=devicePixelRatioF(); + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); if(num!=3) { QPixmap pixmap=loadSvg(btnicon,Style::SideBarIconSize*ratio); + if(gsetting.get("style-name").toString()=="ukui-light")//反黑 + pixmap=drawSymbolicBlackColoredPixmap(pixmap); + else + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); labelicon->setFixedSize(Style::SideBarIconSize,Style::SideBarIconSize); labelicon->setPixmap(pixmap); @@ -304,7 +304,6 @@ void SideBarWidget::shutdownBtnRightClickSlot() void SideBarWidget::addRightClickMenu(QPushButton *btn) { btn->setContextMenuPolicy(Qt::CustomContextMenu); -// disconnect(btn,&QPushButton::customContextMenuRequested,this,&SideBarWidget::otherBtnRightClickSlot); connect(btn,&QPushButton::customContextMenuRequested,this,&SideBarWidget::otherBtnRightClickSlot); } @@ -391,9 +390,6 @@ void SideBarWidget::userAccountsChanged() facePixmap = facePixmap.scaled((Style::SideBarIconSize+4)*ratio,(Style::SideBarIconSize+4)*ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation); facePixmap = PixmapToRound(facePixmap, (Style::SideBarIconSize+4)*ratio/2); -// QLayoutItem* item=m_userIconBtn->layout()->itemAt(0); -// QLabel* labelicon=qobject_cast(item->widget()); -// labelicon->setScaledContents(true); QLabel* labelicon=m_userIconBtn->findChild("faceLabel"); facePixmap.setDevicePixelRatio(qApp->devicePixelRatio()); labelicon->setPixmap(facePixmap); @@ -413,15 +409,17 @@ void SideBarWidget::loadMinSidebar() m_minMaxWidget->setFixedSize(37,70); m_minMaxLayout->setContentsMargins(0,0,0,0); - m_mainWidgetLayout->setContentsMargins(8,0,10,0); + m_mainWidgetLayout->setContentsMargins(8,0,10,6); Q_FOREACH(QAbstractButton* button,m_buttonList) { QPushButton* btn=qobject_cast(button); setMinSidebarBtn(btn); -// btn->setToolTip(m_textList.at(m_buttonList.indexOf(button))); + btn->setToolTip(m_textList.at(m_buttonList.indexOf(button))); } + changeIconColor(false); + disconnect(m_minMaxBtn,&QToolButton::clicked,this, &SideBarWidget::sendDefaultBtnSignal); connect(m_minMaxBtn, &QToolButton::clicked,this,&SideBarWidget::sendFullScreenBtnSignal); } @@ -431,14 +429,17 @@ void SideBarWidget::loadMinSidebar() */ void SideBarWidget::setMaxBtn() { + const auto ratio=devicePixelRatioF(); + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + QPixmap pixmap=loadSvg(QString(":/data/img/sidebarwidget/max.svg"),14*ratio); + if(gsetting.get("style-name").toString()=="ukui-light")//反黑 + pixmap=drawSymbolicBlackColoredPixmap(pixmap); + else + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + m_minMaxBtn->setFixedSize(37,37); - QSvgRenderer* svgRender = new QSvgRenderer(m_minMaxBtn); - svgRender->load(QString(":/data/img/sidebarwidget/max.svg")); - QPixmap* pixmap = new QPixmap(14,14); - pixmap->fill(Qt::transparent);//设置背景透明 - QPainter p(pixmap); - svgRender->render(&p); - m_minMaxBtn->setIcon(QIcon(*pixmap)); + m_minMaxBtn->setIcon(QIcon(pixmap)); } /** @@ -480,14 +481,23 @@ void SideBarWidget::loadMaxSidebar() m_minMaxWidget->setFixedSize(Style::MinMaxWidWidth,Style::MinMaxWidHeight); m_minMaxLayout->setContentsMargins(m_minMaxWidget->width()-m_minMaxBtn->width(),0,0,0); - m_mainWidgetLayout->setContentsMargins(0,0,0,0); + m_mainWidgetLayout->setContentsMargins(0,0,0,6); Q_FOREACH(QAbstractButton* button,m_buttonList) { QPushButton* btn=qobject_cast(button); setMaxSidebarBtn(btn); + btn->setToolTip(""); + } + + Q_FOREACH(QAbstractButton* button,m_buttonList) + { + QPushButton* btn=qobject_cast(button); + btn->setFixedSize(m_btnWidth,Style::SideBarBtnHeight); } + changeIconColor(true); + disconnect(m_minMaxBtn, &QToolButton::clicked,this,&SideBarWidget::sendFullScreenBtnSignal); connect(m_minMaxBtn, &QToolButton::clicked,this,&SideBarWidget::sendDefaultBtnSignal); } @@ -497,14 +507,13 @@ void SideBarWidget::loadMaxSidebar() */ void SideBarWidget::setMinBtn() { + const auto ratio=devicePixelRatioF(); + QPixmap pixmap=loadSvg(QString(":/data/img/sidebarwidget/min.svg"),14*ratio); + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + m_minMaxBtn->setFixedSize(Style::MinMaxBtnWidth,Style::MinMaxBtnWidth); - QSvgRenderer* svgRender = new QSvgRenderer(m_minMaxBtn); - svgRender->load(QString(":/data/img/sidebarwidget/min.svg")); - QPixmap* pixmap = new QPixmap(Style::MinMaxIconSize,Style::MinMaxIconSize); - pixmap->fill(Qt::transparent);//设置背景透明 - QPainter p(pixmap); - svgRender->render(&p); - m_minMaxBtn->setIcon(QIcon(*pixmap)); + m_minMaxBtn->setIcon(QIcon(pixmap)); } /** @@ -539,7 +548,6 @@ void SideBarWidget::setMaxSidebarBtn(QPushButton *btn) } //添加文本 QLabel* labeltext=new QLabel; - labeltext->setStyleSheet(QString("QLabel{background:transparent;color:#ffffff;border:0px;}")); if(m_buttonList.indexOf(btn)<=2) { labeltext->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); @@ -557,27 +565,18 @@ void SideBarWidget::setMaxSidebarBtn(QPushButton *btn) labeltext->setFixedSize(m_btnWidth-44,Style::SideBarBtnHeight); labeltext->adjustSize(); } - + QPalette pe = labeltext->palette(); + pe.setColor(QPalette::ButtonText,QColor(Qt::white)); + labeltext->setPalette(pe); btn->layout()->addWidget(labeltext); - btn->setFixedSize(m_btnWidth,Style::SideBarBtnHeight); -// btn->setToolTip(""); +// btn->setFixedSize(m_btnWidth,Style::SideBarBtnHeight); } void SideBarWidget::btnGroupClickedSlot(QAbstractButton *btn) { - char btncolor[300]; - sprintf(btncolor,"QPushButton{background:transparent;border:0px;padding-left:0;border-radius:4px;}\ - QPushButton:hover{background-color:%s;border:0px;border-radius:4px;}\ - QPushButton:pressed{background-color:%s;border:0px;border-radius:4px;}", - SBFunBtnHoverBackground,SBFunBtnHoverBackground); - - char pressstyle[200]; - sprintf(pressstyle,"QPushButton{background-color:%s;border:0px;padding-left:0;border-radius:4px;}",SBClassifyBtnSelectedBackground); - Q_FOREACH (QAbstractButton* button, m_buttonList) { if(m_btnGroup->id(btn)==m_buttonList.indexOf(button)) { - button->setStyleSheet(pressstyle); if(m_btnGroup->id(btn)==0) { if(m_isFullScreen) @@ -597,8 +596,116 @@ void SideBarWidget::btnGroupClickedSlot(QAbstractButton *btn) else Q_EMIT sendFunctionBtnSignal(); } } - else{ - button->setStyleSheet(btncolor); + } +} + +void SideBarWidget::themeModeChangeSlot(QString styleName) +{ + if(styleName=="styleName") + { + QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); + Q_FOREACH(QAbstractButton *button,m_buttonList) + { + QPushButton *btn=qobject_cast(button); + QLayoutItem *item=btn->layout()->itemAt(0); + QLabel *label=qobject_cast(item->widget()); + QString iconStr; + switch (m_buttonList.indexOf(button)) { + case 0: + iconStr=QString(":/data/img/sidebarwidget/commonuse.svg"); + break; + case 1: + iconStr=QString(":/data/img/sidebarwidget/letter.svg"); + break; + case 2: + iconStr=QString(":/data/img/sidebarwidget/function.svg"); + break; + case 3: + userAccountsChanged(); + break; + case 4: + iconStr=QString(":/data/img/sidebarwidget/personal.svg"); + break; + case 5: + iconStr=QString(":/data/img/sidebarwidget/trash.svg"); + break; + case 6: + iconStr=QString(":/data/img/sidebarwidget/computer.svg"); + break; + case 7: + iconStr=QString(":/data/img/sidebarwidget/setting.svg"); + break; + case 8: + iconStr=QString(":/data/img/sidebarwidget/shutdown.svg"); + break; + default: + break; + } + if(m_buttonList.indexOf(button)!=3) + { + const auto ratio=devicePixelRatioF(); + QPixmap pixmap=loadSvg(iconStr,19*ratio); + if(gsetting->get("style-name").toString()=="ukui-light")//反黑 + pixmap=drawSymbolicBlackColoredPixmap(pixmap); + else + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + label->setPixmap(pixmap); + } + } + } +} + +void SideBarWidget::changeIconColor(bool isFullScreen) +{ + QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); + Q_FOREACH(QAbstractButton *button,m_buttonList) + { + QPushButton *btn=qobject_cast(button); + QLayoutItem *item=btn->layout()->itemAt(0); + QLabel *label=qobject_cast(item->widget()); + QString iconStr; + switch (m_buttonList.indexOf(button)) { + case 0: + iconStr=QString(":/data/img/sidebarwidget/commonuse.svg"); + break; + case 1: + iconStr=QString(":/data/img/sidebarwidget/letter.svg"); + break; + case 2: + iconStr=QString(":/data/img/sidebarwidget/function.svg"); + break; + case 3: + userAccountsChanged(); + break; + case 4: + iconStr=QString(":/data/img/sidebarwidget/personal.svg"); + break; + case 5: + iconStr=QString(":/data/img/sidebarwidget/trash.svg"); + break; + case 6: + iconStr=QString(":/data/img/sidebarwidget/computer.svg"); + break; + case 7: + iconStr=QString(":/data/img/sidebarwidget/setting.svg"); + break; + case 8: + iconStr=QString(":/data/img/sidebarwidget/shutdown.svg"); + break; + default: + break; + } + if(m_buttonList.indexOf(button)!=3) + { + const auto ratio=devicePixelRatioF(); + QPixmap pixmap=loadSvg(iconStr,19*ratio); + if(gsetting->get("style-name").toString()=="ukui-light" && !isFullScreen)//反黑 + pixmap=drawSymbolicBlackColoredPixmap(pixmap); + else + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + label->setPixmap(pixmap); } } } @@ -622,20 +729,6 @@ void SideBarWidget::setSideBarBtnGeometry() m_mainWidget->show(); } -void SideBarWidget::widgetMakeZero() -{ - char pressstyle[200]; - sprintf(pressstyle,"QPushButton{background-color:%s;border:0px;padding-left:0;border-radius:4px;}",SBClassifyBtnSelectedBackground); - m_allBtn->setStyleSheet(pressstyle); - char btncolor[300]; - sprintf(btncolor,"QPushButton{background:transparent;border:0px;padding-left:0;border-radius:4px;}\ - QPushButton:hover{background-color:%s;border:0px;border-radius:4px;}\ - QPushButton:pressed{background-color:%s;border:0px;border-radius:4px;}", - SBFunBtnHoverBackground,SBFunBtnHoverBackground); - m_letterBtn->setStyleSheet(btncolor); - m_functionBtn->setStyleSheet(btncolor); -} - //void SideBarWidget::mousePressEvent(QMouseEvent *event) //{ // if(m_isFullScreen && event->button()==Qt::LeftButton) diff --git a/src/SideBarWidget/sidebarwidget.h b/src/SideBarWidget/sidebarwidget.h index 74cc62f..5ccf32d 100644 --- a/src/SideBarWidget/sidebarwidget.h +++ b/src/SideBarWidget/sidebarwidget.h @@ -51,10 +51,6 @@ public: * @brief Load the full-screen sidebar */ void loadMaxSidebar(); - /** - * @brief Initializes the interface state - */ - void widgetMakeZero(); /** * @brief Sidebar animation */ @@ -72,7 +68,7 @@ private: QWidget *m_minMaxWidget=nullptr; QHBoxLayout *m_minMaxLayout=nullptr; - QToolButton *m_minMaxBtn=nullptr; + QPushButton *m_minMaxBtn=nullptr; QButtonGroup *m_btnGroup=nullptr; QList m_buttonList; @@ -138,6 +134,7 @@ protected: */ void setMaxBtn(); QPixmap PixmapToRound(const QPixmap &src, int radius); + void changeIconColor(bool isFullScreen); // void mousePressEvent(QMouseEvent* event); private Q_SLOTS: @@ -186,6 +183,7 @@ private Q_SLOTS: * @brief Reset the sidebar button */ void resetSidebarBtnSlot(); + void themeModeChangeSlot(QString styleName); Q_SIGNALS: /** diff --git a/src/Style/style.h b/src/Style/style.h index c1f6e64..a13fad5 100644 --- a/src/Style/style.h +++ b/src/Style/style.h @@ -42,14 +42,17 @@ #define RightClickMenuOpacity 0.95 #define ToolTipBackground "rgba(26, 26, 26, 0.7)" #define DefaultBackground "rgba(19, 19, 20, 0.7)" //默认态背景色 -#define LineBackground "rgba(255,255,255,0.06)" //分割线背景色 +#define LineBackground "rgba(255,255,255)" //分割线背景色 #define SBClassifyBtnSelectedBackground "#3D6BE5" //侧边栏上部分类按钮选择背景 #define SBFunBtnHoverBackground "rgba(255, 255, 255, 0.14)" //侧边栏目下部功能按钮悬浮背景 #define ClassifyBtnHoverBackground "rgba(255, 255, 255, 0.14)" //分类按钮悬浮背景 #define MMBtnHoverBackground "rgba(255, 255, 255, 0.14)" //最大化最小化按钮悬浮背景 -#define QueryLineEditBackground "rgba(0, 0, 0,0.4)" //搜索框背景 -#define QueryLineEditClickedBackground "rgba(0, 0, 0,0.5)" //搜索框背景选中 -#define QueryLineEditClickedBorder "rgba(61, 107, 229, 1)" //搜索框背景选中边框 +#define QueryLineEditDefaultBackground "rgba(0, 0, 0,0.04)" //搜索框默认态背景 +#define QueryLineEditBackground "rgba(255, 255, 255,0.06)" //搜索框背景 +#define QueryLineEditClickedDefaultBackground "rgba(0, 0, 0,0.04)" //搜索框默认态背景选中 +#define QueryLineEditClickedBackground "rgba(255, 255, 255,0.06)" //搜索框背景选中 +#define QueryLineEditClickedBorderDefault "rgba(0, 0, 0,0.1)" //搜索框默认态背景选中边框 +#define QueryLineEditClickedBorder "rgba(255, 255, 255,0.15)" //搜索框背景选中边框 #define AppBtnHover "#ffffff" //按钮悬浮 /** diff --git a/src/UtilityFunction/classifybtnscrollarea.cpp b/src/UtilityFunction/classifybtnscrollarea.cpp new file mode 100644 index 0000000..4627604 --- /dev/null +++ b/src/UtilityFunction/classifybtnscrollarea.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see +#include + +ClassifyBtnScrollAreaWid::ClassifyBtnScrollAreaWid() +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setAttribute(Qt::WA_TranslucentBackground); + +} + +void ClassifyBtnScrollAreaWid::paintEvent(QPaintEvent *event) +{ + QGSettings* gsetting=new QGSettings(QString("org.ukui.control-center.personalise").toLocal8Bit()); + double transparency=gsetting->get("transparency").toDouble(); + QPainter painter(this); +// painter.setRenderHint(QPainter::Antialiasing); +// painter.setOpacity(0.25); +// painter.setBrush(Qt::black); +// painter.setPen(Qt::NoPen); +// QRect rect = this->rect(); +// rect.setWidth(rect.width()); +// rect.setHeight(rect.height()); +// painter.drawRect(rect); + + if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) + { + QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); + if(gsetting.keys().contains(QString("effect"))) + { + if(gsetting.get("effect").toBool()) + { + painter.setBrush(Qt::black); + painter.setPen(Qt::transparent); + painter.setOpacity(0.25); + painter.drawRect(this->rect()); + } + else + { + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); + } + } + else + { + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); + } + } + else{ + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); + } + QWidget::paintEvent(event); +} + +ClassifyBtnScrollArea::ClassifyBtnScrollArea(QWidget *parent): + QScrollArea(parent) +{ + initWid(); +} + +void ClassifyBtnScrollArea::initWid() +{ + this->verticalScrollBar()->setHidden(true); + this->horizontalScrollBar()->setHidden(true); + this->setWidgetResizable(true); + this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + this->setFrameShape(QFrame::NoFrame); +} diff --git a/src/UtilityFunction/classifyscrollarea.h b/src/UtilityFunction/classifybtnscrollarea.h similarity index 76% rename from src/UtilityFunction/classifyscrollarea.h rename to src/UtilityFunction/classifybtnscrollarea.h index d902862..465bd4f 100644 --- a/src/UtilityFunction/classifyscrollarea.h +++ b/src/UtilityFunction/classifybtnscrollarea.h @@ -20,11 +20,21 @@ #define CLASSIFYSCROLLAREA_H #include #include +#include -class ClassifyScrollArea : public QScrollArea +class ClassifyBtnScrollAreaWid: public QWidget { public: - explicit ClassifyScrollArea(QWidget* parent=nullptr); + ClassifyBtnScrollAreaWid(); + +protected: + void paintEvent(QPaintEvent* event); +}; + +class ClassifyBtnScrollArea : public QScrollArea +{ +public: + explicit ClassifyBtnScrollArea(QWidget* parent=nullptr); protected: void initWid(); diff --git a/src/UtilityFunction/classifyscrollarea.cpp b/src/UtilityFunction/classifyscrollarea.cpp deleted file mode 100644 index 1725e3d..0000000 --- a/src/UtilityFunction/classifyscrollarea.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see verticalScrollBar()->setHidden(true); - this->horizontalScrollBar()->setHidden(true); - this->setWidgetResizable(true); - this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - -} diff --git a/src/UtilityFunction/fullitemdelegate.cpp b/src/UtilityFunction/fullitemdelegate.cpp index e01cc6e..c4476b2 100644 --- a/src/UtilityFunction/fullitemdelegate.cpp +++ b/src/UtilityFunction/fullitemdelegate.cpp @@ -37,7 +37,6 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti { if(index.isValid()) { - painter->save(); QStyleOptionViewItem viewOption(option);//用来在视图中画一个item QRectF rect; rect.setX(option.rect.x()); @@ -58,19 +57,20 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti path.lineTo(rect.topRight() + QPointF(0, radius)); path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); -// painter->setRenderHint(QPainter::Antialiasing); -// if(option.state.testFlag(QStyle::State_Selected)) -// if(option.state & QStyle::State_MouseOver) -// { -// painter->setPen(QPen(Qt::NoPen)); -// QColor color; -// color.setNamedColor(QString::fromLocal8Bit(AppBtnHover)); -// painter->setBrush(QBrush(color)); - -// painter->setOpacity(0.14); -// painter->drawPath(path); -// } + painter->setRenderHint(QPainter::Antialiasing); + if(option.state & QStyle::State_MouseOver) + { +// QColor color = option.palette.text().color(); +// color.setAlphaF(0.15); + painter->save(); + painter->setPen(QPen(Qt::NoPen)); + painter->setBrush(Qt::white); + painter->setOpacity(0.15); + painter->drawPath(path); + painter->restore(); + } + painter->save(); painter->setOpacity(1); QString desktopfp=index.data(Qt::DisplayRole).value(); QString iconstr=pUkuiMenuInterface->getAppIcon(desktopfp); @@ -105,6 +105,10 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); + else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) + icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) + icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); else icon=QIcon::fromTheme(QString("application-x-desktop")); } @@ -119,19 +123,13 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti Style::AppListIconSize, Style::AppListIconSize); icon.paint(painter,iconRect); + painter->restore(); - textRect=QRect(rect.x()+5, - iconRect.bottom()+Style::AppSpaceBetweenIconText, - rect.width()-10, - rect.height()-iconRect.height()-Style::AppSpaceBetweenIconText); - + painter->save(); bool is_locked=false; - bool is_recentapp=false; QFileInfo fileInfo(desktopfp); QString desktopfn=fileInfo.fileName(); - QFontMetrics fm=painter->fontMetrics(); - QString appnameElidedText=fm.elidedText(appname,Qt::ElideRight,rect.width()-10,Qt::TextShowMnemonic); - + //添加固定图标 if(module==0) { setting->beginGroup("lockapplication"); @@ -143,6 +141,18 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti } setting->endGroup(); } + painter->restore(); + + textRect=QRect(rect.x()+5, + iconRect.bottom()+Style::AppSpaceBetweenIconText, + rect.width()-10, + rect.height()-iconRect.height()-Style::AppSpaceBetweenIconText); + + painter->save(); + //添加最近安装蓝色标签 + bool is_recentapp=false; + QFontMetrics fm=painter->fontMetrics(); + QString appnameElidedText=fm.elidedText(appname,Qt::ElideRight,rect.width()-10,Qt::TextShowMnemonic); setting->beginGroup("recentapp"); if(setting->contains(desktopfn) && !is_locked) { @@ -168,22 +178,18 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti } setting->endGroup(); + painter->restore(); + painter->save(); +// painter->setPen(QPen(option.palette.text().color())); painter->setPen(QPen(Qt::white)); + painter->setBrush(Qt::NoBrush); painter->drawText(textRect,Qt::AlignHCenter |Qt::AlignTop,appnameElidedText); +// painter->drawText(textRect,Qt::TextWordWrap |Qt::AlignHCenter,appname); + painter->restore(); - painter->setRenderHint(QPainter::Antialiasing); -// if(option.state.testFlag(QStyle::State_Selected)) if(option.state & QStyle::State_MouseOver) { - painter->setPen(QPen(Qt::NoPen)); - QColor color; - color.setNamedColor(QString::fromLocal8Bit(AppBtnHover)); - painter->setBrush(QBrush(color)); - - painter->setOpacity(0.14); - painter->drawPath(path); - int len=0; if(!is_locked && is_recentapp) len=fm.boundingRect(appname).width()+23; @@ -197,8 +203,6 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti else { QToolTip::hideText(); } - painter->restore(); - } } diff --git a/src/UtilityFunction/fulllistview.cpp b/src/UtilityFunction/fulllistview.cpp index dcfacd8..7b09a1d 100644 --- a/src/UtilityFunction/fulllistview.cpp +++ b/src/UtilityFunction/fulllistview.cpp @@ -41,23 +41,7 @@ FullListView::~FullListView() void FullListView::initWidget() { - char style[500]; - sprintf(style,"QListView{border:0px;}\ - QListView:Item{background:transparent;border:0px;color:#ffffff;font-size:14px;padding-left:0px;}\ - QListView:Item:hover{background:transparent;}\ - QListView:Item:pressed{background:transparent;}"); - - if(module!=1 && module!=2) - this->verticalScrollBar()->setStyleSheet("QScrollBar{width:3px;padding-top:0px;padding-bottom:0px;background:transparent;border-radius:6px;}" - "QScrollBar::handle{background-color:rgba(255,255,255,0.25); width:3px;border-radius:1.5px;}" - "QScrollBar::handle:hover{background-color:#697883;border-radius:1.5px;}" - "QScrollBar::handle:pressed{background-color:#8897a3;border-radius:1.5px;}" - "QScrollBar::sub-line{background-color:transparent;height:0px;width:0px;}" - "QScrollBar::add-line{background-color:transparent;height:0px;width:0px;}" - ); - - -// this->setStyleSheet(style); + viewport()->setAttribute(Qt::WA_TranslucentBackground); this->setSelectionMode(QAbstractItemView::SingleSelection); this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); if(module==1 || module==2) @@ -73,6 +57,7 @@ void FullListView::initWidget() this->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); this->setGridSize(QSize(Style::AppListGridSizeWidth,Style::AppListGridSizeWidth)); this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); + this->setFrameShape(QFrame::NoFrame);//移除边框 connect(this,&FullListView::customContextMenuRequested,this,&FullListView::rightClickedSlot); connect(this,&FullListView::clicked,this,&FullListView::onClicked); } @@ -175,6 +160,55 @@ void FullListView::leaveEvent(QEvent *e) this->verticalScrollBar()->setVisible(false); } +void FullListView::paintEvent(QPaintEvent *e) +{ + QGSettings* gsetting=new QGSettings(QString("org.ukui.control-center.personalise").toLocal8Bit()); + double transparency=gsetting->get("transparency").toDouble(); + QPainter painter(this->viewport()); +// painter.setOpacity(0.25); +// painter.setPen(Qt::NoPen); +// painter.fillRect(this->rect(),QBrush(Qt::black)); +// QListView::paintEvent(e); + + + if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) + { + QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); + if(gsetting.keys().contains(QString("effect"))) + { + if(gsetting.get("effect").toBool()) + { + painter.setBrush(Qt::black); + painter.setPen(Qt::transparent); + painter.setOpacity(0.25); + painter.drawRect(this->rect()); + } + else + { + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); + } + } + else + { + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); + } + } + else + { + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); + } + QListView::paintEvent(e); +} + //void FullListView::mousePressEvent(QMouseEvent *event) //{ // if(!(this->indexAt(event->pos()).isValid()) && event->button()==Qt::LeftButton) diff --git a/src/UtilityFunction/fulllistview.h b/src/UtilityFunction/fulllistview.h index 9b7f455..36c14a0 100644 --- a/src/UtilityFunction/fulllistview.h +++ b/src/UtilityFunction/fulllistview.h @@ -43,6 +43,7 @@ protected: void initWidget(); void enterEvent(QEvent* e) Q_DECL_OVERRIDE; void leaveEvent(QEvent* e) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *e) override; // void mousePressEvent(QMouseEvent *event); private: diff --git a/src/UtilityFunction/functionclassifybutton.cpp b/src/UtilityFunction/functionclassifybutton.cpp index b4d6203..21ee26a 100644 --- a/src/UtilityFunction/functionclassifybutton.cpp +++ b/src/UtilityFunction/functionclassifybutton.cpp @@ -20,6 +20,8 @@ #include "utility.h" #include #include +#include +#include FunctionClassifyButton::FunctionClassifyButton(int width, int height, @@ -38,22 +40,30 @@ FunctionClassifyButton::FunctionClassifyButton(int width, m_iconLabel(new QLabel), m_textLabel(new QLabel) { - m_textLabel->setAutoFillBackground(true); + this->setFlat(true); this->setFixedSize(m_width,m_height); - this->setCheckable(true); this->setFocusPolicy(Qt::NoFocus); m_iconLabel->setFixedSize(m_iconSize,m_iconSize); m_textLabel->adjustSize(); - m_iconLabel->setStyleSheet("background:transparent;"); + if(m_fullscreen) + { + QPalette pe = m_textLabel->palette(); + pe.setColor(QPalette::ButtonText,QColor(Qt::white)); + m_textLabel->setPalette(pe); + } setLabelText(); if(m_fullscreen) + { updateIconState(Normal); + this->setCheckable(true); + } else { if(m_enabled) updateIconState(Enabled); else updateIconState(Disabled); + this->setCheckable(false); } QHBoxLayout* mainlayout=new QHBoxLayout; @@ -66,6 +76,49 @@ FunctionClassifyButton::FunctionClassifyButton(int width, connect(this,&FunctionClassifyButton::clicked,this,&FunctionClassifyButton::buttonClickedSlot); } +void FunctionClassifyButton::paintEvent(QPaintEvent* e) +{ + Q_UNUSED(e); + QStylePainter painter(this); + QStyleOptionButton option; + initStyleOption(&option); + if ((option.state & QStyle::State_Enabled) && (option.state & QStyle::State_MouseOver)) { + painter.save(); + painter.setPen(Qt::NoPen); + if(!m_fullscreen) + { + QColor color = option.palette.color(QPalette::Text); + color.setAlphaF(0.15); + painter.setBrush(color); + } + else + { + painter.setOpacity(0.15); + painter.setBrush(Qt::white); + } + painter.drawRoundedRect(option.rect, 4, 4); + painter.restore(); + } + if(m_fullscreen && (option.state & QStyle::State_On)) + { + painter.save(); + painter.setPen(Qt::NoPen); +// QColor color = option.palette.color(QPalette::Text); +// color.setAlphaF(0.15); +// painter.setBrush(color); + painter.setOpacity(0.15); + painter.setBrush(Qt::white); + painter.drawRoundedRect(option.rect, 4, 4); + painter.restore(); + } + + QStyleOptionButton subopt = option; + subopt.rect = painter.style()->subElementRect(QStyle::SE_PushButtonContents, &option, this); + subopt.palette.setBrush(QPalette::HighlightedText, subopt.palette.text()); + painter.style()->drawControl(QStyle::CE_PushButtonLabel, &subopt, &painter, this); + return; +} + void FunctionClassifyButton::updateBtnState() { if(m_enabled) @@ -77,26 +130,15 @@ void FunctionClassifyButton::updateBtnState() void FunctionClassifyButton::enterEvent(QEvent *e) { Q_UNUSED(e); - QByteArray byte=QString(ClassifyBtnHoverBackground).toLocal8Bit(); - char* hover=byte.data(); - char style[100]; if(m_enabled) { updateIconState(Checked); - if(!m_fullscreen) - { - sprintf(style,"border:0px;border-radius:4px;padding-left:0px;background-color:%s;",hover); - this->setStyleSheet(QString::fromLocal8Bit(style)); - } - else - this->setStyleSheet("border:0px;border-radius:4px;padding-left:0px;background:transparent;"); } } void FunctionClassifyButton::leaveEvent(QEvent *e) { Q_UNUSED(e); - this->setStyleSheet("border:0px;border-radius:4px;padding-left:0px;background:transparent;"); if(m_fullscreen) { if(!isChecked()) @@ -125,6 +167,34 @@ void FunctionClassifyButton::buttonClickedSlot() Q_EMIT buttonClicked(); } +void FunctionClassifyButton::updateIconState() +{ + this->setFlat(true); + QString picState; + switch (m_state) + { + case Enabled: picState="Enabled"; break; + case Disabled: picState="Disabled"; break; + case Normal: picState="Normal"; break; + case Checked: picState="Checked"; break; + default: break; + } + + const auto ratio = devicePixelRatioF(); + QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/%1-%2.svg").arg(m_category).arg(picState), m_iconSize*ratio); + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + if(gsetting.get("style-name").toString()=="ukui-light")//反黑 + { + pixmap=drawSymbolicBlackColoredPixmap(pixmap); + } + else + { + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 + } + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + m_iconLabel->setPixmap(pixmap); +} + void FunctionClassifyButton::updateIconState(const FunctionClassifyButton::State state) { if (state == m_state) @@ -143,6 +213,20 @@ void FunctionClassifyButton::updateIconState(const FunctionClassifyButton::State const auto ratio = devicePixelRatioF(); QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/%1-%2.svg").arg(m_category).arg(picState), m_iconSize*ratio); + if(!m_fullscreen) + { + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + if(gsetting.get("style-name").toString()=="ukui-light")//反黑 + { + pixmap=drawSymbolicBlackColoredPixmap(pixmap); + } + else + { + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 + } + } + else + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); m_iconLabel->setPixmap(pixmap); updateTextState(state); @@ -155,19 +239,19 @@ void FunctionClassifyButton::updateTextState(const FunctionClassifyButton::State { case Enabled: // p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1)); - m_textLabel->setStyleSheet("background:transparent; color:rgba(255, 255, 255);"); +// 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%);"); +// 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%);"); +// 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);"); +// m_textLabel->setStyleSheet("background:transparent;color:rgba(255, 255, 255);"); break; default: break; diff --git a/src/UtilityFunction/functionclassifybutton.h b/src/UtilityFunction/functionclassifybutton.h index 2c1f998..1b80037 100644 --- a/src/UtilityFunction/functionclassifybutton.h +++ b/src/UtilityFunction/functionclassifybutton.h @@ -78,10 +78,12 @@ public: State m_state=Checked; void updateBtnState(); + void updateIconState();//根据主题修改图标 protected: void enterEvent(QEvent* e); void leaveEvent(QEvent* e); + void paintEvent(QPaintEvent* e); void updateIconState(const State state); void updateTextState(const State state); void setLabelText(); diff --git a/src/UtilityFunction/itemdelegate.cpp b/src/UtilityFunction/itemdelegate.cpp index 87ef0c3..41d945b 100644 --- a/src/UtilityFunction/itemdelegate.cpp +++ b/src/UtilityFunction/itemdelegate.cpp @@ -39,7 +39,6 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, { if(index.isValid()) { - painter->save(); QStyleOptionViewItem viewOption(option);//用来在视图中画一个item QRectF rect; QStringList strlist1=index.model()->data(index,Qt::DisplayRole).toStringList(); @@ -73,16 +72,15 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, QStringList strlist=index.model()->data(index,Qt::DisplayRole).toStringList(); painter->setRenderHint(QPainter::Antialiasing); -// if(option.state.testFlag(QStyle::State_Selected)) if(option.state & QStyle::State_MouseOver) { + QColor color = option.palette.text().color(); + color.setAlphaF(0.15); + painter->save(); painter->setPen(QPen(Qt::NoPen)); - QColor color; - color.setNamedColor(QString::fromLocal8Bit(AppBtnHover)); painter->setBrush(color); - painter->setOpacity(0.14); painter->drawPath(path); - + painter->restore(); } painter->setOpacity(1); @@ -111,15 +109,21 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) + icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) + icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); else icon=QIcon::fromTheme(QString("application-x-desktop")); } } + painter->save(); icon.paint(painter,iconRect,Qt::AlignLeft); - painter->setPen(QPen(Qt::white)); QString appname=pUkuiMenuInterface->getAppName(strlist.at(0)); painter->drawText(QRect(iconRect.right()+15,rect.y(), rect.width()-62,rect.height()),Qt::AlignVCenter,appname); + painter->restore(); + painter->save(); setting->beginGroup("recentapp"); QFileInfo fileInfo(strlist.at(0)); QString desktopfn=fileInfo.fileName(); @@ -130,22 +134,24 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, painter->drawEllipse(QPoint(rect.topRight().x()-22,rect.y()+(rect.height()-8)/2+4),4,4); } setting->endGroup(); + painter->restore(); } else { - painter->setPen(QPen(Qt::white)); + //绘制分割线 + painter->save(); QRect textRect=QRect(rect.x()+11,rect.y()+12,rect.width(),rect.height()); painter->drawText(textRect,Qt::AlignLeft,strlist.at(0)); painter->setRenderHint(QPainter::Antialiasing, true); - painter->setPen(QPen(QColor("#FFFFFF"),1)); - painter->setOpacity(0.06); + painter->setPen(QPen(QColor(option.palette.text().color()),1)); + painter->setOpacity(0.1); painter->drawLine(QPoint(5,rect.bottom()),QPoint(rect.right(),rect.bottom())); + painter->restore(); } } else { - painter->setOpacity(1); QRect iconRect=QRect(rect.left()+11,rect.y()+(rect.height()-32)/2,32,32); QString iconstr=pUkuiMenuInterface->getAppIcon(strlist.at(0)); QIcon icon; @@ -159,8 +165,6 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, icon=QIcon::fromTheme(iconstr); if(icon.isNull()) { - if(pUkuiMenuInterface->getAppName(strlist.at(0))=="baidunetdisk") - syslog(LOG_LOCAL0 | LOG_DEBUG ,"---2---"); if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); else if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) @@ -169,6 +173,10 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); + else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) + icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) + icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); else icon=QIcon::fromTheme(QString("application-x-desktop")); } @@ -186,6 +194,8 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, icon.paint(painter,QRect(rect.topRight().x()-22,rect.y()+(rect.height()-16)/2,16,16)); } setting->endGroup(); + painter->setOpacity(1); + painter->save(); setting->beginGroup("recentapp"); if(setting->contains(desktopfn) && !is_locked) { @@ -194,12 +204,15 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, painter->drawEllipse(QPoint(rect.topRight().x()-22,rect.y()+(rect.height()-8)/2+4),4,4); } setting->endGroup(); + painter->restore(); + painter->save(); + painter->setPen(QPen(option.palette.text().color())); + painter->setBrush(Qt::NoBrush); painter->setOpacity(1); - painter->setPen(QPen(Qt::white)); painter->drawText(QRect(iconRect.right()+15,rect.y(), rect.width()-62,rect.height()),Qt::AlignVCenter,appname); + painter->restore(); } - painter->restore(); } } diff --git a/src/UtilityFunction/letterclassifybutton.cpp b/src/UtilityFunction/letterclassifybutton.cpp index 30c8339..25066da 100644 --- a/src/UtilityFunction/letterclassifybutton.cpp +++ b/src/UtilityFunction/letterclassifybutton.cpp @@ -17,67 +17,116 @@ */ #include "letterclassifybutton.h" +#include +#include LetterClassifyButton::LetterClassifyButton(QWidget *parent, - QString hoverbg, - QString pressedbg, + bool fullscreen, QString letter): - QToolButton(parent) + QPushButton(parent), + m_fullscreen(fullscreen) { - this->hoverbg=hoverbg; - this->pressedbg=pressedbg; - this->setStyleSheet(QString("background:transparent;color:#8b8b8b;padding-left:0px;")); + this->setFlat(true); QFont font; font.setPixelSize(Style::LeftLetterFontSize); this->setFont(font); this->setText(letter); - this->setFixedSize(Style::LeftLetterBtnHeight,Style::LeftLetterBtnHeight); this->setCheckable(true); connect(this,&LetterClassifyButton::toggled,this,&LetterClassifyButton::reactToToggle); } +void LetterClassifyButton::paintEvent(QPaintEvent* e) +{ + QStylePainter painter(this); + QStyleOptionButton option; + initStyleOption(&option); + if ((option.state & QStyle::State_Enabled) && (option.state & QStyle::State_MouseOver)) { + painter.save(); + painter.setPen(Qt::NoPen); + if(!m_fullscreen) + { + QColor color = option.palette.color(QPalette::Text); + color.setAlphaF(0.15); + painter.setBrush(color); + } + else + { + painter.setOpacity(0.15); + painter.setBrush(Qt::white); + } + painter.drawRoundedRect(option.rect, 4, 4); + painter.restore(); + } + if(m_fullscreen && (option.state & QStyle::State_On)) + { + painter.save(); + painter.setPen(Qt::NoPen); +// QColor color = option.palette.color(QPalette::Text); +// color.setAlphaF(0.15); +// painter.setBrush(color); + painter.setOpacity(0.15); + painter.setBrush(Qt::white); + painter.drawRoundedRect(option.rect, 4, 4); + painter.restore(); + } + + QStyleOptionButton subopt = option; + subopt.rect = painter.style()->subElementRect(QStyle::SE_PushButtonContents, &option, this); + if(m_fullscreen) + subopt.palette.setBrush(QPalette::ButtonText, QColor(Qt::white)); + else + subopt.palette.setBrush(QPalette::HighlightedText, subopt.palette.text()); + painter.style()->drawControl(QStyle::CE_PushButtonLabel, &subopt, &painter, this); + return; +} + void LetterClassifyButton::enterEvent(QEvent *e) { Q_UNUSED(e); - this->setStyleSheet(QString("background:transparent;color:#ffffff;padding-left:0px;")); - QFont font; - font.setPixelSize(Style::LeftLetterFontSize*3); - this->setFont(font); - this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); + if(m_fullscreen) + { + QFont font; + font.setPixelSize(Style::LeftLetterFontSize*3); + this->setFont(font); + this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); + } } void LetterClassifyButton::leaveEvent(QEvent *e) { Q_UNUSED(e); - if(is_pressed) - this->setStyleSheet(QString("background:transparent;color:#ffffff;padding-left:0px;")); - else - this->setStyleSheet(QString("background:transparent;color:#8b8b8b;padding-left:0px;")); - QFont font; - font.setPixelSize(Style::LeftLetterFontSize); - this->setFont(font); - this->setFixedSize(Style::LeftLetterBtnHeight,Style::LeftLetterBtnHeight); + if(m_fullscreen) + { + QFont font; + font.setPixelSize(Style::LeftLetterFontSize); + this->setFont(font); + this->setFixedSize(Style::LeftLetterBtnHeight,Style::LeftLetterBtnHeight); + } } void LetterClassifyButton::mousePressEvent(QMouseEvent *event) { Q_UNUSED(event); - this->setStyleSheet(QString("background:transparent;color:#ffffff;padding-left:0px;")); - QFont font; - font.setPixelSize(Style::LeftLetterFontSize*3); - this->setFont(font); - this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); - is_pressed=true; + if(m_fullscreen) + { + QFont font; + font.setPixelSize(Style::LeftLetterFontSize*3); + this->setFont(font); + this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); + is_pressed=true; + } } void LetterClassifyButton::mouseReleaseEvent(QMouseEvent *event) { Q_UNUSED(event); - this->setStyleSheet(QString("background:transparent;color:#ffffff;padding-left:0px;")); - QFont font; - font.setPixelSize(Style::LeftLetterFontSize*3); - this->setFont(font); - this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); + if(m_fullscreen) + { + QFont font; + font.setPixelSize(Style::LeftLetterFontSize*3); + this->setFont(font); + this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); + } Q_EMIT buttonClicked(this); } @@ -85,12 +134,10 @@ void LetterClassifyButton::reactToToggle(bool checked) { if(checked) { - this->setStyleSheet(QString("background:transparent;color:#ffffff;padding-left:0px;")); this->is_pressed=true; } else { - this->setStyleSheet(QString("background:transparent;color:#8b8b8b;padding-left:0px;")); this->is_pressed=false; } } diff --git a/src/UtilityFunction/letterclassifybutton.h b/src/UtilityFunction/letterclassifybutton.h index 98d6112..7fa1307 100644 --- a/src/UtilityFunction/letterclassifybutton.h +++ b/src/UtilityFunction/letterclassifybutton.h @@ -18,30 +18,29 @@ #ifndef LETTERCLASSIFYBUTTON_H #define LETTERCLASSIFYBUTTON_H -#include +#include #include #include #include "src/Style/style.h" -class LetterClassifyButton : public QToolButton +class LetterClassifyButton : public QPushButton { Q_OBJECT public: LetterClassifyButton(QWidget *parent, - QString hoverbg, - QString pressedbg, + bool fullscreen, QString letter ); bool is_pressed=false; private: - QString hoverbg; - QString pressedbg; + bool m_fullscreen=false; protected: void enterEvent(QEvent* e); void leaveEvent(QEvent* e); + void paintEvent(QPaintEvent* e); void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); diff --git a/src/UtilityFunction/listview.cpp b/src/UtilityFunction/listview.cpp index b0a413c..d4ea435 100644 --- a/src/UtilityFunction/listview.cpp +++ b/src/UtilityFunction/listview.cpp @@ -32,7 +32,6 @@ ListView::ListView(QWidget *parent, int width, int height, int module): QString path=QDir::homePath()+"/.config/ukui/ukui-menu.ini"; setting=new QSettings(path,QSettings::IniFormat); - } ListView::~ListView() { @@ -42,19 +41,11 @@ ListView::~ListView() void ListView::initWidget() { -// this->setFixedSize(w,h); - - this->verticalScrollBar()->setStyleSheet("QScrollBar{padding-top:0px;padding-bottom:0px;background:transparent;width:3px;border-radius:1.5px;}" - "QScrollBar::handle{background-color:rgba(255,255,255,0.25); width:3px;border-radius:1.5px;}" - "QScrollBar::handle:hover{background-color:#697883;width:3px;border-radius:1.5px;}" - "QScrollBar::handle:pressed{background-color:#8897a3;width:3px;border-radius:1.5px;}" - "QScrollBar::sub-line{background-color:transparent;height:0px;width:0px;}" - "QScrollBar::add-line{background-color:transparent;height:0px;width:0px;}" - ); + setAttribute(Qt::WA_TranslucentBackground); + viewport()->setAttribute(Qt::WA_TranslucentBackground); this->setSelectionMode(QAbstractItemView::SingleSelection); this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); -// this->setGridSize(QSize(310,48)); this->setResizeMode(QListView::Adjust); this->setTextElideMode(Qt::ElideRight); this->setViewMode(QListView::ListMode); @@ -63,11 +54,11 @@ void ListView::initWidget() this->setMovement(QListView::Static); this->setEditTriggers(QAbstractItemView::NoEditTriggers); this->setUpdatesEnabled(true); -// this->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); this->setSpacing(0); this->setContentsMargins(0, 0, 0, 0); this->setMouseTracking(true); this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); + this->setFrameShape(QFrame::NoFrame); connect(this,&ListView::customContextMenuRequested,this,&ListView::rightClickedSlot); connect(this,&ListView::clicked,this,&ListView::onClicked); } @@ -179,3 +170,15 @@ void ListView::leaveEvent(QEvent *e) Q_UNUSED(e); this->verticalScrollBar()->setVisible(false); } + +void ListView::paintEvent(QPaintEvent *e) +{ + QGSettings* gsetting=new QGSettings(QString("org.ukui.control-center.personalise").toLocal8Bit()); + double transparency=gsetting->get("transparency").toDouble(); + QPainter painter(this->viewport()); + painter.setOpacity(transparency); + painter.setPen(Qt::NoPen); + painter.setBrush(this->palette().base()); + painter.fillRect(this->rect(), this->palette().base()); + QListView::paintEvent(e); +} diff --git a/src/UtilityFunction/listview.h b/src/UtilityFunction/listview.h index addd5f9..37a61c4 100644 --- a/src/UtilityFunction/listview.h +++ b/src/UtilityFunction/listview.h @@ -45,6 +45,7 @@ protected: void initWidget(); void enterEvent(QEvent* e) Q_DECL_OVERRIDE; void leaveEvent(QEvent* e) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *e) override; private: QStandardItemModel* listmodel=nullptr; diff --git a/src/UtilityFunction/proxystyle.cpp b/src/UtilityFunction/proxystyle.cpp new file mode 100644 index 0000000..ecd103e --- /dev/null +++ b/src/UtilityFunction/proxystyle.cpp @@ -0,0 +1,50 @@ +#include "proxystyle.h" +#include +#include + +ProxyStyle::ProxyStyle() +{ + if(QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) + { + QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); + connect(gsetting,&QGSettings::changed,this,[=]{ + for(auto widget: QApplication::allWidgets()) + { + qDebug()<<"---111---"; + widget->update(); + } + }); + } +} + +QPalette ProxyStyle::standardPalette() const +{ + auto m_palette=QProxyStyle::standardPalette(); + QColor m_highlightbg; + if(QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) + { + QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); + if(gsetting->keys().contains(QString("styleName"))) + { + if(gsetting->get("style-name").toString()=="ukui-light") + { + m_highlightbg=QColor(0, 0, 0); + m_highlightbg.setAlphaF(0.15); + } + else + { + m_highlightbg=QColor(255,255,255); + m_highlightbg.setAlphaF(0.14); + } + } + m_palette.setBrush(QPalette::Highlight,m_highlightbg); + return m_palette; + } + return m_palette; +} + +void ProxyStyle::polish(QPalette &pal) +{ + pal=standardPalette(); +// QProxyStyle::polish(pal); +} diff --git a/src/UtilityFunction/proxystyle.h b/src/UtilityFunction/proxystyle.h new file mode 100644 index 0000000..397e74a --- /dev/null +++ b/src/UtilityFunction/proxystyle.h @@ -0,0 +1,28 @@ +#ifndef INTERNALSTYLE_H +#define INTERNALSTYLE_H +#include +#include +#include +#include +#include +#include + +class ProxyStyle : public QProxyStyle +{ + Q_OBJECT +public: + ProxyStyle(); + +// void drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const; +// void drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const; +// void drawComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = nullptr) const; + void polish(QPalette &pal); +// void polish(QWidget *widget); + QPalette standardPalette() const; + +private: + double transparency; + +}; + +#endif // INTERNALSTYLE_H diff --git a/src/UtilityFunction/scrollarea.cpp b/src/UtilityFunction/scrollarea.cpp index a86855b..6d72db4 100644 --- a/src/UtilityFunction/scrollarea.cpp +++ b/src/UtilityFunction/scrollarea.cpp @@ -18,21 +18,75 @@ #include "scrollarea.h" #include +#include +#include + +ScrollAreaWid::ScrollAreaWid() +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setAttribute(Qt::WA_TranslucentBackground); +} + +void ScrollAreaWid::paintEvent(QPaintEvent *event) +{ + QGSettings* gsetting=new QGSettings(QString("org.ukui.control-center.personalise").toLocal8Bit()); + double transparency=gsetting->get("transparency").toDouble(); + QPainter painter(this); +// painter.setRenderHint(QPainter::Antialiasing); +// painter.setOpacity(0.25); +// painter.setBrush(Qt::black); +// painter.setPen(Qt::NoPen); +// QRect rect = this->rect(); +// rect.setWidth(rect.width()); +// rect.setHeight(rect.height()); +// painter.drawRect(rect); + + if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) + { + QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); + if(gsetting.keys().contains(QString("effect"))) + { + if(gsetting.get("effect").toBool()) + { + painter.setBrush(Qt::black); + painter.setPen(Qt::transparent); + painter.setOpacity(0.25); + painter.drawRect(this->rect()); + } + else + { + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); + } + } + else + { + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); + } + } + else + { + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); + } + QWidget::paintEvent(event); +} ScrollArea::ScrollArea() { this->verticalScrollBar()->setVisible(false); - this->verticalScrollBar()->setStyleSheet("QScrollBar{width:3px;padding-top:0px;padding-bottom:0px;background:transparent;border-radius:6px;}" - "QScrollBar::handle{background-color:rgba(255,255,255,0.25); width:3px;border-radius:1.5px;}" - "QScrollBar::handle:hover{background-color:#697883;border-radius:1.5px;}" - "QScrollBar::handle:pressed{background-color:#8897a3;border-radius:1.5px;}" - "QScrollBar::sub-line{background-color:transparent;height:0px;width:0px;}" - "QScrollBar::add-line{background-color:transparent;height:0px;width:0px;}" - ); - installEventFilter(this); - this->setFocusPolicy(Qt::NoFocus); - this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); + installEventFilter(this); + this->setFocusPolicy(Qt::NoFocus); + this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); + this->setFrameShape(QFrame::NoFrame); } void ScrollArea::enterEvent(QEvent *e) @@ -46,3 +100,13 @@ void ScrollArea::leaveEvent(QEvent *e) Q_UNUSED(e); this->verticalScrollBar()->setVisible(false); } + +void ScrollArea::scrollContentsBy(int dx, int dy) +{ + QScrollArea::scrollContentsBy(dx,dy); + + Q_EMIT requestUpdate(); + +// update(); +// viewport()->update(); +} diff --git a/src/UtilityFunction/scrollarea.h b/src/UtilityFunction/scrollarea.h index 3892462..0660c15 100644 --- a/src/UtilityFunction/scrollarea.h +++ b/src/UtilityFunction/scrollarea.h @@ -25,18 +25,32 @@ #include #include +class ScrollAreaWid: public QWidget +{ +public: + ScrollAreaWid(); + +protected: + void paintEvent(QPaintEvent* event); +}; + class ScrollArea : public QScrollArea { + Q_OBJECT public: ScrollArea(); +Q_SIGNALS: + void requestUpdate(); + protected: void enterEvent(QEvent* e) Q_DECL_OVERRIDE; void leaveEvent(QEvent* e) Q_DECL_OVERRIDE; + void scrollContentsBy(int dx, int dy) override; + private: double m_speedTime = 3; - }; #endif // SCROLLAREA_H diff --git a/src/UtilityFunction/pushbutton.cpp b/src/UtilityFunction/splitbarframe.cpp similarity index 72% rename from src/UtilityFunction/pushbutton.cpp rename to src/UtilityFunction/splitbarframe.cpp index e0fa1a1..6a9b517 100644 --- a/src/UtilityFunction/pushbutton.cpp +++ b/src/UtilityFunction/splitbarframe.cpp @@ -16,10 +16,10 @@ * */ -#include "pushbutton.h" +#include "splitbarframe.h" -PushButton::PushButton(QWidget *parent, QString category, int width, int height, int module): - QPushButton(parent), +SplitBarFrame::SplitBarFrame(QWidget *parent, QString category, int width, int height, int module): + QFrame(parent), m_category(category), m_width(width), m_height(height), @@ -30,47 +30,49 @@ PushButton::PushButton(QWidget *parent, QString category, int width, int height, initAppBtn(); } -PushButton::~PushButton() +SplitBarFrame::~SplitBarFrame() { } -void PushButton::initAppBtn() -{ - char btnstyle[300]; - sprintf(btnstyle,"QPushButton{background:transparent;border:0px;color:#ffffff;font-size:14px;padding-left:0px;text-align: left center;}\ - QPushButton:hover{background-color:%s;}\ - QPushButton:pressed{background-color:%s;}", ClassifyBtnHoverBackground,ClassifyBtnHoverBackground); - +void SplitBarFrame::initAppBtn() +{ this->setFixedSize(m_width,m_height); - this->setStyleSheet(btnstyle); +// this->setStyleSheet("background:transparent"); + //按钮透明 this->setFocusPolicy(Qt::NoFocus); - QHBoxLayout* layout=new QHBoxLayout(this); + this->setAttribute(Qt::WA_TranslucentBackground); + QHBoxLayout* layout=new QHBoxLayout; layout->setContentsMargins(15,0,0,0); layout->setSpacing(6); - char style[100]; - sprintf(style,"color:#ffffff;"); + m_textLabel->setAutoFillBackground(false); m_textLabel->setAlignment(Qt::AlignCenter); - m_textLabel->setStyleSheet(style); if(m_module==1) m_textLabel->setText(m_category); else setLabelText(); m_textLabel->adjustSize(); + QPalette pe=m_textLabel->palette(); + pe.setColor(QPalette::WindowText,Qt::white); + m_textLabel->setPalette(pe); m_line->setFrameShape(QFrame::HLine); m_line->setFixedHeight(1); - m_line->setStyleSheet("background-color:rgba(255, 255, 255, 0.06)"); m_line->setFixedSize(m_width-m_textLabel->width()-15,1); + m_line->setEnabled(false); + QPalette linePe=m_line->palette(); + QColor color(255,255,255); + color.setAlphaF(0.10); + linePe.setColor(QPalette::WindowText,color); + m_line->setPalette(linePe); + this->setLayout(layout); layout->addWidget(m_textLabel); layout->addWidget(m_line); - this->setLayout(layout); - this->setEnabled(false); } -void PushButton::setLabelText() +void SplitBarFrame::setLabelText() { - QMetaEnum metaEnum=QMetaEnum::fromType(); + QMetaEnum metaEnum=QMetaEnum::fromType(); switch (metaEnum.keyToValue(m_category.toLocal8Bit().data())) { case Mobile: diff --git a/src/UtilityFunction/pushbutton.h b/src/UtilityFunction/splitbarframe.h similarity index 91% rename from src/UtilityFunction/pushbutton.h rename to src/UtilityFunction/splitbarframe.h index ff51eae..ee33748 100644 --- a/src/UtilityFunction/pushbutton.h +++ b/src/UtilityFunction/splitbarframe.h @@ -29,7 +29,7 @@ #include "src/RightClickMenu/rightclickmenu.h" #include "utility.h" -class PushButton : public QPushButton +class SplitBarFrame : public QFrame //全屏分隔栏 { Q_OBJECT public: @@ -37,8 +37,8 @@ public: * @param classify为0时为分类按钮、1为应用按钮 * @param module为0时为常用模块,1为字母模块、2为功能模块 */ - PushButton(QWidget *parent,QString category,int width,int height,int module); - ~PushButton(); + SplitBarFrame(QWidget *parent,QString category,int width,int height,int module); + ~SplitBarFrame(); enum Category{ Mobile, @@ -66,7 +66,6 @@ private: protected: void initAppBtn(); void setLabelText(); - }; #endif // PUSHBUTTON_H diff --git a/src/UtilityFunction/toolbutton.cpp b/src/UtilityFunction/toolbutton.cpp index d9fa992..330a353 100644 --- a/src/UtilityFunction/toolbutton.cpp +++ b/src/UtilityFunction/toolbutton.cpp @@ -54,10 +54,10 @@ ToolButton::ToolButton(int width, { this->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); this->setText(tr(text.toLocal8Bit().data())); - this->setStyleSheet("border:0px;padding-left:16px;background:transparent;color:rgba(255, 255, 255, 50%);font-size:14px;"); +// this->setStyleSheet("border:0px;padding-left:16px;background:transparent;color:rgba(255, 255, 255, 50%);font-size:14px;"); } - else - this->setStyleSheet("border:0px;padding-left:0px;background:transparent;"); +// else +// this->setStyleSheet("border:0px;padding-left:0px;background:transparent;"); } void ToolButton::enterEvent(QEvent *e) @@ -70,7 +70,7 @@ void ToolButton::enterEvent(QEvent *e) sprintf(style,"border:0px;padding-left:16px;background-color:%s;color:#ffffff;font-size:14px;",hover); else sprintf(style,"border:0px;padding-left:0px;background-color:%s;",hover); - this->setStyleSheet(QString::fromLocal8Bit(style)); +// this->setStyleSheet(QString::fromLocal8Bit(style)); delete svgRender; svgRender=new QSvgRenderer(this); svgRender->load(piconstr); @@ -89,15 +89,15 @@ void ToolButton::enterEvent(QEvent *e) void ToolButton::leaveEvent(QEvent *e) { Q_UNUSED(e); - if(module==2) - { - if(!is_pressed) - this->setStyleSheet("border:0px;padding-left:16px;background:transparent;color:rgba(255, 255, 255, 50%);font-size:14px;"); - else - this->setStyleSheet("border:0px;padding-left:16px;background:transparent;color:rgba(255, 255, 255);font-size:14px;"); - } - else - this->setStyleSheet("border:0px;padding-left:0px;background:transparent;"); +// if(module==2) +// { +// if(!is_pressed) +// this->setStyleSheet("border:0px;padding-left:16px;background:transparent;color:rgba(255, 255, 255, 50%);font-size:14px;"); +// else +// this->setStyleSheet("border:0px;padding-left:16px;background:transparent;color:rgba(255, 255, 255);font-size:14px;"); +// } +// else +// this->setStyleSheet("border:0px;padding-left:0px;background:transparent;"); delete svgRender; svgRender=new QSvgRenderer(this); if(module==2 && is_pressed) @@ -127,7 +127,7 @@ void ToolButton::mousePressEvent(QMouseEvent *event) sprintf(style,"border:0px;padding-left:0px;background-color:%s;",pressed); if(event->button()==Qt::LeftButton) { - this->setStyleSheet(QString::fromLocal8Bit(style)); +// this->setStyleSheet(QString::fromLocal8Bit(style)); delete svgRender; svgRender=new QSvgRenderer(this); svgRender->load(piconstr); @@ -157,7 +157,7 @@ void ToolButton::mouseReleaseEvent(QMouseEvent *event) sprintf(style,"border:0px;padding-left:0px;background-color:%s;",hover); if(event->button()==Qt::LeftButton) { - this->setStyleSheet(QString::fromLocal8Bit(style)); +// this->setStyleSheet(QString::fromLocal8Bit(style)); delete svgRender; svgRender=new QSvgRenderer(this); svgRender->load(piconstr); diff --git a/src/UtilityFunction/utility.cpp b/src/UtilityFunction/utility.cpp index ca2c517..11cf418 100644 --- a/src/UtilityFunction/utility.cpp +++ b/src/UtilityFunction/utility.cpp @@ -34,3 +34,54 @@ const QPixmap loadSvg(const QString &fileName, const int size) return pixmap; } + +QPixmap drawSymbolicColoredPixmap(const QPixmap &source) +{ + QColor gray(128,128,128); + QColor standard (31,32,34); + QImage img = source.toImage(); + for (int x = 0; x < img.width(); x++) { + for (int y = 0; y < img.height(); y++) { + auto color = img.pixelColor(x, y); + if (color.alpha() > 0) { + if (qAbs(color.red()-gray.red())<20 && qAbs(color.green()-gray.green())<20 && qAbs(color.blue()-gray.blue())<20) { + color.setRed(255); + color.setGreen(255); + color.setBlue(255); + img.setPixelColor(x, y, color); + } + else if(qAbs(color.red()-standard.red())<20 && qAbs(color.green()-standard.green())<20 && qAbs(color.blue()-standard.blue())<20) + { + color.setRed(255); + color.setGreen(255); + color.setBlue(255); + img.setPixelColor(x, y, color); + } + else + { + img.setPixelColor(x, y, color); + } + } + } + } + return QPixmap::fromImage(img); +} + +QPixmap drawSymbolicBlackColoredPixmap(const QPixmap &source) +{ + QImage img = source.toImage(); + for (int x = 0; x < img.width(); x++) { + for (int y = 0; y < img.height(); y++) { + auto color = img.pixelColor(x, y); + if (color.alpha() > 0) { + if (qAbs(color.red())>=200 && qAbs(color.green())>=200 && qAbs(color.blue())>=200) { + color.setRed(56); + color.setGreen(56); + color.setBlue(56); + img.setPixelColor(x, y, color); + } + } + } + } + return QPixmap::fromImage(img); +} diff --git a/src/UtilityFunction/utility.h b/src/UtilityFunction/utility.h index 943c67b..2ae9079 100644 --- a/src/UtilityFunction/utility.h +++ b/src/UtilityFunction/utility.h @@ -23,4 +23,11 @@ const QPixmap loadSvg(const QString &fileName, const int size); +//图片反白 +QPixmap drawSymbolicColoredPixmap(const QPixmap &source); + +//图片反黑 +QPixmap drawSymbolicBlackColoredPixmap(const QPixmap &source); + + #endif // UTILITY_H diff --git a/translations/ukui-menu_bo.ts b/translations/ukui-menu_bo.ts index 7e9676c..bfc754a 100644 --- a/translations/ukui-menu_bo.ts +++ b/translations/ukui-menu_bo.ts @@ -2,417 +2,287 @@ - CommonUseWidget + FunctionClassifyButton - - Form + + Mobile - - - FullCommonUseWidget - - Form - - - - - FullFunctionWidget - - - Form - - - - - - Android - - - - - + Internet - - + Social - - + Video - - + Development - - + Image - - + Game - - + Office - - + Education - - + System - - + Others - FullLetterWidget - - - Form - - - - - FullSearchResultWidget - - - Form - - - - - FunctionButtonWidget - - - Form - - + FunctionWidget - - Android + + Mobile - + Internet - + Social - + Video - + Development - + Image - + Game - + Office - + Education - + System - + Others - FunctionWidget - - - Form - - - - - - Android - - - - - - Internet - - - - - - Social - - - - - - Video - - + MainViewWidget - - - Development + + Search + + + RightClickMenu - - - Image + + Pin to all - - - Game + + Unpin from all - - - Office + + + Pin to taskbar - - - Education + + + Unpin from taskbar - - - System + + Add to desktop shortcuts - - - Others + + Uninstall - - - LetterButtonWidget - - Form + + Sleep - - - LetterWidget - - Form + + Log Out - - - MainViewWidget - - Form + + Restart - - Search + + Power Off - - - MainWindow - - MainWindow + + Personalize this list - RightClickMenu - - - - Pin to all - - - - - - Unpin from all - - - - - - - Pin to taskbar - - + SideBarWidget - - - - Unpin from taskbar + + All - - - Add to desktop shortcuts + + Letter - - - Uninstall + + Function - - Lock Screen + + Trash - - Switch User + + Computer - - Log Out + + Personal - - Restart + + Settings - - Power Off + + Power + + + SplitBarFrame - - Personalize this list + + Mobile - - - SearchResultWidget - - Form + + Internet - - - SideBarWidget - - Form + + Social - - - All + + Video - - - Letter + + Development - - - Function + + Image - - - Computer + + Game - - - Personal + + Office - - - Settings + + Education - - - Recycle Bin + + System - - - Power + + Others diff --git a/translations/ukui-menu_tr.ts b/translations/ukui-menu_tr.ts index 5ae00ce..6460b5f 100644 --- a/translations/ukui-menu_tr.ts +++ b/translations/ukui-menu_tr.ts @@ -4,57 +4,57 @@ FunctionClassifyButton - + Mobile Mobil - + Internet İnternet - + Social Sosyal - + Video Video - + Development Programlama - + Image Grafik - + Game Oyunlar - + Office Ofis Uygulamaları - + Education Eğitim - + System Sistem - + Others Diğer @@ -62,57 +62,57 @@ FunctionWidget - + Mobile Mobil - + Internet İnternet - + Social Sosyal - + Video Video - + Development Programlama - + Image Grafik - + Game Oyunlar - + Office Ofis Uygulamaları - + Education Eğitim - + System Sistem - + Others Diğer @@ -120,7 +120,7 @@ MainViewWidget - + Search Ara @@ -128,132 +128,118 @@ PushButton - Mobile - Mobil + Mobil - Internet - İnternet + İnternet - Social - Sosyal + Sosyal - Video - Video + Video - Development - Programlama + Programlama - Image - Grafik + Grafik - Game - Oyunlar + Oyunlar - Office - Ofis Uygulamaları + Ofis Uygulamaları - Education - Eğitim + Eğitim - System - Sistem + Sistem - Others - Diğer + Diğer RightClickMenu - + Pin to all Tümünü sabitle - + Unpin from all Tüm sabitlemeleri kaldır - - + + Pin to taskbar Görev çubuğuna sabitle - - + + Unpin from taskbar Görev çubuğundan sabitlemeyi kaldır - + Add to desktop shortcuts Masaüstü kısayollarına ekle - + Uninstall Kaldır - Hibernate - Beklemeye Al + Beklemeye Al - + Sleep Uyku Modu - Lock Screen - Ekranı Kilitle + Ekranı Kilitle - Switch User - Kullanıcı Değiştir + Kullanıcı Değiştir - + Log Out Çıkış - + Restart Yeniden Başlat - + Power Off Kapat - + Personalize this list Bu listeyi özelleştirin @@ -261,44 +247,106 @@ SideBarWidget - + All Tümü - + Letter Alfabetik - + Function Kategori - + + Trash + + + + Computer Bilgisayar - + Personal Kişisel - + Settings Ayarlar - Recycle Bin - Çöp + Çöp - + Power Kapat + + SplitBarFrame + + + Mobile + Mobil + + + + Internet + İnternet + + + + Social + Sosyal + + + + Video + Video + + + + Development + Programlama + + + + Image + Grafik + + + + Game + Oyunlar + + + + Office + Ofis Uygulamaları + + + + Education + Eğitim + + + + System + Sistem + + + + Others + Diğer + + diff --git a/translations/ukui-menu_zh_CN.ts b/translations/ukui-menu_zh_CN.ts index fc6a4d6..5a37281 100644 --- a/translations/ukui-menu_zh_CN.ts +++ b/translations/ukui-menu_zh_CN.ts @@ -4,57 +4,57 @@ FunctionClassifyButton - + Mobile 移动 - + Internet 网络 - + Social 社交 - + Video 影音 - + Development 开发 - + Image 图像 - + Game 游戏 - + Office 办公 - + Education 教育 - + System 系统 - + Others 其它 @@ -62,57 +62,57 @@ FunctionWidget - + Mobile 移动 - + Internet 网络 - + Social 社交 - + Video 影音 - + Development 开发 - + Image 图像 - + Game 游戏 - + Office 办公 - + Education 教育 - + System 系统 - + Others 其它 @@ -120,7 +120,7 @@ MainViewWidget - + Search 搜索 @@ -128,132 +128,118 @@ PushButton - Mobile - 移动 + 移动 - Internet - 网络 + 网络 - Social - 社交 + 社交 - Video - 影音 + 影音 - Development - 开发 + 开发 - Image - 图像 + 图像 - Game - 游戏 + 游戏 - Office - 办公 + 办公 - Education - 教育 + 教育 - System - 系统 + 系统 - Others - 其它 + 其它 RightClickMenu - + Pin to all 固定到“所有软件” - + Unpin from all 从“所有软件”取消固定 - - + + Pin to taskbar 固定到任务栏 - - + + Unpin from taskbar 从任务栏取消固定 - + Add to desktop shortcuts 添加到桌面快捷方式 - + Uninstall 卸载 - Hibernate - 休眠 + 休眠 - + Sleep 睡眠 - Lock Screen - 锁屏 + 锁屏 - Switch User - 切换用户 + 切换用户 - + Log Out 注销 - + Restart 重启 - + Power Off 关机 - + Personalize this list 设置开始菜单显示列表 @@ -261,44 +247,106 @@ SideBarWidget - + All 所有软件 - + Letter 字母排序 - + Function 功能分类 - + + Trash + 回收站 + + + Computer 计算机 - + Personal 个人 - + Settings 设置 - Recycle Bin - 回收站 + 回收站 - + Power 电源 + + SplitBarFrame + + + Mobile + 移动 + + + + Internet + 网络 + + + + Social + 社交 + + + + Video + 影音 + + + + Development + 开发 + + + + Image + 图像 + + + + Game + 游戏 + + + + Office + 办公 + + + + Education + 教育 + + + + System + 系统 + + + + Others + 其它 + + diff --git a/ukui-menu.pro b/ukui-menu.pro index 639f803..58bb6c4 100644 --- a/ukui-menu.pro +++ b/ukui-menu.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += core gui svg dbus x11extras KWindowSystem +QT += core gui svg dbus x11extras greaterThan(QT_MAJOR_VERSION, 4): QT += widgets include(src/QtSingleApplication/qtsingleapplication.pri) @@ -62,15 +62,16 @@ SOURCES += \ src/SearchResultWidget/searchresultwidget.cpp \ src/SideBarWidget/sidebarwidget.cpp \ src/Style/style.cpp \ - src/UtilityFunction/classifyscrollarea.cpp \ + src/UtilityFunction/classifybtnscrollarea.cpp \ src/UtilityFunction/fullitemdelegate.cpp \ src/UtilityFunction/fulllistview.cpp \ src/UtilityFunction/functionclassifybutton.cpp \ src/UtilityFunction/itemdelegate.cpp \ src/UtilityFunction/letterclassifybutton.cpp \ src/UtilityFunction/listview.cpp \ - src/UtilityFunction/pushbutton.cpp \ + src/UtilityFunction/proxystyle.cpp \ src/UtilityFunction/scrollarea.cpp \ + src/UtilityFunction/splitbarframe.cpp \ src/UtilityFunction/toolbutton.cpp \ src/Interface/ukuichineseletter.cpp \ src/Interface/ukuimenuinterface.cpp \ @@ -96,15 +97,16 @@ HEADERS += \ src/SearchResultWidget/searchresultwidget.h \ src/SideBarWidget/sidebarwidget.h \ src/Style/style.h \ - src/UtilityFunction/classifyscrollarea.h \ + src/UtilityFunction/classifybtnscrollarea.h \ src/UtilityFunction/fullitemdelegate.h \ src/UtilityFunction/fulllistview.h \ src/UtilityFunction/functionclassifybutton.h \ src/UtilityFunction/itemdelegate.h \ src/UtilityFunction/letterclassifybutton.h \ src/UtilityFunction/listview.h \ - src/UtilityFunction/pushbutton.h \ + src/UtilityFunction/proxystyle.h \ src/UtilityFunction/scrollarea.h \ + src/UtilityFunction/splitbarframe.h \ src/UtilityFunction/toolbutton.h \ src/Interface/ukuichineseletter.h \ src/Interface/ukuimenuinterface.h \ -- 2.30.0