mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-07-11 08:05:59 +08:00
修改 左侧菜单跟随系统活动色
This commit is contained in:
parent
145b1b8e30
commit
6a555b06b9
@ -32,21 +32,21 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
|
||||
|
||||
// connect(DGuiApplicationHelper::instance(),&DGuiApplicationHelper::instance()->applicationPalette().highlight().color()::)
|
||||
|
||||
|
||||
//链接信号和槽
|
||||
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, [ = ](DGuiApplicationHelper::ColorType themeType) {
|
||||
QColor main_color;
|
||||
main_color=DGuiApplicationHelper::instance()->applicationPalette().highlight().color();
|
||||
if(themeType==DGuiApplicationHelper::DarkType){
|
||||
qDebug()<<"Dark";
|
||||
w->setTheme(true);
|
||||
w->setTheme(true,main_color);
|
||||
}else {
|
||||
qDebug()<<"White";
|
||||
w->setTheme(false);
|
||||
w->setTheme(false,main_color);
|
||||
}
|
||||
});
|
||||
// if(DGuiApplicationHelper::instance()-==DGuiApplicationHelper::ColorType::LightType){
|
||||
|
||||
// }
|
||||
connect(setting,&QAction::triggered,w,&Widget::opensetting);
|
||||
connect(searchEdit,&DSearchEdit::editingFinished,this,[=](){
|
||||
QString searchtext=searchEdit->text();
|
||||
|
14
widget.cpp
14
widget.cpp
@ -25,6 +25,7 @@
|
||||
#include "image_show.h"
|
||||
#include <DBlurEffectWidget>
|
||||
#include <QClipboard>
|
||||
#include <DGuiApplicationHelper>
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
Widget::Widget(QWidget *parent) :
|
||||
@ -103,8 +104,6 @@ void Widget::initUI()
|
||||
left_list[12]=ui->menu_btn_theme;left_menu_bg[12]=ui->menu_bg_theme;
|
||||
left_list[13]=ui->menu_btn_download;left_menu_bg[13]=ui->menu_bg_download;
|
||||
|
||||
// DBlurEffectWidget *bwidget=new DBlurEffectWidget;
|
||||
// bwidget->show();
|
||||
|
||||
//初始化web加载动画
|
||||
QHBoxLayout *m_weblayout=new QHBoxLayout;
|
||||
@ -189,16 +188,18 @@ void Widget::initConfig()
|
||||
}
|
||||
aptserver.close();
|
||||
}
|
||||
void Widget::setTheme(bool isDark)
|
||||
void Widget::setTheme(bool isDark,QColor color)
|
||||
{
|
||||
if(isDark){
|
||||
ui->widget_menuList->setStyleSheet("background-color:#282828");
|
||||
ui->webView->setStyleSheet("background-color:#282828");
|
||||
}else {
|
||||
|
||||
}else {
|
||||
ui->widget_menuList->setStyleSheet("background-color:#FFFFFF");
|
||||
ui->webView->setStyleSheet("background-color:#FFFFFF");
|
||||
}
|
||||
main_color=color;
|
||||
chooseLeftMenu(nowMenu);
|
||||
}
|
||||
|
||||
void Widget::on_webView_loadStarted()
|
||||
@ -215,9 +216,6 @@ void Widget::on_webView_loadStarted()
|
||||
if(url_.size()>3){
|
||||
type_name=url_[2];
|
||||
}
|
||||
|
||||
|
||||
// qDebug()<<type_name[2];
|
||||
//如果是app.json就打开详情页
|
||||
if(arg1.path().right(8)=="app.json"){
|
||||
load.cancel();//打开并发加载线程前关闭正在执行的线程
|
||||
@ -480,7 +478,7 @@ void Widget::chooseLeftMenu(int index)
|
||||
left_menu_bg[i]->setStyleSheet("");
|
||||
}
|
||||
left_list[index]->setStyleSheet("color:#FFFFFF");
|
||||
left_menu_bg[index]->setStyleSheet("background-color:#0081FF;border-radius:8");
|
||||
left_menu_bg[index]->setStyleSheet("background-color:"+main_color.name()+";border-radius:8");
|
||||
if(index<=12){
|
||||
ui->webView->setUrl(menuUrl[index]);
|
||||
ui->stackedWidget->setCurrentIndex(0);
|
||||
|
3
widget.h
3
widget.h
@ -41,7 +41,7 @@ public:
|
||||
int isdownload=false;
|
||||
void opensetting(); //打开设置页面
|
||||
void openUrl(QUrl);
|
||||
void setTheme(bool);
|
||||
void setTheme(bool,QColor);
|
||||
|
||||
private slots:
|
||||
|
||||
@ -115,6 +115,7 @@ private:
|
||||
QFuture<void> load;
|
||||
QTimer download_speed;
|
||||
QString type_name;
|
||||
QColor main_color;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user