Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/model/application_menu_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/task_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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::Property>(), NET::WM2Activities);
if (!info.valid() ||
(!info.activities().empty() && !info.activities().contains(currentActivity_))) {
return false;
Expand All @@ -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::Property>(), NET::WM2WindowClass);
const auto program = QString(info.windowClassName());
return TaskInfo(wId, program);
}
Expand Down
2 changes: 1 addition & 1 deletion src/view/clock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
56 changes: 53 additions & 3 deletions src/view/program.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/view/program.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down