Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 85b5a29192 | |||
| b53597396c | |||
| be980dbffd | |||
| 8165ee20cc | |||
| cacffbcc2a | |||
| b4a4b2f554 | |||
| 2b107f8f73 | |||
| 490b89be38 | |||
| 2c57eb2ebf | |||
| 06d2cdb68f | |||
| 431ba3dffa | |||
| 0786a8eb0e | |||
| debda73068 | |||
| ce72177973 | |||
| 5214b9f925 | |||
| f37e89d956 | |||
| 89b084a6a7 | |||
| ee33c72915 | |||
| 59c316a1f0 | |||
| e9e295c3bc | |||
| 52aa0cac10 | |||
| 8e5381fda2 | |||
| 82f58bc24b | |||
| ef3883ed15 | |||
| 79d18bdd5d | |||
| 7468a16d63 | |||
| a5378e32b9 | |||
| 8ab8cb5335 |
@@ -73,3 +73,5 @@ CMakeLists.txt.user*
|
||||
*.exe
|
||||
|
||||
build
|
||||
lib/linux-x86_64
|
||||
lib/*.zip
|
||||
|
||||
@@ -23,6 +23,7 @@ add_library(rktwebview SHARED
|
||||
json.cpp json.h
|
||||
utils.h
|
||||
utils.cpp
|
||||
memqueue.h memqueue.cpp
|
||||
)
|
||||
|
||||
add_executable(rktwebview_prg
|
||||
@@ -42,6 +43,9 @@ add_executable(rktwebview_prg
|
||||
rkt_protocol.h
|
||||
rktwebview_types.h
|
||||
utils.cpp utils.h
|
||||
|
||||
build_menu_from_json.cpp
|
||||
build_menu_from_json.h
|
||||
)
|
||||
|
||||
add_executable(rktwebview_test
|
||||
@@ -52,6 +56,7 @@ target_link_libraries(rktwebview_prg PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
target_link_libraries(rktwebview_prg PRIVATE Qt${QT_VERSION_MAJOR}::WebEngineWidgets)
|
||||
|
||||
target_compile_definitions(rktwebview PRIVATE RKTWEBVIEW_LIBRARY)
|
||||
target_compile_definitions(rktwebview_prg PRIVATE RKTWEBVIEW_PRG_EXE)
|
||||
|
||||
target_link_Libraries(rktwebview_test PRIVATE rktwebview)
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
#include <QJsonArray>
|
||||
#include <QJsonParseError>
|
||||
#include <QJsonObject>
|
||||
#include <QMenu>
|
||||
#include "rktwebview_qt.h"
|
||||
#include "utils.h"
|
||||
|
||||
static QAction *addMenuItemFromJson(Rktwebview_qt *owner,
|
||||
QMenu *menu,
|
||||
const QJsonObject &item,
|
||||
int source_handle);
|
||||
|
||||
static QMenu *buildMenuObjectFromJson(Rktwebview_qt *owner,
|
||||
const QJsonArray &items,
|
||||
int source_handle,
|
||||
QWidget *parent = nullptr)
|
||||
{
|
||||
QMenu *menu = new QMenu(parent);
|
||||
|
||||
for (const QJsonValue &v : items) {
|
||||
if (!v.isObject()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QJsonObject item = v.toObject();
|
||||
|
||||
if (item.value("separator").toBool(false)) {
|
||||
menu->addSeparator();
|
||||
continue;
|
||||
}
|
||||
|
||||
addMenuItemFromJson(owner, menu, item, source_handle);
|
||||
}
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
static QAction *addMenuItemFromJson(Rktwebview_qt *owner,
|
||||
QMenu *menu,
|
||||
const QJsonObject &item,
|
||||
int source_handle)
|
||||
{
|
||||
QString id = item.value("id").toString();
|
||||
QString name = item.value("name").toString();
|
||||
QString icon_file = item.value("icon").toString();
|
||||
|
||||
QAction *action = nullptr;
|
||||
|
||||
QJsonValue submenu_value = item.value("submenu");
|
||||
if (submenu_value.isObject()) {
|
||||
QJsonObject submenu_obj = submenu_value.toObject();
|
||||
QJsonArray submenu_items = submenu_obj.value("menu").toArray();
|
||||
|
||||
QMenu *submenu = buildMenuObjectFromJson(owner,
|
||||
submenu_items,
|
||||
source_handle,
|
||||
menu);
|
||||
|
||||
if (!icon_file.isEmpty()) {
|
||||
submenu->setIcon(QIcon(icon_file));
|
||||
}
|
||||
|
||||
submenu->setTitle(name);
|
||||
action = menu->addMenu(submenu);
|
||||
} else {
|
||||
if (icon_file.isEmpty()) {
|
||||
action = menu->addAction(name);
|
||||
} else {
|
||||
action = menu->addAction(QIcon(icon_file), name);
|
||||
}
|
||||
|
||||
QObject::connect(action, &QAction::triggered,
|
||||
owner, [owner, source_handle, id]() {
|
||||
EventContainer e("tray-menu-item-chosen");
|
||||
e["id"] = id;
|
||||
e["menu_item"] = id;
|
||||
owner->triggerEvent(source_handle, e);
|
||||
});
|
||||
}
|
||||
|
||||
action->setData(id);
|
||||
return action;
|
||||
}
|
||||
|
||||
QMenu *buildMenuFromJson(Rktwebview_qt *self, const QString &menu_json, int source_handle)
|
||||
{
|
||||
QJsonParseError err;
|
||||
QJsonDocument doc = QJsonDocument::fromJson(menu_json.toUtf8(), &err);
|
||||
|
||||
if (err.error != QJsonParseError::NoError || !doc.isObject()) {
|
||||
ERROR2("Json parse error for menu: %d, '%s'\n", err.error, err.errorString().toUtf8().constData());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QJsonObject root = doc.object();
|
||||
QJsonArray items = root.value("menu").toArray();
|
||||
|
||||
return buildMenuObjectFromJson(self, items, source_handle);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef BUILD_MENU_FROM_JSON_H
|
||||
#define BUILD_MENU_FROM_JSON_H
|
||||
|
||||
class QMenu;
|
||||
class Rktwebview_qt;
|
||||
class QString;
|
||||
|
||||
QMenu *buildMenuFromJson(Rktwebview_qt *self, const QString &menu_json, int source_handle);
|
||||
|
||||
#endif // BUILD_MENU_FROM_JSON_H
|
||||
@@ -28,6 +28,12 @@
|
||||
#define COMMAND_SET_OU_TOKEN 22
|
||||
#define COMMAND_NEW_CONTEXT 23
|
||||
#define COMMAND_MESSAGE 24
|
||||
#define COMMAND_SET_ICON 25
|
||||
#define COMMAND_CREATE_TRAY 26
|
||||
#define COMMAND_TRAY_SET_ICON 27
|
||||
#define COMMAND_TRAY_SET_TOOLTIP 28
|
||||
#define COMMAND_TRAY_SHOW_MESSAGE 29
|
||||
#define COMMAND_TRAY_SET_MENU 30
|
||||
|
||||
class Command
|
||||
{
|
||||
|
||||
Regular → Executable
+10
-5
@@ -2,20 +2,21 @@
|
||||
#
|
||||
ARCH=`uname -m`
|
||||
|
||||
LIB="lib/linux/$ARCH"
|
||||
LIB="../lib/linux-$ARCH"
|
||||
BUILD="../build/Release"
|
||||
|
||||
mkdir -p $LIB
|
||||
rm -f $LIB/*.so*
|
||||
cp build/Release/*.so $LIB
|
||||
cp build/Release/rktwebview_prg $LIB
|
||||
cp $BUILD/*.so $LIB
|
||||
cp $BUILD/rktwebview_prg $LIB
|
||||
|
||||
QT_PATH=`ldd build/Release/rktwebview_prg | grep Qt | awk '{print $3}' | head -1 | sed -e 's%[/]lib[/].*%%'`
|
||||
QT_PATH=`ldd $BUILD/rktwebview_prg | grep Qt | awk '{print $3}' | head -1 | sed -e 's%[/]lib[/].*%%'`
|
||||
echo "QT_PATH=$QT_PATH"
|
||||
|
||||
QT_PLUGINS="$QT_PATH/plugins"
|
||||
PLUGINS="platforms position generic iconengines imageformats qmltooling tls xcbglintegrations"
|
||||
|
||||
EXTRA_LIBS_SO=`ldd build/Release/rktwebview_prg | grep Qt | awk '{ print $3 }'`
|
||||
EXTRA_LIBS_SO=`ldd $BUILD/rktwebview_prg | grep Qt | awk '{ print $3 }'`
|
||||
EXTRA_LIBS_PLATFORM_PLUGIN_XCB=`ldd $QT_PATH/plugins/platforms/libqxcb.so | grep Qt | awk '{print $3}'`
|
||||
|
||||
for pl in $PLUGINS
|
||||
@@ -63,4 +64,8 @@ done
|
||||
|
||||
cp $QT_PATH/libexec/QtWebEngineProcess $LIB
|
||||
|
||||
(cd $LIB; cd ..; zip -9 -y -r linux-$ARCH.zip linux-$ARCH)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ const JSON &JSON::at(unsigned int index) const {
|
||||
|
||||
int JSON::length() const {
|
||||
if( Type == Class::Array )
|
||||
return Internal.List->size();
|
||||
return static_cast<int>(Internal.List->size());
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
@@ -105,9 +105,9 @@ bool JSON::hasKey(const std::string &key) const {
|
||||
|
||||
int JSON::size() const {
|
||||
if( Type == Class::Object )
|
||||
return Internal.Map->size();
|
||||
return static_cast<int>(Internal.Map->size());
|
||||
else if( Type == Class::Array )
|
||||
return Internal.List->size();
|
||||
return static_cast<int>(Internal.List->size());
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,48 +0,0 @@
|
||||
[
|
||||
{
|
||||
"name": "qtbase",
|
||||
"repositories": ["qtbase", "qtactiveqt", "qtimageformats"]
|
||||
},
|
||||
{
|
||||
"name": "qtdeclarative",
|
||||
"repositories": ["qtdeclarative"]
|
||||
},
|
||||
{
|
||||
"name": "qtmultimedia",
|
||||
"repositories": ["qtmultimedia"]
|
||||
},
|
||||
{
|
||||
"name": "qtconnectivity",
|
||||
"repositories": ["qtconnectivity"]
|
||||
},
|
||||
{
|
||||
"name": "qtlocation",
|
||||
"repositories": ["qtlocation"]
|
||||
},
|
||||
{
|
||||
"name": "qtwebsockets",
|
||||
"repositories": ["qtwebsockets"]
|
||||
},
|
||||
{
|
||||
"name": "qtserialport",
|
||||
"repositories": ["qtserialport"]
|
||||
},
|
||||
{
|
||||
"name": "qtwebengine",
|
||||
"repositories": ["qtwebengine"]
|
||||
},
|
||||
{
|
||||
"name": "designer",
|
||||
"modules": ["Designer"]
|
||||
},
|
||||
{
|
||||
"name": "linguist"
|
||||
},
|
||||
{
|
||||
"name": "assistant"
|
||||
},
|
||||
{
|
||||
"name": "qt_help",
|
||||
"modules": ["Help"]
|
||||
}
|
||||
]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user