qt: Save button label setting

This commit is contained in:
rainmakerv2 2025-06-04 19:14:48 +08:00
parent 23710f397e
commit 70673102fa
4 changed files with 8 additions and 15 deletions

View File

@ -180,10 +180,6 @@ bool getShowLabelsUnderIcons() {
return showLabelsUnderIcons; return showLabelsUnderIcons;
} }
bool setShowLabelsUnderIcons() {
return false;
}
std::string getFullscreenMode() { std::string getFullscreenMode() {
return fullscreenMode; return fullscreenMode;
} }
@ -431,7 +427,8 @@ void setVblankDiv(u32 value) {
void setIsFullscreen(bool enable) { void setIsFullscreen(bool enable) {
isFullscreen = enable; isFullscreen = enable;
} }
static void setShowLabelsUnderIcons(bool enable) {
void setShowLabelsUnderIcons(bool enable) {
showLabelsUnderIcons = enable; showLabelsUnderIcons = enable;
} }
@ -882,6 +879,7 @@ void load(const std::filesystem::path& path) {
emulator_language = toml::find_or<std::string>(gui, "emulatorLanguage", "en_US"); emulator_language = toml::find_or<std::string>(gui, "emulatorLanguage", "en_US");
backgroundImageOpacity = toml::find_or<int>(gui, "backgroundImageOpacity", 50); backgroundImageOpacity = toml::find_or<int>(gui, "backgroundImageOpacity", 50);
showBackgroundImage = toml::find_or<bool>(gui, "showBackgroundImage", true); showBackgroundImage = toml::find_or<bool>(gui, "showBackgroundImage", true);
showLabelsUnderIcons = toml::find_or<bool>(gui, "showLabels", true);
} }
if (data.contains("Settings")) { if (data.contains("Settings")) {
@ -1096,6 +1094,7 @@ void saveMainWindow(const std::filesystem::path& path) {
data["GUI"]["geometry_h"] = main_window_geometry_h; data["GUI"]["geometry_h"] = main_window_geometry_h;
data["GUI"]["elfDirs"] = m_elf_viewer; data["GUI"]["elfDirs"] = m_elf_viewer;
data["GUI"]["recentFiles"] = m_recent_files; data["GUI"]["recentFiles"] = m_recent_files;
data["GUI"]["showLabels"] = showLabelsUnderIcons;
// Sorting of TOML sections // Sorting of TOML sections
sortTomlSections(data); sortTomlSections(data);

View File

@ -27,7 +27,6 @@ std::filesystem::path GetSaveDataPath();
void setLoadGameSizeEnabled(bool enable); void setLoadGameSizeEnabled(bool enable);
bool getIsFullscreen(); bool getIsFullscreen();
bool getShowLabelsUnderIcons(); bool getShowLabelsUnderIcons();
bool setShowLabelsUnderIcons();
std::string getFullscreenMode(); std::string getFullscreenMode();
bool isNeoModeConsole(); bool isNeoModeConsole();
bool isDevKitConsole(); bool isDevKitConsole();
@ -157,6 +156,7 @@ void setMainWindowHeight(u32 height);
void setElfViewer(const std::vector<std::string>& elfList); void setElfViewer(const std::vector<std::string>& elfList);
void setRecentFiles(const std::vector<std::string>& recentFiles); void setRecentFiles(const std::vector<std::string>& recentFiles);
void setEmulatorLanguage(std::string language); void setEmulatorLanguage(std::string language);
void setShowLabelsUnderIcons(bool enable);
u32 getMainWindowGeometryX(); u32 getMainWindowGeometryX();
u32 getMainWindowGeometryY(); u32 getMainWindowGeometryY();

View File

@ -138,9 +138,8 @@ void MainWindow::PauseGame() {
} }
void MainWindow::toggleLabelsUnderIcons() { void MainWindow::toggleLabelsUnderIcons() {
bool showLabels = ui->toggleLabelsAct->isChecked(); Config::setShowLabelsUnderIcons(ui->toggleLabelsAct->isChecked());
Config::setShowLabelsUnderIcons(); AddUiWidgets();
UpdateToolbarLabels();
if (isGameRunning) { if (isGameRunning) {
UpdateToolbarButtons(); UpdateToolbarButtons();
} }
@ -187,7 +186,7 @@ void MainWindow::AddUiWidgets() {
// add toolbar widgets // add toolbar widgets
QApplication::setStyle("Fusion"); QApplication::setStyle("Fusion");
bool showLabels = ui->toggleLabelsAct->isChecked(); bool showLabels = Config::getShowLabelsUnderIcons();
ui->toolBar->clear(); ui->toolBar->clear();
ui->toolBar->addWidget(createSpacer(this)); ui->toolBar->addWidget(createSpacer(this));
@ -280,10 +279,6 @@ void MainWindow::UpdateToolbarButtons() {
} }
} }
void MainWindow::UpdateToolbarLabels() {
AddUiWidgets();
}
void MainWindow::CreateDockWindows() { void MainWindow::CreateDockWindows() {
// place holder widget is needed for good health they say :) // place holder widget is needed for good health they say :)
QWidget* phCentralWidget = new QWidget(this); QWidget* phCentralWidget = new QWidget(this);

View File

@ -52,7 +52,6 @@ private Q_SLOTS:
private: private:
Ui_MainWindow* ui; Ui_MainWindow* ui;
void AddUiWidgets(); void AddUiWidgets();
void UpdateToolbarLabels();
void UpdateToolbarButtons(); void UpdateToolbarButtons();
QWidget* createButtonWithLabel(QPushButton* button, const QString& labelText, bool showLabel); QWidget* createButtonWithLabel(QPushButton* button, const QString& labelText, bool showLabel);
void CreateActions(); void CreateActions();