进度更新

This commit is contained in:
RigoLigo 2021-07-05 23:35:50 +08:00
parent 8991043127
commit 4df8bf7d0a
24 changed files with 835 additions and 134 deletions

View File

@ -23,11 +23,13 @@ set(REQUIRED_LIBS
Core
Gui
Widgets
Network
Concurrent)
set(REQUIRED_LIBS_QUALIFIED
Qt5::Core
Qt5::Gui
Qt5::Widgets
Qt5::Network
Qt5::Concurrent)
include_directories(inc)
@ -71,9 +73,10 @@ set(SOURCE_FILES
gui/spkmainwindow.cpp
inc/spkpageqsstest.h
gui/spkpageqsstest.cpp
gui/spkcategoryselector.cpp
inc/spkconfig.h
inc/telemetry/collectid.h
gui/spkloading.cpp
inc/spkloading.h
)
include(cmake/FindLibNotify.cmake)

78
gui/spkloading.cpp Normal file
View File

@ -0,0 +1,78 @@
#include <QPaintEvent>
#include <QPainter>
#include "spkloading.h"
SpkLoading::SpkLoading(QWidget *parent) : QWidget(parent)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
mAnimTimer = new QTimeLine(400, this);
mAnimTimer->setFrameRange(10, 30);
mAnimTimer->setEasingCurve(QEasingCurve::InCubic);
for(int i = 0; i < 5; i++)
mSizeList.append(20);
connect(mAnimTimer, &QTimeLine::frameChanged, this, &SpkLoading::timer);
connect(mAnimTimer, &QTimeLine::finished, this, &SpkLoading::loop);
}
void SpkLoading::paintEvent(QPaintEvent *e)
{
QPainter p(this);
QPen pen(Qt::NoPen);
QBrush b({ 0, 0x7b, 0xff }, Qt::SolidPattern); // TODO: Customizable accent color
p.setBrush(b);
p.setPen(pen);
p.setRenderHint(QPainter::Antialiasing);
dx = width() / 2 - dh * 2;
dy = height() / 2;
double r;
for(int i = 0; i < 5; i++)
{
r = dh * mSizeList[i] / 80;
p.drawEllipse({ dx, dy }, r, r);
dx += dh;
}
e->accept();
}
void SpkLoading::resizeEvent(QResizeEvent *e)
{
// Calculate size of drawing space
if(mUserHeight != 0 && mUserHeight * 5 <= e->size().width())
{
dw = 5 * mUserHeight;
dh = mUserHeight;
return;
}
dh = e->size().height();
if(width() < dh * 5)
{
dw = e->size().width();
dh = dw / 5;
}
else
dw = dh * 5;
}
void SpkLoading::timer(int s)
{
for(int i = 4; i > 0; i--)
mSizeList[i] = mSizeList[i - 1];
mSizeList[0] = s;
update();
}
void SpkLoading::loop()
{
mAnimTimer->setDirection(mAnimTimer->direction() == QTimeLine::Forward ?
QTimeLine::Backward : QTimeLine::Forward);
mAnimTimer->start();
}
void SpkLoading::reset()
{
for(int i = 0; i < 5; i++)
mSizeList[i] = 20;
update();
}

View File

@ -33,7 +33,7 @@ void SpkMainWindow::PopulateCategories(QJsonObject aCategoryData)
SpkUiMessage::SendStoreNotification(tr("Failed to load categories; invalid return code."));
return;
}
if(OpRetCode.toDouble() != 0)
if(OpRetCode.toInt() != 0)
{
SpkUiMessage::SendStoreNotification(tr("Failed to load categories; operation failed: %1.")
.arg(OpRetCode.toDouble()));
@ -66,7 +66,7 @@ void SpkMainWindow::PopulateCategories(QJsonObject aCategoryData)
if(j.contains("type_name") && j.value("type_name").isString())
typeName = j.value("type_name").toString();
else goto WRONG_CATEGORY;
w->AddButton(tr(typeName.toLocal8Bit()), typeId /* TODO: ICONS */);
// TODO
continue;
}
WRONG_CATEGORY:
@ -78,9 +78,7 @@ SpkUi::SpkMainWidget::SpkMainWidget(QWidget *parent) : QFrame(parent)
{
setObjectName("spk_mainwidget");
VLayCategoryButtons = new QVBoxLayout;
VLayCategoryButtons->setObjectName("spk_mw_category_vlay");
VLayCategoryButtons->addWidget(new QPushButton);
QTreeWidgetItem *item;
Pager = new QStackedWidget(this);
Pager->setObjectName("spk_mw_pager");
@ -88,7 +86,8 @@ SpkUi::SpkMainWidget::SpkMainWidget(QWidget *parent) : QFrame(parent)
TitleBar = new SpkTitleBar(this);
TitleBar->setObjectName("spk_mw_titlebar");
TitleBar->SetTitle("Title");
TitleBar->SetUseIcon(false);
TitleBar->SetTitle("");
VLayMain = new QVBoxLayout;
VLayMain->setObjectName("spk_mw_main_vlay");
@ -97,20 +96,73 @@ SpkUi::SpkMainWidget::SpkMainWidget(QWidget *parent) : QFrame(parent)
VLayMain->addWidget(TitleBar);
VLayMain->addWidget(Pager);
CategoryWidget = new SpkCategorySelector(this);
VLaySidebar = new QVBoxLayout;
VLaySidebar->setObjectName("spk_mw_sidebar_lay");
VLaySidebar->setSpacing(0);
VLaySidebar->setContentsMargins(0, 0, 0, 0);
SideBarRestrictor = new QWidget(this);
SideBarRestrictor->setObjectName("spk_mw_sidebar_restrictor");
SideBarRestrictor->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
SideBarRestrictor->setMaximumWidth(300);
SideBarRestrictor->setMinimumWidth(300);
SideBarRestrictor->setLayout(VLaySidebar);
HLaySideTop = new QHBoxLayout;
HLaySideTop->setObjectName("spk_mw_sidebar_top_lay");
HLaySideTop->setSpacing(8);
HLaySideTop->setContentsMargins(8, 4, 4, 4);
StoreIcon = new QLabel(this);
StoreIcon->setObjectName("spk_mw_icon");
StoreIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
StoreIcon->setMaximumSize({ 48, 48 });
StoreIcon->setMinimumSize({ 48, 48 });
StoreIcon->setPixmap(QIcon(":/icons/spark-store.svg").pixmap(StoreIcon->size()));
SidebarMgr = new SpkSidebarSelector(this);
SidebarMgr->setObjectName("spk_mw_sidebar_mgr");
BtnSettings = new QPushButton(this);
BtnSettings->setObjectName("spk_styling_plaincheckbtn");
BtnSettings->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
BtnSettings->setCheckable(true);
BtnSettings->setMaximumSize({ 48, 48 });
BtnSettings->setMinimumSize({ 48, 48 });
BtnSettings->setIconSize(QSize(24, 24));
BtnSettings->setIcon(SpkUi::GetThemedIcon("settings"));
BtnSettings->setProperty("spk_pageno", 0);
SidebarMgr->BindPageSwitcherButton(BtnSettings);
HLaySideTop->addWidget(StoreIcon);
HLaySideTop->addStretch();
HLaySideTop->addWidget(BtnSettings);
VLaySidebar->addLayout(HLaySideTop);
CategoryWidget = new QTreeWidget(this);
CategoryWidget->setObjectName("spk_mw_category");
CategoryWidget->setLayout(VLayCategoryButtons);
CategoryWidget->setAutoFillBackground(true);
CategoryWidget->setMaximumWidth(300);
CategoryWidget->setMinimumWidth(300);
CategoryWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
CategoryWidget->setColumnCount(1);
CategoryWidget->setHeaderHidden(true);
CategoryWidget->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
item = new QTreeWidgetItem(QStringList("Placeholder"));
item->setData(0, Qt::UserRole + 1, 1);
item->setData(0, Qt::UserRole + 2, 1);
CategoryWidget->addTopLevelItem(item);
// FIXMEIFPOSSIBLE: Fusion adds extra gradient.
// Details: https://forum.qt.io/topic/128190/fusion-style-kept-adding-an-extra-
// layer-of-gradient-to-my-selected-item-of-qtreewidget-even-with-qss
if(SpkUi::OldSystemStyle)
CategoryWidget->setStyle(SpkUi::OldSystemStyle);
VLaySidebar->addWidget(CategoryWidget);
SidebarMgr->BindCategoryWidget(CategoryWidget);
HorizontalDivide = new QHBoxLayout;
HorizontalDivide->setObjectName("spk_mw_divide_hlay");
HorizontalDivide->setSpacing(0);
HorizontalDivide->setContentsMargins(0, 0, 0, 0);
HorizontalDivide->setAlignment(Qt::AlignLeft);
HorizontalDivide->addWidget(CategoryWidget);
HorizontalDivide->addWidget(SideBarRestrictor);
HorizontalDivide->addLayout(VLayMain);
// Initialize pages

View File

@ -79,7 +79,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_msgboxexpandbtn");
wExpandBtn->setObjectName("spk_styling_checkbtn");
connect(wExpandBtn, &QPushButton::clicked,
[&](){ // FIXME: hint doesn't change when visibility changes, this is a quirky hack
wExtraArea->setVisible(wExpandBtn->isChecked());
@ -88,12 +88,15 @@ int SpkMsgBox::StaticExec(QString msg, QString title, QMessageBox::Icon icon,
else
b->setFixedHeight(InitialHeight);
});
b->AddWidget(wExpandBtn);
b->mBtnLay->addWidget(wExpandBtn);
b->mBtnLay->addStretch();
b->AddWidget(wExtraArea);
}
b->AddSpacing(3);
AddButtons(b, buttons);
if(hasextra) // Keep conventional buttons centered
b->mBtnLay->addStretch();
InitialHeight = b->minimumSizeHint().height();
auto pos = (SpkUi::PrimaryScreenSize - b->sizeHint()) / 2;
b->move(pos.width(), pos.height());

View File

@ -9,7 +9,7 @@ SpkUi::SpkPageQssTest::SpkPageQssTest(QWidget *parent) : QSplitter(parent)
TextStylesheet = new QTextEdit(this);
TextStylesheet->setObjectName("spk_pg_qsstest_qsstext");
TextStylesheet->setPlainText(*SpkUi::CurrentStylesheet);
TextStylesheet->setPlainText(SpkUi::CurrentStylesheet);
BtnApply = new QPushButton(this);
BtnApply->setObjectName("spk_pg_qsstest_btnapply");
@ -38,6 +38,10 @@ SpkUi::SpkPageQssTest::SpkPageQssTest(QWidget *parent) : QSplitter(parent)
Rad->setObjectName("spk_pg_qsstest_radiobtn");
Rad->setText("RadioButton");
Loading = new SpkLoading(this);
Loading->setObjectName("spk_pg_qsstest_loading");
Loading->start();
SlideV = new QSlider(this);
SlideV->setObjectName("spk_pg_qsstest_slider_v");
SlideV->setOrientation(Qt::Vertical);
@ -55,6 +59,7 @@ SpkUi::SpkPageQssTest::SpkPageQssTest(QWidget *parent) : QSplitter(parent)
VLayBtn->addWidget(Btn);
VLayBtn->addWidget(Chk);
VLayBtn->addWidget(Rad);
VLayBtn->addWidget(Loading);
Group = new QGroupBox(this);
Group->setObjectName("spk_pg_qsstest_groupbox");
@ -95,5 +100,5 @@ void SpkUi::SpkPageQssTest::SetStylesheet()
void SpkUi::SpkPageQssTest::FetchStylesheet()
{
TextStylesheet->setPlainText(*SpkUi::CurrentStylesheet);
TextStylesheet->setPlainText(SpkUi::CurrentStylesheet);
}

View File

@ -11,33 +11,40 @@ SpkTitleBar::SpkTitleBar(QWidget *parent) : QWidget(parent)
setMinimumHeight(48);
setMaximumHeight(48);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
mIcon.setFixedSize(32, 32);
mMainLayout.addSpacing(8);
mMainLayout.addWidget(&mIcon);
mMainLayout.addSpacing(8);
mMainLayout.addWidget(&mTitle);
mMainLayout.addSpacing(8);
mMainLayout.addLayout(&mUserSpaceL);
mMainLayout.addStretch();
mMainLayout.addLayout(&mUserSpaceR);
mMainLayout.addSpacing(8);
mMainLayout.addWidget(&mBtnMin);
mMainLayout.addWidget(&mBtnMaxRestore);
mMainLayout.addWidget(&mBtnClose);
mIcon = new QLabel(this);
mTitle = new QLabel(this);
mIcon->setFixedSize(32, 32);
mBtnMin.SetRole(OperationButton::Minimize);
mBtnMaxRestore.SetRole(OperationButton::MaximizeRestore);
mBtnClose.SetRole(OperationButton::Close);
mMainLayout = new QHBoxLayout(this);
mUserSpace = new QHBoxLayout();
mBtnGroup = new QHBoxLayout();
mBtnMin = new SpkTitleBarDefaultButton(this);
mBtnMaxRestore = new SpkTitleBarDefaultButton(this);
mBtnClose= new SpkTitleBarDefaultButton(this);
mMainLayout->setSpacing(8);
mBtnGroup->setSpacing(0);
mMainLayout.setSpacing(0);
mMainLayout.setContentsMargins(0, 0, 0, 0);
mMainLayout->addSpacing(8);
mMainLayout->addWidget(mIcon);
mMainLayout->addWidget(mTitle);
mMainLayout->addLayout(mUserSpace);
mMainLayout->addLayout(mBtnGroup);
mBtnGroup->addWidget(mBtnMin);
mBtnGroup->addWidget(mBtnMaxRestore);
mBtnGroup->addWidget(mBtnClose);
setLayout(&mMainLayout);
mBtnMin->SetRole(OperationButton::Minimize);
mBtnMaxRestore->SetRole(OperationButton::MaximizeRestore);
mBtnClose->SetRole(OperationButton::Close);
connect(&mBtnClose, &QPushButton::clicked, this, &SpkTitleBar::CloseWindow);
connect(&mBtnMin, &QPushButton::clicked, this, &SpkTitleBar::MinimizeWindow);
connect(&mBtnMaxRestore, &QPushButton::clicked, this, &SpkTitleBar::MaximizeRestoreWindow);
mMainLayout->setContentsMargins(0, 0, 0, 0);
setLayout(mMainLayout);
connect(mBtnClose, &QPushButton::clicked, this, &SpkTitleBar::CloseWindow);
connect(mBtnMin, &QPushButton::clicked, this, &SpkTitleBar::MinimizeWindow);
connect(mBtnMaxRestore, &QPushButton::clicked, this, &SpkTitleBar::MaximizeRestoreWindow);
}
SpkTitleBar::~SpkTitleBar()
@ -47,9 +54,9 @@ SpkTitleBar::~SpkTitleBar()
void SpkTitleBar::SetOperationButton(OperationButton type)
{
mBtnClose.setVisible(type & OperationButton::Close);
mBtnMaxRestore.setVisible(type & OperationButton::MaximizeRestore);
mBtnMin.setVisible(type & OperationButton::Minimize);
mBtnClose->setVisible(type & OperationButton::Close);
mBtnMaxRestore->setVisible(type & OperationButton::MaximizeRestore);
mBtnMin->setVisible(type & OperationButton::Minimize);
}
bool SpkTitleBar::event(QEvent *evt)
@ -59,7 +66,7 @@ bool SpkTitleBar::event(QEvent *evt)
case QEvent::MouseButtonDblClick:
{
if(static_cast<QMouseEvent*>(evt)->button())
emit mBtnMaxRestore.clicked();
emit mBtnMaxRestore->clicked();
break;
}
default:;
@ -90,7 +97,7 @@ void SpkTitleBar::MaximizeRestoreWindow()
}
}
SpkTitleBarDefaultButton::SpkTitleBarDefaultButton()
SpkTitleBarDefaultButton::SpkTitleBarDefaultButton(QWidget* parent) : QPushButton(parent)
{
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
setMaximumWidth(ButtonWidth);

View File

@ -22,10 +22,12 @@
namespace SpkUi
{
QString StylesheetLight, StylesheetDark, *CurrentStylesheet = &StylesheetLight;
SpkUiStyle CurrentStyle;
QString StylesheetBase, CurrentStylesheet;
QColor ColorLine, ColorBack;
QSize PrimaryScreenSize;
SpkDtkPlugin *DtkPlugin = nullptr;
QStyle *OldSystemStyle = nullptr;
namespace Priv
{
@ -36,13 +38,9 @@ namespace SpkUi
{
// Obtain global stylesheets
QFile ObtainStylesheet;
ObtainStylesheet.setFileName(":/stylesheets/stylesheets/mainwindow.css");
ObtainStylesheet.open(QIODevice::ReadOnly);
StylesheetLight = ObtainStylesheet.readAll();
ObtainStylesheet.close();
ObtainStylesheet.setFileName(":/stylesheets/stylesheets/mainwindow_dark.css");
ObtainStylesheet.open(QIODevice::ReadOnly);
StylesheetDark = ObtainStylesheet.readAll();
StylesheetBase = ObtainStylesheet.readAll();
ObtainStylesheet.close();
SetGlobalStyle(Dark);
@ -96,10 +94,16 @@ namespace SpkUi
// FIXME: Chameleon style kept adding unwanted blue focus indication border
// to widgets that shouldn't have borders.
// We need to eliminate this irritating problem.
if(qgetenv("SPARK_NO_QSTYLE_CHANGE") == "1")
return;
OldSystemStyle = QStyleFactory::create("chameleon"); // TreeWidget doesn't work well with Fusion
auto styles = QStyleFactory::keys();
styles.removeAll("chameleon");
if(styles.contains("Fusion"))
qApp->setStyle(QStyleFactory::create("Fusion"));
{
auto style = QStyleFactory::create("Fusion");
qApp->setStyle(style);
}
else if(styles.size()) // What? This shouldn't happen.
qApp->setStyle(QStyleFactory::create(styles[0]));
else // Duh...
@ -109,22 +113,34 @@ namespace SpkUi
void SetGlobalStyle(const SpkUiStyle aStyle)
{
CurrentStyle = aStyle;
switch(aStyle)
{
case Light:
qApp->setStyleSheet(StylesheetLight);
CurrentStylesheet = &StylesheetLight;
CurrentStylesheet = StylesheetFromColors(
QList<QColor>{
0x353535, 0x353535, 0xff0000, 0x0070ff, 0x2987ff,
0x6b6b6b, 0x656565, 0x606060, 0x404040, 0x383838,
ColorTextOnBackground(0x0070ff)
});
qApp->setStyleSheet(CurrentStylesheet);
// TODO
ColorLine = Qt::black;
break;
case Dark:
qApp->setStyleSheet(StylesheetDark);
CurrentStylesheet = &StylesheetDark;
CurrentStylesheet = StylesheetFromColors(
QList<QColor>{
0x353535, 0x353535, 0xff0000, 0x0070ff, 0x2987ff,
0x6b6b6b, 0x656565, 0x606060, 0x404040, 0x383838,
ColorTextOnBackground(0x0070ff)
});
qApp->setStyleSheet(CurrentStylesheet);
ColorLine = Qt::white;
break;
default:
sWarn(QObject::tr("SetGlobalStyle invoked with unknown style %1.")
.arg(static_cast<int>(aStyle)));
break;
// default:
// sWarn(QObject::tr("SetGlobalStyle invoked with unknown style %1.")
// .arg(static_cast<int>(aStyle)));
// break;
}
}
@ -195,4 +211,27 @@ namespace SpkUi
"to continue execution.").arg(sig));
}
}
QIcon GetThemedIcon(QString name)
{
if(CurrentStyle == SpkUiStyle::Dark)
name += "-dark";
return QIcon(":/icons/" + name + ".svg");
}
QString StylesheetFromColors(QList<QColor> aColors)
{
QString ret = StylesheetBase;
foreach(auto &i, aColors)
ret = ret.arg(i.name());
return ret;
}
QColor ColorTextOnBackground(QColor c)
{
// From https://github.com/feiyangqingyun/qtkaifajingyan
double gray = (0.299 * c.red() + 0.587 * c.green() + 0.114 * c.blue()) / 255;
return gray > 0.5 ? Qt::black : Qt::white;
}
}

View File

@ -14,7 +14,7 @@
SpkWindow::SpkWindow(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, flags)
{
if(SpkUi::DtkPlugin)
if(SpkUi::DtkPlugin && qgetenv("SPARK_NO_DXCB") == "0")
SpkUi::DtkPlugin->addWindow(this, parent); // Register window to DXcb so we got Deepin
else
setWindowFlags(Qt::FramelessWindowHint); // Remove default title bar
@ -24,6 +24,7 @@ SpkWindow::SpkWindow(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(paren
mResizing = false;
mCloseHook = nullptr;
mMaximized = windowState().testFlag(Qt::WindowMaximized);
mUseCustomEvents = SpkUi::DtkPlugin == nullptr;
PopulateUi();
}
@ -35,15 +36,19 @@ SpkWindow::~SpkWindow()
bool SpkWindow::event(QEvent *evt)
{
// These custom events weren't useful for Deepin platform
if(!mUseCustomEvents)
return QMainWindow::event(evt);
switch(evt->type())
{
case QEvent::WindowStateChange:
{
mMaximized = windowState().testFlag(Qt::WindowMaximized);
if(mMaximized)
mTitleBarComponent->mBtnMaxRestore.SetRole(SpkTitleBarDefaultButton::Restore);
mTitleBarComponent->mBtnMaxRestore->SetRole(SpkTitleBarDefaultButton::Restore);
else
mTitleBarComponent->mBtnMaxRestore.SetRole(SpkTitleBarDefaultButton::MaximizeRestore);
mTitleBarComponent->mBtnMaxRestore->SetRole(SpkTitleBarDefaultButton::MaximizeRestore);
break;
}
case QEvent::MouseButtonPress:
@ -211,10 +216,10 @@ void SpkWindow::SetWindowTheme(SpkWindow::SpkWindowStyle style)
switch(style)
{
case Light:
this->setStyleSheet(SpkUi::StylesheetLight);
SpkUi::SetGlobalStyle(SpkUi::SpkUiStyle::Light);
break;
case Dark:
this->setStyleSheet(SpkUi::StylesheetDark);
SpkUi::SetGlobalStyle(SpkUi::SpkUiStyle::Dark);
break;
default:
;

View File

@ -9,6 +9,7 @@
class SpkDialog : public SpkWindow
{
Q_OBJECT
friend class SpkMsgBox;
public:
SpkDialog(QWidget *parent = nullptr);
~SpkDialog();

34
inc/spkloading.h Normal file
View File

@ -0,0 +1,34 @@
#pragma once
#include <QWidget>
#include <QTimeLine>
class SpkLoading : public QWidget
{
Q_OBJECT
public:
explicit SpkLoading(QWidget *parent = nullptr);
virtual void paintEvent(QPaintEvent *e) override;
virtual void resizeEvent(QResizeEvent *e) override;
private:
QTimeLine *mAnimTimer;
QList<int> mSizeList;
int mUserHeight = 0;
int dw, dh;
double dx, dy;
public slots:
void start() { mAnimTimer->start(); }
void stop() { mAnimTimer->stop(); }
void Begin() { start(); setVisible(true); }
void End() { stop(); setVisible(false); }
void setHeight(int h) { mUserHeight = h; }
void reset();
private slots:
void timer(int s);
void loop();
};

View File

@ -9,54 +9,110 @@
#include <QStackedWidget>
#include <QButtonGroup>
#include <QJsonObject>
#include <QTreeWidget>
#include "spkpageqsstest.h"
namespace SpkUi
{
class SpkCategoryButton : public QPushButton
{
class SpkSidebarSelector : public QObject
{
Q_OBJECT
public:
SpkCategoryButton(QWidget *parent = nullptr);
void SetIcon(QPixmap);
void SetText(QString);
static constexpr int Spacing = 8;
private:
QHBoxLayout *mLayout;
QLabel *mIcon, *mText;
};
class SpkCategorySelector : public QWidget
{
Q_OBJECT
public:
SpkCategorySelector(QWidget *parent = nullptr);
QPushButton *mLastCheckedBtn;
QTreeWidgetItem *mLastSelectedItem;
QTreeWidget *mCategoryWidget;
void AddButton(QString aBtnText, int aCategoryId = 0, QPixmap *aBtnIcon = nullptr);
void DeleteAllButtons();
public:
SpkSidebarSelector(QObject *parent = nullptr) : QObject(parent)
{
mLastCheckedBtn = nullptr;
mLastSelectedItem = nullptr;
}
// Tree item can either represent a page or a category, data of special roles
// help identify them; Buttons instead can only represent a page
constexpr static int RoleItemIsCategory = Qt::UserRole + 1;
constexpr static int RoleItemCategoryPageId= Qt::UserRole + 2;
void BindPageSwitcherButton(QAbstractButton* w)
{
connect(w, &QAbstractButton::pressed,
this, &SpkSidebarSelector::ButtonPressed);
}
void BindCategoryWidget(QTreeWidget* w)
{
mCategoryWidget = w;
connect(w, &QTreeWidget::itemPressed, this,
&SpkSidebarSelector::TreeItemSelected);
}
private slots:
// We assume the objects in interest all have the correct properties
void ButtonPressed()
{
auto b = qobject_cast<QPushButton*>(sender());
if(mLastCheckedBtn)
{
if(mLastCheckedBtn != b)
{
mLastCheckedBtn->setChecked(false);
mLastCheckedBtn = nullptr;
}
else
// QUESTIONABLE:
// 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);
}
else if(mLastSelectedItem)
{
mLastSelectedItem->setSelected(false);
mLastSelectedItem = nullptr;
}
mLastCheckedBtn = b;
emit SwitchToPage(b->property("spk_pageno").toInt());
}
void TreeItemSelected(QTreeWidgetItem *item, int column)
{
if(mLastCheckedBtn)
{
mLastCheckedBtn->setChecked(false);
mLastCheckedBtn = nullptr;
}
mLastSelectedItem = item;
if(item->data(column, RoleItemIsCategory).toBool())
emit SwitchToCategory(item->data(column, RoleItemCategoryPageId).toInt());
else
emit SwitchToPage(item->data(column, RoleItemCategoryPageId).toInt());
}
signals:
void CategorySelected(int);
private:
QVBoxLayout *mBtnLayout;
QButtonGroup *mGroup;
QList<SpkCategoryButton*> mBtnList;
void SwitchToCategory(int aCategoryId);
void SwitchToPage(int aPageId);
};
class SpkMainWidget : public QFrame
{
Q_OBJECT
public:
SpkMainWidget(QWidget *parent = nullptr);
QHBoxLayout *HorizontalDivide;
SpkCategorySelector *CategoryWidget;
QVBoxLayout *VLayCategoryButtons,
*VLayMain;
QVBoxLayout *VLayMain;
SpkTitleBar *TitleBar;
QStackedWidget *Pager;
// Category widget is for switching pages
QWidget *SideBarRestrictor;
QVBoxLayout *VLaySidebar;
QHBoxLayout *HLaySideTop;
QLabel *StoreIcon;
QPushButton *BtnSettings, *BtnFeedback, *BtnLogs;
QTreeWidget *CategoryWidget;
QMap<int, QTreeWidgetItem> *CategoryItemMap;
SpkSidebarSelector *SidebarMgr;
//Pages
SpkPageQssTest *PageQssTest;
};

View File

@ -10,6 +10,9 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QSlider>
#include "spkloading.h"
namespace SpkUi
{
class SpkPageQssTest : public QSplitter
@ -33,6 +36,7 @@ namespace SpkUi
QGroupBox *Group;
QSlider *SlideH;
QSlider *SlideV;
SpkLoading *Loading;
public slots:
void SetStylesheet();

View File

@ -1,11 +1,11 @@
//
// Created by rigoligo on 2021/5/12.
//
#pragma once
#include <QMap>
#include <QString>
#include <QtNetwork/QNetworkReply>
#include <QtNetwork/QNetworkAccessManager>
#include "spklogging.h"
#include "spkmainwindow.h"
@ -23,10 +23,32 @@ class SpkStore : public QObject
SpkStore(bool aCli, QString &aLogPath);
~SpkStore();
SpkMainWindow* GetRootWindow() { return mMainWindow; };
SpkMainWindow* GetRootWindow() { return mMainWindow; }
private:
SpkLogger *mLogger;
SpkMainWindow *mMainWindow = nullptr;
QNetworkAccessManager *mNetMgr = nullptr;
// Following are stationary signal-slot bindings between UI and Store, mostly for handling
// API calls and resource downloading.
public slots:
// void RequestStoreMetadata(); ///< All required metadata the store needs when launched
// void RequestCategoryPage(int aCategoryId);
// void RequestApplicationMetadata(int aAppId);
// void RequestRefreshApiUrls(QString aCustomUrl);
signals:
void StatusStoreMetadata(QNetworkReply::NetworkError, QString);
void StatusCategoryPage(QNetworkReply::NetworkError, QString);
void StatusApplicationMetadata(QNetworkReply::NetworkError, QString);
void StatusRefreshApiUrls(QNetworkReply::NetworkError, QString);
private:
// Store manages all kinds of possible replies, and the caller can only get JSON they need
QNetworkReply *mReplyStoreMetadata = nullptr,
*mReplyCategory = nullptr,
*mReplyAppMetadata = nullptr,
*mReplyApiUrls = nullptr;
};

View File

@ -23,7 +23,7 @@ class SpkTitleBarDefaultButton : public QPushButton
{
Q_OBJECT
public:
SpkTitleBarDefaultButton();
SpkTitleBarDefaultButton(QWidget* parent = nullptr);
enum OperationButton { Minimize = 1, MaximizeRestore = 2, Close = 4, Restore = 3 };
void SetRole(OperationButton);
constexpr static int ButtonWidth = 60;
@ -46,23 +46,22 @@ class SpkTitleBar : public QWidget
using OperationButton = SpkTitleBarDefaultButton::OperationButton;
void SetOperationButton(OperationButton);
void SetIcon(QPixmap &p) { mIcon.setPixmap(p); };
void SetTitle(QString t) { mTitle.setText(t); };
QString GetTitle() { return mTitle.text(); };
void SetUseIcon(bool t) { mIcon.setVisible(t); };
void SetLinkedWindow(QMainWindow *w) { mLinkedWindow = w; };
void SetIcon(QPixmap &p) { mIcon->setPixmap(p); }
void SetTitle(QString t) { mTitle->setText(t); }
QString GetTitle() { return mTitle->text(); }
void SetUseIcon(bool t) { mIcon->setVisible(t); }
void SetLinkedWindow(QMainWindow *w) { mLinkedWindow = w; }
QHBoxLayout &GetLeftUserSpace() { return mUserSpaceL; };
QHBoxLayout &GetRightUserSpace() { return mUserSpaceR; };
QHBoxLayout *GetUserSpace() { return mUserSpace; }
protected:
bool event(QEvent*) override;
private:
QLabel mIcon;
QLabel mTitle;
QLabel *mIcon;
QLabel *mTitle;
QMainWindow *mLinkedWindow;
QHBoxLayout mMainLayout, mUserSpaceL, mUserSpaceR;
SpkTitleBarDefaultButton mBtnMin, mBtnMaxRestore, mBtnClose;
QHBoxLayout *mMainLayout, *mUserSpace, *mBtnGroup;
SpkTitleBarDefaultButton *mBtnMin, *mBtnMaxRestore, *mBtnClose;
private slots:
void CloseWindow();

View File

@ -13,15 +13,18 @@
namespace SpkUi
{
enum SpkUiStyle { Light, Dark };
enum SpkButtonStyle { Normal = 0, Recommend, Warn };
constexpr int StackTraceArraySize = 64;
constexpr const char * const StoreIconName = "spark-store";
extern QString StylesheetLight, StylesheetDark, *CurrentStylesheet;
extern SpkUiStyle CurrentStyle;
extern QString StylesheetBase, CurrentStylesheet;
extern QColor ColorLine, ColorBack;
extern QSize PrimaryScreenSize;
extern SpkDtkPlugin *DtkPlugin;
enum SpkUiStyle { Light, Dark };
enum SpkButtonStyle { Normal = 0, Recommend, Warn };
extern QStyle *OldSystemStyle;
namespace Priv
{
@ -32,6 +35,10 @@ namespace SpkUi
void GuessAppropriateTheme();
void PrepareForDeepinDesktop();
bool CheckIsDeepinDesktop();
QString StylesheetFromColors(QList<QColor>);
QIcon GetThemedIcon(QString);
QColor ColorTextOnBackground(QColor);
void CrashSignalHandler(int);

View File

@ -27,6 +27,7 @@ class SpkWindow : public QMainWindow
bool mMoving, mResizing, mMaximized, mResizable;
Qt::Edges mEdgesBeingResized;
bool (*mCloseHook)(void);
bool mUseCustomEvents;
static constexpr int BorderWidth = 10;

View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="48"
height="48"
viewBox="0 0 12.7 12.7"
version="1.1"
id="svg5"
inkscape:version="1.1 (c4e8f9ed74, 2021-05-24)"
sodipodi:docname="settings.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#505050"
bordercolor="#eeeeee"
borderopacity="1"
inkscape:pageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:document-units="px"
showgrid="true"
showguides="true"
inkscape:guide-bbox="true"
inkscape:zoom="14.285166"
inkscape:cx="25.060961"
inkscape:cy="22.505863"
inkscape:window-width="1920"
inkscape:window-height="979"
inkscape:window-x="1440"
inkscape:window-y="30"
inkscape:window-maximized="1"
inkscape:current-layer="layer1">
<inkscape:grid
type="xygrid"
id="grid9" />
<sodipodi:guide
position="6.35,6.35"
orientation="1,0"
id="guide11" />
<sodipodi:guide
position="6.35,6.35"
orientation="0,1"
id="guide13" />
</sodipodi:namedview>
<defs
id="defs2" />
<g
inkscape:label="图层 1"
inkscape:groupmode="layer"
id="layer1">
<path
id="path3842"
style="fill:#dddddd;fill-rule:evenodd;stroke:none;stroke-width:0.343937;stroke-linecap:round;stroke-linejoin:round;paint-order:markers stroke fill;stroke-opacity:1"
d="m 2.4098143,1.9035478 0.7541001,2.0141066 a 4.0110148,4.0110148 0 0 0 -0.5134382,0.888368 l -2.12081888,0.3532617 9.178e-5,2.3814089 2.120632,0.3533485 a 4.0110148,4.0110148 0 0 0 0.5133361,0.8880906 l -0.7537904,2.0140909 2.0620563,1.190336 1.366532,-1.660758 a 4.0110148,4.0110148 0 0 0 0.5114618,0.03528 4.0110148,4.0110148 0 0 0 0.5114047,-0.0351 L 8.2281517,11.986371 10.290186,10.796452 9.5360854,8.7823455 A 4.0110148,4.0110148 0 0 0 10.049524,7.8939774 L 12.170342,7.5407157 12.170251,5.1593068 10.051736,4.8065257 A 4.0110148,4.0110148 0 0 0 9.5372976,3.9154917 L 10.290073,1.9037771 8.2280168,0.71344079 6.8636532,2.3717535 A 4.0110148,4.0110148 0 0 0 6.350023,2.3389153 4.0110148,4.0110148 0 0 0 5.8386182,2.3740101 l -1.36677,-1.66038137 z m 3.014144,2.8425009 A 1.8520833,1.8520833 0 0 1 7.9539511,5.4239583 1.8520833,1.8520833 0 0 1 7.2760416,7.9539511 1.8520833,1.8520833 0 0 1 4.7460487,7.2760416 1.8520833,1.8520833 0 0 1 5.4239583,4.7460487 Z" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1,268 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="200mm"
height="200mm"
viewBox="0 0 200 200"
version="1.1"
id="svg8"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
sodipodi:docname="deepin-community-store.svg">
<defs
id="defs2">
<linearGradient
inkscape:collect="always"
id="linearGradient1200">
<stop
style="stop-color:#000000;stop-opacity:0.1299435"
offset="0"
id="stop1196" />
<stop
style="stop-color:#dadada;stop-opacity:0.81960785"
offset="1"
id="stop1198" />
</linearGradient>
<linearGradient
id="linearGradient1138"
inkscape:collect="always">
<stop
id="stop1134"
offset="0"
style="stop-color:#99e7ea;stop-opacity:1" />
<stop
id="stop1136"
offset="1"
style="stop-color:#007ffc;stop-opacity:1" />
</linearGradient>
<linearGradient
inkscape:collect="always"
id="linearGradient1128">
<stop
style="stop-color:#99e7ea;stop-opacity:1"
offset="0"
id="stop1124" />
<stop
style="stop-color:#007ffc;stop-opacity:1"
offset="1"
id="stop1126" />
</linearGradient>
<inkscape:path-effect
effect="bspline"
id="path-effect960"
is_visible="true"
weight="33.333333"
steps="2"
helper_size="0"
apply_no_weight="true"
apply_with_weight="true"
only_selected="false" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient1128"
id="radialGradient1130"
cx="100.35268"
cy="199.86011"
fx="100.35268"
fy="199.86011"
r="90.135414"
gradientTransform="matrix(1,0,0,0.98112945,0,3.7714702)"
gradientUnits="userSpaceOnUse" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient1138"
id="radialGradient1132"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,0.98112945,0,3.7714702)"
cx="100.35268"
cy="199.86011"
fx="100.35268"
fy="199.86011"
r="90.135414" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient1200"
id="radialGradient1202"
cx="100.35268"
cy="199.86011"
fx="100.35268"
fy="199.86011"
r="90.135414"
gradientTransform="matrix(1,0,0,0.98112945,0,3.7714702)"
gradientUnits="userSpaceOnUse" />
<filter
style="color-interpolation-filters:sRGB;"
inkscape:label="Drop Shadow"
id="filter1448">
<feFlood
flood-opacity="0.372549"
flood-color="rgb(145,145,145)"
result="flood"
id="feFlood1438" />
<feComposite
in="flood"
in2="SourceGraphic"
operator="in"
result="composite1"
id="feComposite1440" />
<feGaussianBlur
in="composite1"
stdDeviation="5.2918"
result="blur"
id="feGaussianBlur1442" />
<feOffset
dx="0"
dy="0"
result="offset"
id="feOffset1444" />
<feComposite
in="SourceGraphic"
in2="offset"
operator="over"
result="composite2"
id="feComposite1446" />
</filter>
<filter
style="color-interpolation-filters:sRGB;"
inkscape:label="Drop Shadow"
id="filter2201">
<feFlood
flood-opacity="0.372549"
flood-color="rgb(145,145,145)"
result="flood"
id="feFlood2191" />
<feComposite
in="flood"
in2="SourceGraphic"
operator="in"
result="composite1"
id="feComposite2193" />
<feGaussianBlur
in="composite1"
stdDeviation="3.76995"
result="blur"
id="feGaussianBlur2195" />
<feOffset
dx="0"
dy="0"
result="offset"
id="feOffset2197" />
<feComposite
in="SourceGraphic"
in2="offset"
operator="over"
result="composite2"
id="feComposite2199" />
</filter>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.35"
inkscape:cx="120.33119"
inkscape:cy="507.94585"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1040"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-97)">
<rect
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#ebebeb;stroke-width:2.87003541;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter2201)"
id="rect2119"
width="162.54665"
height="170.16383"
x="20.431099"
y="112.51035"
rx="30"
ry="30" />
<circle
style="opacity:1;fill:#959595;fill-opacity:1;stroke:#e9e9e9;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path2121"
cx="58.208336"
cy="131.8244"
r="6.0476193" />
<circle
style="opacity:1;fill:#9c9c9c;fill-opacity:1;stroke:#eaeaea;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path2121-5"
cx="143.63095"
cy="133.71429"
r="6.0476193" />
</g>
<g
inkscape:groupmode="layer"
id="layer2"
inkscape:label="Layer 2">
<path
style="fill:#ffc344;fill-opacity:1;stroke:none;stroke-width:0.3091144px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 94.205599,42.389243 c 0,0 11.145081,-0.157476 22.599701,6.928753 11.45465,7.086223 18.11074,13.857508 20.27783,18.266716 2.16708,4.409209 9.28755,12.125332 9.13277,26.297795 -0.15488,14.172433 -3.40543,23.620763 -8.97797,31.494323 -5.57254,7.87359 -15.63405,13.85751 -27.70786,14.17247 -12.073829,0.31494 -19.813453,-7.55863 -22.444927,-11.96786 -2.631469,-4.4092 -3.715019,-13.85751 -0.464377,-20.62877 3.250645,-6.77132 8.358796,-6.77132 10.061513,-6.14141 1.702724,0.6299 2.167092,1.5747 3.095852,3.30689 0.928749,1.73219 1.547929,1.41726 2.941089,0.47243 1.39311,-0.94484 1.85748,-2.04715 1.54792,-3.46439 -0.30958,-1.417253 -2.16711,-3.149433 -3.71505,-3.621853 -1.547909,-0.47241 -3.715016,-1.88966 -6.810869,-1.41721 -3.095848,0.47238 -9.132757,2.04711 -14.240906,8.975843 -5.108153,6.92875 -4.488988,17.63684 -1.393134,22.67593 3.095849,5.0391 8.977962,14.48739 21.980539,17.79431 13.00259,3.30693 34.05435,-6.45633 41.32959,-21.57361 7.27524,-15.1173 7.43004,-22.20352 7.12048,-34.643764 C 148.22821,76.875544 137.23793,58.293884 125.00933,51.522601 112.78073,44.751315 103.64797,40.814522 94.205599,42.389243 Z"
id="path1002"
inkscape:connector-curvature="0" />
<path
style="fill:#f06767;fill-opacity:1;stroke:none;stroke-width:0.3091144px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 100.67541,105.29647 c 0,0 -3.06474,-2.8951 -5.801108,2.22698 -2.736373,5.12205 -4.049827,9.68737 -1.313459,15.25486 2.736367,5.56745 8.428007,8.90792 17.184447,8.79659 8.75636,-0.11148 15.21419,-2.22699 19.0451,-8.5739 3.83094,-6.34692 6.7862,-11.02357 7.11457,-13.36191 0.32839,-2.33835 2.07965,0.33404 1.53239,2.33834 -0.54728,2.00426 -0.43783,5.9015 1.09454,5.12204 1.53237,-0.77942 2.73637,-2.00427 2.95526,-1.44753 0.21893,0.55673 -1.75127,4.00859 -2.68162,5.73449 -0.93039,1.7259 -3.83094,5.90153 -5.5275,7.51607 -1.69652,1.61458 -4.04981,3.89724 -6.84092,5.56747 -2.79109,1.67024 -7.11454,3.61887 -9.52255,4.06427 -2.40801,0.44539 -7.22403,1.39184 -9.96042,1.2805 -2.73635,-0.11137 -6.23892,-0.61243 -10.124558,-2.56104 -3.885645,-1.94859 -8.099657,-4.95505 -9.741479,-7.96148 -1.641825,-3.00643 -4.159283,-5.73449 -3.61201,-13.30623 0.547277,-7.57175 3.010008,-11.46899 4.870741,-13.25056 1.860731,-1.7816 4.597103,-2.56105 6.403105,-2.17131 1.806004,0.38971 2.955282,1.44755 3.393102,2.22697 0.43781,0.77944 1.149279,2.22699 1.532369,2.50538 z"
id="path1012"
inkscape:connector-curvature="0" />
<path
style="fill:#3f62eb;fill-opacity:1;stroke:none;stroke-width:0.3091144px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 128.47695,145.38219 c 0,0 13.13457,-7.6831 19.26404,-19.82016 6.12948,-12.13707 8.7564,-19.93152 7.99021,-31.84592 -0.76619,-11.914358 -2.62692,-6.012854 -0.54728,-11.134928 2.07964,-5.122074 -1.31345,-15.254857 0.10943,-15.922949 1.42292,-0.668097 4.48765,4.453971 5.3633,8.573903 0.87562,4.119922 4.70654,16.813721 1.64181,32.959394 -3.06472,16.14564 -10.28872,22.60391 -15.10475,26.94655 -4.81603,4.34261 -15.7615,11.91437 -17.40332,11.80302 -1.64183,-0.11148 -1.86073,-0.11148 -1.31348,-1.55891 z"
id="path1014"
inkscape:connector-curvature="0" />
<path
style="fill:#fce102;fill-opacity:1;stroke:none;stroke-width:0.3091144px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 104.83471,121.99883 c 0,0 7.00512,1.5589 12.36838,-1.78156 5.3633,-3.3405 9.5226,-8.79661 10.17931,-10.91225 0.65672,-2.11564 0.76619,1.89294 1.53236,-0.11125 0.76618,-2.00432 3.83093,-6.01288 2.29855,-15.366239 -1.53237,-9.35333 -1.64182,-9.798747 -4.48762,-14.809463 -2.84586,-5.010719 -9.63207,-11.91437 -13.79134,-14.141359 -4.15927,-2.226986 -9.96037,-5.567464 -17.950594,-5.344766 -7.990202,0.222699 -5.363286,-0.334048 -13.025124,1.002146 -7.661836,1.336187 -14.557491,5.010717 -16.856041,7.015006 -2.298552,2.004286 -8.428023,7.460405 -10.61712,10.46684 -2.189098,3.00643 -8.209113,9.798741 -11.383303,19.263442 -3.174189,9.464683 -4.487646,10.466823 -4.706555,16.702393 -0.21891,6.23557 0.547274,7.90578 -0.766185,8.46256 -1.31346,0.55673 -1.094547,-4.67668 -0.985094,-8.35123 0.109463,-3.6745 0.109463,-13.25056 4.925468,-23.940084 4.816015,-10.689538 13.353489,-19.597489 18.169503,-22.826622 4.816009,-3.229128 10.398208,-7.571752 19.045135,-9.687392 8.646933,-2.115635 17.293863,-1.781586 22.65716,-0.779443 5.3633,1.002145 13.68187,4.453974 18.1695,7.905802 4.48766,3.45183 9.41314,7.683099 13.13459,14.586765 3.72146,6.903648 4.70654,15.700251 4.59709,19.374771 -0.10943,3.674543 -1.97019,12.137103 -4.81601,16.257013 -2.84583,4.11993 -6.67674,9.0193 -10.61711,10.80089 -3.94039,1.78157 -8.75642,2.33833 -12.69675,0.55674 -3.94039,-1.78161 -3.72147,-2.44969 -4.3782,-4.34263 z"
id="path1016"
inkscape:connector-curvature="0" />
<path
style="fill:#5ed938;fill-opacity:1;stroke:none;stroke-width:0.3091144px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 104.83471,121.99883 c 0,0 5.54674,1.56707 10.22918,-0.55878 4.68248,-2.12587 6.4239,-4.17301 7.54615,-5.3934 1.12223,-1.22042 3.25064,-3.50376 3.83112,-4.56669 0.58046,-1.06292 1.19962,-1.69282 1.19962,-2.08649 0,-0.39369 -1.08353,-1.33853 -0.0386,-3.62186 1.04482,-2.28333 1.97361,-7.519273 1.50922,-9.881333 -0.46438,-2.362073 -1.54792,-15.471616 -10.83547,-24.211303 -9.28753,-8.739678 -18.497709,-9.763242 -18.497709,-9.763242 0,0 14.705309,4.645415 21.593569,18.739134 6.88828,14.093741 4.64376,23.148344 0.23218,28.659854 -4.41158,5.51151 -10.68068,6.14141 -12.38342,4.72415 -1.70268,-1.41725 -5.2113,6.47164 -4.38574,7.95996 z"
id="path1018"
inkscape:connector-curvature="0" />
<path
style="fill:#8fdbe9;fill-opacity:1;stroke:none;stroke-width:0.3091144px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 86.930353,71.44277 c 0,0 -9.906718,-0.07875 -17.414156,4.881616 -7.507436,4.960371 -11.14506,8.975903 -13.23476,12.125332 -2.089697,3.149446 -4.488981,7.479909 -4.179395,7.401179 0.309585,-0.0788 9.055364,-12.2828 15.866229,-15.432236 6.81087,-3.149436 13.621741,-7.558644 22.986687,-4.330482 9.364952,3.228184 13.776542,7.716118 15.788842,6.613829 2.0123,-1.1023 2.3993,-2.440824 1.23835,-3.936804 -1.16094,-1.495979 -9.364961,-8.818417 -21.051797,-7.322434 z"
id="path1020"
inkscape:connector-curvature="0" />
<path
style="fill:#fd7aff;fill-opacity:1;stroke:none;stroke-width:0.3091144px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 72.107699,134.35862 c 0.65673,0.33404 5.58219,8.90795 9.522571,10.35548 3.940372,1.44755 6.567286,1.55888 7.005104,2.227 0.437821,0.66809 0.328367,4.00858 3.830921,5.45614 3.502555,1.44753 19.920785,6.01284 24.627325,6.45824 4.70658,0.4454 0.76621,3.22911 3.61202,4.23125 2.84584,1.00217 14.99532,1.5589 17.95061,0.33405 2.95527,-1.22483 2.95527,1.1135 -2.1891,3.1178 -5.14437,2.00427 -18.71677,6.79231 -27.58261,5.67882 -8.86586,-1.1135 -19.373526,-3.00644 -25.284086,-7.23772 -5.910565,-4.23126 -8.42802,-6.1242 -6.238924,-6.45824 2.189096,-0.33407 7.990199,5.9015 10.507662,6.56959 2.517463,0.66809 4.597103,0.66809 3.064735,-0.8908 -1.532366,-1.55888 -11.492755,-8.46253 -12.477849,-8.1285 -0.985092,0.33405 -3.064737,0.55674 -4.816012,-1.78159 -1.751278,-2.33832 -10.945484,-15.25485 -10.39821,-22.1585 0.547273,-6.90365 2.298552,-5.12208 4.378195,-2.56103 2.079641,2.56103 4.487648,4.78801 4.487648,4.78801 z"
id="path1022"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#939393;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 56.889259,34.981831 c 0,0 16.252976,26.08036 43.845241,26.83631 27.59226,0.75596 42.33333,-23.8125 42.33333,-23.8125"
id="path2138"
inkscape:connector-curvature="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -1,9 +1,12 @@
<RCC>
<qresource prefix="/stylesheets">
<file>stylesheets/mainwindow.css</file>
<file>stylesheets/mainwindow_dark.css</file>
</qresource>
<qresource prefix="/info">
<file>lipsum.txt</file>
</qresource>
<qresource prefix="/">
<file>icons/spark-store.svg</file>
<file>icons/settings-dark.svg</file>
</qresource>
</RCC>

View File

@ -0,0 +1,2 @@
<!DOCTYPE RCC>
<RCC version="1.0"/>

View File

@ -1,4 +0,0 @@
QWidget
{
background-color: #f7f7f7;
}

View File

@ -1,6 +1,45 @@
/*
Spark Customizable style sheet conventions
%1 : Global background color
%2 : Controls background color
%3 : Controls background color highlighted
%4 : Selection/Activation background color
%5 : Selection/Activation background color hightlighted
%6 : Light controls gradient light
%7 : Light controls gradient dark
%8 : Light controls gradient darker
%9 : Dark controls gradient light
%10: Dark controls gradient dark
%11: Text on Selection/Activation
*/
QWidget
{
background-color: #353535;
background-color: %1
}
QTreeWidget[objectName=spk_mw_category]
{
border: none;
font-size: 16px;
show-decoration-selected: 1;
}
QTreeWidget[objectName=spk_mw_category]::item
{
height: 50px;
border: none;
color: %11;
}
QTreeWidget[objectName=spk_mw_category]::item:selected
{
background-color: %4;
}
QTreeWidget[objectName=spk_mw_category]::branch:selected
{
background-color: %4;
}
QLabel
@ -23,35 +62,51 @@ QPushButton
font-weight: 300;
border-top-color: #7b7b7b;
border-style: solid;
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #6b6b6b, stop:1 #656565)
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 %6, stop:1 %7)
}
QPushButton::pressed
{
border-top-color: #656565;
border-bottom-color: #7b7b7b;
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #606060, stop:1 #6b6b6b)
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 %8, stop:1 %6)
}
QPushButton[objectName=spk_styling_msgboxexpandbtn]
QPushButton[objectName=spk_styling_checkbtn]
{
border-width: 0px;
background-color: #434343
background-color: %9
}
QPushButton[objectName=spk_styling_msgboxexpandbtn]::checked
QPushButton[objectName=spk_styling_checkbtn]:pressed
{
background-color: #0070ff
background-color: %5
}
SpkWindow::!focused
QPushButton[objectName=spk_styling_checkbtn]:checked
{
background-color: #2c2c2c
background-color: %4
}
QPushButton[objectName=spk_styling_plaincheckbtn]
{
border-width: 0px;
background-color: %1
}
QPushButton[objectName=spk_styling_plaincheckbtn]:pressed
{
background-color: %5
}
QPushButton[objectName=spk_styling_plaincheckbtn]:checked
{
background-color: %4
}
SpkTitleBar
{
border-color: #404040;
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 %10, stop:1 %9)
}
SpkTitleBarDefaultButton
@ -59,17 +114,17 @@ SpkTitleBarDefaultButton
margin: 0px;
border-radius: 0px;
border-width: 0px;
background-color: #353535;
background-color: %2;
}
SpkTitleBarDefaultButton:hover
{
background-color: #404040;
background-color: %9;
}
SpkTitleBarDefaultButton:pressed
{
background-color: #5e5e5e;
background-color: %8;
}
QScrollBar::handle

View File

@ -1,13 +1,9 @@
#include <QApplication>
#include <QPushButton>
#include <spklogging.h>
#include "spkwindow.h"
#include "spkui_general.h"
#include "spkstore.h"
#include <QFile>
#include "spkmsgbox.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
@ -16,7 +12,5 @@ int main(int argc, char *argv[])
SpkStore store(false, LogPath);
SpkMsgBox::StaticExec("E", "F");
return QApplication::exec();
}

View File

@ -12,12 +12,19 @@ SpkStore::SpkStore(bool aCli, QString &aLogPath)
{
mLogger = new SpkLogger(aLogPath);
// Singleton
Q_ASSERT(Instance == nullptr);
Instance = this;
// Finish all essential initialization after this.
mNetMgr = new QNetworkAccessManager(this);
// Finish all essential initialization before this.
if(aCli)
return;
// UI Initialization
SpkUi::Initialize();
mMainWindow = new SpkMainWindow;