diff --git a/CMakeLists.txt b/CMakeLists.txt index 19ee3df..a61d79a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,11 +65,13 @@ set(SOURCE_FILES inc/spkpageuitest.h gui/spkpageuitest.cpp inc/spkloading.h gui/spkloading.cpp inc/spksidebartree.h gui/spksidebartree.cpp + inc/spkappitem.h gui/spkappitem.cpp inc/spkpopup.h gui/spkpopup.cpp inc/spkstore.h src/spkstore.cpp inc/spkuimsg.h src/spkuimsg.cpp inc/spklogging.h src/spklogging.cpp + inc/spkresource.h src/spkresource.cpp ) include(cmake/FindLibNotify.cmake) diff --git a/gui/spkappitem.cpp b/gui/spkappitem.cpp new file mode 100644 index 0000000..70ae843 --- /dev/null +++ b/gui/spkappitem.cpp @@ -0,0 +1,45 @@ + +#include +#include +#include "spkappitem.h" + +SpkAppItem::SpkAppItem(QWidget *parent) : QWidget(parent) +{ + mMainLay = new QHBoxLayout(this); + mLayText = new QVBoxLayout; + + mIcon = new QLabel; + mIcon->setFixedSize(IconSize, IconSize); + mIcon->setAutoFillBackground(false); + + mTitle = new QLabel; + mTitle->setWordWrap(false); + mTitle->setObjectName("styAppItmTitle"); + mTitle->setAutoFillBackground(true); + mDescription = new QLabel; + mDescription->setWordWrap(true); + mDescription->setObjectName("styAppItmDesc"); + mDescription->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + mDescription->setAlignment(Qt::AlignTop | Qt::AlignLeft); + mDescription->setAutoFillBackground(true); + mLayText->addWidget(mTitle); + mLayText->addWidget(mDescription); + mLayText->setAlignment(Qt::AlignTop); + + mMainLay->addWidget(mIcon); + mMainLay->addLayout(mLayText); + + setMinimumHeight(82); + setMaximumHeight(82); + setMinimumWidth(300); + setMaximumWidth(350); +} + +void SpkAppItem::paintEvent(QPaintEvent *e) +{ + Q_UNUSED(e) + QStyleOption opt; + opt.init(this); + QPainter p(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); +} diff --git a/gui/spkdialog.cpp b/gui/spkdialog.cpp index bf5a8d8..81c2ce7 100644 --- a/gui/spkdialog.cpp +++ b/gui/spkdialog.cpp @@ -44,10 +44,10 @@ void SpkDialog::AddButton(QString text, SpkUi::SpkButtonStyle style) { case SpkUi::SpkButtonStyle::Recommend: - b->setObjectName("spk_styling_recommendbtn"); + b->setObjectName("sty_recommendbtn"); break; case SpkUi::SpkButtonStyle::Warn: - b->setObjectName("spk_styling_warnbtn"); + b->setObjectName("sty_warnbtn"); break; default: break; diff --git a/gui/spkloading.cpp b/gui/spkloading.cpp index f7cffd2..7281d42 100644 --- a/gui/spkloading.cpp +++ b/gui/spkloading.cpp @@ -4,7 +4,7 @@ #include "spkloading.h" #include "spkui_general.h" -SpkLoading::SpkLoading(QWidget *parent) : QWidget(parent) +SpkLoading::SpkLoading(QWidget *parent) : QFrame(parent) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); mAnimTimer = new QTimeLine(400, this); diff --git a/gui/spkmainwindow.cpp b/gui/spkmainwindow.cpp index f112dc0..10069d8 100644 --- a/gui/spkmainwindow.cpp +++ b/gui/spkmainwindow.cpp @@ -103,8 +103,8 @@ SpkUi::SpkMainWidget::SpkMainWidget(QWidget *parent) : QFrame(parent) SideBarRestrictor = new QWidget(this); SideBarRestrictor->setObjectName("spk_mw_sidebar_restrictor"); SideBarRestrictor->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); - SideBarRestrictor->setMaximumWidth(300); - SideBarRestrictor->setMinimumWidth(300); + SideBarRestrictor->setMaximumWidth(200); + SideBarRestrictor->setMinimumWidth(200); SideBarRestrictor->setLayout(VLaySidebar); HLaySideTop = new QHBoxLayout; @@ -123,7 +123,7 @@ SpkUi::SpkMainWidget::SpkMainWidget(QWidget *parent) : QFrame(parent) SidebarMgr->setObjectName("spk_mw_sidebar_mgr"); BtnSettings = new QPushButton(this); - BtnSettings->setObjectName("spk_styling_plaincheckbtn"); + BtnSettings->setObjectName("styPlainChkBtn"); BtnSettings->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); BtnSettings->setCheckable(true); BtnSettings->setMaximumSize({ 48, 48 }); @@ -140,7 +140,7 @@ SpkUi::SpkMainWidget::SpkMainWidget(QWidget *parent) : QFrame(parent) using SpkUi::SpkSidebarSelector; CategoryWidget = new SpkSidebarTree(this); - CategoryWidget->setObjectName("spk_mw_category"); + CategoryWidget->setObjectName("styMwCateg"); CategoryWidget->setAutoFillBackground(true); CategoryWidget->setColumnCount(1); CategoryWidget->setHeaderHidden(true); diff --git a/gui/spkmsgbox.cpp b/gui/spkmsgbox.cpp index 070203e..639ece4 100644 --- a/gui/spkmsgbox.cpp +++ b/gui/spkmsgbox.cpp @@ -82,7 +82,7 @@ int SpkMsgBox::StaticExec(QString msg, QString title, QMessageBox::Icon icon, wExpandBtn->setMaximumWidth(100); wExpandBtn->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); wExpandBtn->setCheckable(true); - wExpandBtn->setObjectName("spk_styling_checkbtn"); + wExpandBtn->setObjectName("styChkBtn"); connect(wExpandBtn, &QPushButton::clicked, [&](){ // FIXME: hint doesn't change when visibility changes, this is a quirky hack wExtraArea->setVisible(wExpandBtn->isChecked()); diff --git a/gui/spkpageuitest.cpp b/gui/spkpageuitest.cpp index ae35da7..5894eb3 100644 --- a/gui/spkpageuitest.cpp +++ b/gui/spkpageuitest.cpp @@ -44,6 +44,13 @@ SpkUi::SpkPageUiTest::SpkPageUiTest(QWidget *parent) : QSplitter(parent) Loading->setObjectName("spk_pg_qsstest_loading"); Loading->start(); + AppItem = new SpkAppItem(this); + AppItem->setObjectName("spk_pg_qsstest_appitem"); + AppItem->SetTitle("Lorem Ipsum"); + AppItem->SetDescription("Nam vehicula lacus vitae leo fermentum efficitur. " + "Phasellus finibus risus id aliquam pulvinar."); + AppItem->SetIcon(QIcon::fromTheme("dialog-information").pixmap(72, 72)); + PopupText = new QLineEdit(this); PopupText->setObjectName("spk_pg_qsstest_poptext"); PopupText->setText("Hello, world"); @@ -68,20 +75,21 @@ SpkUi::SpkPageUiTest::SpkPageUiTest(QWidget *parent) : QSplitter(parent) SlideH->setMaximum(1000); SlideH->setMinimum(0); - VLayBtn = new QVBoxLayout; - VLayBtn->setObjectName("spk_pg_qsstest_vlay_btn"); - VLayBtn->addWidget(Btn); - VLayBtn->addWidget(Chk); - VLayBtn->addWidget(Rad); - VLayBtn->addWidget(Loading); - VLayBtn->addWidget(PopupText); - VLayBtn->addWidget(ShowPopup); - VLayBtn->addWidget(ShowAbout); + VLayTestWidgets = new QVBoxLayout; + VLayTestWidgets->setObjectName("spk_pg_qsstest_vlay_btn"); + VLayTestWidgets->addWidget(Btn); + VLayTestWidgets->addWidget(Chk); + VLayTestWidgets->addWidget(Rad); + VLayTestWidgets->addWidget(Loading); + VLayTestWidgets->addWidget(PopupText); + VLayTestWidgets->addWidget(ShowPopup); + VLayTestWidgets->addWidget(ShowAbout); + VLayTestWidgets->addWidget(AppItem); Group = new QGroupBox(this); Group->setObjectName("spk_pg_qsstest_groupbox"); Group->setTitle("GroupBox"); - Group->setLayout(VLayBtn); + Group->setLayout(VLayTestWidgets); VLayInput = new QVBoxLayout; VLayInput->setObjectName("spk_pg_qsstest_inputlay"); diff --git a/inc/spkappitem.h b/inc/spkappitem.h new file mode 100644 index 0000000..a589f12 --- /dev/null +++ b/inc/spkappitem.h @@ -0,0 +1,31 @@ + +#pragma once + +#include +#include +#include + +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; +}; + diff --git a/inc/spkloading.h b/inc/spkloading.h index e9bf182..7a88f67 100644 --- a/inc/spkloading.h +++ b/inc/spkloading.h @@ -1,10 +1,10 @@ #pragma once -#include +#include #include -class SpkLoading : public QWidget +class SpkLoading : public QFrame { Q_OBJECT public: diff --git a/inc/spkmainwindow.h b/inc/spkmainwindow.h index 5a8ce8a..1e39137 100644 --- a/inc/spkmainwindow.h +++ b/inc/spkmainwindow.h @@ -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(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) { diff --git a/inc/spkpageuitest.h b/inc/spkpageuitest.h index 49065e5..ea7cbcd 100644 --- a/inc/spkpageuitest.h +++ b/inc/spkpageuitest.h @@ -11,6 +11,7 @@ #include #include #include +#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, diff --git a/inc/spkresource.h b/inc/spkresource.h new file mode 100644 index 0000000..ffcb96f --- /dev/null +++ b/inc/spkresource.h @@ -0,0 +1,4 @@ +#ifndef SPKRESOURCE_H +#define SPKRESOURCE_H + +#endif // SPKRESOURCE_H diff --git a/inc/spkui_general.h b/inc/spkui_general.h index 5461a61..7d08c3f 100644 --- a/inc/spkui_general.h +++ b/inc/spkui_general.h @@ -45,7 +45,6 @@ namespace SpkUi static UiMetaObject *sGlobalInstance; public: UiMetaObject() {} - UiMetaObject *Instance() {return nullptr;} //FIXME!! public slots: void SetAccentColor(QColor); }; diff --git a/resource/stylesheets/mainwindow_dark.css b/resource/stylesheets/mainwindow_dark.css index 7f801fa..9a67b13 100644 --- a/resource/stylesheets/mainwindow_dark.css +++ b/resource/stylesheets/mainwindow_dark.css @@ -22,32 +22,37 @@ QWidget color: #ffffff; } -#spk_mw_category +QLabel +{ + background: transparent; +} + +#styMwCateg { border: none; font-size: 14px; show-decoration-selected: 1; } -#spk_mw_category::item +#styMwCateg::item { height: 35px; border: none; color: %13; } -#spk_mw_category::item:selected +#styMwCateg::item:selected { color: %11; background-color: %4; } -#spk_mw_category::branch:!has-children +#styMwCateg::branch:!has-children { background: %1; } -#spk_mw_category::branch:selected +#styMwCateg::branch:selected { background-color: %4; } @@ -83,34 +88,34 @@ QPushButton::pressed background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 %8, stop:1 %6) } -#spk_styling_checkbtn +#styChkBtn { border-width: 0px; background-color: %9 } -#spk_styling_checkbtn:pressed +#styChkBtn:pressed { background-color: %5 } -#spk_styling_checkbtn:checked +#styChkBtn:checked { background-color: %4 } -#spk_styling_plaincheckbtn +#styPlainChkBtn { border-width: 0px; background-color: %1 } -#spk_styling_plaincheckbtn:pressed +#styPlainChkBtn:pressed { background-color: %5 } -#spk_styling_plaincheckbtn:checked +#styPlainChkBtn:checked { background-color: %4 } @@ -157,7 +162,19 @@ QScrollBar::add-line, QScrollBar::sub-line height:0px } -#spk_about_desc +#styAboutDesc { color: %14 } + +SpkAppItem +{ + background: %10; + border-radius: 11px; +} + +#styAppItmTitle +{ + font-weight: 500; + font-size: 17px; +} diff --git a/src/spkresource.cpp b/src/spkresource.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/spkuimsg.cpp b/src/spkuimsg.cpp index 55b3a14..602b34a 100644 --- a/src/spkuimsg.cpp +++ b/src/spkuimsg.cpp @@ -24,9 +24,11 @@ void SpkUiMessage::SendDesktopNotification(QString s, const char * const icon) notify_notification_show(_notify, nullptr); } -void SpkUiMessage::SendStoreNotification(QString s) // TODO: IMPLEMENT IN-APP NOTIFICATION +void SpkUiMessage::SendStoreNotification(QString s) { - SpkUi::Popup->Show(s); + // I don't really understand these measures of preventing copying really well, + // but Clang-tidy said so, so I did as instructed. + SpkUi::Popup->Show(std::move(s)); } void SpkUiMessage::SetDesktopNotifyTimeout(int ms)