Commit 25669cd5 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Raise window when activating instance

parent d16a2117
Pipeline #177578 passed with stage
in 1 minute and 48 seconds
......@@ -14,3 +14,4 @@ Dependencies:
'frameworks/ksonnet': '@stable'
'frameworks/kdoctools': '@stable'
'frameworks/kglobalaccel': '@stable'
'frameworks/kwindowsystem': '@stable'
......@@ -39,6 +39,7 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Sonnet
DocTools
GlobalAccel
WindowSystem
)
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050f00)
......@@ -94,6 +95,7 @@ target_link_libraries(kmenuedit
KF5::SonnetCore
KF5::SonnetUi
KF5::XmlGui
KF5::WindowSystem
)
# add clang-format target for all our real source files
......
......@@ -12,14 +12,13 @@
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <Kdelibs4ConfigMigrator>
#endif
#include <KWindowSystem>
#include <kdbusservice.h>
#include "kmenuedit.h"
#include <QApplication>
#include <QCommandLineParser>
static KMenuEdit *menuEdit = nullptr;
class KMenuApplication : public QApplication
{
public:
......@@ -67,15 +66,28 @@ int main(int argc, char **argv)
parser.process(app);
aboutData.processCommandLine(&parser);
const auto args = parser.positionalArguments();
auto *menuEdit = new KMenuEdit();
menuEdit = new KMenuEdit();
if (!args.isEmpty()) {
menuEdit->selectMenu(args.at(0));
if (args.count() > 1) {
menuEdit->selectMenuEntry(args.at(1));
auto useArgs = [menuEdit](const QCommandLineParser &parser) {
const QStringList args = parser.positionalArguments();
if (!args.isEmpty()) {
menuEdit->selectMenu(args.at(0));
if (args.count() > 1) {
menuEdit->selectMenuEntry(args.at(1));
}
}
}
};
useArgs(parser);
QObject::connect(&service, &KDBusService::activateRequested, menuEdit, [useArgs, &parser, menuEdit](const QStringList &args, const QString & /*workDir*/) {
parser.parse(args);
useArgs(parser);
KWindowSystem::updateStartupId(menuEdit->windowHandle());
KWindowSystem::activateWindow(menuEdit->windowHandle());
});
menuEdit->show();
return app.exec();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment