feat: save instance view state
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
d9b265d7ac
commit
319b816d79
@ -617,6 +617,8 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
m_settings->registerSetting("MainWindowState", "");
|
m_settings->registerSetting("MainWindowState", "");
|
||||||
m_settings->registerSetting("MainWindowGeometry", "");
|
m_settings->registerSetting("MainWindowGeometry", "");
|
||||||
|
|
||||||
|
m_settings->registerSetting("InstanceViewTableHeaderState", "");
|
||||||
|
|
||||||
m_settings->registerSetting("ConsoleWindowState", "");
|
m_settings->registerSetting("ConsoleWindowState", "");
|
||||||
m_settings->registerSetting("ConsoleWindowGeometry", "");
|
m_settings->registerSetting("ConsoleWindowGeometry", "");
|
||||||
|
|
||||||
|
@ -1910,6 +1910,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||||||
// Save the window state and geometry.
|
// Save the window state and geometry.
|
||||||
APPLICATION->settings()->set("MainWindowState", saveState().toBase64());
|
APPLICATION->settings()->set("MainWindowState", saveState().toBase64());
|
||||||
APPLICATION->settings()->set("MainWindowGeometry", saveGeometry().toBase64());
|
APPLICATION->settings()->set("MainWindowGeometry", saveGeometry().toBase64());
|
||||||
|
view->storeState();
|
||||||
event->accept();
|
event->accept();
|
||||||
emit isClosing();
|
emit isClosing();
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
* or later.
|
* or later.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
#include "InstanceView.h"
|
#include "InstanceView.h"
|
||||||
#include <qabstractitemmodel.h>
|
|
||||||
|
|
||||||
#include "InstanceList.h"
|
#include "InstanceList.h"
|
||||||
#include "ui/instanceview/InstanceProxyModel.h"
|
#include "ui/instanceview/InstanceProxyModel.h"
|
||||||
@ -39,6 +39,10 @@ InstanceView::InstanceView(QWidget *parent, InstanceList *instances) : QStackedW
|
|||||||
setCurrentWidget(m_table);
|
setCurrentWidget(m_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstanceView::storeState() {
|
||||||
|
APPLICATION->settings()->set("InstanceViewTableHeaderState", m_table->horizontalHeader()->saveState().toBase64());
|
||||||
|
}
|
||||||
|
|
||||||
void InstanceView::prepareModel() {
|
void InstanceView::prepareModel() {
|
||||||
m_proxy = new InstanceProxyModel(this);
|
m_proxy = new InstanceProxyModel(this);
|
||||||
m_proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
|
m_proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||||
@ -68,6 +72,8 @@ void InstanceView::createTable() {
|
|||||||
m_table->verticalHeader()->hide();
|
m_table->verticalHeader()->hide();
|
||||||
|
|
||||||
QHeaderView *header = m_table->horizontalHeader();
|
QHeaderView *header = m_table->horizontalHeader();
|
||||||
|
header->restoreState(QByteArray::fromBase64(APPLICATION->settings()->get("InstanceViewTableHeaderState").toByteArray()));
|
||||||
|
|
||||||
header->setSectionsMovable(true);
|
header->setSectionsMovable(true);
|
||||||
header->setSectionResizeMode(InstanceList::Icon, QHeaderView::Fixed);
|
header->setSectionResizeMode(InstanceList::Icon, QHeaderView::Fixed);
|
||||||
header->setSectionResizeMode(InstanceList::Name, QHeaderView::Stretch);
|
header->setSectionResizeMode(InstanceList::Name, QHeaderView::Stretch);
|
||||||
@ -77,6 +83,9 @@ void InstanceView::createTable() {
|
|||||||
m_table->setColumnWidth(InstanceList::Icon, m_rowHeight + 3 + 3); // padding left and right
|
m_table->setColumnWidth(InstanceList::Icon, m_rowHeight + 3 + 3); // padding left and right
|
||||||
m_table->verticalHeader()->setDefaultSectionSize(m_rowHeight + 1 + 1); // padding top and bottom
|
m_table->verticalHeader()->setDefaultSectionSize(m_rowHeight + 1 + 1); // padding top and bottom
|
||||||
|
|
||||||
|
if (!APPLICATION->settings()->contains("InstanceViewTableHeaderState"))
|
||||||
|
m_table->sortByColumn(InstanceList::LastPlayed, Qt::AscendingOrder);
|
||||||
|
|
||||||
connect(m_table, &QTableView::doubleClicked, this, &InstanceView::activateInstance);
|
connect(m_table, &QTableView::doubleClicked, this, &InstanceView::activateInstance);
|
||||||
connect(m_table->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &InstanceView::currentRowChanged);
|
connect(m_table->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &InstanceView::currentRowChanged);
|
||||||
connect(m_table->selectionModel(), &QItemSelectionModel::currentColumnChanged, this, &InstanceView::selectNameColumn);
|
connect(m_table->selectionModel(), &QItemSelectionModel::currentColumnChanged, this, &InstanceView::selectNameColumn);
|
||||||
|
@ -27,7 +27,7 @@ class InstanceProxyModel;
|
|||||||
class InstanceList;
|
class InstanceList;
|
||||||
|
|
||||||
class InstanceView : public QStackedWidget {
|
class InstanceView : public QStackedWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit InstanceView(QWidget *parent = nullptr, InstanceList* instances = nullptr);
|
explicit InstanceView(QWidget *parent = nullptr, InstanceList* instances = nullptr);
|
||||||
@ -38,6 +38,9 @@ public:
|
|||||||
|
|
||||||
InstancePtr currentInstance();
|
InstancePtr currentInstance();
|
||||||
|
|
||||||
|
// save state of current view
|
||||||
|
void storeState();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void instanceActivated(InstancePtr inst);
|
void instanceActivated(InstancePtr inst);
|
||||||
void currentInstanceChanged(InstancePtr current, InstancePtr previous);
|
void currentInstanceChanged(InstancePtr current, InstancePtr previous);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user