ui/qt/toolkit.cpp

changeset 535
ede57f5b6178
parent 526
f6a6b0b08641
child 536
4a1c2eae4bcd
--- a/ui/qt/toolkit.cpp	Sun Mar 30 11:28:24 2025 +0200
+++ b/ui/qt/toolkit.cpp	Sun Mar 30 12:00:26 2025 +0200
@@ -35,6 +35,8 @@
 
 #include "../common/document.h"
 #include "../common/properties.h"
+#include "../common/menu.h"
+#include "../common/toolbar.h"
 
 static const char *application_name;
 
@@ -59,9 +61,11 @@
     application = new QApplication(app_argc, app_argv);
     
     uic_docmgr_init();
+    uic_menu_init();
+    uic_toolbar_init();
     
     uic_load_app_properties();
-   
+     
 }
 
 const char* ui_appname() {
@@ -115,6 +119,7 @@
 
 
 
+/* --------------------- Implemtation UiEventWrapper --------------------- */
 
 UiEventWrapper::UiEventWrapper(UiObject *obj, ui_callback f, void* userdata) {
     this->obj = obj;
@@ -123,6 +128,10 @@
 }
 
 void UiEventWrapper::slot() {
+    if(!callback) {
+        return;
+    }
+    
     UiEvent e;
     e.obj = obj;
     e.window = obj->window;
@@ -141,3 +150,33 @@
 void UiEventWrapper::destroy() {
     delete this;
 }
+
+
+/* --------------------- Implemtation UiAction --------------------- */
+
+UiAction::UiAction(UiObject *obj, QString &label, ui_callback f, void *userdata) : QAction(label, NULL) {
+    this->obj = obj;
+    this->callback = f;
+    this->userdata = userdata;
+}
+
+UiAction::~UiAction() {
+    
+}
+
+void UiAction::trigger() {
+    if(!callback) {
+        return;
+    }
+    
+    UiEvent e;
+    e.obj = obj;
+    e.window = obj->window;
+    e.document = obj->ctx->document;
+    e.eventdata = NULL;
+    e.intval = 0;
+    e.set = ui_get_setop();
+    callback(&e, userdata);
+    
+    // TODO: notify var observers
+}

mercurial