mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-21 03:55:04 +00:00
Qt5: set the parent view of a QPluginWidget's view
For the correct integration of a QPluginWidget in a parent QWidget, with this commit the parent QWidget's Nitpicker view is made the parent view of the plugin's Nitpicker view. Fixes #1173.
This commit is contained in:
parent
64863a4b33
commit
4672ae637a
@ -45,6 +45,7 @@ class PluginStarter : public QThread
|
||||
QByteArray _args;
|
||||
int _max_width;
|
||||
int _max_height;
|
||||
Nitpicker::View_capability _parent_view;
|
||||
|
||||
Loader::Connection *_pc;
|
||||
enum Plugin_loading_state _plugin_loading_state;
|
||||
@ -60,7 +61,8 @@ class PluginStarter : public QThread
|
||||
|
||||
public:
|
||||
PluginStarter(QUrl plugin_url, QString &args,
|
||||
int max_width, int max_height);
|
||||
int max_width, int max_height,
|
||||
Nitpicker::View_capability parent_view);
|
||||
|
||||
void run();
|
||||
enum Plugin_loading_state plugin_loading_state() { return _plugin_loading_state; }
|
||||
@ -82,6 +84,10 @@ class QPluginWidget : public QNitpickerViewWidget
|
||||
QString _plugin_loading_error_string;
|
||||
|
||||
PluginStarter *_plugin_starter;
|
||||
bool _plugin_starter_started;
|
||||
|
||||
QUrl _plugin_url;
|
||||
QString _plugin_args;
|
||||
|
||||
int _max_width;
|
||||
int _max_height;
|
||||
@ -95,6 +101,7 @@ class QPluginWidget : public QNitpickerViewWidget
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *event);
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
|
||||
protected slots:
|
||||
void pluginStartFinished();
|
||||
|
@ -7,4 +7,4 @@ HEADERS += qpluginwidget.h
|
||||
vpath %.h $(REP_DIR)/include/qt5/qpluginwidget
|
||||
vpath %.cpp $(REP_DIR)/src/lib/qt5/qpluginwidget
|
||||
|
||||
LIBS += qt5_gui qt5_widgets qt5_network qt5_qnitpickerviewwidget qt5_core libc zlib
|
||||
LIBS += qt5_gui qt5_widgets qt5_network qt5_qnitpickerviewwidget qt5_core qt5_qpa_nitpicker libc qoost zlib
|
||||
|
@ -14,9 +14,8 @@
|
||||
#include <zlib.h>
|
||||
|
||||
#include <QtGui>
|
||||
#if 0
|
||||
#include <private/qwindowsurface_qws_p.h>
|
||||
#endif
|
||||
|
||||
#include <qnitpickerplatformwindow.h>
|
||||
|
||||
#include <qpluginwidget/qpluginwidget.h>
|
||||
|
||||
@ -88,11 +87,13 @@ class Signal_wait_thread : public QThread
|
||||
|
||||
|
||||
PluginStarter::PluginStarter(QUrl plugin_url, QString &args,
|
||||
int max_width, int max_height)
|
||||
int max_width, int max_height,
|
||||
Nitpicker::View_capability parent_view)
|
||||
: _plugin_url(plugin_url),
|
||||
_args(args.toLatin1()),
|
||||
_max_width(max_width),
|
||||
_max_height(max_height),
|
||||
_parent_view(parent_view),
|
||||
_pc(0),
|
||||
_plugin_loading_state(LOADING),
|
||||
_qnam(0),
|
||||
@ -191,6 +192,7 @@ void PluginStarter::_start_plugin(QString &file_name, QByteArray const &file_buf
|
||||
|
||||
_pc->view_ready_sigh(sig_rec.manage(&sig_ctx));
|
||||
_pc->constrain_geometry(_max_width, _max_height);
|
||||
_pc->parent_view(_parent_view);
|
||||
_pc->start("init", "init");
|
||||
|
||||
Timed_semaphore view_ready_semaphore;
|
||||
@ -289,6 +291,9 @@ QPluginWidget::QPluginWidget(QWidget *parent, QUrl plugin_url, QString &args,
|
||||
QNitpickerViewWidget(parent),
|
||||
_plugin_loading_state(LOADING),
|
||||
_plugin_starter(0),
|
||||
_plugin_starter_started(false),
|
||||
_plugin_url(plugin_url),
|
||||
_plugin_args(args),
|
||||
_max_width(max_width),
|
||||
_max_height(max_height)
|
||||
{
|
||||
@ -302,11 +307,6 @@ QPluginWidget::QPluginWidget(QWidget *parent, QUrl plugin_url, QString &args,
|
||||
_last->cleanup();
|
||||
_last = this;
|
||||
}
|
||||
|
||||
_plugin_starter = new PluginStarter(plugin_url, args, max_width, max_height);
|
||||
_plugin_starter->moveToThread(_plugin_starter);
|
||||
connect(_plugin_starter, SIGNAL(finished()), this, SLOT(pluginStartFinished()));
|
||||
_plugin_starter->start();
|
||||
}
|
||||
|
||||
|
||||
@ -372,6 +372,29 @@ void QPluginWidget::paintEvent(QPaintEvent *event)
|
||||
}
|
||||
|
||||
|
||||
void QPluginWidget::showEvent(QShowEvent *event)
|
||||
{
|
||||
/* only now do we know the parent widget for sure */
|
||||
|
||||
if (!_plugin_starter_started) {
|
||||
|
||||
QNitpickerPlatformWindow *platform_window =
|
||||
dynamic_cast<QNitpickerPlatformWindow*>(window()->windowHandle()->handle());
|
||||
|
||||
_plugin_starter = new PluginStarter(_plugin_url, _plugin_args,
|
||||
_max_width, _max_height,
|
||||
platform_window->view_cap());
|
||||
_plugin_starter->moveToThread(_plugin_starter);
|
||||
connect(_plugin_starter, SIGNAL(finished()), this, SLOT(pluginStartFinished()));
|
||||
_plugin_starter->start();
|
||||
|
||||
_plugin_starter_started = true;
|
||||
}
|
||||
|
||||
QNitpickerViewWidget::showEvent(event);
|
||||
}
|
||||
|
||||
|
||||
void QPluginWidget::pluginStartFinished()
|
||||
{
|
||||
_plugin_loading_state = _plugin_starter->plugin_loading_state();
|
||||
|
Loading…
Reference in New Issue
Block a user