feat(InstancePages): save/load wide bar visibility settings
Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
parent
479843f56b
commit
2d69d63efe
@ -70,11 +70,21 @@ void ExternalResourcesPage::ShowContextMenu(const QPoint& pos)
|
||||
void ExternalResourcesPage::openedImpl()
|
||||
{
|
||||
m_model->startWatching();
|
||||
|
||||
auto const setting_name = QString("WideBarVisibility_%1").arg(id());
|
||||
if (!APPLICATION->settings()->contains(setting_name))
|
||||
m_wide_bar_setting = APPLICATION->settings()->registerSetting(setting_name);
|
||||
else
|
||||
m_wide_bar_setting = APPLICATION->settings()->getSetting(setting_name);
|
||||
|
||||
ui->actionsToolbar->setVisibilityState(m_wide_bar_setting->get().toByteArray());
|
||||
}
|
||||
|
||||
void ExternalResourcesPage::closedImpl()
|
||||
{
|
||||
m_model->stopWatching();
|
||||
|
||||
m_wide_bar_setting->set(ui->actionsToolbar->getVisibilityState());
|
||||
}
|
||||
|
||||
void ExternalResourcesPage::retranslate()
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
#include "Application.h"
|
||||
#include "settings/Setting.h"
|
||||
#include "minecraft/MinecraftInstance.h"
|
||||
#include "ui/pages/BasePage.h"
|
||||
|
||||
@ -71,4 +72,6 @@ class ExternalResourcesPage : public QMainWindow, public BasePage {
|
||||
QString m_viewFilter;
|
||||
|
||||
bool m_controlsEnabled = true;
|
||||
|
||||
std::shared_ptr<Setting> m_wide_bar_setting = nullptr;
|
||||
};
|
||||
|
@ -537,6 +537,19 @@ void ScreenshotsPage::openedImpl()
|
||||
ui->listView->setModel(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
auto const setting_name = QString("WideBarVisibility_%1").arg(id());
|
||||
if (!APPLICATION->settings()->contains(setting_name))
|
||||
m_wide_bar_setting = APPLICATION->settings()->registerSetting(setting_name);
|
||||
else
|
||||
m_wide_bar_setting = APPLICATION->settings()->getSetting(setting_name);
|
||||
|
||||
ui->toolBar->setVisibilityState(m_wide_bar_setting->get().toByteArray());
|
||||
}
|
||||
|
||||
void ScreenshotsPage::closedImpl()
|
||||
{
|
||||
m_wide_bar_setting->set(ui->toolBar->getVisibilityState());
|
||||
}
|
||||
|
||||
#include "ScreenshotsPage.moc"
|
||||
|
@ -40,6 +40,8 @@
|
||||
#include "ui/pages/BasePage.h"
|
||||
#include <Application.h>
|
||||
|
||||
#include "settings/Setting.h"
|
||||
|
||||
class QFileSystemModel;
|
||||
class QIdentityProxyModel;
|
||||
namespace Ui
|
||||
@ -59,7 +61,8 @@ public:
|
||||
explicit ScreenshotsPage(QString path, QWidget *parent = 0);
|
||||
virtual ~ScreenshotsPage();
|
||||
|
||||
virtual void openedImpl() override;
|
||||
void openedImpl() override;
|
||||
void closedImpl() override;
|
||||
|
||||
enum
|
||||
{
|
||||
@ -110,4 +113,6 @@ private:
|
||||
QString m_folder;
|
||||
bool m_valid = false;
|
||||
bool m_uploadActive = false;
|
||||
|
||||
std::shared_ptr<Setting> m_wide_bar_setting = nullptr;
|
||||
};
|
||||
|
@ -765,11 +765,21 @@ void ServersPage::updateState()
|
||||
void ServersPage::openedImpl()
|
||||
{
|
||||
m_model->observe();
|
||||
|
||||
auto const setting_name = QString("WideBarVisibility_%1").arg(id());
|
||||
if (!APPLICATION->settings()->contains(setting_name))
|
||||
m_wide_bar_setting = APPLICATION->settings()->registerSetting(setting_name);
|
||||
else
|
||||
m_wide_bar_setting = APPLICATION->settings()->getSetting(setting_name);
|
||||
|
||||
ui->toolBar->setVisibilityState(m_wide_bar_setting->get().toByteArray());
|
||||
}
|
||||
|
||||
void ServersPage::closedImpl()
|
||||
{
|
||||
m_model->unobserve();
|
||||
|
||||
m_wide_bar_setting->set(ui->toolBar->getVisibilityState());
|
||||
}
|
||||
|
||||
void ServersPage::on_actionAdd_triggered()
|
||||
|
@ -42,6 +42,8 @@
|
||||
#include "ui/pages/BasePage.h"
|
||||
#include <Application.h>
|
||||
|
||||
#include "settings/Setting.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ServersPage;
|
||||
@ -112,5 +114,7 @@ private: // data
|
||||
Ui::ServersPage *ui = nullptr;
|
||||
ServersModel * m_model = nullptr;
|
||||
InstancePtr m_inst = nullptr;
|
||||
|
||||
std::shared_ptr<Setting> m_wide_bar_setting = nullptr;
|
||||
};
|
||||
|
||||
|
@ -125,6 +125,21 @@ void VersionPage::retranslate()
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
|
||||
void VersionPage::openedImpl()
|
||||
{
|
||||
auto const setting_name = QString("WideBarVisibility_%1").arg(id());
|
||||
if (!APPLICATION->settings()->contains(setting_name))
|
||||
m_wide_bar_setting = APPLICATION->settings()->registerSetting(setting_name);
|
||||
else
|
||||
m_wide_bar_setting = APPLICATION->settings()->getSetting(setting_name);
|
||||
|
||||
ui->toolBar->setVisibilityState(m_wide_bar_setting->get().toByteArray());
|
||||
}
|
||||
void VersionPage::closedImpl()
|
||||
{
|
||||
m_wide_bar_setting->set(ui->toolBar->getVisibilityState());
|
||||
}
|
||||
|
||||
QMenu * VersionPage::createPopupMenu()
|
||||
{
|
||||
QMenu* filteredMenu = QMainWindow::createPopupMenu();
|
||||
|
@ -69,6 +69,9 @@ public:
|
||||
virtual bool shouldDisplay() const override;
|
||||
void retranslate() override;
|
||||
|
||||
void openedImpl() override;
|
||||
void closedImpl() override;
|
||||
|
||||
private slots:
|
||||
void on_actionChange_version_triggered();
|
||||
void on_actionInstall_Forge_triggered();
|
||||
@ -114,6 +117,8 @@ private:
|
||||
int currentIdx = 0;
|
||||
bool controlsEnabled = false;
|
||||
|
||||
std::shared_ptr<Setting> m_wide_bar_setting = nullptr;
|
||||
|
||||
public slots:
|
||||
void versionCurrent(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
|
||||
|
@ -113,11 +113,21 @@ WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worl
|
||||
void WorldListPage::openedImpl()
|
||||
{
|
||||
m_worlds->startWatching();
|
||||
|
||||
auto const setting_name = QString("WideBarVisibility_%1").arg(id());
|
||||
if (!APPLICATION->settings()->contains(setting_name))
|
||||
m_wide_bar_setting = APPLICATION->settings()->registerSetting(setting_name);
|
||||
else
|
||||
m_wide_bar_setting = APPLICATION->settings()->getSetting(setting_name);
|
||||
|
||||
ui->toolBar->setVisibilityState(m_wide_bar_setting->get().toByteArray());
|
||||
}
|
||||
|
||||
void WorldListPage::closedImpl()
|
||||
{
|
||||
m_worlds->stopWatching();
|
||||
|
||||
m_wide_bar_setting->set(ui->toolBar->getVisibilityState());
|
||||
}
|
||||
|
||||
WorldListPage::~WorldListPage()
|
||||
|
@ -42,6 +42,8 @@
|
||||
#include <Application.h>
|
||||
#include <LoggedProcess.h>
|
||||
|
||||
#include "settings/Setting.h"
|
||||
|
||||
class WorldList;
|
||||
namespace Ui
|
||||
{
|
||||
@ -102,6 +104,8 @@ private:
|
||||
unique_qobject_ptr<LoggedProcess> m_mceditProcess;
|
||||
bool m_mceditStarting = false;
|
||||
|
||||
std::shared_ptr<Setting> m_wide_bar_setting = nullptr;
|
||||
|
||||
private slots:
|
||||
void on_actionCopy_Seed_triggered();
|
||||
void on_actionMCEdit_triggered();
|
||||
|
Loading…
Reference in New Issue
Block a user