diff --git a/src/model/application_menu_config.cc b/src/model/application_menu_config.cc index 869a739..fa5ee11 100644 --- a/src/model/application_menu_config.cc +++ b/src/model/application_menu_config.cc @@ -157,10 +157,16 @@ bool ApplicationMenuConfig::loadEntry(const QString &file) { return false; } } - + // Qt::SkipEmptyParts was introduced in Qt 5.14 +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + const QStringList categories = + desktopFile.entryMap("Desktop Entry")["Categories"] + .split(';', Qt::SkipEmptyParts); +#else const QStringList categories = desktopFile.entryMap("Desktop Entry")["Categories"] - .split(';', QString::SkipEmptyParts); + .split(';', QString::SkipEmptyParts); +#endif if (categories.isEmpty()) { return false; } diff --git a/src/utils/task_helper.cc b/src/utils/task_helper.cc index 7e65c16..6bedd83 100644 --- a/src/utils/task_helper.cc +++ b/src/utils/task_helper.cc @@ -122,7 +122,7 @@ bool TaskHelper::isValidTask(WId wId, int screen, bool currentDesktopOnly, } if (currentActivityOnly) { - KWindowInfo info(wId, 0, NET::WM2Activities); + KWindowInfo info(wId, QFlags(), NET::WM2Activities); if (!info.valid() || (!info.activities().empty() && !info.activities().contains(currentActivity_))) { return false; @@ -133,7 +133,7 @@ bool TaskHelper::isValidTask(WId wId, int screen, bool currentDesktopOnly, } /* static */ TaskInfo TaskHelper::getBasicTaskInfo(WId wId) { - KWindowInfo info(wId, 0, NET::WM2WindowClass); + KWindowInfo info(wId, QFlags(), NET::WM2WindowClass); const auto program = QString(info.windowClassName()); return TaskInfo(wId, program); } diff --git a/src/view/clock.cc b/src/view/clock.cc index 6c1bebd..c7f63dc 100644 --- a/src/view/clock.cc +++ b/src/view/clock.cc @@ -86,7 +86,7 @@ void Clock::mousePressEvent(QMouseEvent *e) { } QString Clock::getLabel() const { - return QDate::currentDate().toString(Qt::SystemLocaleLongDate); + return QLocale::system().toString(QDate::currentDate(), QLocale::ShortFormat); } void Clock::updateTime() { diff --git a/src/view/program.cc b/src/view/program.cc index e798a48..9108c02 100644 --- a/src/view/program.cc +++ b/src/view/program.cc @@ -186,10 +186,60 @@ void Program::pinUnpin() { } } -void Program::launch(const QString& command) { - if (!QProcess::startDetached(command)) { +// Code from Qt 6.0 QProcess::splitCommand +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) +QStringList Program::splitCommand(QStringView command) +{ + QStringList args; + QString tmp; + int quoteCount = 0; + bool inQuote = false; + + // handle quoting. tokens can be surrounded by double quotes + // "hello world". three consecutive double quotes represent + // the quote character itself. + for (int i = 0; i < command.size(); ++i) { + if (command.at(i) == QLatin1Char('"')) { + ++quoteCount; + if (quoteCount == 3) { + // third consecutive quote + quoteCount = 0; + tmp += command.at(i); + } + continue; + } + if (quoteCount) { + if (quoteCount == 1) + inQuote = !inQuote; + quoteCount = 0; + } + if (!inQuote && command.at(i).isSpace()) { + if (!tmp.isEmpty()) { + args += tmp; + tmp.clear(); + } + } else { + tmp += command.at(i); + } + } + if (!tmp.isEmpty()) + args += tmp; + + return args; +} +#endif + +void Program::launch(const QString& commandLine) { + // Code from Qt 6.0 QProcess::startCommand +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) + QStringList args = splitCommand(commandLine); +#else + QStringList args = QProcess::splitCommand(commandLine); +#endif + const QString program = args.takeFirst(); + if (!QProcess::startDetached(program, args)) { KMessageBox::error(nullptr, - i18n("Could not run command: ") + command); + i18n("Could not run command: ") + commandLine); } } diff --git a/src/view/program.h b/src/view/program.h index 8513cdd..2390fd4 100644 --- a/src/view/program.h +++ b/src/view/program.h @@ -91,7 +91,10 @@ class Program : public QObject, public IconBasedDockItem { void pinUnpin(); void launch(); - static void launch(const QString& command); +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) + static QStringList splitCommand(QStringView command); +#endif + static void launch(const QString& commandLine); static void lockScreen() { launch(kLockScreenCommand); } private: