Trophy: Save dialog state (#3729)

* Trophy: Save dialog state and add show type settings

* SaveDataManager: Save Dialog State

* SaveDataList: Minor Optimization

* Qt: Save icon size on mouseevent resizes

it's a bit slower than using the slider because it saves every single resize. But better than not saving at all for now

* SaveData: Optimize saving to settings a bit

No Saving needed there

* Qt: get rid of all-uppercase enums and namespaces

* Qt/Linux: adjust remaining DX12 tooltip

* Qt: prevent dockwidget contextmenu
This commit is contained in:
Megamouse 2017-11-22 12:11:59 +01:00 committed by Ivan
parent de465cb941
commit fb52cbb8b2
24 changed files with 607 additions and 436 deletions

View file

@ -10,20 +10,20 @@
#include <QBitmap>
#include <QLabel>
struct GUI_SAVE
struct gui_save
{
QString key;
QString name;
QVariant def;
GUI_SAVE()
gui_save()
{
key = "";
name = "";
def = QVariant();
};
GUI_SAVE(const QString& k, const QString& n, const QVariant& d)
gui_save(const QString& k, const QString& n, const QVariant& d)
{
key = k;
name = n;
@ -37,24 +37,24 @@ typedef QPair<QString, QSize> q_size_pair;
typedef QList<q_string_pair> q_pair_list;
typedef QList<q_size_pair> q_size_list;
namespace GUI
namespace gui
{
static QString stylesheet;
enum game_list_columns
{
COLUMN_ICON,
COLUMN_NAME,
COLUMN_SERIAL,
COLUMN_FIRMWARE,
COLUMN_VERSION,
COLUMN_CATEGORY,
COLUMN_PATH,
COLUMN_RESOLUTION,
COLUMN_SOUND,
COLUMN_PARENTAL,
column_icon,
column_name,
column_serial,
column_firmware,
column_version,
column_category,
column_path,
column_resolution,
column_sound,
column_parental,
COLUMN_COUNT
column_count
};
const QSize gl_icon_size_min = QSize(40, 22);
@ -107,6 +107,8 @@ namespace GUI
const QString meta = "Meta";
const QString fs = "FileSystem";
const QString gs_frame = "GSFrame";
const QString trophy = "Trophy";
const QString savedata = "SaveData";
const QColor gl_icon_color = QColor(209, 209, 209, 255);
const QColor gl_tool_icon_color = QColor( 0, 100, 231, 255);
@ -114,71 +116,83 @@ namespace GUI
const QColor mw_tool_bar_color = QColor(227, 227, 227, 255);
const QColor mw_thumb_icon_color = QColor( 0, 100, 231, 255);
const GUI_SAVE rg_freeze = GUI_SAVE( main_window, "recentGamesFrozen", false);
const GUI_SAVE rg_entries = GUI_SAVE( main_window, "recentGamesNames", QVariant::fromValue(q_pair_list()));
const gui_save rg_freeze = gui_save(main_window, "recentGamesFrozen", false);
const gui_save rg_entries = gui_save(main_window, "recentGamesNames", QVariant::fromValue(q_pair_list()));
const GUI_SAVE ib_pkg_success = GUI_SAVE( main_window, "infoBoxEnabledInstallPKG", true );
const GUI_SAVE ib_pup_success = GUI_SAVE( main_window, "infoBoxEnabledInstallPUP", true );
const GUI_SAVE ib_show_welcome = GUI_SAVE( main_window, "infoBoxEnabledWelcome", true );
const gui_save ib_pkg_success = gui_save(main_window, "infoBoxEnabledInstallPKG", true );
const gui_save ib_pup_success = gui_save(main_window, "infoBoxEnabledInstallPUP", true );
const gui_save ib_show_welcome = gui_save(main_window, "infoBoxEnabledWelcome", true );
const GUI_SAVE fd_install_pkg = GUI_SAVE( main_window, "lastExplorePathPKG", "" );
const GUI_SAVE fd_install_pup = GUI_SAVE( main_window, "lastExplorePathPUP", "" );
const GUI_SAVE fd_boot_elf = GUI_SAVE( main_window, "lastExplorePathELF", "" );
const GUI_SAVE fd_boot_game = GUI_SAVE( main_window, "lastExplorePathGAME", "" );
const GUI_SAVE fd_decrypt_sprx = GUI_SAVE( main_window, "lastExplorePathSPRX", "" );
const GUI_SAVE fd_cg_disasm = GUI_SAVE( main_window, "lastExplorePathCGD", "" );
const gui_save fd_install_pkg = gui_save(main_window, "lastExplorePathPKG", "" );
const gui_save fd_install_pup = gui_save(main_window, "lastExplorePathPUP", "" );
const gui_save fd_boot_elf = gui_save(main_window, "lastExplorePathELF", "" );
const gui_save fd_boot_game = gui_save(main_window, "lastExplorePathGAME", "" );
const gui_save fd_decrypt_sprx = gui_save(main_window, "lastExplorePathSPRX", "" );
const gui_save fd_cg_disasm = gui_save(main_window, "lastExplorePathCGD", "" );
const GUI_SAVE mw_debugger = GUI_SAVE( main_window, "debuggerVisible", false );
const GUI_SAVE mw_logger = GUI_SAVE( main_window, "loggerVisible", true );
const GUI_SAVE mw_gamelist = GUI_SAVE( main_window, "gamelistVisible", true );
const GUI_SAVE mw_toolBarVisible = GUI_SAVE( main_window, "toolBarVisible", true );
const GUI_SAVE mw_toolBarColor = GUI_SAVE( main_window, "toolBarColor", mw_tool_bar_color);
const GUI_SAVE mw_toolIconColor = GUI_SAVE( main_window, "toolIconColor", mw_tool_icon_color);
const GUI_SAVE mw_geometry = GUI_SAVE( main_window, "geometry", QByteArray() );
const GUI_SAVE mw_windowState = GUI_SAVE( main_window, "windowState", QByteArray() );
const GUI_SAVE mw_mwState = GUI_SAVE( main_window, "wwState", QByteArray() );
const gui_save mw_debugger = gui_save(main_window, "debuggerVisible", false );
const gui_save mw_logger = gui_save(main_window, "loggerVisible", true );
const gui_save mw_gamelist = gui_save(main_window, "gamelistVisible", true );
const gui_save mw_toolBarVisible = gui_save(main_window, "toolBarVisible", true );
const gui_save mw_toolBarColor = gui_save(main_window, "toolBarColor", mw_tool_bar_color);
const gui_save mw_toolIconColor = gui_save(main_window, "toolIconColor", mw_tool_icon_color);
const gui_save mw_geometry = gui_save(main_window, "geometry", QByteArray() );
const gui_save mw_windowState = gui_save(main_window, "windowState", QByteArray() );
const gui_save mw_mwState = gui_save(main_window, "wwState", QByteArray() );
const GUI_SAVE cat_hdd_game = GUI_SAVE( game_list, "categoryVisibleHDDGame", true );
const GUI_SAVE cat_disc_game = GUI_SAVE( game_list, "categoryVisibleDiscGame", true );
const GUI_SAVE cat_home = GUI_SAVE( game_list, "categoryVisibleHome", true );
const GUI_SAVE cat_audio_video = GUI_SAVE( game_list, "categoryVisibleAudioVideo", true );
const GUI_SAVE cat_game_data = GUI_SAVE( game_list, "categoryVisibleGameData", false );
const GUI_SAVE cat_unknown = GUI_SAVE( game_list, "categoryVisibleUnknown", true );
const GUI_SAVE cat_other = GUI_SAVE( game_list, "categoryVisibleOther", true );
const gui_save cat_hdd_game = gui_save(game_list, "categoryVisibleHDDGame", true );
const gui_save cat_disc_game = gui_save(game_list, "categoryVisibleDiscGame", true );
const gui_save cat_home = gui_save(game_list, "categoryVisibleHome", true );
const gui_save cat_audio_video = gui_save(game_list, "categoryVisibleAudioVideo", true );
const gui_save cat_game_data = gui_save(game_list, "categoryVisibleGameData", false );
const gui_save cat_unknown = gui_save(game_list, "categoryVisibleUnknown", true );
const gui_save cat_other = gui_save(game_list, "categoryVisibleOther", true );
const GUI_SAVE gl_sortAsc = GUI_SAVE( game_list, "sortAsc", true );
const GUI_SAVE gl_sortCol = GUI_SAVE( game_list, "sortCol", 1 );
const GUI_SAVE gl_state = GUI_SAVE( game_list, "state", QByteArray() );
const GUI_SAVE gl_iconSize = GUI_SAVE( game_list, "iconSize", get_Index(gl_icon_size_small));
const GUI_SAVE gl_iconColor = GUI_SAVE( game_list, "iconColor", gl_icon_color);
const GUI_SAVE gl_listMode = GUI_SAVE( game_list, "listMode", true );
const GUI_SAVE gl_textFactor = GUI_SAVE( game_list, "textFactor", (qreal) 2.0 );
const GUI_SAVE gl_marginFactor = GUI_SAVE( game_list, "marginFactor", (qreal) 0.09 );
const GUI_SAVE gl_toolBarVisible = GUI_SAVE( game_list, "toolBarVisible", false);
const GUI_SAVE gl_toolIconColor = GUI_SAVE( game_list, "toolIconColor", gl_tool_icon_color);
const gui_save gl_sortAsc = gui_save(game_list, "sortAsc", true );
const gui_save gl_sortCol = gui_save(game_list, "sortCol", 1 );
const gui_save gl_state = gui_save(game_list, "state", QByteArray() );
const gui_save gl_iconSize = gui_save(game_list, "iconSize", get_Index(gl_icon_size_small));
const gui_save gl_iconColor = gui_save(game_list, "iconColor", gl_icon_color);
const gui_save gl_listMode = gui_save(game_list, "listMode", true );
const gui_save gl_textFactor = gui_save(game_list, "textFactor", (qreal) 2.0 );
const gui_save gl_marginFactor = gui_save(game_list, "marginFactor", (qreal) 0.09 );
const gui_save gl_toolBarVisible = gui_save(game_list, "toolBarVisible", false);
const gui_save gl_toolIconColor = gui_save(game_list, "toolIconColor", gl_tool_icon_color);
const GUI_SAVE fs_emulator_dir_list = GUI_SAVE( fs, "emulator_dir_list", QStringList());
const GUI_SAVE fs_dev_hdd0_list = GUI_SAVE( fs, "dev_hdd0_list", QStringList());
const GUI_SAVE fs_dev_hdd1_list = GUI_SAVE( fs, "dev_hdd1_list", QStringList());
const GUI_SAVE fs_dev_flash_list = GUI_SAVE( fs, "dev_flash_list", QStringList());
const GUI_SAVE fs_dev_usb000_list = GUI_SAVE( fs, "dev_usb000_list", QStringList());
const gui_save fs_emulator_dir_list = gui_save(fs, "emulator_dir_list", QStringList());
const gui_save fs_dev_hdd0_list = gui_save(fs, "dev_hdd0_list", QStringList());
const gui_save fs_dev_hdd1_list = gui_save(fs, "dev_hdd1_list", QStringList());
const gui_save fs_dev_flash_list = gui_save(fs, "dev_flash_list", QStringList());
const gui_save fs_dev_usb000_list = gui_save(fs, "dev_usb000_list", QStringList());
const GUI_SAVE l_tty = GUI_SAVE( logger, "TTY", true );
const GUI_SAVE l_level = GUI_SAVE( logger, "level", (uint)(logs::level::success) );
const GUI_SAVE l_stack = GUI_SAVE( logger, "stack", false );
const gui_save l_tty = gui_save(logger, "TTY", true );
const gui_save l_level = gui_save(logger, "level", (uint)(logs::level::success) );
const gui_save l_stack = gui_save(logger, "stack", false );
const GUI_SAVE d_splitterState = GUI_SAVE( debugger, "splitterState", QByteArray());
const gui_save d_splitterState = gui_save(debugger, "splitterState", QByteArray());
const GUI_SAVE m_currentConfig = GUI_SAVE( meta, "currentConfig", QObject::tr("CurrentSettings"));
const GUI_SAVE m_currentStylesheet = GUI_SAVE( meta, "currentStylesheet", Default);
const GUI_SAVE m_saveNotes = GUI_SAVE( meta, "saveNotes", QVariantMap());
const GUI_SAVE m_showDebugTab = GUI_SAVE( meta, "showDebugTab", false);
const GUI_SAVE m_enableUIColors = GUI_SAVE( meta, "enableUIColors", false);
const gui_save m_currentConfig = gui_save(meta, "currentConfig", QObject::tr("CurrentSettings"));
const gui_save m_currentStylesheet = gui_save(meta, "currentStylesheet", Default);
const gui_save m_saveNotes = gui_save(meta, "saveNotes", QVariantMap());
const gui_save m_showDebugTab = gui_save(meta, "showDebugTab", false);
const gui_save m_enableUIColors = gui_save(meta, "enableUIColors", false);
const GUI_SAVE gs_disableMouse = GUI_SAVE( gs_frame, "disableMouse", false);
const GUI_SAVE gs_resize = GUI_SAVE( gs_frame, "resize", false);
const GUI_SAVE gs_width = GUI_SAVE( gs_frame, "width", 1280);
const GUI_SAVE gs_height = GUI_SAVE( gs_frame, "height", 720);
const gui_save gs_disableMouse = gui_save(gs_frame, "disableMouse", false);
const gui_save gs_resize = gui_save(gs_frame, "resize", false);
const gui_save gs_width = gui_save(gs_frame, "width", 1280);
const gui_save gs_height = gui_save(gs_frame, "height", 720);
const gui_save tr_icon_height = gui_save(trophy, "icon_height", 75);
const gui_save tr_show_locked = gui_save(trophy, "show_locked", true);
const gui_save tr_show_unlocked = gui_save(trophy, "show_unlocked", true);
const gui_save tr_show_hidden = gui_save(trophy, "show_hidden", false);
const gui_save tr_show_bronze = gui_save(trophy, "show_bronze", true);
const gui_save tr_show_silver = gui_save(trophy, "show_silver", true);
const gui_save tr_show_gold = gui_save(trophy, "show_gold", true);
const gui_save tr_show_platinum = gui_save(trophy, "show_platinum", true);
const gui_save tr_geometry = gui_save(trophy, "geometry", QByteArray());
const gui_save sd_geometry = gui_save(savedata, "geometry", QByteArray());
}
/** Class for GUI settings..
@ -197,11 +211,11 @@ public:
void ChangeToConfig(const QString& destination);
bool GetCategoryVisibility(int cat);
QVariant GetValue(const GUI_SAVE& entry);
QVariant GetValue(const gui_save& entry);
QVariant List2Var(const q_pair_list& list);
q_pair_list Var2List(const QVariant &var);
void ShowInfoBox(const GUI_SAVE& entry, const QString& title, const QString& text, QWidget* parent = 0);
void ShowInfoBox(const gui_save& entry, const QString& title, const QString& text, QWidget* parent = 0);
logs::level GetLogLevel();
bool GetGamelistColVisibility(int col);
@ -226,7 +240,7 @@ public Q_SLOTS:
void Reset(bool removeMeta = false);
/** Write value to entry */
void SetValue(const GUI_SAVE& entry, const QVariant& value);
void SetValue(const gui_save& entry, const QVariant& value);
/** Sets the visibility of the chosen category. */
void SetCategoryVisibility(int cat, const bool& val);