mirror of
https://github.com/Luca1991/NDSFactory.git
synced 2025-07-08 21:20:13 +02:00
Implemented theme selector and fixed FatTools UI
This commit is contained in:
parent
aa2ed50ade
commit
4b886a9033
@ -40,6 +40,9 @@ file(GLOB_RECURSE TABS_SOURCES ui/tabs/*.cpp)
|
|||||||
file(GLOB_RECURSE MODELS_HEADERS ui/models/*.h)
|
file(GLOB_RECURSE MODELS_HEADERS ui/models/*.h)
|
||||||
file(GLOB_RECURSE MODELS_SOURCES ui/models/*.cpp)
|
file(GLOB_RECURSE MODELS_SOURCES ui/models/*.cpp)
|
||||||
|
|
||||||
|
## Utils
|
||||||
|
file(GLOB_RECURSE UTILS_HEADERS ui/utils/*.h)
|
||||||
|
|
||||||
## NDSFactory
|
## NDSFactory
|
||||||
file(GLOB_RECURSE NDSFACTORY_SOURCES ndsfactory/*.cpp)
|
file(GLOB_RECURSE NDSFACTORY_SOURCES ndsfactory/*.cpp)
|
||||||
file(GLOB_RECURSE NDSFACTORY_HEADERS ndsfactory/*.h)
|
file(GLOB_RECURSE NDSFACTORY_HEADERS ndsfactory/*.h)
|
||||||
@ -59,6 +62,7 @@ SET(HEADERS
|
|||||||
${TABS_HEADERS}
|
${TABS_HEADERS}
|
||||||
${MODELS_HEADERS}
|
${MODELS_HEADERS}
|
||||||
${DIALOGS_HEADERS}
|
${DIALOGS_HEADERS}
|
||||||
|
${UTILS_HEADERS}
|
||||||
)
|
)
|
||||||
|
|
||||||
set(FORMS
|
set(FORMS
|
||||||
|
18
main.cpp
18
main.cpp
@ -1,13 +1,23 @@
|
|||||||
#include "ui/mainwindow.h"
|
#include "ui/mainwindow.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
|
#include "ui/utils/theme.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication::setStyle(QStyleFactory::create("Fusion"));
|
QApplication::setStyle(QStyleFactory::create("Fusion"));
|
||||||
QApplication a(argc, argv);
|
QApplication app(argc, argv);
|
||||||
MainWindow w;
|
app.setApplicationName("NDSFactory");
|
||||||
w.show();
|
app.setOrganizationName("NDSFactory");
|
||||||
|
|
||||||
return a.exec();
|
QString theme = getCurrentTheme();
|
||||||
|
if(theme == "dark")
|
||||||
|
setDarkTheme(app);
|
||||||
|
else if(theme == "light")
|
||||||
|
setLightTheme(app);
|
||||||
|
|
||||||
|
MainWindow mainWindow;
|
||||||
|
mainWindow.show();
|
||||||
|
|
||||||
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#ifndef CRCTABLE_H
|
#pragma once
|
||||||
#define CRCTABLE_H
|
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
@ -39,5 +38,3 @@ static const uint16_t lCRCTable[] =
|
|||||||
0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
|
0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
|
||||||
0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
|
0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CRCTABLE_H
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#ifndef FATSTRUCT_H
|
#pragma once
|
||||||
#define FATSTRUCT_H
|
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
@ -7,5 +6,3 @@ struct FatRange {
|
|||||||
uint32_t startAddr;
|
uint32_t startAddr;
|
||||||
uint32_t endAddr;
|
uint32_t endAddr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FATSTRUCT_H
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#ifndef NDSFACTORY_H
|
#pragma once
|
||||||
#define NDSFACTORY_H
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -29,4 +28,3 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NDSFACTORY_H
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#ifndef NDSHEADER_H
|
#pragma once
|
||||||
#define NDSHEADER_H
|
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
@ -69,5 +68,3 @@ struct NDSHeader
|
|||||||
unsigned char Reserved4[0x90];
|
unsigned char Reserved4[0x90];
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
#endif // NDSHEADER_H
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#ifndef ABOUTDIALOG_H
|
#pragma once
|
||||||
#define ABOUTDIALOG_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
@ -18,5 +17,3 @@ class AboutDialog : public QDialog
|
|||||||
Ui::AboutDialog *ui;
|
Ui::AboutDialog *ui;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ABOUTDIALOG_H
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#ifndef REVISION_H
|
#ifndef REVISION_H
|
||||||
#define REVISION_H
|
#define REVISION_H
|
||||||
|
|
||||||
#define GIT_COMMIT_HASH "c7eaa8e"
|
#define GIT_COMMIT_HASH "aa2ed50"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include "dialogs/about/aboutdialog.h"
|
#include "dialogs/about/aboutdialog.h"
|
||||||
|
#include "utils/theme.h"
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
@ -26,3 +27,18 @@ void MainWindow::on_actionAbout_triggered()
|
|||||||
AboutDialog aboutDialog;
|
AboutDialog aboutDialog;
|
||||||
aboutDialog.exec();
|
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
|
#pragma once
|
||||||
#define MAINWINDOW_H
|
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@ -35,6 +34,9 @@ private slots:
|
|||||||
void on_unpackerDecodeFatFilesBtn_clicked();
|
void on_unpackerDecodeFatFilesBtn_clicked();
|
||||||
void notifyExtractionResult(bool result);
|
void notifyExtractionResult(bool result);
|
||||||
|
|
||||||
|
void on_actionDark_triggered();
|
||||||
|
void on_actionLight_triggered();
|
||||||
|
void on_actionDefault_triggered();
|
||||||
void on_actionExit_triggered();
|
void on_actionExit_triggered();
|
||||||
void on_actionAbout_triggered();
|
void on_actionAbout_triggered();
|
||||||
|
|
||||||
@ -113,5 +115,3 @@ private:
|
|||||||
|
|
||||||
bool patchFat(const std::string& loadPath, uint32_t shiftSize, const std::string& savePath);
|
bool patchFat(const std::string& loadPath, uint32_t shiftSize, const std::string& savePath);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
|
||||||
|
@ -617,23 +617,27 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_15">
|
<layout class="QVBoxLayout" name="verticalLayout_15">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_83">
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
<property name="sizePolicy">
|
<item>
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
<widget class="QLabel" name="label_83">
|
||||||
<horstretch>0</horstretch>
|
<property name="sizePolicy">
|
||||||
<verstretch>0</verstretch>
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
</sizepolicy>
|
<horstretch>0</horstretch>
|
||||||
</property>
|
<verstretch>0</verstretch>
|
||||||
<property name="text">
|
</sizepolicy>
|
||||||
<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>
|
<property name="text">
|
||||||
<property name="scaledContents">
|
<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>
|
||||||
<bool>false</bool>
|
</property>
|
||||||
</property>
|
<property name="scaledContents">
|
||||||
<property name="alignment">
|
<bool>false</bool>
|
||||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
</property>
|
||||||
</property>
|
<property name="alignment">
|
||||||
</widget>
|
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_35">
|
<layout class="QHBoxLayout" name="horizontalLayout_35">
|
||||||
@ -760,6 +764,15 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>File</string>
|
<string>File</string>
|
||||||
</property>
|
</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"/>
|
<addaction name="actionExit"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuHelp">
|
<widget class="QMenu" name="menuHelp">
|
||||||
@ -786,6 +799,21 @@
|
|||||||
<string>Exit</string>
|
<string>Exit</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</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>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#ifndef NDSHEADERMODEL_H
|
#pragma once
|
||||||
#define NDSHEADERMODEL_H
|
|
||||||
|
|
||||||
#include <QAbstractTableModel>
|
#include <QAbstractTableModel>
|
||||||
|
|
||||||
@ -21,5 +20,3 @@ private:
|
|||||||
NDSHeader *ndsHeader;
|
NDSHeader *ndsHeader;
|
||||||
bool isValueRowEditable = false;
|
bool isValueRowEditable = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NDSHEADERMODEL_H
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#ifndef HEADERNAMES_H
|
#pragma once
|
||||||
#define HEADERNAMES_H
|
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -52,5 +51,3 @@ namespace NDSHeaderNames {
|
|||||||
FATFilesAddress
|
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();
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user