Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
8da75f69
Commit
8da75f69
authored
Sep 21, 2022
by
Eric Armbruster
🍁
Committed by
Christoph Cullmann
Sep 22, 2022
Browse files
Add an action to detach a tab
parent
ec9b8196
Pipeline
#235715
passed with stage
in 5 minutes and 46 seconds
Changes
3
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
apps/lib/kateviewmanager.cpp
View file @
8da75f69
...
...
@@ -425,6 +425,15 @@ void KateViewManager::openUrl(const QUrl &url)
openUrl
(
url
,
QString
());
}
KTextEditor
::
View
*
KateViewManager
::
openViewForDoc
(
KTextEditor
::
Document
*
doc
)
{
// forward to currently active view space
activeViewSpace
()
->
registerDocument
(
doc
);
connect
(
doc
,
&
KTextEditor
::
Document
::
documentSavedOrUploaded
,
this
,
&
KateViewManager
::
documentSavedOrUploaded
);
return
activateView
(
doc
);
}
void
KateViewManager
::
addPositionToHistory
(
const
QUrl
&
url
,
KTextEditor
::
Cursor
pos
)
{
if
(
KateViewSpace
*
avs
=
activeViewSpace
())
{
...
...
apps/lib/kateviewmanager.h
View file @
8da75f69
...
...
@@ -72,6 +72,8 @@ public:
KTextEditor
::
View
*
openUrlWithView
(
const
QUrl
&
url
,
const
QString
&
encoding
);
KTextEditor
::
View
*
openViewForDoc
(
KTextEditor
::
Document
*
doc
);
public
Q_SLOTS
:
void
openUrl
(
const
QUrl
&
url
);
void
addPositionToHistory
(
const
QUrl
&
url
,
KTextEditor
::
Cursor
pos
);
...
...
apps/lib/kateviewspace.cpp
View file @
8da75f69
...
...
@@ -961,6 +961,9 @@ void KateViewSpace::showContextMenu(int idx, const QPoint &globalPos)
QAction
*
aCloseOthers
=
menu
.
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"tab-close-other"
)),
i18n
(
"Close Other &Documents"
));
QAction
*
aCloseAll
=
menu
.
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"tab-close-all"
)),
i18n
(
"Close &All Documents"
));
menu
.
addSeparator
();
QAction
*
aDetachTab
=
menu
.
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"tab-detach"
)),
i18n
(
"D&etach Document"
));
aDetachTab
->
setWhatsThis
(
i18n
(
"Opens the document in a new window and closes it in the current window"
));
menu
.
addSeparator
();
QAction
*
aCopyPath
=
addActionFromCollection
(
&
menu
,
"file_copy_filepath"
);
QAction
*
aOpenFolder
=
addActionFromCollection
(
&
menu
,
"file_open_containing_folder"
);
QAction
*
aFileProperties
=
addActionFromCollection
(
&
menu
,
"file_properties"
);
...
...
@@ -983,6 +986,7 @@ void KateViewSpace::showContextMenu(int idx, const QPoint &globalPos)
if
(
KateApp
::
self
()
->
documentManager
()
->
documentList
().
size
()
<
2
)
{
aCloseOthers
->
setEnabled
(
false
);
aDetachTab
->
setEnabled
(
false
);
}
if
(
doc
->
url
().
isEmpty
())
{
...
...
@@ -992,6 +996,7 @@ void KateViewSpace::showContextMenu(int idx, const QPoint &globalPos)
aDeleteFile
->
setEnabled
(
false
);
aFileProperties
->
setEnabled
(
false
);
compareUsing
->
setEnabled
(
false
);
aDetachTab
->
setEnabled
(
false
);
}
// both documents must have urls and must not be the same to have the compare feature enabled
...
...
@@ -1046,6 +1051,14 @@ void KateViewSpace::showContextMenu(int idx, const QPoint &globalPos)
i18n
(
"The selected program could not be started. Maybe it is not installed."
),
QMessageBox
::
StandardButton
::
Ok
);
}
}
else
if
(
choice
==
aDetachTab
)
{
auto
mainWindow
=
KateApp
::
self
()
->
newMainWindow
();
mainWindow
->
viewManager
()
->
openViewForDoc
(
doc
);
// use single shot as this action can trigger deletion of this viewspace!
QTimer
::
singleShot
(
0
,
this
,
[
this
,
idx
]()
{
closeTabRequest
(
idx
);
});
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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