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