mirror of
https://github.com/Luca1991/NDSFactory.git
synced 2026-02-04 05:36:15 +01:00
Implemented theme selector and fixed FatTools UI
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#ifndef ABOUTDIALOG_H
|
||||
#define ABOUTDIALOG_H
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
@@ -18,5 +17,3 @@ class AboutDialog : public QDialog
|
||||
Ui::AboutDialog *ui;
|
||||
|
||||
};
|
||||
|
||||
#endif // ABOUTDIALOG_H
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifndef REVISION_H
|
||||
#define REVISION_H
|
||||
|
||||
#define GIT_COMMIT_HASH "c7eaa8e"
|
||||
#define GIT_COMMIT_HASH "aa2ed50"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "dialogs/about/aboutdialog.h"
|
||||
#include "utils/theme.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
@@ -26,3 +27,18 @@ void MainWindow::on_actionAbout_triggered()
|
||||
AboutDialog aboutDialog;
|
||||
aboutDialog.exec();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionDark_triggered()
|
||||
{
|
||||
setTheme("dark");
|
||||
}
|
||||
|
||||
void MainWindow::on_actionLight_triggered()
|
||||
{
|
||||
setTheme("light");
|
||||
}
|
||||
|
||||
void MainWindow::on_actionDefault_triggered()
|
||||
{
|
||||
setTheme("default");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
#pragma once
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <cstdint>
|
||||
@@ -35,6 +34,9 @@ private slots:
|
||||
void on_unpackerDecodeFatFilesBtn_clicked();
|
||||
void notifyExtractionResult(bool result);
|
||||
|
||||
void on_actionDark_triggered();
|
||||
void on_actionLight_triggered();
|
||||
void on_actionDefault_triggered();
|
||||
void on_actionExit_triggered();
|
||||
void on_actionAbout_triggered();
|
||||
|
||||
@@ -113,5 +115,3 @@ private:
|
||||
|
||||
bool patchFat(const std::string& loadPath, uint32_t shiftSize, const std::string& savePath);
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
||||
@@ -617,23 +617,27 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_15">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_83">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>If the address of the fat_data.bin file is different from the original location in ROM, you need to patch the fat.bin file...</string>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_83">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>If the address of the fat_data.bin file is different from the original location in ROM, you need to patch the fat.bin file...</string>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_35">
|
||||
@@ -760,6 +764,15 @@
|
||||
<property name="title">
|
||||
<string>File</string>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuTheme">
|
||||
<property name="title">
|
||||
<string>Theme</string>
|
||||
</property>
|
||||
<addaction name="actionDark"/>
|
||||
<addaction name="actionLight"/>
|
||||
<addaction name="actionDefault"/>
|
||||
</widget>
|
||||
<addaction name="menuTheme"/>
|
||||
<addaction name="actionExit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuHelp">
|
||||
@@ -786,6 +799,21 @@
|
||||
<string>Exit</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDark">
|
||||
<property name="text">
|
||||
<string>Dark</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLight">
|
||||
<property name="text">
|
||||
<string>Light</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDefault">
|
||||
<property name="text">
|
||||
<string>Default</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#ifndef NDSHEADERMODEL_H
|
||||
#define NDSHEADERMODEL_H
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
@@ -21,5 +20,3 @@ private:
|
||||
NDSHeader *ndsHeader;
|
||||
bool isValueRowEditable = false;
|
||||
};
|
||||
|
||||
#endif // NDSHEADERMODEL_H
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#ifndef HEADERNAMES_H
|
||||
#define HEADERNAMES_H
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
@@ -52,5 +51,3 @@ namespace NDSHeaderNames {
|
||||
FATFilesAddress
|
||||
};
|
||||
}
|
||||
|
||||
#endif // HEADERNAMES_H
|
||||
|
||||
60
ui/utils/theme.h
Normal file
60
ui/utils/theme.h
Normal file
@@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include <QApplication>
|
||||
#include <QPalette>
|
||||
#include <QSettings>
|
||||
#include <QMessageBox>
|
||||
|
||||
inline void setDarkTheme(QApplication& app)
|
||||
{
|
||||
QPalette darkPalette;
|
||||
darkPalette.setColor(QPalette::Window, QColor(53, 53, 53));
|
||||
darkPalette.setColor(QPalette::WindowText, Qt::white);
|
||||
darkPalette.setColor(QPalette::Base, QColor(35, 35, 35));
|
||||
darkPalette.setColor(QPalette::AlternateBase, QColor(53, 53, 53));
|
||||
darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
|
||||
darkPalette.setColor(QPalette::ToolTipText, Qt::white);
|
||||
darkPalette.setColor(QPalette::Text, Qt::white);
|
||||
darkPalette.setColor(QPalette::Button, QColor(53, 53, 53));
|
||||
darkPalette.setColor(QPalette::ButtonText, Qt::white);
|
||||
darkPalette.setColor(QPalette::BrightText, Qt::red);
|
||||
darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
|
||||
darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
|
||||
darkPalette.setColor(QPalette::HighlightedText, Qt::black);
|
||||
|
||||
app.setPalette(darkPalette);
|
||||
}
|
||||
|
||||
inline void setLightTheme(QApplication& app)
|
||||
{
|
||||
QPalette lightPalette;
|
||||
lightPalette.setColor(QPalette::Window, QColor(240, 240, 240));
|
||||
lightPalette.setColor(QPalette::WindowText, Qt::black);
|
||||
lightPalette.setColor(QPalette::Base, QColor(255, 255, 255));
|
||||
lightPalette.setColor(QPalette::AlternateBase, QColor(233, 233, 233));
|
||||
lightPalette.setColor(QPalette::ToolTipBase, Qt::black);
|
||||
lightPalette.setColor(QPalette::ToolTipText, Qt::white);
|
||||
lightPalette.setColor(QPalette::Text, Qt::black);
|
||||
lightPalette.setColor(QPalette::Button, QColor(240, 240, 240));
|
||||
lightPalette.setColor(QPalette::ButtonText, Qt::black);
|
||||
lightPalette.setColor(QPalette::BrightText, Qt::red);
|
||||
lightPalette.setColor(QPalette::Link, QColor(42, 130, 218));
|
||||
lightPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
|
||||
lightPalette.setColor(QPalette::HighlightedText, Qt::white);
|
||||
|
||||
app.setPalette(lightPalette);
|
||||
}
|
||||
|
||||
inline void setTheme(QString themeValue)
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue("theme", themeValue);
|
||||
QMessageBox::information(nullptr, "NDS Factory", "Restart NDSFactory to change theme!");
|
||||
|
||||
}
|
||||
|
||||
inline QString getCurrentTheme()
|
||||
{
|
||||
QSettings settings;
|
||||
return settings.value("theme", "default").toString();
|
||||
}
|
||||
Reference in New Issue
Block a user