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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,7 +130,11 @@ private:
|
|||||||
|
|
||||||
void Save();
|
void Save();
|
||||||
|
|
||||||
|
void SaveGeometry();
|
||||||
|
|
||||||
private:
|
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