Save/restore geometry in settings dialog
This commit is contained in:
parent
019b49a219
commit
69d86513ae
@ -70,10 +70,10 @@
|
||||
|
||||
class QShowEvent;
|
||||
|
||||
const char *SettingsDialog::kSettingsGroup = "SettingsDialog";
|
||||
|
||||
SettingsItemDelegate::SettingsItemDelegate(QObject *parent)
|
||||
: QStyledItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
: QStyledItemDelegate(parent) {}
|
||||
|
||||
QSize SettingsItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
||||
|
||||
@ -149,12 +149,28 @@ SettingsDialog::SettingsDialog(Application *app, QWidget *parent)
|
||||
|
||||
ui_->buttonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence::Close);
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
if (s.contains("geometry")) {
|
||||
restoreGeometry(s.value("geometry").toByteArray());
|
||||
}
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
|
||||
SettingsDialog::~SettingsDialog() {
|
||||
delete ui_;
|
||||
}
|
||||
|
||||
void SettingsDialog::SaveGeometry() {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
s.setValue("geometry", saveGeometry());
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
|
||||
QTreeWidgetItem *SettingsDialog::AddCategory(const QString &name) {
|
||||
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem;
|
||||
@ -216,6 +232,7 @@ void SettingsDialog::Save() {
|
||||
|
||||
void SettingsDialog::accept() {
|
||||
Save();
|
||||
SaveGeometry();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
@ -225,6 +242,7 @@ void SettingsDialog::reject() {
|
||||
for (const PageData &data : pages_.values()) {
|
||||
data.page_->Cancel();
|
||||
}
|
||||
SaveGeometry();
|
||||
|
||||
QDialog::reject();
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
class SettingsDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
SettingsDialog(Application *app, QWidget *parent = nullptr);
|
||||
~SettingsDialog();
|
||||
|
||||
@ -111,14 +111,14 @@ public:
|
||||
|
||||
void ComboBoxLoadFromSettings(QSettings &s, QComboBox *combobox, QString setting, QString default_value);
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void NotificationPreview(OSD::Behaviour, QString, QString);
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void CurrentItemChanged(QTreeWidgetItem *item);
|
||||
void DialogButtonClicked(QAbstractButton *button);
|
||||
|
||||
private:
|
||||
private:
|
||||
struct PageData {
|
||||
QTreeWidgetItem *item_;
|
||||
QScrollArea *scroll_area_;
|
||||
@ -130,7 +130,11 @@ private:
|
||||
|
||||
void Save();
|
||||
|
||||
private:
|
||||
void SaveGeometry();
|
||||
|
||||
private:
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
Application *app_;
|
||||
Player *player_;
|
||||
EngineBase *engine_;
|
||||
|
@ -17,7 +17,7 @@
|
||||
<iconset resource="../../data/icons.qrc">
|
||||
<normaloff>:/icons/64x64/strawberry.png</normaloff>:/icons/64x64/strawberry.png</iconset>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<layout class="QHBoxLayout" name="layout_dialog">
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="list">
|
||||
<property name="maximumSize">
|
||||
@ -55,7 +55,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_1">
|
||||
<layout class="QVBoxLayout" name="layout">
|
||||
<item>
|
||||
<widget class="QLabel" name="title"/>
|
||||
</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user