mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-13 12:22:05 +08:00
新增了SpkAppItem,更改style型对象名,修复侧边栏bug
This commit is contained in:
31
inc/spkappitem.h
Normal file
31
inc/spkappitem.h
Normal 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;
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <QFrame>
|
||||
#include <QTimeLine>
|
||||
|
||||
class SpkLoading : public QWidget
|
||||
class SpkLoading : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
4
inc/spkresource.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#ifndef SPKRESOURCE_H
|
||||
#define SPKRESOURCE_H
|
||||
|
||||
#endif // SPKRESOURCE_H
|
||||
@@ -45,7 +45,6 @@ namespace SpkUi
|
||||
static UiMetaObject *sGlobalInstance;
|
||||
public:
|
||||
UiMetaObject() {}
|
||||
UiMetaObject *Instance() {return nullptr;} //FIXME!!
|
||||
public slots:
|
||||
void SetAccentColor(QColor);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user