Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[lipstick] Allow overriding the openUrl functionality. Contributes to…
… JB#45282
  • Loading branch information
adenexter committed May 29, 2019
1 parent 6bdadf6 commit 84c4835
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/compositor/lipstickcompositor.cpp
Expand Up @@ -188,11 +188,26 @@ bool LipstickCompositor::openUrl(WaylandClient *client, const QUrl &url)
bool LipstickCompositor::openUrl(const QUrl &url)
{
#if defined(HAVE_CONTENTACTION)
ContentAction::Action action = url.scheme() == "file"? ContentAction::Action::defaultActionForFile(url.toString()) : ContentAction::Action::defaultActionForScheme(url.toString());
if (action.isValid()) {
action.trigger();
const bool isFile = url.scheme() == QLatin1String("file");
ContentAction::Action defaultAction = isFile
? ContentAction::Action::defaultActionForFile(url)
: ContentAction::Action::defaultActionForScheme(url.toString());

static const QMetaMethod requestSignal = QMetaMethod::fromSignal(
&LipstickCompositor::openUrlRequested);
if (isSignalConnected(requestSignal)) {
openUrlRequested(
url,
defaultAction,
isFile
? ContentAction::Action::actionsForFile(url)
: ContentAction::Action::actionsForScheme(url.toString()));
return true;
} else if (defaultAction.isValid()) {
defaultAction.trigger();
}
return action.isValid();

return defaultAction.isValid();
#else
Q_UNUSED(url)
return false;
Expand Down
9 changes: 9 additions & 0 deletions src/compositor/lipstickcompositor.h
Expand Up @@ -33,6 +33,10 @@ class QOrientationSensor;
class LipstickRecorderManager;
class LipstickKeymap;

namespace ContentAction {
class Action;
}

class LIPSTICK_EXPORT LipstickCompositor : public QQuickWindow, public QWaylandQuickCompositor,
public QQmlParserStatus
{
Expand Down Expand Up @@ -154,6 +158,11 @@ class LIPSTICK_EXPORT LipstickCompositor : public QQuickWindow, public QWaylandQ

void showUnlockScreen();

void openUrlRequested(
const QUrl &url,
const ContentAction::Action &defaultAction,
const QList<ContentAction::Action> &candidateActions);

private slots:
void surfaceMapped();
void surfaceUnmapped();
Expand Down

0 comments on commit 84c4835

Please sign in to comment.