代码拉取完成,页面将自动刷新
同步操作将从 柚子/Oh my dde 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QSettings>
#include <QIcon>
#include <QGraphicsOpacityEffect>
#include <DSettings>
#include <DSettingsOption>
#include <DSettingsDialog>
#include <DBlurEffectWidget>
#include <DApplication>
#include <DGuiApplicationHelper>
#include <QDir>
#include <QDesktopServices>
DWIDGET_USE_NAMESPACE
Widget::Widget(DBlurEffectWidget *parent) :
DBlurEffectWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
initUI();
//侧边栏按钮
connect(ui->jmwg,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(0);});
connect(ui->yjcd,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(1);});
connect(ui->cyml,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(2);});
connect(ui->wtfButton,&QPushButton::clicked,[=](){QDesktopServices::openUrl(QUrl(QLatin1String("https://gitee.com/Limexb/oh-my-dde/issues/I3JWD3")));});
//主题切换
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, [=](DGuiApplicationHelper::ColorType themeType) {
QColor main_color;
main_color=DGuiApplicationHelper::instance()->applicationPalette().highlight().color();
if(themeType==DGuiApplicationHelper::DarkType){
setTheme(true,main_color);
ui->youjianpage->setTheme(true,main_color);
ui->systemuipage->setTheme(true,main_color);
}else {
setTheme(false,main_color);
ui->youjianpage->setTheme(false,main_color);
ui->systemuipage->setTheme(false,main_color);
}
});
QFileInfo *file=new QFileInfo(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/autostart/omd-requ.desktop");
if(file->exists()==false)
{
QFile::copy(":/kjfs/omd-requ.desktop",QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/autostart/omd-requ.desktop");
}
delete file;
QMenu *tmenu=new QMenu;
QAction *rewg=new QAction;
rewg->setText(tr("Restart file manager"));
tmenu->addAction(rewg);
ui->titlebar->setMenu(tmenu);
connect(rewg,&QAction::triggered,[=](){QProcess *cmd=new QProcess;cmd->start("killall dde-file-manager");});
}
Widget::~Widget()
{
delete ui;
DApplication::quit();
}
void Widget::initUI()
{
// ui初始化
setMaskAlpha(220);
ui->stackedWidget->setCurrentIndex(0);
ui->icon->setPixmap(QIcon::fromTheme("youjian").pixmap(70,70));
ui->titlebar->setFixedHeight(50);
titlebar=ui->titlebar;
// 添加菜单项
QAction *setting=new QAction("设置");
QMenu *menu=new QMenu;
menu->addAction(setting);
titlebar->setMenu(menu);
// 初始化菜单数组
left_list[0]=ui->jmwg;
left_list[1]=ui->yjcd;
left_list[2]=ui->cyml;
}
void Widget::setTheme(bool isDark,QColor color)
{
// 菜单图标
if(isDark){
// 黑色模式
themeIsDark=true;
ui->label_3->setStyleSheet("color:"+color.name());
QPalette palette = ui->label_3->palette();
palette.setColor(QPalette::Window,QColor("#282828"));
palette.setColor(QPalette::Base,QColor("#282828"));
ui->scrollArea_3->setPalette(palette);
ui->titlebar->setPalette(palette);
QPalette palette1 = ui->line->palette();
palette1.setColor(QPalette::Light,QColor("#282929"));
ui->line->setPalette(palette1);
}else {
// 亮色模式
themeIsDark=false;
ui->label_3->setStyleSheet("color:"+color.name());
QPalette palette = ui->label_3->palette();
palette.setColor(QPalette::Window,QColor("#FFFFFF"));
palette.setColor(QPalette::Base,QColor("#FFFFFF"));
ui->scrollArea_3->setPalette(palette);
ui->titlebar->setPalette(palette);
QPalette palette1 = ui->line->palette();
palette1.setColor(QPalette::Light,QColor("#EBEBEB"));
ui->line->setPalette(palette1);
}
main_color=color;
updateUI();
if(ui->stackedWidget->currentIndex()==0){
chooseLeftMenu(nowMenu);
}
}
DTitlebar* Widget::getTitlebar()
{
return ui->titlebar;
}
void Widget::updateUI()
{
if(themeIsDark){
left_list[1]->setIcon(QIcon(":/icons/icons/xjwd_dark.svg"));
left_list[0]->setIcon(QIcon(":/icons/icons/gdgj_dark.svg"));
left_list[2]->setIcon(QIcon(":/icons/icons/cyml_dark.svg"));
}else {
left_list[1]->setIcon(QIcon(":/icons/icons/xjwd.svg"));
left_list[0]->setIcon(QIcon(":/icons/icons/gdgj.svg"));
left_list[2]->setIcon(QIcon(":/icons/icons/cyml.svg"));
}
for (int i=0;i<3;i++) {
left_list[i]->setFont(QFont("",11));
left_list[i]->setFixedHeight(38);
if(themeIsDark){
left_list[i]->setStyleSheet("color:#FFFFFF;border:0px");
}else {
left_list[i]->setStyleSheet("color:#252525;border:0px");
}
}
switch (nowMenu) {
case 1:
left_list[1]->setIcon(QIcon(":/icons/icons/xjwd_dark.svg"));
break;
case 0:
left_list[0]->setIcon(QIcon(":/icons/icons/gdgj_dark.svg"));
break;
case 2:
left_list[2]->setIcon(QIcon(":/icons/icons/cyml_dark.svg"));
break;
}
left_list[nowMenu]->setStyleSheet("color:#FFFFFF;background-color:"+main_color.name()+";border-radius:8;border:0px");
}
// 菜单切换逻辑
void Widget::chooseLeftMenu(int index)
{
nowMenu=index;
updateUI();
ui->stackedWidget->setCurrentIndex(nowMenu);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。