This commit is contained in:
2026-04-08 16:39:23 +02:00
parent a5378e32b9
commit 7468a16d63
7 changed files with 43 additions and 0 deletions

View File

@@ -28,6 +28,7 @@
#define COMMAND_SET_OU_TOKEN 22
#define COMMAND_NEW_CONTEXT 23
#define COMMAND_MESSAGE 24
#define COMMAND_SET_ICON 25
class Command
{

View File

@@ -271,6 +271,13 @@ void Handler::run()
result_queue->enqueue(r);
}
break;
case CMD_SET_ICON: {
int wv = data_obj["wv"].toInt();
QString icon_file = data_obj["icon"].toString();
result_t r = webview_handler->rktWindowSetIcon(wv, icon_file.toUtf8().constData());
result_queue->enqueue(r);
}
break;
case CMD_CHOOSE_DIR: {
int wv = data_obj["wv"].toInt();
QString title = data_obj["title"].toString();

View File

@@ -28,6 +28,7 @@
#define CMD_MSG_BOX 25 // arguments: wv: int, title:string, message: string, submessage: string, type:int -> result_t: int
#define CMD_SET_LOGLEVEL 26 // arguments: ll: int
#define CMD_INFO 27 // arguments: none
#define CMD_SET_ICON 28 // arguments: wv: int, icon:string (absolute filename to icon in png/jpg/svg)
#define RESULT_QUIT 36379

View File

@@ -474,6 +474,11 @@ result_t rkt_webview_set_title(rktwebview_t wv, const char *title)
CMDRES(CMD_SET_TITLE, wv, "title", title)
}
result_t rkt_webview_set_icon(rktwebview_t wv, const char *icon_file)
{
CMDRES(CMD_SET_ICON, wv, "icon", icon_file)
}
result_t rkt_webview_choose_dir(rktwebview_t w, const char *title, const char *base_dir)
{
CMDRES2(CMD_CHOOSE_DIR, w, "title", title, "base_dir", base_dir)
@@ -591,3 +596,5 @@ rkt_data_t *rkt_webview_info()
return d;
}

View File

@@ -28,6 +28,7 @@ RKTWEBVIEW_EXPORT int rkt_webview_create(rkt_wv_context_t context, rktwebview_t
RKTWEBVIEW_EXPORT void rkt_webview_close(rktwebview_t wv);
RKTWEBVIEW_EXPORT bool rkt_webview_valid(rktwebview_t wv);
RKTWEBVIEW_EXPORT result_t rkt_webview_set_title(rktwebview_t wv, const char *title);
RKTWEBVIEW_EXPORT result_t rkt_webview_set_icon(rktwebview_t wv, const char *icon_file);
RKTWEBVIEW_EXPORT void rkt_webview_set_ou_token(rktwebview_t wv, const char *token);
RKTWEBVIEW_EXPORT result_t rkt_webview_set_url(rktwebview_t wv, const char *url);

View File

@@ -229,6 +229,20 @@ void Rktwebview_qt::processCommand(Command *cmd)
cmd->done = true;
}
break;
case COMMAND_SET_ICON: {
int wv = cmd->args[0].toInt();
QString icon_file = cmd->args[1].toString();
if (_views.contains(wv)) {
WebviewWindow *w = _views[wv];
QIcon icn(icon_file);
w->setWindowIcon(icn);
cmd->result = true;
} else {
cmd->result = false;
}
cmd->done = true;
}
break;
case COMMAND_RUN_JS: {
int wv = cmd->args[0].toInt();
QString js = cmd->args[1].toString();
@@ -777,6 +791,17 @@ result_t Rktwebview_qt::rktWindowSetTitle(rktwebview_t wv, const char *title)
return r ? result_t::oke : result_t::failed;
}
result_t Rktwebview_qt::rktWindowSetIcon(rktwebview_t wv, const char *icon_file)
{
Command c(COMMAND_SET_ICON);
c.args.push_back(wv);
c.args.push_back(icon_file);
postCommand(&c);
while(!c.done) { doEvents(); }
bool r = c.result.toBool();
return r ? result_t::oke : result_t::failed;
}
void Rktwebview_qt::msgBox(rktwebview_t w, const QString &title, const QString &message, const QString &submessage, rkt_messagetype_t type)
{

View File

@@ -106,6 +106,7 @@ public:
result_t rktFileSave(rktwebview_t w, const char *title, const char *base_dir, const char *permitted_exts);
result_t rktWindowSetTitle(rktwebview_t wv, const char *title);
result_t rktWindowSetIcon(rktwebview_t wv, const char *icon_file);
result_t rktMessageBox(rktwebview_t w, const char *title, const char *message, const char *submessage, rkt_messagetype_t type);
bool rktValid(rktwebview_t wv);