MCPcopy Create free account
hub / github.com/OpenBoard-org/OpenBoard / UBGraphicsWidgetItem

Method UBGraphicsWidgetItem

src/domain/UBGraphicsWidgetItem.cpp:137–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135#endif
136
137UBGraphicsWidgetItem::UBGraphicsWidgetItem(const QUrl &pWidgetUrl, QGraphicsItem *parent)
138 : QGraphicsProxyWidget(parent)
139 , mInitialLoadDone(false)
140 , mIsFreezable(true)
141 , mIsResizable(false)
142 , mLoadIsErronous(false)
143 , mCanBeContent(0)
144 , mCanBeTool(0)
145 , mWidgetUrl(pWidgetUrl)
146 , mIsFrozen(false)
147 , mIsWebActive(true)
148 , mShouldMoveWidget(false)
149 , mUniboardAPI(nullptr)
150{
151 mWebEngineView = new UBWebEngineView();
152 setWidget(mWebEngineView);
153
154 setData(UBGraphicsItemData::ItemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
155
156 // create the page using a profile
157 QWebEngineProfile* profile = UBApplication::webController->webProfile();
158 mWebEngineView->setPage(new WebPage(profile, mWebEngineView));
159
160 // see https://stackoverflow.com/questions/31928444/qt-qwebenginepagesetwebchannel-transport-object
161 mWebChannel = new QWebChannel(this);
162 mWebEngineView->page()->setWebChannel(mWebChannel);
163
164 // NOTE to enable fullscreen, we would have to move the page to a fullscreen view.
165 // webEngineView->settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true);
166
167 setAcceptDrops(true);
168 setAutoFillBackground(false);
169
170 /*
171 * Quick workaround for https://bugreports.qt.io/browse/QTBUG-128241 (bug appearing with Qt 6.7.2, fixed in 6.8.1)
172 */
173#if (QT_VERSION < QT_VERSION_CHECK(6, 7, 2) || QT_VERSION > QT_VERSION_CHECK(6, 8, 0))
174 mWebEngineView->setAttribute(Qt::WA_TranslucentBackground);
175 mWebEngineView->page()->setBackgroundColor(QColor(Qt::transparent));
176#else
177 mWebEngineView->page()->setBackgroundColor(QColor(Qt::white));
178#endif
179 setDelegate(new UBGraphicsWidgetItemDelegate(this));
180
181 setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
182 setAcceptHoverEvents(true);
183
184 // workaround for QTBUG-108284 - to be removed when bug is fixed
185 QWindow* window = mWebEngineView->windowHandle();
186
187 if (window)
188 {
189 window->installEventFilter(this);
190 }
191}
192
193UBGraphicsWidgetItem::~UBGraphicsWidgetItem()
194{

Callers

nothing calls this directly

Calls 4

setDataFunction · 0.85
webProfileMethod · 0.80
setPageMethod · 0.80
pageMethod · 0.80

Tested by

no test coverage detected