新增了SpkAppItem,更改style型对象名,修复侧边栏bug

This commit is contained in:
RigoLigoRLC
2021-08-18 16:44:05 +08:00
parent d49917c6fb
commit f6baf41306
16 changed files with 150 additions and 44 deletions

31
inc/spkappitem.h Normal file
View File

@@ -0,0 +1,31 @@
#pragma once
#include <QLabel>
#include <QVBoxLayout>
#include <QHBoxLayout>
class SpkAppItem : public QWidget
{
Q_OBJECT
public:
SpkAppItem(QWidget *parent = nullptr);
void SetIcon(QPixmap p) { mIcon->setPixmap(p); }
void SetTitle(QString s) { mTitle->setText(s); }
void SetDescription(QString s) { mDescription->setText(s); }
protected:
void paintEvent(QPaintEvent *e);
private:
QLabel *mIcon;
QLabel *mTitle;
QLabel *mDescription;
QVBoxLayout *mLayText;
QHBoxLayout *mMainLay;
static constexpr int IconSize = 72;
};

View File

@@ -1,10 +1,10 @@
#pragma once
#include <QWidget>
#include <QFrame>
#include <QTimeLine>
class SpkLoading : public QWidget
class SpkLoading : public QFrame
{
Q_OBJECT
public:

View File

@@ -43,20 +43,20 @@ namespace SpkUi
constexpr static int RoleItemCategoryPageId= Qt::UserRole + 2;
void BindPageSwitcherButton(QAbstractButton* w)
{
connect(w, &QAbstractButton::pressed,
connect(w, &QAbstractButton::toggled,
this, &SpkSidebarSelector::ButtonPressed);
}
void BindCategoryWidget(QTreeWidget* w)
{
mCategoryWidget = w;
connect(w, &QTreeWidget::itemClicked, this,
connect(w, &QTreeWidget::itemPressed, this,
&SpkSidebarSelector::TreeItemSelected);
}
void AddUnusableItem(QTreeWidgetItem *i) { mUnusableItems.append(i); }
private slots:
// We assume the objects in interest all have the correct properties
void ButtonPressed()
void ButtonPressed(bool aBtnState)
{
auto b = qobject_cast<QPushButton*>(sender());
if(mLastCheckedBtn)
@@ -67,11 +67,7 @@ namespace SpkUi
mLastCheckedBtn = nullptr;
}
else
// NOTE:
// Apparently for checkable buttons, Qt flip their checked property AFTER
// this slot function. So to prevent a checkable button being unchecked,
// we set it to unchecked here. Qt will flip it back to checked later.
b->setChecked(false);
b->setChecked(aBtnState);
}
else if(mLastSelectedItem)
{

View File

@@ -11,6 +11,7 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QSlider>
#include "spkappitem.h"
#include "spkloading.h"
@@ -23,7 +24,7 @@ namespace SpkUi
SpkPageUiTest(QWidget *parent = nullptr);
QWidget *WidL, *WidR;
QVBoxLayout *VLayWidgets,
*VLayBtn,
*VLayTestWidgets,
*VLayInput;
QHBoxLayout *HLay4Slider,
*HLayInputBtns;
@@ -38,6 +39,7 @@ namespace SpkUi
QSlider *SlideH;
QSlider *SlideV;
SpkLoading *Loading;
SpkAppItem *AppItem;
QLineEdit *PopupText;
QPushButton *ShowPopup,

4
inc/spkresource.h Normal file
View File

@@ -0,0 +1,4 @@
#ifndef SPKRESOURCE_H
#define SPKRESOURCE_H
#endif // SPKRESOURCE_H

View File

@@ -45,7 +45,6 @@ namespace SpkUi
static UiMetaObject *sGlobalInstance;
public:
UiMetaObject() {}
UiMetaObject *Instance() {return nullptr;} //FIXME!!
public slots:
void SetAccentColor(QColor);
};