save sets dialog size (#4791)
* save sets dialog size * reset sorting when restoring * add to gitignore
This commit is contained in:
parent
421da882d8
commit
70ab02987a
9 changed files with 61 additions and 8 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -11,3 +11,5 @@ preferences
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
.vs/
|
.vs/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
.cache
|
||||||
|
.gdb_history
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "pictureloader.h"
|
#include "pictureloader.h"
|
||||||
#include "setsmodel.h"
|
#include "setsmodel.h"
|
||||||
|
#include "settingscache.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -84,7 +85,6 @@ WndSets::WndSets(QWidget *parent) : QMainWindow(parent)
|
||||||
displayModel->setDynamicSortFilter(false);
|
displayModel->setDynamicSortFilter(false);
|
||||||
view = new QTreeView;
|
view = new QTreeView;
|
||||||
view->setModel(displayModel);
|
view->setModel(displayModel);
|
||||||
view->setMinimumSize(QSize(500, 250));
|
|
||||||
|
|
||||||
view->setAlternatingRowColors(true);
|
view->setAlternatingRowColors(true);
|
||||||
view->setUniformRowHeights(true);
|
view->setUniformRowHeights(true);
|
||||||
|
@ -98,10 +98,6 @@ WndSets::WndSets(QWidget *parent) : QMainWindow(parent)
|
||||||
view->setDropIndicatorShown(true);
|
view->setDropIndicatorShown(true);
|
||||||
view->setDragDropMode(QAbstractItemView::InternalMove);
|
view->setDragDropMode(QAbstractItemView::InternalMove);
|
||||||
|
|
||||||
view->header()->setSectionResizeMode(QHeaderView::Stretch);
|
|
||||||
view->header()->setSectionResizeMode(SetsModel::EnabledCol, QHeaderView::ResizeToContents);
|
|
||||||
view->header()->setSectionResizeMode(SetsModel::LongNameCol, QHeaderView::ResizeToContents);
|
|
||||||
|
|
||||||
view->sortByColumn(SetsModel::SortKeyCol, Qt::AscendingOrder);
|
view->sortByColumn(SetsModel::SortKeyCol, Qt::AscendingOrder);
|
||||||
view->setColumnHidden(SetsModel::SortKeyCol, true);
|
view->setColumnHidden(SetsModel::SortKeyCol, true);
|
||||||
view->setColumnHidden(SetsModel::IsKnownCol, true);
|
view->setColumnHidden(SetsModel::IsKnownCol, true);
|
||||||
|
@ -170,7 +166,7 @@ WndSets::WndSets(QWidget *parent) : QMainWindow(parent)
|
||||||
|
|
||||||
mainLayout = new QGridLayout;
|
mainLayout = new QGridLayout;
|
||||||
mainLayout->addLayout(filterBox, 0, 1, 1, 2);
|
mainLayout->addLayout(filterBox, 0, 1, 1, 2);
|
||||||
mainLayout->addWidget(setsEditToolBar, 1, 0, 2, 1);
|
mainLayout->addWidget(setsEditToolBar, 1, 0, 4, 1);
|
||||||
mainLayout->addWidget(view, 1, 1, 1, 2);
|
mainLayout->addWidget(view, 1, 1, 1, 2);
|
||||||
mainLayout->addWidget(enableAllButton, 2, 1);
|
mainLayout->addWidget(enableAllButton, 2, 1);
|
||||||
mainLayout->addWidget(disableAllButton, 2, 2);
|
mainLayout->addWidget(disableAllButton, 2, 2);
|
||||||
|
@ -190,13 +186,35 @@ WndSets::WndSets(QWidget *parent) : QMainWindow(parent)
|
||||||
setCentralWidget(centralWidget);
|
setCentralWidget(centralWidget);
|
||||||
|
|
||||||
setWindowTitle(tr("Manage sets"));
|
setWindowTitle(tr("Manage sets"));
|
||||||
resize(800, 500);
|
setMinimumSize(800, 500);
|
||||||
|
auto &geometry = SettingsCache::instance().getSetsDialogGeometry();
|
||||||
|
if (!geometry.isEmpty()) {
|
||||||
|
restoreGeometry(geometry);
|
||||||
|
}
|
||||||
|
auto &headerState = SettingsCache::instance().layouts().getSetsDialogHeaderState();
|
||||||
|
if (!headerState.isEmpty()) {
|
||||||
|
view->header()->restoreState(headerState);
|
||||||
|
view->header()->setSortIndicator(SORT_RESET, Qt::DescendingOrder);
|
||||||
|
} else {
|
||||||
|
view->header()->resizeSections(QHeaderView::ResizeToContents);
|
||||||
|
}
|
||||||
|
connect(view->header(), &QHeaderView::geometriesChanged, this, &WndSets::saveHeaderState);
|
||||||
}
|
}
|
||||||
|
|
||||||
WndSets::~WndSets()
|
WndSets::~WndSets()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WndSets::closeEvent(QCloseEvent * /*ev*/)
|
||||||
|
{
|
||||||
|
SettingsCache::instance().setSetsDialogGeometry(saveGeometry());
|
||||||
|
}
|
||||||
|
|
||||||
|
void WndSets::saveHeaderState()
|
||||||
|
{
|
||||||
|
SettingsCache::instance().layouts().setSetsDialogHeaderState(view->header()->saveState());
|
||||||
|
}
|
||||||
|
|
||||||
void WndSets::rebuildMainLayout(int actionToTake)
|
void WndSets::rebuildMainLayout(int actionToTake)
|
||||||
{
|
{
|
||||||
if (mainLayout == nullptr)
|
if (mainLayout == nullptr)
|
||||||
|
|
|
@ -40,6 +40,8 @@ private:
|
||||||
QHBoxLayout *filterBox;
|
QHBoxLayout *filterBox;
|
||||||
int sortIndex;
|
int sortIndex;
|
||||||
Qt::SortOrder sortOrder;
|
Qt::SortOrder sortOrder;
|
||||||
|
void closeEvent(QCloseEvent *ev) override;
|
||||||
|
void saveHeaderState();
|
||||||
void rebuildMainLayout(int actionToTake);
|
void rebuildMainLayout(int actionToTake);
|
||||||
bool setOrderIsSorted;
|
bool setOrderIsSorted;
|
||||||
enum
|
enum
|
||||||
|
|
|
@ -68,6 +68,16 @@ void LayoutsSettings::setDeckEditorDbHeaderState(const QByteArray &value)
|
||||||
setValue(value, "layouts/deckEditorDbHeader_state");
|
setValue(value, "layouts/deckEditorDbHeader_state");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QByteArray LayoutsSettings::getSetsDialogHeaderState()
|
||||||
|
{
|
||||||
|
return getValue("layouts/setsDialogHeader_state").toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayoutsSettings::setSetsDialogHeaderState(const QByteArray &value)
|
||||||
|
{
|
||||||
|
setValue(value, "layouts/setsDialogHeader_state");
|
||||||
|
}
|
||||||
|
|
||||||
void LayoutsSettings::setGamePlayAreaGeometry(const QByteArray &value)
|
void LayoutsSettings::setGamePlayAreaGeometry(const QByteArray &value)
|
||||||
{
|
{
|
||||||
setValue(value, "layouts/gameplayarea_geometry");
|
setValue(value, "layouts/gameplayarea_geometry");
|
||||||
|
@ -183,4 +193,4 @@ const QSize LayoutsSettings::getReplayReplaySize()
|
||||||
void LayoutsSettings::setReplayReplaySize(const QSize &value)
|
void LayoutsSettings::setReplayReplaySize(const QSize &value)
|
||||||
{
|
{
|
||||||
setValue(value, "layouts/replayplayarea_ReplaySize");
|
setValue(value, "layouts/replayplayarea_ReplaySize");
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ public:
|
||||||
void setDeckEditorDeckSize(const QSize &value);
|
void setDeckEditorDeckSize(const QSize &value);
|
||||||
void setDeckEditorFilterSize(const QSize &value);
|
void setDeckEditorFilterSize(const QSize &value);
|
||||||
void setDeckEditorDbHeaderState(const QByteArray &value);
|
void setDeckEditorDbHeaderState(const QByteArray &value);
|
||||||
|
void setSetsDialogHeaderState(const QByteArray &value);
|
||||||
|
|
||||||
void setGamePlayAreaGeometry(const QByteArray &value);
|
void setGamePlayAreaGeometry(const QByteArray &value);
|
||||||
void setGamePlayAreaState(const QByteArray &value);
|
void setGamePlayAreaState(const QByteArray &value);
|
||||||
|
@ -37,6 +38,7 @@ public:
|
||||||
const QSize getDeckEditorDeckSize();
|
const QSize getDeckEditorDeckSize();
|
||||||
const QSize getDeckEditorFilterSize();
|
const QSize getDeckEditorFilterSize();
|
||||||
const QByteArray getDeckEditorDbHeaderState();
|
const QByteArray getDeckEditorDbHeaderState();
|
||||||
|
const QByteArray getSetsDialogHeaderState();
|
||||||
|
|
||||||
const QByteArray getGamePlayAreaLayoutState();
|
const QByteArray getGamePlayAreaLayoutState();
|
||||||
const QByteArray getGamePlayAreaGeometry();
|
const QByteArray getGamePlayAreaGeometry();
|
||||||
|
|
|
@ -225,6 +225,7 @@ SettingsCache::SettingsCache()
|
||||||
|
|
||||||
mainWindowGeometry = settings->value("interface/main_window_geometry").toByteArray();
|
mainWindowGeometry = settings->value("interface/main_window_geometry").toByteArray();
|
||||||
tokenDialogGeometry = settings->value("interface/token_dialog_geometry").toByteArray();
|
tokenDialogGeometry = settings->value("interface/token_dialog_geometry").toByteArray();
|
||||||
|
setsDialogGeometry = settings->value("interface/sets_dialog_geometry").toByteArray();
|
||||||
notificationsEnabled = settings->value("interface/notificationsenabled", true).toBool();
|
notificationsEnabled = settings->value("interface/notificationsenabled", true).toBool();
|
||||||
spectatorNotificationsEnabled = settings->value("interface/specnotificationsenabled", false).toBool();
|
spectatorNotificationsEnabled = settings->value("interface/specnotificationsenabled", false).toBool();
|
||||||
buddyConnectNotificationsEnabled = settings->value("interface/buddyconnectnotificationsenabled", true).toBool();
|
buddyConnectNotificationsEnabled = settings->value("interface/buddyconnectnotificationsenabled", true).toBool();
|
||||||
|
@ -617,6 +618,12 @@ void SettingsCache::setTokenDialogGeometry(const QByteArray &_tokenDialogGeometr
|
||||||
settings->setValue("interface/token_dialog_geometry", tokenDialogGeometry);
|
settings->setValue("interface/token_dialog_geometry", tokenDialogGeometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsCache::setSetsDialogGeometry(const QByteArray &_setsDialogGeometry)
|
||||||
|
{
|
||||||
|
setsDialogGeometry = _setsDialogGeometry;
|
||||||
|
settings->setValue("interface/sets_dialog_geometry", setsDialogGeometry);
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsCache::setPixmapCacheSize(const int _pixmapCacheSize)
|
void SettingsCache::setPixmapCacheSize(const int _pixmapCacheSize)
|
||||||
{
|
{
|
||||||
pixmapCacheSize = _pixmapCacheSize;
|
pixmapCacheSize = _pixmapCacheSize;
|
||||||
|
|
|
@ -70,6 +70,7 @@ private:
|
||||||
|
|
||||||
QByteArray mainWindowGeometry;
|
QByteArray mainWindowGeometry;
|
||||||
QByteArray tokenDialogGeometry;
|
QByteArray tokenDialogGeometry;
|
||||||
|
QByteArray setsDialogGeometry;
|
||||||
QString lang;
|
QString lang;
|
||||||
QString deckPath, replaysPath, picsPath, customPicsPath, cardDatabasePath, customCardDatabasePath, themesPath,
|
QString deckPath, replaysPath, picsPath, customPicsPath, cardDatabasePath, customCardDatabasePath, themesPath,
|
||||||
spoilerDatabasePath, tokenDatabasePath, themeName;
|
spoilerDatabasePath, tokenDatabasePath, themeName;
|
||||||
|
@ -154,6 +155,10 @@ public:
|
||||||
{
|
{
|
||||||
return tokenDialogGeometry;
|
return tokenDialogGeometry;
|
||||||
}
|
}
|
||||||
|
const QByteArray &getSetsDialogGeometry() const
|
||||||
|
{
|
||||||
|
return setsDialogGeometry;
|
||||||
|
}
|
||||||
QString getLang() const
|
QString getLang() const
|
||||||
{
|
{
|
||||||
return lang;
|
return lang;
|
||||||
|
@ -493,6 +498,7 @@ public slots:
|
||||||
|
|
||||||
void setMainWindowGeometry(const QByteArray &_mainWindowGeometry);
|
void setMainWindowGeometry(const QByteArray &_mainWindowGeometry);
|
||||||
void setTokenDialogGeometry(const QByteArray &_tokenDialog);
|
void setTokenDialogGeometry(const QByteArray &_tokenDialog);
|
||||||
|
void setSetsDialogGeometry(const QByteArray &_setsDialog);
|
||||||
void setLang(const QString &_lang);
|
void setLang(const QString &_lang);
|
||||||
void setShowTipsOnStartup(bool _showTipsOnStartup);
|
void setShowTipsOnStartup(bool _showTipsOnStartup);
|
||||||
void setSeenTips(const QList<int> &_seenTips);
|
void setSeenTips(const QList<int> &_seenTips);
|
||||||
|
|
|
@ -199,6 +199,9 @@ void SettingsCache::setMainWindowGeometry(const QByteArray & /* _mainWindowGeome
|
||||||
void SettingsCache::setTokenDialogGeometry(const QByteArray & /* _tokenDialogGeometry */)
|
void SettingsCache::setTokenDialogGeometry(const QByteArray & /* _tokenDialogGeometry */)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
void SettingsCache::setSetsDialogGeometry(const QByteArray & /* _setsDialogGeometry */)
|
||||||
|
{
|
||||||
|
}
|
||||||
void SettingsCache::setPixmapCacheSize(const int /* _pixmapCacheSize */)
|
void SettingsCache::setPixmapCacheSize(const int /* _pixmapCacheSize */)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,6 +203,9 @@ void SettingsCache::setMainWindowGeometry(const QByteArray & /* _mainWindowGeome
|
||||||
void SettingsCache::setTokenDialogGeometry(const QByteArray & /* _tokenDialogGeometry */)
|
void SettingsCache::setTokenDialogGeometry(const QByteArray & /* _tokenDialogGeometry */)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
void SettingsCache::setSetsDialogGeometry(const QByteArray & /* _setsDialogGeometry */)
|
||||||
|
{
|
||||||
|
}
|
||||||
void SettingsCache::setPixmapCacheSize(const int /* _pixmapCacheSize */)
|
void SettingsCache::setPixmapCacheSize(const int /* _pixmapCacheSize */)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue