mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-11-14 04:52:20 +08:00
加入SpkAbout(无内容)
This commit is contained in:
parent
f7becc1a66
commit
8198dc48c5
@ -1,18 +1,56 @@
|
|||||||
|
|
||||||
|
#include "gitver.h"
|
||||||
#include "spkabout.h"
|
#include "spkabout.h"
|
||||||
|
|
||||||
SpkAbout::SpkAbout(QWidget *parent) : SpkDialog(parent)
|
SpkAbout::SpkAbout(QWidget *parent) : SpkDialog(parent)
|
||||||
{
|
{
|
||||||
setWindowModality(Qt::ApplicationModal);
|
setWindowModality(Qt::ApplicationModal);
|
||||||
|
|
||||||
|
mIconLay = new QHBoxLayout;
|
||||||
|
|
||||||
|
mSpkVersion = new QLabel;
|
||||||
|
mSpkVersion->setText(tr("<h1>Spark Store</h1>"
|
||||||
|
"<h3>Version %1</h3>"
|
||||||
|
"<t>Code committed on (%2)</t><br>"
|
||||||
|
"<t>Built on %3 %4</t>")
|
||||||
|
.arg(GitVer::DescribeTags())
|
||||||
|
.arg(GitVer::CommitDate())
|
||||||
|
.arg(__DATE__)
|
||||||
|
.arg(__TIME__));
|
||||||
|
|
||||||
|
mSpkIcon = new QLabel;
|
||||||
|
mSpkIcon->setPixmap(QIcon(":/icons/spark-store.svg").pixmap(QSize(128, 128)));
|
||||||
|
|
||||||
|
QFile lipsum(":/info/lipsum.txt");
|
||||||
|
lipsum.open(QFile::ReadOnly);
|
||||||
|
mDescriptionText = new QLabel;
|
||||||
|
mDescriptionText->setText(lipsum.readAll());
|
||||||
|
lipsum.close();
|
||||||
|
|
||||||
|
mIconLay->addWidget(mSpkIcon);
|
||||||
|
mIconLay->addWidget(mSpkVersion);
|
||||||
|
mIconLay->setAlignment(Qt::AlignVCenter);
|
||||||
|
AddLayout(mIconLay);
|
||||||
|
AddSpacing(18);
|
||||||
|
AddWidget(mDescriptionText);
|
||||||
|
SetMargin(18);
|
||||||
|
|
||||||
|
GetTitleBar()->SetOperationButton(SpkTitleBar::OperationButton::Close);
|
||||||
|
GetTitleBar()->SetTitle(tr("About Spark Store"));
|
||||||
|
}
|
||||||
|
|
||||||
|
SpkAbout::~SpkAbout()
|
||||||
|
{
|
||||||
|
// delete mIconLay;
|
||||||
|
// delete mDescriptionText;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpkAbout::Show()
|
void SpkAbout::Show()
|
||||||
{
|
{
|
||||||
SpkAbout *b = new SpkAbout;
|
SpkAbout *b = new SpkAbout;
|
||||||
|
|
||||||
b->GetTitleBar()->SetOperationButton(SpkTitleBar::OperationButton::Close);
|
|
||||||
|
|
||||||
// TODO: Waiting for qygw
|
|
||||||
|
|
||||||
b->Exec();
|
b->Exec();
|
||||||
delete b;
|
delete b;
|
||||||
|
|||||||
@ -59,16 +59,29 @@ void SpkDialog::AddButton(QString text, SpkUi::SpkButtonStyle style)
|
|||||||
|
|
||||||
void SpkDialog::AddWidget(QWidget *w)
|
void SpkDialog::AddWidget(QWidget *w)
|
||||||
{
|
{
|
||||||
|
// Adding a widget does not take the ownership.
|
||||||
mWidgetsVLay->addWidget(w);
|
mWidgetsVLay->addWidget(w);
|
||||||
mWidgetsList << w;
|
mWidgetsList << w;
|
||||||
mParentsList << w->parentWidget();
|
mParentsList << w->parentWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SpkDialog::AddLayout(QLayout *w)
|
||||||
|
{
|
||||||
|
mWidgetsVLay->addLayout(w);
|
||||||
|
mWidgetsList << w;
|
||||||
|
mParentsList << w->parentWidget();
|
||||||
|
}
|
||||||
|
|
||||||
void SpkDialog::AddSpacing(int a)
|
void SpkDialog::AddSpacing(int a)
|
||||||
{
|
{
|
||||||
mWidgetsVLay->addSpacing(a);
|
mWidgetsVLay->addSpacing(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SpkDialog::SetMargin(int a)
|
||||||
|
{
|
||||||
|
mWidgetsVLay->setMargin(a);
|
||||||
|
}
|
||||||
|
|
||||||
int SpkDialog::Exec()
|
int SpkDialog::Exec()
|
||||||
{
|
{
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
|
|||||||
@ -25,7 +25,7 @@ SpkTitleBar::SpkTitleBar(QWidget *parent) : QWidget(parent)
|
|||||||
mMainLayout->setSpacing(8);
|
mMainLayout->setSpacing(8);
|
||||||
mBtnGroup->setSpacing(0);
|
mBtnGroup->setSpacing(0);
|
||||||
|
|
||||||
mMainLayout->addSpacing(8);
|
mMainLayout->addSpacing(12);
|
||||||
mMainLayout->addWidget(mIcon);
|
mMainLayout->addWidget(mIcon);
|
||||||
mMainLayout->addWidget(mTitle);
|
mMainLayout->addWidget(mTitle);
|
||||||
mMainLayout->addLayout(mUserSpace);
|
mMainLayout->addLayout(mUserSpace);
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
SpkWindow::SpkWindow(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, flags)
|
SpkWindow::SpkWindow(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, flags)
|
||||||
{
|
{
|
||||||
|
mUseCustomEvents = SpkUi::DtkPlugin == nullptr; // Put to the front, to prevent warnings
|
||||||
if(SpkUi::DtkPlugin && !qgetenv("SPARK_NO_DXCB").toInt())
|
if(SpkUi::DtkPlugin && !qgetenv("SPARK_NO_DXCB").toInt())
|
||||||
SpkUi::DtkPlugin->addWindow(this, parent); // Register window to DXcb so we got Deepin
|
SpkUi::DtkPlugin->addWindow(this, parent); // Register window to DXcb so we got Deepin
|
||||||
else
|
else
|
||||||
@ -24,7 +25,6 @@ SpkWindow::SpkWindow(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(paren
|
|||||||
mMoving = mResizing = false;
|
mMoving = mResizing = false;
|
||||||
mCloseHook = nullptr;
|
mCloseHook = nullptr;
|
||||||
mMaximized = windowState().testFlag(Qt::WindowMaximized);
|
mMaximized = windowState().testFlag(Qt::WindowMaximized);
|
||||||
mUseCustomEvents = SpkUi::DtkPlugin == nullptr;
|
|
||||||
|
|
||||||
PopulateUi();
|
PopulateUi();
|
||||||
}
|
}
|
||||||
@ -225,6 +225,20 @@ void SpkWindow::closeEvent(QCloseEvent *e)
|
|||||||
emit Closed();
|
emit Closed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SpkWindow::paintEvent(QPaintEvent *e)
|
||||||
|
{
|
||||||
|
//FIXME: DOESN'T WORK!
|
||||||
|
// QPainter painter(this);
|
||||||
|
// painter.setBrush(QBrush(Qt::NoBrush));
|
||||||
|
// painter.setPen(QPen(SpkUi::ColorLine));
|
||||||
|
// QRect rect = this->rect();
|
||||||
|
// rect.setWidth(rect.width() - 2);
|
||||||
|
// rect.setHeight(rect.height() - 2);
|
||||||
|
// rect.adjust(-1, -1, 1, 1);
|
||||||
|
// painter.drawRect(rect);
|
||||||
|
// QWidget::paintEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
void SpkWindow::SetCornerRadius(int radius)
|
void SpkWindow::SetCornerRadius(int radius)
|
||||||
{
|
{
|
||||||
mCornerRadius = radius;
|
mCornerRadius = radius;
|
||||||
|
|||||||
@ -1,11 +1,21 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QHBoxLayout>
|
||||||
#include "spkdialog.h"
|
#include "spkdialog.h"
|
||||||
|
|
||||||
class SpkAbout : public SpkDialog
|
class SpkAbout : public SpkDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SpkAbout(QWidget* parent = nullptr);
|
SpkAbout(QWidget* parent = nullptr);
|
||||||
void Show();
|
~SpkAbout();
|
||||||
|
static void Show();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QHBoxLayout *mIconLay;
|
||||||
|
QLabel *mSpkIcon;
|
||||||
|
QLabel *mSpkVersion;
|
||||||
|
QLabel *mDescriptionText;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -15,7 +15,9 @@ class SpkDialog : public SpkWindow
|
|||||||
~SpkDialog();
|
~SpkDialog();
|
||||||
void AddButton(QString text, SpkUi::SpkButtonStyle style = SpkUi::SpkButtonStyle::Normal);
|
void AddButton(QString text, SpkUi::SpkButtonStyle style = SpkUi::SpkButtonStyle::Normal);
|
||||||
void AddWidget(QWidget*);
|
void AddWidget(QWidget*);
|
||||||
|
void AddLayout(QLayout*);
|
||||||
void AddSpacing(int);
|
void AddSpacing(int);
|
||||||
|
void SetMargin(int);
|
||||||
int Exec();
|
int Exec();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@ -31,5 +33,5 @@ class SpkDialog : public SpkWindow
|
|||||||
QVBoxLayout *mMainVLay, *mWidgetsVLay;
|
QVBoxLayout *mMainVLay, *mWidgetsVLay;
|
||||||
QHBoxLayout *mBtnLay;
|
QHBoxLayout *mBtnLay;
|
||||||
QButtonGroup *mBtnGroup;
|
QButtonGroup *mBtnGroup;
|
||||||
QList<QWidget*> mWidgetsList, mParentsList;
|
QList<QObject*> mWidgetsList, mParentsList;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -17,6 +17,11 @@ class QNetworkReply;
|
|||||||
|
|
||||||
namespace SpkUi
|
namespace SpkUi
|
||||||
{
|
{
|
||||||
|
enum SpkStackedPages
|
||||||
|
{
|
||||||
|
PgQssTest // Must be at last
|
||||||
|
};
|
||||||
|
|
||||||
class SpkSidebarSelector : public QObject
|
class SpkSidebarSelector : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@ -35,5 +35,5 @@ class SpkStore : public QObject
|
|||||||
SpkLogger *mLogger;
|
SpkLogger *mLogger;
|
||||||
SpkMainWindow *mMainWindow = nullptr;
|
SpkMainWindow *mMainWindow = nullptr;
|
||||||
QNetworkAccessManager *mNetMgr = nullptr;
|
QNetworkAccessManager *mNetMgr = nullptr;
|
||||||
QString mDistroName, mApiRequestUrl, mUserAgentStr;
|
QString mDistroName, mApiRequestUrl, mUserAgentStr, mConfigPath;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -59,7 +59,7 @@ class SpkWindow : public QMainWindow
|
|||||||
void SetMouseCursor(Qt::Edges);
|
void SetMouseCursor(Qt::Edges);
|
||||||
void ResizeWindowByCursor(QPoint);
|
void ResizeWindowByCursor(QPoint);
|
||||||
void closeEvent(QCloseEvent *) override;
|
void closeEvent(QCloseEvent *) override;
|
||||||
// void paintEvent(QPaintEvent *) override;
|
void paintEvent(QPaintEvent *) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void PopulateUi();
|
void PopulateUi();
|
||||||
|
|||||||
@ -4,6 +4,8 @@
|
|||||||
#include "spkui_general.h"
|
#include "spkui_general.h"
|
||||||
#include "spkstore.h"
|
#include "spkstore.h"
|
||||||
|
|
||||||
|
#include "spkabout.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
@ -12,5 +14,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
SpkStore store(false, LogPath);
|
SpkStore store(false, LogPath);
|
||||||
|
|
||||||
|
SpkAbout::Show();
|
||||||
|
|
||||||
return QApplication::exec();
|
return QApplication::exec();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,10 +26,11 @@ SpkStore::SpkStore(bool aCli, QString &aLogPath)
|
|||||||
|
|
||||||
mConfigPath = QDir::homePath() + "/.config/spark-store/config"; //TODO: flexible config via CLI
|
mConfigPath = QDir::homePath() + "/.config/spark-store/config"; //TODO: flexible config via CLI
|
||||||
if(QFileInfo(mConfigPath).exists())
|
if(QFileInfo(mConfigPath).exists())
|
||||||
mCfg = new QSettings(QDir::homePath() + "/.config/spark-store/config", QSettings::IniFormat);
|
mCfg = new QSettings(QDir::homePath() + "/.config/spark-store/config", QSettings::IniFormat,
|
||||||
|
this);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mCfg = new QSettings(":/info/default_config", QSettings::IniFormat);
|
mCfg = new QSettings(":/info/default_config", QSettings::IniFormat, this);
|
||||||
#if 0
|
#if 0
|
||||||
bool cfgDirOk;
|
bool cfgDirOk;
|
||||||
if(!qgetenv("SPARK_NO_INSTALL_CONFIG").toInt())
|
if(!qgetenv("SPARK_NO_INSTALL_CONFIG").toInt())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user