mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-07-05 13:15:59 +08:00
feat: #IAJDMD restore window size when last closed on startup
record window size in ~MainWindow() to config.ini; in MainWindow::initUI restore window size Log: restore window size when last closed on startup
This commit is contained in:
parent
fa488c0a9d
commit
92fa8e552d
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include <DSysInfo>
|
#include <DSysInfo>
|
||||||
#include <DApplicationSettings>
|
#include <DApplicationSettings>
|
||||||
#include <DWidgetUtil>
|
|
||||||
|
|
||||||
#include <QDate>
|
#include <QDate>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
@ -196,8 +195,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
a.setMainWindow(&w); // 设置应用程序主窗口,用于初始化关于对话框
|
a.setMainWindow(&w); // 设置应用程序主窗口,用于初始化关于对话框
|
||||||
// 让打开时界面显示在正中
|
|
||||||
Dtk::Widget::moveToCenter(&w);
|
|
||||||
|
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
{
|
{
|
||||||
|
@ -48,6 +48,11 @@ MainWindow::~MainWindow()
|
|||||||
delete ui;
|
delete ui;
|
||||||
|
|
||||||
downloadlistwidget->deleteLater();
|
downloadlistwidget->deleteLater();
|
||||||
|
|
||||||
|
QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat);
|
||||||
|
config.setValue("window/width", width());
|
||||||
|
config.setValue("window/height", height());
|
||||||
|
config.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::initDbus()
|
void MainWindow::initDbus()
|
||||||
@ -123,6 +128,17 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||||||
|
|
||||||
void MainWindow::initUI()
|
void MainWindow::initUI()
|
||||||
{
|
{
|
||||||
|
QSettings config(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/config.ini", QSettings::IniFormat);
|
||||||
|
QSize size;
|
||||||
|
size.rwidth() = config.value("window/width").toInt();
|
||||||
|
size.rheight() = config.value("window/height").toInt();
|
||||||
|
if (!size.isEmpty()) {
|
||||||
|
resize(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 让打开时界面显示在正中
|
||||||
|
moveToCenter(this);
|
||||||
|
|
||||||
setWindowTitle(QObject::tr("Spark Store"));
|
setWindowTitle(QObject::tr("Spark Store"));
|
||||||
setMaskAlpha(250);
|
setMaskAlpha(250);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user