Add StyleSheet automatic reload function
This commit is contained in:
@@ -88,6 +88,12 @@ if(${Req_FOUND})
|
||||
target_link_libraries(${PROJECT_NAME} Req)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
# If the debug configuration pass the DEBUG define to the compiler
|
||||
$<$<CONFIG:Debug>:_DEBUG>
|
||||
)
|
||||
|
||||
if(NOT UNIX)
|
||||
find_program(POWERSHELL_PATH NAMES powershell)
|
||||
|
||||
|
||||
14
src/main.cpp
14
src/main.cpp
@@ -19,6 +19,7 @@
|
||||
#include "utilities/TouchScreenSignalSender.h"
|
||||
#include "keyboard/KeyboardManager.h"
|
||||
#include "appvals/AppGlobalValues.h"
|
||||
#include <QFileSystemWatcher>
|
||||
|
||||
QString loadFontFromFile(QString path)
|
||||
{
|
||||
@@ -75,6 +76,19 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
a.setStyleSheet(QLatin1String(file.readAll()));
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
QFileSystemWatcher fileWatcher;
|
||||
fileWatcher.addPath("../src/stylesheet/Dark2.css");
|
||||
QObject::connect(&fileWatcher, &QFileSystemWatcher::fileChanged, [](const QString &path){
|
||||
QFile file(path);
|
||||
if (file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
qobject_cast<QApplication*>(QApplication::instance())->setStyleSheet(file.readAll());
|
||||
file.close();
|
||||
qDebug()<<"style updated!";
|
||||
}
|
||||
});
|
||||
#endif
|
||||
AppGlobalValues::setDBconnected(false);
|
||||
MainWindow w;
|
||||
DialogManager::Default()->init(&w);
|
||||
|
||||
Reference in New Issue
Block a user