Add saucer4lua integration, window management features

Integrates the saucer4lua library for enhanced Lua support and adds new window management functionalities, including window centering and resizing capabilities. Updates related files, such as CMakeLists, headers, and submodules, to support the new library and features effectively.
This commit is contained in:
2025-01-17 09:59:13 +01:00
parent f49d8874c1
commit c93758f732
5 changed files with 63 additions and 1 deletions

5
.gitmodules vendored
View File

@@ -15,4 +15,7 @@
url = https://github.com/nlohmann/json.git
[submodule "lib/cppcodec"]
path = lib/cppcodec
url = https://github.com/tplgy/cppcodec.git
url = https://github.com/tplgy/cppcodec.git
[submodule "lib/saucer4lua"]
path = lib/saucer4lua
url = https://git.schmidti.digital/Yadciel/saucer4lua.git

View File

@@ -13,6 +13,7 @@ add_subdirectory(lib/cppcodec)
add_subdirectory(lib/saucer)
add_subdirectory(lib/lua)
add_subdirectory(lib/sol2)
add_subdirectory(lib/saucer4lua)
include_directories(inc)
include_directories(lib/json/include/nlohmann)
@@ -65,6 +66,7 @@ target_link_libraries(Toolbox
tray
nlohmann_json
cppcodec
#saucer4lua
)
if (WIN32 AND (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel"))

View File

@@ -49,6 +49,8 @@ private:
std::string jsonString;
int size_x,size_y;
#ifdef _WIN32
std::filesystem::path userPath = std::getenv("USERPROFILE"); // Windows
#else
@@ -60,6 +62,7 @@ private:
bool serveHtmlFile(const std::string &htmlPath, bool setDecorations);
void configureWindow();
void moveWindowTo(int x, int y);
void loadResources();
void runLuaScript();
@@ -80,6 +83,9 @@ private:
void SetJsonItems();
void openEinst();
void centerWindow();
void resizeWindow(int width, int height);
void resizeWindow(double widthPercent, double heightPercent);
void openIndex();
void getNewContent();

BIN
installer/toolbox.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -67,6 +67,12 @@ void ToolboxWindow::configureWindow() {
}
}
void ToolboxWindow::moveWindowTo(int x, int y) {
if (const HWND hwnd = m_webview.module<hwnd_module>().get_hwnd()) {
SetWindowPos(hwnd, nullptr, x, y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
}
}
void ToolboxWindow::loadResources() {
auto resources = saucer::embedded::all();
@@ -366,6 +372,51 @@ void ToolboxWindow::openEinst() {
return;
}
isIndex = false;
resizeWindow(60.0, 70.0);
centerWindow();
}
void ToolboxWindow::centerWindow() {
const int screenWidth = GetSystemMetrics(SM_CXSCREEN);
const int screenHeight = GetSystemMetrics(SM_CYSCREEN);
// Aktuelle Fenstergröße abrufen
int windowWidth = 0;
int windowHeight = 0;
if (const HWND hwnd = m_webview.module<hwnd_module>().get_hwnd()) {
RECT rect;
if (GetWindowRect(hwnd, &rect)) {
windowWidth = rect.right - rect.left;
windowHeight = rect.bottom - rect.top;
}
}
// Berechnung der zentralen Position
const int xPos = (screenWidth - windowWidth) / 2;
const int yPos = (screenHeight - windowHeight) / 2;
// Bewege das Fenster an die zentrale Position
moveWindowTo(xPos, yPos);
}
void ToolboxWindow::resizeWindow(int width, int height)
{
// Stellen Sie die Größe des Fensters ein
m_webview.set_size(width, height);
}
void ToolboxWindow::resizeWindow(double widthPercent, double heightPercent)
{
const int screenWidth = GetSystemMetrics(SM_CXSCREEN);
const int screenHeight = GetSystemMetrics(SM_CYSCREEN);
// Berechnung der Fenstergröße basierend auf Prozentwerten
const int width = static_cast<int>(screenWidth * (widthPercent / 100.0));
const int height = static_cast<int>(screenHeight * (heightPercent / 100.0));
// Stellen Sie die Größe des Fensters ein
m_webview.set_size(width, height);
}
void ToolboxWindow::openIndex() {