Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Okular
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
John Zhang
Okular
Commits
c75a2e52
Commit
c75a2e52
authored
Oct 29, 2016
by
Aleix Pol Gonzalez
🐧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make context menu on a bookmark menu action work again
Solves a todo from porting to kf5 Reviewed by Albert Astals
parent
7304d320
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
13 deletions
+40
-13
part.cpp
part.cpp
+38
-12
part.h
part.h
+2
-1
No files found.
part.cpp
View file @
c75a2e52
...
...
@@ -44,6 +44,7 @@
#include <QSpinBox>
#include <QStandardPaths>
#include <QWidgetAction>
#include <QContextMenuEvent>
#include <KAboutApplicationDialog>
#include <KActionCollection>
...
...
@@ -2156,15 +2157,8 @@ void Part::slotRenameCurrentViewportBookmark()
slotRenameBookmark
(
m_document
->
viewport
()
);
}
void
Part
::
slotA
boutToShowContextMenu
(
QMenu
*
/*menu*/
,
QAction
*
action
,
QMenu
*
contextMenu
)
bool
Part
::
a
boutToShowContextMenu
(
QMenu
*
/*menu*/
,
QAction
*
action
,
QMenu
*
contextMenu
)
{
const
QList
<
QAction
*>
actions
=
contextMenu
->
findChildren
<
QAction
*>
(
QStringLiteral
(
"OkularPrivateRenameBookmarkActions"
));
foreach
(
QAction
*
a
,
actions
)
{
contextMenu
->
removeAction
(
a
);
delete
a
;
}
KBookmarkAction
*
ba
=
dynamic_cast
<
KBookmarkAction
*>
(
action
);
if
(
ba
!=
NULL
)
{
...
...
@@ -2174,6 +2168,7 @@ void Part::slotAboutToShowContextMenu(QMenu * /*menu*/, QAction *action, QMenu *
renameAction
->
setData
(
ba
->
property
(
"htmlRef"
).
toString
());
renameAction
->
setObjectName
(
QStringLiteral
(
"OkularPrivateRenameBookmarkActions"
));
}
return
ba
;
}
void
Part
::
slotPreviousBookmark
()
...
...
@@ -3009,12 +3004,10 @@ void Part::rebuildBookmarkMenu( bool unplugActions )
bool
containerFound
=
false
;
for
(
int
i
=
0
;
!
containerFound
&&
i
<
clients
.
size
();
++
i
)
{
Q
Widget
*
container
=
factory
()
->
container
(
QStringLiteral
(
"bookmarks"
),
clients
[
i
]
);
Q
Menu
*
container
=
dynamic_cast
<
QMenu
*>
(
factory
()
->
container
(
QStringLiteral
(
"bookmarks"
),
clients
[
i
])
);
if
(
container
&&
container
->
actions
().
contains
(
m_bookmarkActions
.
first
()))
{
Q_ASSERT
(
dynamic_cast
<
QMenu
*>
(
container
));
disconnect
(
container
,
0
,
this
,
0
);
connect
(
container
,
SIGNAL
(
aboutToShowContextMenu
(
QMenu
*
,
QAction
*
,
QMenu
*
)),
this
,
SLOT
(
slotAboutToShowContextMenu
(
QMenu
*
,
QAction
*
,
QMenu
*
)));
// kf5 FIXME
container
->
installEventFilter
(
this
);
containerFound
=
true
;
}
}
...
...
@@ -3024,6 +3017,39 @@ void Part::rebuildBookmarkMenu( bool unplugActions )
m_nextBookmark
->
setEnabled
(
havebookmarks
);
}
bool
Part
::
eventFilter
(
QObject
*
watched
,
QEvent
*
event
)
{
switch
(
event
->
type
())
{
case
QEvent
::
ContextMenu
:
{
QContextMenuEvent
*
e
=
static_cast
<
QContextMenuEvent
*>
(
event
);
QMenu
*
menu
=
static_cast
<
QMenu
*>
(
watched
);
QScopedPointer
<
QMenu
>
ctxMenu
(
new
QMenu
);
QPoint
pos
;
bool
ret
=
false
;
if
(
e
->
reason
()
==
QContextMenuEvent
::
Mouse
)
{
pos
=
e
->
pos
();
ret
=
aboutToShowContextMenu
(
menu
,
menu
->
actionAt
(
e
->
pos
()),
ctxMenu
.
data
());
}
else
if
(
menu
->
activeAction
())
{
pos
=
menu
->
actionGeometry
(
menu
->
activeAction
()).
center
();
ret
=
aboutToShowContextMenu
(
menu
,
menu
->
activeAction
(),
ctxMenu
.
data
());
}
ctxMenu
->
exec
(
menu
->
mapToGlobal
(
pos
));
if
(
ret
)
{
event
->
accept
();
}
return
ret
;
}
default:
break
;
}
return
false
;
}
void
Part
::
updateAboutBackendAction
()
{
const
KPluginMetaData
data
=
m_document
->
generatorInfo
();
...
...
part.h
View file @
c75a2e52
...
...
@@ -190,7 +190,6 @@ class OKULARPART_EXPORT Part : public KParts::ReadWritePart, public Okular::Docu
void
slotAddBookmark
();
void
slotRenameBookmarkFromMenu
();
void
slotRenameCurrentViewportBookmark
();
void
slotAboutToShowContextMenu
(
QMenu
*
menu
,
QAction
*
action
,
QMenu
*
contextMenu
);
void
slotPreviousBookmark
();
void
slotNextBookmark
();
void
slotFindNext
();
...
...
@@ -240,6 +239,8 @@ class OKULARPART_EXPORT Part : public KParts::ReadWritePart, public Okular::Docu
void
moveSplitter
(
const
int
sideWidgetSize
);
private:
bool
aboutToShowContextMenu
(
QMenu
*
menu
,
QAction
*
action
,
QMenu
*
contextMenu
);
bool
eventFilter
(
QObject
*
watched
,
QEvent
*
event
)
override
;
Document
::
OpenResult
doOpenFile
(
const
QMimeType
&
mime
,
const
QString
&
fileNameToOpen
,
bool
*
isCompressedFile
);
void
setupViewerActions
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment