!85 fix history button UI

Merge pull request !85 from likehomedream/plymouthshow
This commit is contained in:
KevinDuan 2023-12-25 01:23:04 +00:00 committed by Gitee
commit f803c1e2a0
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
10 changed files with 86 additions and 17 deletions

View File

@ -7,6 +7,9 @@ buildResultWidget::buildResultWidget(QWidget *parent)
this->setWindowModality(Qt::ApplicationModal);
this->setWindowFlags(Qt::FramelessWindowHint);
this->setBackgroundRole(QPalette::Base);
this->setAutoFillBackground(true);
m_buildResultLayout = new QVBoxLayout;
m_buildResult = new QLabel;
m_buildResult->setText("主题制作完成!");

View File

@ -99,7 +99,7 @@ MainWindow::MainWindow(QWidget *parent)
FileProcess::g_debPath = path;
m_bridge->savePathConfigChanged(path);
});
this->setContentsMargins(0,2,0,0);
this->setContentsMargins(5,5,5,0);
}
MainWindow::~MainWindow()
@ -201,6 +201,12 @@ void MainWindow::initUI()
buttonGroup->addButton(m_plymouthbtn);
buttonGroup->addButton(m_grubbtn);
m_globalbtn->setProperty("useButtonPalette", true);
m_iconbtn->setProperty("useButtonPalette", true);
m_cursorbtn->setProperty("useButtonPalette", true);
m_plymouthbtn->setProperty("useButtonPalette", true);
m_grubbtn->setProperty("useButtonPalette", true);
connect(m_historywidget,&HistoryWidget::startSecondEdit,[=](HistoryInfo InfoData){
m_titlebar->setGoHomeBtn(true);
m_maininterface->isHistory(true);

View File

@ -40,8 +40,14 @@ void CursorThemeWidget::eidtInitWidget(const HistoryInfo &InfoData)
m_preview2->updateIconMap(m_historytimeiconpathmap);
updateCustomPathMap(m_historyiconpathmap,"cursor");
updateCustomPathMap(m_historytimeiconpathmap,"timecursor");
if(m_info.wallpaperpath != nullptr){
m_preview->updateImage(m_info.wallpaperpath);
m_preview2->updateImage(m_info.wallpaperpath);
}else{
m_preview->updateImage(":/resource/background/1-openkylin.jpg");
m_preview2->updateImage(":/resource/background/1-openkylin.jpg");
}
}
/**

View File

@ -151,8 +151,8 @@ void GlobalThemeWidget::initPreviewWidget()
void GlobalThemeWidget::initRightWidget()
{
m_rightwidget = new QWidget(this);
m_rightwidget->setMinimumSize(400,620);
m_rightwidget->setMaximumWidth(400);
m_rightwidget->setMinimumSize(410,620);
m_rightwidget->setMaximumWidth(410);
m_rightwidget->setBackgroundRole(QPalette::Base);
m_rightwidget->setContentsMargins(0,0,0,0);

View File

@ -165,6 +165,7 @@ HistoryButton::HistoryButton(QWidget* parent): QPushButton(parent)
// this->setBackgroundRole(QPalette::Base);
this->setFixedSize(240, 280);
m_menu = new QMenu(this);
this->installEventFilter(this);
}
void HistoryButton::setHistoryTime(const QString &text)
@ -196,6 +197,7 @@ void HistoryButton::setThemeType(const QString &themeType)
*/
void HistoryButton::initUI()
{
this->setProperty("useButtonPalette", true);
QVBoxLayout* layout = new QVBoxLayout(this);
QLabel* imageLabel = new QLabel;
@ -231,7 +233,6 @@ void HistoryButton::initUI()
QHBoxLayout * btnwidgetlayout = new QHBoxLayout(btnwidget);
btnwidgetlayout->setContentsMargins(0,0,0,0);
QPushButton* button;
QString buttonText;
if (m_themetype == "globalTheme") {
buttonText = tr("globalTheme");
@ -244,13 +245,19 @@ void HistoryButton::initUI()
} else {
buttonText = tr("grubTheme");
}
button = new QPushButton(buttonText, this);
m_typebutton = new QPushButton(buttonText, this);
m_typebutton->setProperty("useButtonPalette", true);
m_typebutton->setProperty("setRadius", 18);
QPushButton* btn_menu = new QPushButton("···");
btn_menu->setFixedWidth(50);
btnwidgetlayout->addWidget(button);
m_menubutton = new QToolButton(this);
m_menubutton->setProperty("useButtonPalette", true);
m_menubutton->setFixedWidth(50);
m_menubutton->setText("···");
m_menubutton->setPopupMode(QToolButton::InstantPopup);
btnwidgetlayout->addWidget(m_typebutton);
btnwidgetlayout->addStretch(1);
btnwidgetlayout->addWidget(btn_menu);
btnwidgetlayout->addWidget(m_menubutton);
btnwidget->setLayout(btnwidgetlayout);
layout->addWidget(btnwidget);
@ -258,10 +265,15 @@ void HistoryButton::initUI()
// 创建并添加菜单选项
QAction* action1 = m_menu->addAction("删除");
QAction* action2 = m_menu->addAction("导出");
connect(btn_menu, &QPushButton::clicked, this, [=]() {
m_menu->exec(btn_menu->mapToGlobal(btn_menu->rect().bottomLeft()));
});
m_menubutton->setMenu(m_menu);
if(m_themename != nullptr){
action2->setDisabled(false);
}else{
action2->setDisabled(true);
}
// connect(btn_menu, &QPushButton::clicked, this, [=]() {
// m_menu->exec(btn_menu->mapToGlobal(btn_menu->rect().bottomLeft()));
// });
// connect(action2,&QAction::triggered,this,[=](){
// emit startBuild(m_historytime);
// });
@ -297,7 +309,28 @@ void HistoryButton::initUI()
FileProcess::g_createThemeType = nullptr;
});
});
//FIX ME:现在是三个button当historybutton hover的时候button和btn_menu没有悬浮导致有色差用qss的话一样会出现这个问题。暂时没有好的解决方式
connect(this, &HistoryButton::hoverStateChanged, this, [&](bool ishover) {
if(ishover){
m_typebutton->setAttribute(Qt::WA_UnderMouse, true);
m_menubutton->setAttribute(Qt::WA_UnderMouse, true);
}else{
m_typebutton->setAttribute(Qt::WA_UnderMouse, false);
m_menubutton->setAttribute(Qt::WA_UnderMouse, false);
}
});
}
bool HistoryButton::eventFilter(QObject *obj, QEvent *event)
{
if (obj == this) {
if (event->type() == QEvent::Enter) {
emit hoverStateChanged(true);
} else if (event->type() == QEvent::Leave) {
emit hoverStateChanged(false);
}
}
return QPushButton::eventFilter(obj, event);
}

View File

@ -17,6 +17,7 @@
#include <QMenu>
#include <QAction>
#include <QMouseEvent>
#include <QToolButton>
class HistoryButton : public QPushButton
{
@ -28,16 +29,21 @@ public:
void setThemeName(const QString &themeName);
void setThemeType(const QString &themeType);
void initUI();
protected:
bool eventFilter(QObject* obj, QEvent* event);
signals:
void updateHistoryRequested();
void startBuild(QString &historytime);
void hoverStateChanged(bool isHovered);
private:
QString m_historytime = nullptr;
QString m_showhistorytime = nullptr;
QString m_coverpath = nullptr;
QString m_themename = nullptr;
QString m_themetype = nullptr;
QPushButton* m_typebutton;
QToolButton* m_menubutton;
QMenu *m_menu;
};

View File

@ -547,7 +547,12 @@ void IconThemeWidget::eidtInitWidget(const HistoryInfo &InfoData)
m_systempreview->updateIconMap(m_historysystemiconmap);
updateCustomIconPathMap(m_historyiconmap);
updateCustomSyetemIconPathMap(m_historysystemiconmap);
if(m_info.wallpaperpath != nullptr){
m_preview->updateImage(m_info.wallpaperpath);
}else{
m_preview->updateImage(":/resource/background/1-openkylin.jpg");
}
}
/**

View File

@ -87,7 +87,10 @@ void InfoCreateWidget::InitInfoBtn(const QString &m_state){
m_exitBtn->setText(tr("Back"));
m_recogniseBtn->setText(tr("OK"));
m_createDebBtn->setText(tr("Create"));
QShortcut *shortcut = new QShortcut(QKeySequence(Qt::Key_Return), m_recogniseBtn);
QObject::connect(shortcut, &QShortcut::activated, m_recogniseBtn, &QPushButton::click);
QShortcut *shortcut1 = new QShortcut(QKeySequence(Qt::Key_Return), m_createDebBtn);
QObject::connect(shortcut1, &QShortcut::activated, m_createDebBtn, &QPushButton::click);
m_infoBtnLayout->addWidget(m_exitBtn);
m_infoBtnLayout->addWidget(m_recogniseBtn);
m_infoBtnLayout->addWidget(m_createDebBtn);

View File

@ -21,6 +21,7 @@
#include <QLineEdit>
#include <QRegExp>
#include <QRegularExpressionValidator>
#include <QShortcut>
class InfoCreateWidget : public QWidget
{

View File

@ -31,24 +31,29 @@ TitleBar::TitleBar(QWidget *parent) : QWidget(parent)
m_gohomebtn->setIcon(QIcon::fromTheme("go-home-symbolic"));
m_gohomebtn->setToolTip(tr("Return"));
m_gohomebtn->setFlat(true);
m_gohomebtn->setProperty("isWindowButton", 0x01);
m_minimumbtn = new QPushButton();
m_minimumbtn->setFixedSize(30,30);
m_minimumbtn->setIcon(QIcon::fromTheme("window-minimize-symbolic"));
m_minimumbtn->setToolTip(tr("Minimize"));
m_minimumbtn->setFlat(true);
m_minimumbtn->setProperty("isWindowButton", 0x01);
m_maximumbtn = new QPushButton();
m_maximumbtn->setFixedSize(30,30);
m_maximumbtn->setIcon(QIcon::fromTheme("window-maximize-symbolic"));
m_maximumbtn->setToolTip(tr("Maximize"));
m_maximumbtn->setFlat(true);
m_maximumbtn->setProperty("isWindowButton", 0x01);
m_closebtn = new QPushButton();
m_closebtn->setFixedSize(30, 30);
m_closebtn->setIcon(QIcon::fromTheme("window-close-symbolic"));
m_closebtn->setToolTip(tr("Close"));
m_closebtn->setFlat(true);
m_closebtn->setProperty("isWindowButton", 0x02);
connect(m_gohomebtn, &QPushButton::clicked, this,[=](){
emit gohomesignal();
@ -63,6 +68,7 @@ TitleBar::TitleBar(QWidget *parent) : QWidget(parent)
m_optionbtn->setFixedSize(30,30);
m_optionbtn->setIcon(QIcon::fromTheme("application-menu"));
m_optionbtn->setAutoRaise(true);
m_optionbtn->setProperty("isWindowButton", 0x01);
QMenu* menu = new QMenu(m_optionbtn);