新增SpkIconButton为主题和按钮工作减负

This commit is contained in:
RigoLigoRLC
2021-12-05 18:09:31 +08:00
parent 2e04d05b34
commit cefd309097
12 changed files with 171 additions and 18 deletions

View File

@@ -11,9 +11,11 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QSlider>
#include <QProgressBar>
#include "spkappitem.h"
#include "spkstretchlayout.h"
#include "page/spkpageappdetails.h"
#include "spkiconbutton.h"
#include "spkloading.h"
@@ -40,6 +42,8 @@ namespace SpkUi
QGroupBox *Group;
QSlider *SlideH;
QSlider *SlideV;
SpkIconButton *IconBtn;
QProgressBar *Prog;
SpkLoading *Loading;
SpkAppItem *AppItem;
SpkStretchLayout *DetailsLay;

30
inc/spkiconbutton.h Normal file
View File

@@ -0,0 +1,30 @@
#ifndef SPKICONBUTTON_H
#define SPKICONBUTTON_H
#include <QPushButton>
#include "spkui_general.h"
class SpkIconButton : public QPushButton
{
Q_OBJECT
public:
SpkIconButton(QWidget *parent = nullptr);
~SpkIconButton() {};
void SetIcon(QIcon, QSize);
void SetIcon(QPixmap);
void SetIconSize(QSize);
protected:
void paintEvent(QPaintEvent *) override;
private:
static enum { Dark, Light } sCurrentTheme;
QPixmap mPmapPaintedIcon;
QSize mPmapSize;
static constexpr int IconMargin = 8; // shall we make it changable?
};
#endif // SPKICONBUTTON_H

View File

@@ -14,6 +14,7 @@
#include <QPointer>
#include <QTimeLine>
#include "spkfocuslineedit.h"
#include "spkiconbutton.h"
#include "page/spkpageuitest.h"
#include "page/spkpageapplist.h"
#include "page/spkpageappdetails.h"
@@ -144,7 +145,7 @@ namespace SpkUi
QVBoxLayout *VLaySidebar;
QHBoxLayout *HLaySideTop;
QLabel *StoreIcon;
QPushButton *BtnSettings, *BtnFeedback, *BtnLogs, *BtnDayNight;
SpkIconButton *BtnSettings, *BtnFeedback, *BtnLogs, *BtnDayNight;
SpkSidebarTree *CategoryWidget;
QMap<int, QTreeWidgetItem> *CategoryItemMap;
SpkSidebarSelector *SidebarMgr;
@@ -184,7 +185,7 @@ class SpkMainWindow : public SpkWindow
mCategoryAppListGetReply,
mAppDetailsGetReply;
SpkUi::SpkStackedPages mCurrentPage = SpkUi::PgInvalid;
QList<QPair<QPushButton*, QString>> mThemedUiIconReferences;
QList<QPair<SpkIconButton*, QString>> mThemedUiIconReferences;
public slots:
void ReloadThemedUiIcons();

View File

@@ -39,7 +39,9 @@ namespace SpkUi
extern UiMetaObject SpkUiMetaObject;
extern SpkUiStyle CurrentStyle;
extern QString StylesheetBase, CurrentStylesheet;
extern QColor ColorLine, ColorBack;
extern QColor ColorLine, ColorBack,
ColorBtnMaskUnselected, ///< SpkIconButton icon mask colors, unselected & selected
ColorBtnMaskSelected;
extern QSize PrimaryScreenSize;
extern SpkDtkPlugin *DtkPlugin;
extern QStyle *OldSystemStyle;