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
20fa8af2
Commit
20fa8af2
authored
Sep 08, 2022
by
Waqar Ahmed
Committed by
Christoph Cullmann
Sep 09, 2022
Browse files
Add interfaces for mainWindow functions instead of using metaobject
parent
d1ec5682
Pipeline
#229758
passed with stage
in 7 minutes and 24 seconds
Changes
23
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
addons/compiler-explorer/ce_plugin.h
View file @
20fa8af2
...
...
@@ -42,8 +42,6 @@ public:
*/
explicit
CEPluginView
(
CEPlugin
*
plugin
,
KTextEditor
::
MainWindow
*
mainwindow
);
Q_SIGNAL
void
message
(
const
QVariantMap
&
message
);
/**
* Our Destructor
*/
...
...
addons/compiler-explorer/ce_widget.cpp
View file @
20fa8af2
...
...
@@ -4,6 +4,7 @@
#include
"ce_plugin.h"
#include
"ce_service.h"
#include
"compiledbreader.h"
#include
"ktexteditor_utils.h"
#include
<QComboBox>
#include
<QEvent>
...
...
@@ -569,7 +570,7 @@ void CEWidget::sendMessage(const QString &plainText, bool warn)
genericMessage
.
insert
(
QStringLiteral
(
"type"
),
warn
?
QStringLiteral
(
"Error"
)
:
QStringLiteral
(
"Info"
));
genericMessage
.
insert
(
QStringLiteral
(
"category"
),
i18n
(
"CompilerExplorer"
));
genericMessage
.
insert
(
QStringLiteral
(
"text"
),
plainText
);
Q_EMIT
m_pluginView
->
m
essage
(
genericMessage
);
Utils
::
showM
essage
(
genericMessage
,
m_mainWindow
);
}
void
CEWidget
::
warnIfBadArgs
(
const
QStringList
&
args
)
...
...
addons/externaltools/externaltoolsplugin.cpp
View file @
20fa8af2
...
...
@@ -286,12 +286,7 @@ KateToolRunner *KateExternalToolsPlugin::runnerForTool(const KateExternalTool &t
:
i18n
(
"Running %1: %2 %3 with input %4"
,
copy
->
name
,
copy
->
executable
,
copy
->
arguments
,
tool
.
input
);
// use generic output view for status
QVariantMap
genericMessage
;
genericMessage
.
insert
(
QStringLiteral
(
"type"
),
QStringLiteral
(
"Info"
));
genericMessage
.
insert
(
QStringLiteral
(
"category"
),
i18n
(
"External Tools"
));
genericMessage
.
insert
(
QStringLiteral
(
"categoryIcon"
),
QIcon
::
fromTheme
(
QStringLiteral
(
"system-run"
)));
genericMessage
.
insert
(
QStringLiteral
(
"text"
),
messageText
);
Q_EMIT
pluginView
->
message
(
genericMessage
);
Utils
::
showMessage
(
messageText
,
QIcon
::
fromTheme
(
QStringLiteral
(
"system-run"
)),
i18n
(
"External Tools"
),
QStringLiteral
(
"Info"
),
pluginView
->
mainWindow
());
// Allocate runner on heap such that it lives as long as the child
// process is running and does not block the main thread.
...
...
@@ -402,12 +397,7 @@ void KateExternalToolsPlugin::handleToolFinished(KateToolRunner *runner, int exi
}
// use generic output view for status
QVariantMap
genericMessage
;
genericMessage
.
insert
(
QStringLiteral
(
"type"
),
messageType
);
genericMessage
.
insert
(
QStringLiteral
(
"category"
),
i18n
(
"External Tools"
));
genericMessage
.
insert
(
QStringLiteral
(
"categoryIcon"
),
QIcon
::
fromTheme
(
QStringLiteral
(
"system-run"
)));
genericMessage
.
insert
(
QStringLiteral
(
"text"
),
messageBody
);
Q_EMIT
pluginView
->
message
(
genericMessage
);
Utils
::
showMessage
(
messageBody
,
QIcon
::
fromTheme
(
QStringLiteral
(
"system-run"
)),
i18n
(
"External Tools"
),
messageType
,
pluginView
->
mainWindow
());
// on successful execution => show output
// otherwise the global output pane settings will ensure we see the error output
...
...
addons/externaltools/kateexternaltoolsview.h
View file @
20fa8af2
...
...
@@ -143,14 +143,6 @@ private Q_SLOTS:
void
onDocumentSaved
(
KTextEditor
::
Document
*
doc
);
void
onDocumentAboutToSave
(
KTextEditor
::
Document
*
doc
);
Q_SIGNALS:
/**
* Signal for outgoing message, the host application will handle them!
* Will only be handled inside the main windows of this plugin view.
* @param message outgoing message we send to the host application
*/
void
message
(
const
QVariantMap
&
message
);
private:
KateExternalToolsPlugin
*
m_plugin
;
KTextEditor
::
MainWindow
*
m_mainWindow
;
...
...
addons/git-blame/kategitblameplugin.cpp
View file @
20fa8af2
...
...
@@ -7,6 +7,7 @@
#include
"kategitblameplugin.h"
#include
"commitfilesview.h"
#include
"diffparams.h"
#include
"ktexteditor_utils.h"
#include
<gitprocess.h>
...
...
@@ -310,7 +311,7 @@ void KateGitBlamePluginView::sendMessage(const QString &text, bool error)
genericMessage
.
insert
(
QStringLiteral
(
"category"
),
i18n
(
"Git"
));
genericMessage
.
insert
(
QStringLiteral
(
"categoryIcon"
),
gitIcon
());
genericMessage
.
insert
(
QStringLiteral
(
"text"
),
text
);
Q_EMIT
m
essage
(
genericMessage
);
Utils
::
showM
essage
(
genericMessage
,
m_mainWindow
);
}
void
KateGitBlamePluginView
::
blameFinished
(
int
exitCode
,
QProcess
::
ExitStatus
exitStatus
)
...
...
@@ -582,10 +583,9 @@ void KateGitBlamePluginView::hideToolView()
void
KateGitBlamePluginView
::
showDiffForFile
(
const
QByteArray
&
diffContents
,
const
QString
&
file
)
{
auto
mw
=
m_mainWindow
->
window
();
DiffParams
d
;
d
.
srcFile
=
file
;
QMetaObject
::
invokeMethod
(
mw
,
"showDiff"
,
Q_ARG
(
QByteArray
,
diffContents
),
Q_ARG
(
DiffParams
,
d
)
);
Utils
::
showDiff
(
diffContents
,
d
,
m_mainWindow
);
}
#include
"kategitblameplugin.moc"
addons/git-blame/kategitblameplugin.h
View file @
20fa8af2
...
...
@@ -91,8 +91,6 @@ public:
void
showCommitTreeView
(
const
QUrl
&
url
);
Q_SIGNAL
void
message
(
const
QVariantMap
&
);
private:
void
sendMessage
(
const
QString
&
text
,
bool
error
);
...
...
addons/keyboardmacros/CMakeLists.txt
View file @
20fa8af2
kate_add_plugin
(
keyboardmacrosplugin
)
target_compile_definitions
(
keyboardmacrosplugin PRIVATE TRANSLATION_DOMAIN=
"katekeyboardmacros"
)
target_link_libraries
(
keyboardmacrosplugin PRIVATE KF5::I18n KF5::TextEditor
)
target_link_libraries
(
keyboardmacrosplugin PRIVATE
kateprivate
KF5::I18n KF5::TextEditor
)
target_sources
(
keyboardmacrosplugin
...
...
addons/keyboardmacros/keyboardmacrosplugin.cpp
View file @
20fa8af2
...
...
@@ -3,6 +3,13 @@
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include
"keyboardmacrosplugin.h"
#include
"keyboardmacrosplugincommands.h"
#include
"keyboardmacrospluginview.h"
#include
"keycombination.h"
#include
"ktexteditor_utils.h"
#include
"macro.h"
#include
<QAction>
#include
<QApplication>
#include
<QCoreApplication>
...
...
@@ -33,12 +40,6 @@
#include
<KTextEditor/Plugin>
#include
<KTextEditor/View>
#include
"keyboardmacrosplugin.h"
#include
"keyboardmacrosplugincommands.h"
#include
"keyboardmacrospluginview.h"
#include
"keycombination.h"
#include
"macro.h"
Q_LOGGING_CATEGORY
(
KM_DBG
,
"kate.plugin.keyboardmacros"
,
QtWarningMsg
)
K_PLUGIN_FACTORY_WITH_JSON
(
KeyboardMacrosPluginFactory
,
"keyboardmacrosplugin.json"
,
registerPlugin
<
KeyboardMacrosPlugin
>
();)
...
...
@@ -132,7 +133,7 @@ void KeyboardMacrosPlugin::sendMessage(const QString &text, bool error)
genericMessage
.
insert
(
QStringLiteral
(
"category"
),
i18n
(
"Keyboard Macros"
));
genericMessage
.
insert
(
QStringLiteral
(
"categoryIcon"
),
QIcon
::
fromTheme
(
QStringLiteral
(
"input-keyboard"
)));
genericMessage
.
insert
(
QStringLiteral
(
"text"
),
text
);
Q_EMIT
m
essage
(
genericMessage
);
Utils
::
showM
essage
(
genericMessage
,
KTextEditor
::
Editor
::
instance
()
->
application
()
->
activeMainWindow
()
);
}
void
KeyboardMacrosPlugin
::
displayMessage
(
const
QString
&
text
,
KTextEditor
::
Message
::
MessageType
type
)
...
...
addons/keyboardmacros/keyboardmacrosplugin.h
View file @
20fa8af2
...
...
@@ -64,9 +64,6 @@ private:
void
sendMessage
(
const
QString
&
text
,
bool
error
);
void
displayMessage
(
const
QString
&
text
,
KTextEditor
::
Message
::
MessageType
type
);
Q_SIGNALS:
void
message
(
const
QVariantMap
&
message
);
// Events filter and focus management helpers
public:
bool
eventFilter
(
QObject
*
obj
,
QEvent
*
event
)
override
;
...
...
addons/lspclient/lspclientpluginview.cpp
View file @
20fa8af2
...
...
@@ -568,12 +568,6 @@ class LSPClientPluginViewImpl : public QObject, public KXMLGUIClient, public KTe
SemanticHighlighter
m_semHighlightingManager
;
Q_SIGNALS:
/**
* Signal for outgoing message, the host application will handle them!
* Will only be handled inside the main windows of this plugin view.
* @param message outgoing message we send to the host application
*/
void
message
(
const
QVariantMap
&
message
);
/**
* Signal for location changed.
...
...
@@ -2738,7 +2732,7 @@ public:
}
// host application will handle these message for us, including auto-show settings
Q_EMIT
m
essage
(
genericMessage
);
Utils
::
showM
essage
(
genericMessage
,
m_mainWindow
);
}
// params type is same for show or log and is treated the same way
...
...
addons/project/branchesdialog.cpp
View file @
20fa8af2
...
...
@@ -7,6 +7,7 @@
#include
"branchesdialogmodel.h"
#include
"gitprocess.h"
#include
"kateprojectpluginview.h"
#include
"ktexteditor_utils.h"
#include
<QCoreApplication>
#include
<QKeyEvent>
...
...
@@ -137,5 +138,5 @@ void BranchesDialog::sendMessage(const QString &plainText, bool warn)
genericMessage
.
insert
(
QStringLiteral
(
"category"
),
i18n
(
"Git"
));
genericMessage
.
insert
(
QStringLiteral
(
"categoryIcon"
),
gitIcon
());
genericMessage
.
insert
(
QStringLiteral
(
"text"
),
plainText
);
Q_EMIT
m_pluginView
->
message
(
genericMessage
);
Utils
::
showMessage
(
genericMessage
,
m_pluginView
->
mainWindow
()
);
}
addons/project/comparebranchesview.cpp
View file @
20fa8af2
...
...
@@ -171,10 +171,10 @@ void CompareBranchesView::showDiff(const QModelIndex &idx)
return
;
}
}
auto
mw
=
m_pluginView
->
mainWindow
()
->
window
();
DiffParams
d
;
d
.
tabTitle
=
QStringLiteral
(
"Diff %1[%2 .. %3]"
).
arg
(
Utils
::
fileNameFromPath
(
file
)).
arg
(
m_fromBr
).
arg
(
m_toBr
);
d
.
workingDir
=
m_gitDir
;
d
.
arguments
=
git
.
arguments
();
QMetaObject
::
invokeMethod
(
mw
,
"showDiff"
,
Q_ARG
(
QByteArray
,
git
.
readAllStandardOutput
()),
Q_ARG
(
DiffParams
,
d
));
Utils
::
showDiff
(
git
.
readAllStandardOutput
(),
d
,
m_pluginView
->
mainWindow
(
));
}
addons/project/gitwidget.cpp
View file @
20fa8af2
...
...
@@ -15,6 +15,7 @@
#include
"kateproject.h"
#include
"kateprojectplugin.h"
#include
"kateprojectpluginview.h"
#include
"ktexteditor_utils.h"
#include
"pushpulldialog.h"
#include
"stashdialog.h"
...
...
@@ -459,7 +460,7 @@ void GitWidget::sendMessage(const QString &plainText, bool warn)
genericMessage
.
insert
(
QStringLiteral
(
"category"
),
i18n
(
"Git"
));
genericMessage
.
insert
(
QStringLiteral
(
"categoryIcon"
),
gitIcon
());
genericMessage
.
insert
(
QStringLiteral
(
"text"
),
plainText
);
Q_EMIT
m_pluginView
->
m
essage
(
genericMessage
);
Utils
::
showM
essage
(
genericMessage
,
mainWindow
()
);
}
KTextEditor
::
MainWindow
*
GitWidget
::
mainWindow
()
...
...
@@ -639,7 +640,6 @@ void GitWidget::showDiff(const QString &file, bool staged)
if
(
es
!=
QProcess
::
NormalExit
||
exitCode
!=
0
)
{
sendMessage
(
i18n
(
"Failed to get Diff of file: %1"
,
QString
::
fromUtf8
(
git
->
readAllStandardError
())),
true
);
}
else
{
auto
mw
=
mainWindow
()
->
window
();
DiffParams
d
;
d
.
srcFile
=
file
;
d
.
workingDir
=
m_activeGitDirPath
;
...
...
@@ -650,7 +650,7 @@ void GitWidget::showDiff(const QString &file, bool staged)
// When file is empty, we are showing diff of multiple file usually
const
bool
showfile
=
file
.
isEmpty
()
&&
(
staged
?
m_model
->
stagedFiles
().
size
()
>
1
:
m_model
->
changedFiles
().
size
()
>
1
);
d
.
flags
.
setFlag
(
DiffParams
::
Flag
::
ShowFileName
,
showfile
);
QMetaObject
::
invokeMethod
(
mw
,
"showDiff"
,
Q_ARG
(
QByteArray
,
git
->
readAllStandardOutput
()
)
,
Q_ARG
(
DiffParams
,
d
));
Utils
::
showDiff
(
git
->
readAllStandardOutput
(),
d
,
mainWindow
(
));
}
git
->
deleteLater
();
});
...
...
@@ -950,11 +950,10 @@ void GitWidget::createStashDialog(StashMode m, const QString &gitPath)
auto
stashDialog
=
new
StashDialog
(
this
,
mainWindow
()
->
window
(),
gitPath
);
connect
(
stashDialog
,
&
StashDialog
::
message
,
this
,
&
GitWidget
::
sendMessage
);
connect
(
stashDialog
,
&
StashDialog
::
showStashDiff
,
this
,
[
this
](
const
QByteArray
&
r
)
{
auto
mw
=
mainWindow
()
->
window
();
DiffParams
d
;
d
.
tabTitle
=
i18n
(
"Diff - stash"
);
d
.
workingDir
=
m_activeGitDirPath
;
QMetaObject
::
invokeMethod
(
mw
,
"showDiff"
,
Q_ARG
(
QByteArray
,
r
),
Q_ARG
(
DiffParams
,
d
));
Utils
::
showDiff
(
r
,
d
,
mainWindow
(
));
});
connect
(
stashDialog
,
&
StashDialog
::
done
,
this
,
[
this
,
stashDialog
]
{
updateStatus
();
...
...
addons/project/kateprojectplugin.cpp
View file @
20fa8af2
...
...
@@ -10,6 +10,7 @@
#include
"kateproject.h"
#include
"kateprojectconfigpage.h"
#include
"kateprojectpluginview.h"
#include
"ktexteditor_utils.h"
#include
<kcoreaddons_version.h>
#include
<ktexteditor/application.h>
...
...
@@ -707,5 +708,5 @@ void KateProjectPlugin::sendMessage(const QString &text, bool error)
genericMessage
.
insert
(
QStringLiteral
(
"category"
),
i18n
(
"Project"
));
genericMessage
.
insert
(
QStringLiteral
(
"categoryIcon"
),
QIcon
::
fromTheme
(
QStringLiteral
(
"project-open"
)));
genericMessage
.
insert
(
QStringLiteral
(
"text"
),
text
);
Q_EMIT
m
essage
(
genericMessage
);
Utils
::
showM
essage
(
genericMessage
);
}
addons/project/kateprojectplugin.h
View file @
20fa8af2
...
...
@@ -192,13 +192,6 @@ Q_SIGNALS:
*/
void
configUpdated
();
/**
* Signal for outgoing message, the host application will handle them!
* Will be handled in all open main windows.
* @param message outgoing message we send to the host application
*/
void
message
(
const
QVariantMap
&
message
);
/**
* Signal emitted to tell the views to activate some project.
* Used for loading projects from the command line.
...
...
addons/project/kateprojectpluginview.h
View file @
20fa8af2
...
...
@@ -248,13 +248,6 @@ Q_SIGNALS:
*/
void
gotoSymbol
(
const
QString
&
word
,
int
&
results
);
/**
* Signal for outgoing message, the host application will handle them!
* Will only be handled inside the main windows of this plugin view.
* @param message outgoing message we send to the host application
*/
void
message
(
const
QVariantMap
&
message
);
/**
* Signal for location changed. Location gets saved in history
* of the current KateViewSpace
...
...
addons/project/kateprojectviewtree.cpp
View file @
20fa8af2
...
...
@@ -10,6 +10,7 @@
#include
"kateprojectfiltermodel.h"
#include
"kateprojectpluginview.h"
#include
"kateprojecttreeviewcontextmenu.h"
#include
"ktexteditor_utils.h"
#include
<KTextEditor/Document>
#include
<KTextEditor/MainWindow>
...
...
@@ -135,7 +136,7 @@ void KateProjectViewTree::addFile(const QModelIndex &idx, const QString &fileNam
genericMessage
.
insert
(
QStringLiteral
(
"category"
),
i18n
(
"Project"
));
genericMessage
.
insert
(
QStringLiteral
(
"categoryIcon"
),
QIcon
::
fromTheme
(
QStringLiteral
(
"document-new"
)));
genericMessage
.
insert
(
QStringLiteral
(
"text"
),
i18n
(
"Failed to create file: %1, Error: %2"
,
fileName
,
f
.
errorString
()));
Q_EMIT
m_pluginView
->
message
(
genericMessage
);
Utils
::
showMessage
(
genericMessage
,
m_pluginView
->
mainWindow
()
);
return
;
}
...
...
@@ -160,7 +161,7 @@ void KateProjectViewTree::addDirectory(const QModelIndex &idx, const QString &na
genericMessage
.
insert
(
QStringLiteral
(
"category"
),
i18n
(
"Project"
));
genericMessage
.
insert
(
QStringLiteral
(
"categoryIcon"
),
QIcon
::
fromTheme
(
QStringLiteral
(
"folder-new"
)));
genericMessage
.
insert
(
QStringLiteral
(
"text"
),
i18n
(
"Failed to create dir: %1"
,
name
));
Q_EMIT
m_pluginView
->
message
(
genericMessage
);
Utils
::
showMessage
(
genericMessage
,
m_pluginView
->
mainWindow
()
);
return
;
}
...
...
apps/lib/filehistorywidget.cpp
View file @
20fa8af2
...
...
@@ -325,11 +325,10 @@ void FileHistoryWidget::itemClicked(const QModelIndex &idx)
}
const
QByteArray
contents
(
git
.
readAllStandardOutput
());
auto
mw
=
m_mainWindow
->
window
();
DiffParams
d
;
const
QString
shortCommit
=
QString
::
fromUtf8
(
commit
.
hash
.
mid
(
0
,
7
));
d
.
tabTitle
=
QStringLiteral
(
"%1[%2]"
).
arg
(
Utils
::
fileNameFromPath
(
m_file
),
shortCommit
);
QMetaObject
::
invokeMethod
(
mw
,
"showDiff"
,
Q_ARG
(
QByteArray
,
contents
),
Q_ARG
(
DiffParams
,
d
)
);
Utils
::
showDiff
(
contents
,
d
,
m_mainWindow
);
}
}
...
...
@@ -343,7 +342,7 @@ void FileHistory::showFileHistory(const QString &file, KTextEditor::MainWindow *
const
auto
repoBase
=
getRepoBasePath
(
fi
.
absolutePath
());
if
(
!
repoBase
.
has_value
())
{
// TODO: show message
;
Utils
::
showMessage
(
i18n
(
"%1 doesn't exist in a git repo."
,
file
),
gitIcon
(),
i18n
(
"Git"
),
i18n
(
"Error"
),
mainWindow
)
;
return
;
}
...
...
apps/lib/katemainwindow.cpp
View file @
20fa8af2
...
...
@@ -1338,6 +1338,14 @@ void KateMainWindow::showDiff(const QByteArray &wordDiff, const DiffParams ¶
w
->
openDiff
(
wordDiff
);
}
void
KateMainWindow
::
showMessage
(
const
QVariantMap
&
map
)
{
if
(
!
m_outputView
)
{
return
;
}
m_outputView
->
slotMessage
(
map
);
}
void
KateMainWindow
::
mousePressEvent
(
QMouseEvent
*
e
)
{
switch
(
e
->
button
())
{
...
...
apps/lib/katemainwindow.h
View file @
20fa8af2
...
...
@@ -524,6 +524,11 @@ public Q_SLOTS:
void
showDiff
(
const
QByteArray
&
wordDiff
,
const
DiffParams
&
params
);
/**
* @brief show a message in the output view. See KTextEditor::MainWindow::showMessage for details
*/
void
showMessage
(
const
QVariantMap
&
map
);
private
Q_SLOTS
:
void
slotUpdateBottomViewBar
();
...
...
Prev
1
2
Next
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