Skip to content

Commit 1c27f43

Browse files
committed
better context menu
1 parent 9fd8b31 commit 1c27f43

File tree

4 files changed

+17
-39
lines changed

4 files changed

+17
-39
lines changed

src/webengine-page.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ bool QPage::acceptNavigationRequest(const QUrl &url,
7474
bool isMainFrame)
7575
{
7676
// Handle filesystem dialogs:
77-
if ((url.scheme() == "file" or url.authority() == "localhost") and
77+
if ((url.scheme() == "file" or url.host() == "localhost") and
7878
type == QWebEnginePage::NavigationTypeLinkClicked and
7979
url.fileName().contains(".dialog") and
8080
isMainFrame == true) {

src/webengine-view.h

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,12 @@ public slots:
8080

8181
QMenu menu;
8282

83-
if (!contextMenuTest.isContentEditable()) {
84-
if (contextMenuTest.selectedText().length() == 0) {
85-
QAction *selectAllAct = menu
86-
.addAction(
87-
qApp->property("selectAllLabel").toString());
88-
QObject::connect(selectAllAct, SIGNAL(triggered()),
89-
this, SLOT(qSelectAllAction()));
90-
}
91-
92-
if (contextMenuTest.selectedText().length() > 0) {
93-
QAction *copyAct = menu
94-
.addAction(qApp->property("copyLabel").toString());
95-
QObject::connect(copyAct, SIGNAL(triggered()),
96-
this, SLOT(qCopyAction()));
97-
}
83+
if (!contextMenuTest.isContentEditable() and
84+
contextMenuTest.selectedText().length() > 0) {
85+
QAction *copyAct = menu
86+
.addAction(qApp->property("copyLabel").toString());
87+
QObject::connect(copyAct, SIGNAL(triggered()),
88+
this, SLOT(qCopyAction()));
9889
}
9990

10091
if (contextMenuTest.isContentEditable()) {

src/webkit-page.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ public slots:
440440

441441
// Handle filesystem dialogs:
442442
if ((request.url().scheme() == "file" or
443-
request.url().authority() == "localhost") and
443+
request.url().host() == "localhost") and
444444
navigationType == QWebPage::NavigationTypeLinkClicked and
445445
request.url().fileName().contains(".dialog")) {
446446
qHandleDialogs(request.url().fileName().replace(".dialog", ""));

src/webkit-view.h

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -79,40 +79,27 @@ public slots:
7979

8080
QMenu menu;
8181

82-
if (!contextMenuTest.isContentEditable()) {
83-
if (!contextMenuTest.isContentSelected()) {
84-
QAction *selectAllAct =
85-
menu.addAction(
86-
qApp->property("selectAllLabel").toString());
87-
QObject::connect(selectAllAct, SIGNAL(triggered()),
88-
this, SLOT(qSelectAllAction()));
89-
}
90-
91-
if (contextMenuTest.isContentSelected()) {
92-
QAction *copyAct =
93-
menu.addAction(
94-
qApp->property("copyLabel").toString());
95-
QObject::connect(copyAct, SIGNAL(triggered()),
96-
this, SLOT(qCopyAction()));
97-
}
82+
if (!contextMenuTest.isContentEditable() and
83+
contextMenuTest.isContentSelected()) {
84+
QAction *copyAct =
85+
menu.addAction(qApp->property("copyLabel").toString());
86+
QObject::connect(copyAct, SIGNAL(triggered()),
87+
this, SLOT(qCopyAction()));
9888
}
9989

10090
if (contextMenuTest.isContentEditable()) {
10191
QAction *cutAct =
102-
menu.addAction(
103-
qApp->property("cutLabel").toString());
92+
menu.addAction(qApp->property("cutLabel").toString());
10493
QObject::connect(cutAct, SIGNAL(triggered()),
10594
this, SLOT(qCutAction()));
10695

10796
QAction *copyAct =
108-
menu.addAction(
109-
qApp->property("copyLabel").toString());
97+
menu.addAction(qApp->property("copyLabel").toString());
11098
QObject::connect(copyAct, SIGNAL(triggered()),
11199
this, SLOT(qCopyAction()));
112100

113101
QAction *pasteAct =
114-
menu.addAction(
115-
qApp->property("pasteLabel").toString());
102+
menu.addAction(qApp->property("pasteLabel").toString());
116103
QObject::connect(pasteAct, SIGNAL(triggered()),
117104
this, SLOT(qPasteAction()));
118105

0 commit comments

Comments
 (0)