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"
|
||||
|
||||
SpkAbout::SpkAbout(QWidget *parent) : SpkDialog(parent)
|
||||
{
|
||||
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()
|
||||
{
|
||||
SpkAbout *b = new SpkAbout;
|
||||
|
||||
b->GetTitleBar()->SetOperationButton(SpkTitleBar::OperationButton::Close);
|
||||
|
||||
// TODO: Waiting for qygw
|
||||
|
||||
|
||||
b->Exec();
|
||||
delete b;
|
||||
|
||||
@ -59,16 +59,29 @@ void SpkDialog::AddButton(QString text, SpkUi::SpkButtonStyle style)
|
||||
|
||||
void SpkDialog::AddWidget(QWidget *w)
|
||||
{
|
||||
// Adding a widget does not take the ownership.
|
||||
mWidgetsVLay->addWidget(w);
|
||||
mWidgetsList << w;
|
||||
mParentsList << w->parentWidget();
|
||||
}
|
||||
|
||||
void SpkDialog::AddLayout(QLayout *w)
|
||||
{
|
||||
mWidgetsVLay->addLayout(w);
|
||||
mWidgetsList << w;
|
||||
mParentsList << w->parentWidget();
|
||||
}
|
||||
|
||||
void SpkDialog::AddSpacing(int a)
|
||||
{
|
||||
mWidgetsVLay->addSpacing(a);
|
||||
}
|
||||
|
||||
void SpkDialog::SetMargin(int a)
|
||||
{
|
||||
mWidgetsVLay->setMargin(a);
|
||||
}
|
||||
|
||||
int SpkDialog::Exec()
|
||||
{
|
||||
QEventLoop loop;
|
||||
|
||||
@ -25,7 +25,7 @@ SpkTitleBar::SpkTitleBar(QWidget *parent) : QWidget(parent)
|
||||
mMainLayout->setSpacing(8);
|
||||
mBtnGroup->setSpacing(0);
|
||||
|
||||
mMainLayout->addSpacing(8);
|
||||
mMainLayout->addSpacing(12);
|
||||
mMainLayout->addWidget(mIcon);
|
||||
mMainLayout->addWidget(mTitle);
|
||||
mMainLayout->addLayout(mUserSpace);
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
|
||||
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())
|
||||
SpkUi::DtkPlugin->addWindow(this, parent); // Register window to DXcb so we got Deepin
|
||||
else
|
||||
@ -24,7 +25,6 @@ SpkWindow::SpkWindow(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(paren
|
||||
mMoving = mResizing = false;
|
||||
mCloseHook = nullptr;
|
||||
mMaximized = windowState().testFlag(Qt::WindowMaximized);
|
||||
mUseCustomEvents = SpkUi::DtkPlugin == nullptr;
|
||||
|
||||
PopulateUi();
|
||||
}
|
||||
@ -225,6 +225,20 @@ void SpkWindow::closeEvent(QCloseEvent *e)
|
||||
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)
|
||||
{
|
||||
mCornerRadius = radius;
|
||||
|
||||
@ -1,11 +1,21 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
#include "spkdialog.h"
|
||||
|
||||
class SpkAbout : public SpkDialog
|
||||
{
|
||||
public:
|
||||
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();
|
||||
void AddButton(QString text, SpkUi::SpkButtonStyle style = SpkUi::SpkButtonStyle::Normal);
|
||||
void AddWidget(QWidget*);
|
||||
void AddLayout(QLayout*);
|
||||
void AddSpacing(int);
|
||||
void SetMargin(int);
|
||||
int Exec();
|
||||
|
||||
private slots:
|
||||
@ -31,5 +33,5 @@ class SpkDialog : public SpkWindow
|
||||
QVBoxLayout *mMainVLay, *mWidgetsVLay;
|
||||
QHBoxLayout *mBtnLay;
|
||||
QButtonGroup *mBtnGroup;
|
||||
QList<QWidget*> mWidgetsList, mParentsList;
|
||||
QList<QObject*> mWidgetsList, mParentsList;
|
||||
};
|
||||
|
||||
@ -17,6 +17,11 @@ class QNetworkReply;
|
||||
|
||||
namespace SpkUi
|
||||
{
|
||||
enum SpkStackedPages
|
||||
{
|
||||
PgQssTest // Must be at last
|
||||
};
|
||||
|
||||
class SpkSidebarSelector : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -35,5 +35,5 @@ class SpkStore : public QObject
|
||||
SpkLogger *mLogger;
|
||||
SpkMainWindow *mMainWindow = 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 ResizeWindowByCursor(QPoint);
|
||||
void closeEvent(QCloseEvent *) override;
|
||||
// void paintEvent(QPaintEvent *) override;
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
|
||||
private:
|
||||
void PopulateUi();
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
#include "spkui_general.h"
|
||||
#include "spkstore.h"
|
||||
|
||||
#include "spkabout.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
@ -12,5 +14,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
SpkStore store(false, LogPath);
|
||||
|
||||
SpkAbout::Show();
|
||||
|
||||
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
|
||||
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
|
||||
{
|
||||
mCfg = new QSettings(":/info/default_config", QSettings::IniFormat);
|
||||
mCfg = new QSettings(":/info/default_config", QSettings::IniFormat, this);
|
||||
#if 0
|
||||
bool cfgDirOk;
|
||||
if(!qgetenv("SPARK_NO_INSTALL_CONFIG").toInt())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user