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
K
kumir2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
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
kumir
kumir2
Commits
8514867b
Commit
8514867b
authored
Sep 05, 2014
by
Victor Yacovlev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DocBookViewer: context menu && copy example link
parent
20d365bb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
28 deletions
+101
-28
share/kumir2/translations/DocBookViewer_ru.ts
share/kumir2/translations/DocBookViewer_ru.ts
+36
-26
src/shared/docbookviewer/CMakeLists.txt
src/shared/docbookviewer/CMakeLists.txt
+1
-1
src/shared/docbookviewer/contentview.cpp
src/shared/docbookviewer/contentview.cpp
+58
-1
src/shared/docbookviewer/contentview.h
src/shared/docbookviewer/contentview.h
+6
-0
No files found.
share/kumir2/translations/DocBookViewer_ru.ts
View file @
8514867b
...
...
@@ -4,9 +4,9 @@
<
context
>
<
name
>
DocBookViewer
::
ContentView
<
/name
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
511
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
524
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
1
403
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
619
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
632
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
1
544
"
/>
<
source
>
Table
&
amp
;
nbsp
;
%
1
.
<
/source
>
<
translation
>
Таблица
&
amp
;
nbsp
;
%
1
.
<
/translation
>
<
/message
>
...
...
@@ -15,54 +15,64 @@
<
translation
type
=
"
obsolete
"
>
Контекст
:
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
667
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
67
"
/>
<
source
>
Copy
<
/source
>
<
translation
>
Скопировать
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
493
"
/>
<
source
>
Copy
example
<
/source
>
<
translation
>
Скопировать
пример
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
775
"
/>
<
source
>
See
%
1
for
more
details
.
<
/source
>
<
translation
>
Подробное
описание
см
.
в
%
1
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
687
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
706
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
1
402
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
795
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
814
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
1
543
"
/>
<
source
>
Example
&
amp
;
nbsp
;
%
1
.
<
/source
>
<
translation
>
Пример
&
amp
;
nbsp
;
%
1
.
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
727
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
835
"
/>
<
source
>
Algorithm
<
/source
>
<
translation
>
Алгоритм
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
758
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
866
"
/>
<
source
>
Synopsis
:
<
/source
>
<
translation
>
Синтаксис
:
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
992
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
1106
"
/>
<
source
>
Figure
&
amp
;
nbsp
;
%
1
<
/source
>
<
translation
>
Рисунок
&
amp
;
nbsp
;
%
1
.
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
1
227
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
1
358
"
/>
<
source
>
(
see
&
amp
;
nbsp
;
&
lt
;
a
href
=&
quot
;
%
1
&
quot
;
&
gt
;
%
2
&
lt
;
/a>
)
</
source
>
<
translation
>
(
см
.
&
amp
;
nbsp
;
&
lt
;
a
href
=&
quot
;
%
1
&
quot
;
&
gt
;
%
2
&
lt
;
/a>
)
</
translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
1
334
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
1
472
"
/>
<
source
>
List
of
examples
in
&
quot
;
%
1
&
quot
;
<
/source
>
<
translation
>
Список
примеров
в
&
quot
;
%
1
&
quot
;
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
1
337
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
1
475
"
/>
<
source
>
List
of
tables
in
&
quot
;
%
1
&
quot
;
<
/source
>
<
translation
>
Список
таблиц
в
&
quot
;
%
1
&
quot
;
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
1
341
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
1
479
"
/>
<
source
>
List
of
Standard
Library
algorithms
<
/source
>
<
translation
>
Список
встроенных
алгоритмов
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
1
343
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/contentview.cpp
"
line
=
"
1
481
"
/>
<
source
>
List
of
algorithms
of
module
&
quot
;
%
1
&
quot
;
<
/source
>
<
translation
>
Список
алгоритмов
исполнителя
&
quot
;
%
1
&
quot
;
<
/translation
>
<
/message
>
...
...
@@ -70,22 +80,22 @@
<
context
>
<
name
>
DocBookViewer
::
DocBookViewImpl
<
/name
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/docbookview_impl.cpp
"
line
=
"
8
0
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/docbookview_impl.cpp
"
line
=
"
8
4
"
/>
<
source
>
Hide
side
bar
<
/source
>
<
translation
>
Скрыть
панель
навигации
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/docbookview_impl.cpp
"
line
=
"
8
1
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/docbookview_impl.cpp
"
line
=
"
8
5
"
/>
<
source
>
Show
side
bar
<
/source
>
<
translation
>
Показать
панель
навигации
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/docbookview_impl.cpp
"
line
=
"
2
19
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/docbookview_impl.cpp
"
line
=
"
2
23
"
/>
<
source
>
Toggle
sidebar
visible
<
/source
>
<
translation
>
Показывать
боковую
панель
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/docbookview_impl.cpp
"
line
=
"
22
2
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/docbookview_impl.cpp
"
line
=
"
22
6
"
/>
<
source
>
Print
...
<
/source
>
<
translation
>
Печать
...
<
/translation
>
<
/message
>
...
...
@@ -209,10 +219,10 @@
<
translation
>
Алгоритмы
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/sidepanel.ui
"
line
=
"
1
38
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/sidepanel.ui
"
line
=
"
1
8
0
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/sidepanel.ui
"
line
=
"
2
22
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/sidepanel.ui
"
line
=
"
2
6
4
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/sidepanel.ui
"
line
=
"
1
43
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/sidepanel.ui
"
line
=
"
1
9
0
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/sidepanel.ui
"
line
=
"
2
37
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/sidepanel.ui
"
line
=
"
2
8
4
"
/>
<
source
>
Filter
:
<
/source
>
<
translation
>&
amp
;
Фильтр
:
<
/translation
>
<
/message
>
...
...
@@ -235,17 +245,17 @@
<
translation
type
=
"
obsolete
"
>
Искать
:
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/sidepanel.cpp
"
line
=
"
23
1
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/sidepanel.cpp
"
line
=
"
23
2
"
/>
<
source
>
List
of
examples
in
&
quot
;
%
1
&
quot
;
<
/source
>
<
translation
>
Список
примеров
в
&
quot
;
%
1
&
quot
;
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/sidepanel.cpp
"
line
=
"
2
59
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/sidepanel.cpp
"
line
=
"
2
60
"
/>
<
source
>
List
of
tables
in
&
quot
;
%
1
&
quot
;
<
/source
>
<
translation
>
Список
таблиц
в
&
quot
;
%
1
&
quot
;
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../../src/shared/docbookviewer/sidepanel.cpp
"
line
=
"
2
79
"
/>
<
location
filename
=
"
../../../src/shared/docbookviewer/sidepanel.cpp
"
line
=
"
2
80
"
/>
<
source
>
Standard
Library
functions
<
/source
>
<
translation
>
Встроенные
алгоритмы
<
/translation
>
<
/message
>
...
...
src/shared/docbookviewer/CMakeLists.txt
View file @
8514867b
...
...
@@ -76,7 +76,7 @@ else()
endif
()
add_library
(
DocBookViewer SHARED
${
SOURCES
}
${
MOC_SOURCES
}
${
UI_SOURCES
}
)
target_link_libraries
(
DocBookViewer
${
QT_LIBRARIES
}
ExtensionSystem
)
target_link_libraries
(
DocBookViewer
${
QT_LIBRARIES
}
ExtensionSystem
Widgets
)
set_property
(
TARGET DocBookViewer APPEND PROPERTY COMPILE_DEFINITIONS LIBRARY_BUILD
)
if
(
${
BUILD_AS_PART_OF_KUMIR
}
)
...
...
src/shared/docbookviewer/contentview.cpp
View file @
8514867b
...
...
@@ -3,6 +3,7 @@
#include "mathmlrenderer.h"
#include "extensionsystem/pluginmanager.h"
#include "widgets/iconprovider.h"
#include <QUrl>
#include <QtCore>
...
...
@@ -59,6 +60,15 @@ ContentView::ContentView(QWidget *parent)
ExtraFontsLoaded_
=
true
;
}
#endif
contextMenu_
=
new
QMenu
(
this
);
actionCopyToClipboard_
=
contextMenu_
->
addAction
(
Widgets
::
IconProvider
::
self
()
->
iconForName
(
"edit-copy"
),
tr
(
"Copy"
),
this
,
SLOT
(
copy
())
);
actionCopyToClipboard_
->
setEnabled
(
false
);
connect
(
this
,
SIGNAL
(
copyAvailable
(
bool
)),
actionCopyToClipboard_
,
SLOT
(
setEnabled
(
bool
)));
}
QSize
ContentView
::
minimumSizeHint
()
const
...
...
@@ -463,8 +473,27 @@ QString ContentView::programTextForLanguage(const QString &source,
QString
ContentView
::
renderProgramListing
(
ModelPtr
data
)
const
{
QString
result
=
"<pre align='left' class='code'>"
;
QString
result
;
bool
parentIsExample
=
false
;
ModelPtr
p
=
data
->
parent
();
while
(
p
)
{
if
(
Example
==
p
->
modelType
())
{
parentIsExample
=
true
;
break
;
}
p
=
p
->
parent
();
}
const
QString
programText
=
renderChilds
(
data
);
if
(
parentIsExample
)
{
const
QByteArray
b64Text
=
programText
.
toUtf8
().
toBase64
();
const
QString
href
=
QString
::
fromLatin1
(
"to_clipboard:%1"
)
.
arg
(
QString
::
fromLatin1
(
b64Text
));
result
+=
"<div align='right'><a href='"
+
href
+
"'>"
;
result
+=
"<img src='icon:edit-copy:16'/> "
;
result
+=
tr
(
"Copy example"
);
result
+=
"</a></div>
\n
"
;
}
result
+=
"<pre align='left' class='code'>"
;
result
+=
programTextForLanguage
(
programText
,
data
->
role
());
result
+=
"</pre>
\n
"
;
return
result
;
...
...
@@ -1189,6 +1218,21 @@ QVariant ContentView::loadResource(int type, const QUrl &name)
}
}
}
else
if
(
link
.
startsWith
(
"icon:"
))
{
const
QStringList
parts
=
link
.
split
(
":"
);
if
(
parts
.
count
()
>
1
)
{
QSize
iconSize
(
16
,
16
);
if
(
parts
.
count
()
>
2
)
{
iconSize
=
QSize
(
parts
[
2
].
toInt
(),
parts
[
2
].
toInt
());
}
const
QIcon
icon
=
Widgets
::
IconProvider
::
self
()
->
iconForName
(
parts
[
1
]);
if
(
!
icon
.
isNull
())
{
ignore
=
false
;
result
=
icon
.
pixmap
(
iconSize
).
toImage
();
}
}
}
}
if
(
ignore
)
{
return
QTextBrowser
::
loadResource
(
type
,
name
);
...
...
@@ -1535,6 +1579,13 @@ void ContentView::handleInternalLink(const QUrl &url)
ds
>>
ptr
;
emit
itemRequest
(
findModelByRawPtr
(
ptr
));
}
else
if
(
url
.
toEncoded
().
startsWith
(
"to_clipboard:"
))
{
const
QByteArray
b64
=
url
.
toEncoded
().
mid
(
13
);
const
QByteArray
u8
=
QByteArray
::
fromBase64
(
b64
);
const
QString
text
=
QString
::
fromUtf8
(
u8
).
trimmed
();
QClipboard
*
clipboard
=
QApplication
::
clipboard
();
clipboard
->
setText
(
text
);
}
}
ModelPtr
ContentView
::
findModelByRawPtr
(
quintptr
raw
)
const
...
...
@@ -1687,6 +1738,12 @@ void ContentView::wheelEvent(QWheelEvent *e)
}
}
void
ContentView
::
contextMenuEvent
(
QContextMenuEvent
*
e
)
{
contextMenu_
->
exec
(
e
->
globalPos
());
e
->
accept
();
}
void
ContentView
::
clearLastAnchorUrl
()
{
if
(
!
ignoreClearAnchorUrl_
)
{
...
...
src/shared/docbookviewer/contentview.h
View file @
8514867b
...
...
@@ -8,6 +8,9 @@
#include <QSharedPointer>
#include <QResizeEvent>
#include <QWheelEvent>
#include <QContextMenuEvent>
#include <QMenu>
#include <QAction>
namespace
DocBookViewer
{
...
...
@@ -31,6 +34,7 @@ signals:
private:
void
resizeEvent
(
QResizeEvent
*
e
);
void
wheelEvent
(
QWheelEvent
*
e
);
void
contextMenuEvent
(
QContextMenuEvent
*
e
);
QString
wrapHTML
(
const
QString
&
body
)
const
;
QString
renderModel
(
ModelPtr
data
)
const
;
...
...
@@ -135,6 +139,8 @@ private /*fields*/:
bool
ignoreClearAnchorUrl_
;
static
bool
ExtraFontsLoaded_
;
QMenu
*
contextMenu_
;
QAction
*
actionCopyToClipboard_
;
private
slots
:
void
clearLastAnchorUrl
();
...
...
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