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_SOURCES ui/models/*.cpp)
|
||||
|
||||
## Utils
|
||||
file(GLOB_RECURSE UTILS_HEADERS ui/utils/*.h)
|
||||
|
||||
## NDSFactory
|
||||
file(GLOB_RECURSE NDSFACTORY_SOURCES ndsfactory/*.cpp)
|
||||
file(GLOB_RECURSE NDSFACTORY_HEADERS ndsfactory/*.h)
|
||||
@ -59,6 +62,7 @@ SET(HEADERS
|
||||
${TABS_HEADERS}
|
||||
${MODELS_HEADERS}
|
||||
${DIALOGS_HEADERS}
|
||||
${UTILS_HEADERS}
|
||||
)
|
||||
|
||||
set(FORMS
|
||||
|
18
main.cpp
18
main.cpp
@ -1,13 +1,23 @@
|
||||
#include "ui/mainwindow.h"
|
||||
#include <QApplication>
|
||||
#include <QStyleFactory>
|
||||
#include "ui/utils/theme.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication::setStyle(QStyleFactory::create("Fusion"));
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
QApplication app(argc, argv);
|
||||
app.setApplicationName("NDSFactory");
|
||||
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
|
||||
#define CRCTABLE_H
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@ -39,5 +38,3 @@ static const uint16_t lCRCTable[] =
|
||||
0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
|
||||
0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
|
||||
};
|
||||
|
||||
#endif // CRCTABLE_H
|
||||
|
@ -1,5 +1,4 @@
|
||||
#ifndef FATSTRUCT_H
|
||||
#define FATSTRUCT_H
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@ -7,5 +6,3 @@ struct FatRange {
|
||||
uint32_t startAddr;
|
||||
uint32_t endAddr;
|
||||
};
|
||||
|
||||
#endif // FATSTRUCT_H
|
||||
|
@ -1,5 +1,4 @@
|
||||
#ifndef NDSFACTORY_H
|
||||
#define NDSFACTORY_H
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -29,4 +28,3 @@ private:
|
||||
|
||||
};
|
||||
|
||||
#endif // NDSFACTORY_H
|
||||
|
@ -1,5 +1,4 @@
|
||||
#ifndef NDSHEADER_H
|
||||
#define NDSHEADER_H
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@ -69,5 +68,3 @@ struct NDSHeader
|
||||
unsigned char Reserved4[0x90];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif // NDSHEADER_H
|
||||
|
@ -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
|
||||
|
@ -616,6 +616,8 @@
|
||||
<string>FAT Patcher</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_15">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_83">
|
||||
<property name="sizePolicy">
|
||||
@ -635,6 +637,8 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_35">
|
||||
<property name="leftMargin">
|
||||
@ -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();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user