mirror of
https://github.com/loimu/zeit.git
synced 2025-09-15 12:58:44 +08:00
zeit: save window parameters between sessions
This commit is contained in:
parent
b022bdfdfb
commit
1d364ff6ee
@ -36,5 +36,5 @@ QString BaseDelegate::elideText(const QString& text) const {
|
||||
const QFontMetrics& fm = ui->listWidget->fontMetrics();
|
||||
return fm.elidedText(text,
|
||||
isElidedTextEnabled ? Qt::ElideRight : Qt::ElideNone,
|
||||
ui->listWidget->width() - 36 /* hardcoded icon size */);
|
||||
ui->listWidget->width() - 48 /* hardcoded icon size */);
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QKeyEvent>
|
||||
#include <QProcess>
|
||||
#include <QSettings>
|
||||
|
||||
#ifdef BUILD_HELPER
|
||||
#define ROOT_ACTIONS cron->isSystemCron()
|
||||
@ -153,6 +154,12 @@ MainWindow::~MainWindow() {
|
||||
|
||||
void MainWindow::show() {
|
||||
QMainWindow::show();
|
||||
QSettings settings(QCoreApplication::organizationName(),
|
||||
QCoreApplication::applicationName());
|
||||
restoreGeometry(settings.value(QStringLiteral("geometry")).toByteArray());
|
||||
restoreState(settings.value(QStringLiteral("windowState")).toByteArray());
|
||||
ui->actionShortenText->setChecked(
|
||||
settings.value(QStringLiteral("General/shortenText")).toBool());
|
||||
updateWindow();
|
||||
refreshActions(false);
|
||||
}
|
||||
@ -167,6 +174,16 @@ void MainWindow::resizeEvent(QResizeEvent* e) {
|
||||
list->view();
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent* e) {
|
||||
QSettings settings(QCoreApplication::organizationName(),
|
||||
QCoreApplication::applicationName());
|
||||
settings.setValue(QStringLiteral("geometry"), saveGeometry());
|
||||
settings.setValue(QStringLiteral("windowState"), saveState());
|
||||
settings.setValue(QStringLiteral("General/shortenText"),
|
||||
ui->actionShortenText->isChecked());
|
||||
QMainWindow::closeEvent(e);
|
||||
}
|
||||
|
||||
void MainWindow::refreshActions(bool enabled) {
|
||||
bool currentUser = cron->isCurrentUserCron() || ROOT_ACTIONS;
|
||||
ui->toggleItemAction->setDisabled(ui->actionCommands->isChecked() || !enabled);
|
||||
|
||||
@ -45,6 +45,7 @@ class MainWindow : public QMainWindow
|
||||
BaseDelegate* list = nullptr;
|
||||
void keyPressEvent(QKeyEvent*);
|
||||
void resizeEvent(QResizeEvent*);
|
||||
void closeEvent(QCloseEvent*);
|
||||
void refreshActions(bool);
|
||||
void updateWindow();
|
||||
void switchView();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user