更换SpkWindow基类为QWidget并修复多个问题

修复mResizable为false时阻止窗口移动的问题
更改About窗口为固定大小
This commit is contained in:
RigoLigoRLC
2022-02-06 22:40:46 +08:00
parent 58a0336a23
commit f2e417e02a
8 changed files with 63 additions and 39 deletions

View File

@@ -17,6 +17,7 @@ class SpkDialog : public SpkWindow
void AddWidget(QWidget*);
void AddLayout(QLayout*);
void AddSpacing(int);
void AddStretch(int a = 0);
void SetMargin(int);
void SetMargin(int, int, int, int);
int Exec();

View File

@@ -50,7 +50,7 @@ class SpkTitleBar : public QWidget
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 SetLinkedWindow(SpkWindow *w) { mLinkedWindow = w; }
QHBoxLayout *GetUserSpace() { return mUserSpace; }
protected:
@@ -59,7 +59,7 @@ class SpkTitleBar : public QWidget
private:
QLabel *mIcon;
QLabel *mTitle;
QMainWindow *mLinkedWindow;
SpkWindow *mLinkedWindow;
QHBoxLayout *mMainLayout, *mUserSpace, *mBtnGroup;
SpkTitleBarDefaultButton *mBtnMin, *mBtnMaxRestore, *mBtnClose;

View File

@@ -4,16 +4,16 @@
#pragma once
#include <QMainWindow>
#include <QFrame>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPushButton>
#include <QLabel>
#include <QCloseEvent>
#include "spktitlebar.h"
class SpkWindow : public QMainWindow
class SpkTitleBar;
class SpkWindow : public QWidget
{
Q_OBJECT
public:
@@ -21,7 +21,7 @@ class SpkWindow : public QMainWindow
static constexpr int BorderWidth = 7;
private:
QWidget *mCentralWidget, *mUserCentralWidget;
QWidget *mUserCentralWidget;
QVBoxLayout *mMainVLayout;
SpkTitleBar *mTitleBarComponent;
int mCornerRadius;
@@ -32,7 +32,7 @@ class SpkWindow : public QMainWindow
bool mUseCustomEvents;
public:
SpkWindow(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
SpkWindow(QWidget *parent = nullptr);
~SpkWindow() override;
void SetCentralWidget(QWidget *);
bool GetUseTitleBar();
@@ -62,4 +62,6 @@ class SpkWindow : public QMainWindow
private:
void PopulateUi();
void paintWindowBorder();
};