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()
|
void ExternalResourcesPage::openedImpl()
|
||||||
{
|
{
|
||||||
m_model->startWatching();
|
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()
|
void ExternalResourcesPage::closedImpl()
|
||||||
{
|
{
|
||||||
m_model->stopWatching();
|
m_model->stopWatching();
|
||||||
|
|
||||||
|
m_wide_bar_setting->set(ui->actionsToolbar->getVisibilityState());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExternalResourcesPage::retranslate()
|
void ExternalResourcesPage::retranslate()
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
#include "settings/Setting.h"
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
#include "ui/pages/BasePage.h"
|
#include "ui/pages/BasePage.h"
|
||||||
|
|
||||||
@ -71,4 +72,6 @@ class ExternalResourcesPage : public QMainWindow, public BasePage {
|
|||||||
QString m_viewFilter;
|
QString m_viewFilter;
|
||||||
|
|
||||||
bool m_controlsEnabled = true;
|
bool m_controlsEnabled = true;
|
||||||
|
|
||||||
|
std::shared_ptr<Setting> m_wide_bar_setting = nullptr;
|
||||||
};
|
};
|
||||||
|
@ -537,6 +537,19 @@ void ScreenshotsPage::openedImpl()
|
|||||||
ui->listView->setModel(nullptr);
|
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"
|
#include "ScreenshotsPage.moc"
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
#include "ui/pages/BasePage.h"
|
#include "ui/pages/BasePage.h"
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
|
|
||||||
|
#include "settings/Setting.h"
|
||||||
|
|
||||||
class QFileSystemModel;
|
class QFileSystemModel;
|
||||||
class QIdentityProxyModel;
|
class QIdentityProxyModel;
|
||||||
namespace Ui
|
namespace Ui
|
||||||
@ -59,7 +61,8 @@ public:
|
|||||||
explicit ScreenshotsPage(QString path, QWidget *parent = 0);
|
explicit ScreenshotsPage(QString path, QWidget *parent = 0);
|
||||||
virtual ~ScreenshotsPage();
|
virtual ~ScreenshotsPage();
|
||||||
|
|
||||||
virtual void openedImpl() override;
|
void openedImpl() override;
|
||||||
|
void closedImpl() override;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -110,4 +113,6 @@ private:
|
|||||||
QString m_folder;
|
QString m_folder;
|
||||||
bool m_valid = false;
|
bool m_valid = false;
|
||||||
bool m_uploadActive = false;
|
bool m_uploadActive = false;
|
||||||
|
|
||||||
|
std::shared_ptr<Setting> m_wide_bar_setting = nullptr;
|
||||||
};
|
};
|
||||||
|
@ -765,11 +765,21 @@ void ServersPage::updateState()
|
|||||||
void ServersPage::openedImpl()
|
void ServersPage::openedImpl()
|
||||||
{
|
{
|
||||||
m_model->observe();
|
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()
|
void ServersPage::closedImpl()
|
||||||
{
|
{
|
||||||
m_model->unobserve();
|
m_model->unobserve();
|
||||||
|
|
||||||
|
m_wide_bar_setting->set(ui->toolBar->getVisibilityState());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServersPage::on_actionAdd_triggered()
|
void ServersPage::on_actionAdd_triggered()
|
||||||
|
@ -42,6 +42,8 @@
|
|||||||
#include "ui/pages/BasePage.h"
|
#include "ui/pages/BasePage.h"
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
|
|
||||||
|
#include "settings/Setting.h"
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
class ServersPage;
|
class ServersPage;
|
||||||
@ -112,5 +114,7 @@ private: // data
|
|||||||
Ui::ServersPage *ui = nullptr;
|
Ui::ServersPage *ui = nullptr;
|
||||||
ServersModel * m_model = nullptr;
|
ServersModel * m_model = nullptr;
|
||||||
InstancePtr m_inst = nullptr;
|
InstancePtr m_inst = nullptr;
|
||||||
|
|
||||||
|
std::shared_ptr<Setting> m_wide_bar_setting = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -125,6 +125,21 @@ void VersionPage::retranslate()
|
|||||||
ui->retranslateUi(this);
|
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 * VersionPage::createPopupMenu()
|
||||||
{
|
{
|
||||||
QMenu* filteredMenu = QMainWindow::createPopupMenu();
|
QMenu* filteredMenu = QMainWindow::createPopupMenu();
|
||||||
|
@ -69,6 +69,9 @@ public:
|
|||||||
virtual bool shouldDisplay() const override;
|
virtual bool shouldDisplay() const override;
|
||||||
void retranslate() override;
|
void retranslate() override;
|
||||||
|
|
||||||
|
void openedImpl() override;
|
||||||
|
void closedImpl() override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_actionChange_version_triggered();
|
void on_actionChange_version_triggered();
|
||||||
void on_actionInstall_Forge_triggered();
|
void on_actionInstall_Forge_triggered();
|
||||||
@ -114,6 +117,8 @@ private:
|
|||||||
int currentIdx = 0;
|
int currentIdx = 0;
|
||||||
bool controlsEnabled = false;
|
bool controlsEnabled = false;
|
||||||
|
|
||||||
|
std::shared_ptr<Setting> m_wide_bar_setting = nullptr;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void versionCurrent(const QModelIndex ¤t, const QModelIndex &previous);
|
void versionCurrent(const QModelIndex ¤t, const QModelIndex &previous);
|
||||||
|
|
||||||
|
@ -113,11 +113,21 @@ WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worl
|
|||||||
void WorldListPage::openedImpl()
|
void WorldListPage::openedImpl()
|
||||||
{
|
{
|
||||||
m_worlds->startWatching();
|
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()
|
void WorldListPage::closedImpl()
|
||||||
{
|
{
|
||||||
m_worlds->stopWatching();
|
m_worlds->stopWatching();
|
||||||
|
|
||||||
|
m_wide_bar_setting->set(ui->toolBar->getVisibilityState());
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldListPage::~WorldListPage()
|
WorldListPage::~WorldListPage()
|
||||||
|
@ -42,6 +42,8 @@
|
|||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <LoggedProcess.h>
|
#include <LoggedProcess.h>
|
||||||
|
|
||||||
|
#include "settings/Setting.h"
|
||||||
|
|
||||||
class WorldList;
|
class WorldList;
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
@ -102,6 +104,8 @@ private:
|
|||||||
unique_qobject_ptr<LoggedProcess> m_mceditProcess;
|
unique_qobject_ptr<LoggedProcess> m_mceditProcess;
|
||||||
bool m_mceditStarting = false;
|
bool m_mceditStarting = false;
|
||||||
|
|
||||||
|
std::shared_ptr<Setting> m_wide_bar_setting = nullptr;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_actionCopy_Seed_triggered();
|
void on_actionCopy_Seed_triggered();
|
||||||
void on_actionMCEdit_triggered();
|
void on_actionMCEdit_triggered();
|
||||||
|
Loading…
Reference in New Issue
Block a user