mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-06-05 22:49:51 +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 <DApplicationSettings>
|
||||
#include <DWidgetUtil>
|
||||
|
||||
#include <QDate>
|
||||
#include <QProcessEnvironment>
|
||||
@ -196,8 +195,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
MainWindow w;
|
||||
a.setMainWindow(&w); // 设置应用程序主窗口,用于初始化关于对话框
|
||||
// 让打开时界面显示在正中
|
||||
Dtk::Widget::moveToCenter(&w);
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
|
@ -48,6 +48,11 @@ MainWindow::~MainWindow()
|
||||
delete ui;
|
||||
|
||||
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()
|
||||
@ -123,6 +128,17 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
|
||||
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"));
|
||||
setMaskAlpha(250);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user