Commit 3165752f authored by David Jarvie's avatar David Jarvie

Report if terminal for command alarms is not configured

Previously, the only indication that no terminal was configured for
command alarms was a misleading error message "Failure to execute
command" when the alarm triggered. Now a warning is given when the
alarm is created, and the error message is improved at trigger time.
parent 6bd3af54
KAlarm Change Log
=== Version 2.11.13 (KDE Applications 17.04) --- 2 January 2017 ===
+ Report if terminal for command alarms is not configured.
=== Version 2.11.12 (KDE Applications 16.12.1) --- 1 January 2017 ===
+ Fix Export Alarms file save error [KDE Bug 374337]
+ Fix arrow/page up/down keys not working in date edit control
......
/*
* editdlgtypes.cpp - dialogs to create or edit alarm or alarm template types
* Program: kalarm
* Copyright © 2001-2014 by David Jarvie <djarvie@kde.org>
* Copyright © 2001-2017 by David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -983,6 +983,13 @@ bool EditCommandAlarmDlg::type_validate(bool trial)
// Convert the log file to an absolute path
mCmdLogFileEdit->setText(info.absoluteFilePath());
}
else if (mCmdOutputGroup->checkedButton() == mCmdExecInTerm)
{
if (KAMessageBox::warningContinueCancel(this, xi18nc("@info", "<para>No terminal is selected for command alarms.</para>"
"<para>Please set it in the <application>KAlarm</application> Configuration dialog.</para>"))
!= KMessageBox::Continue)
return false;
}
return true;
}
......
/*
* kalarmapp.cpp - the KAlarm application object
* Program: kalarm
* Copyright © 2001-2016 by David Jarvie <djarvie@kde.org>
* Copyright © 2001-2017 by David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -2028,6 +2028,14 @@ ShellProcess* KAlarmApp::doShellCommand(const QString& command, const KAEvent& e
{
// Execute the command in a terminal window.
cmd = composeXTermCommand(command, event, alarm, flags, tmpXtermFile);
if (cmd.isEmpty())
{
qCWarning(KALARM_LOG) << "Command failed (no terminal selected)";
QStringList errors;
errors << i18nc("@info", "Failed to execute command\n(no terminal selected for command alarms)");
commandErrorMsg(Q_NULLPTR, event, alarm, flags, errors);
return Q_NULLPTR;
}
}
else
{
......@@ -2103,6 +2111,8 @@ QString KAlarmApp::composeXTermCommand(const QString& command, const KAEvent& ev
qCDebug(KALARM_LOG) << command << "," << event.id();
tempScriptFile.clear();
QString cmd = Preferences::cmdXTermCommand();
if (cmd.isEmpty())
return QString(); // no terminal application is configured
cmd.replace(QLatin1String("%t"), KAboutData::applicationData().displayName()); // set the terminal window title
if (cmd.indexOf(QLatin1String("%C")) >= 0)
{
......@@ -2250,11 +2260,11 @@ void KAlarmApp::slotCommandExited(ShellProcess* proc)
/******************************************************************************
* Output an error message for a shell command, and record the alarm's error status.
*/
void KAlarmApp::commandErrorMsg(const ShellProcess* proc, const KAEvent& event, const KAAlarm* alarm, int flags)
void KAlarmApp::commandErrorMsg(const ShellProcess* proc, const KAEvent& event, const KAAlarm* alarm, int flags, const QStringList& errors)
{
KAEvent::CmdErrType cmderr;
QStringList errmsgs;
QString dontShowAgain;
QStringList errmsgs = errors;
if (flags & ProcData::PRE_ACTION)
{
if (event.extraActionOptions() & KAEvent::DontShowPreActError)
......
/*
* kalarmapp.h - the KAlarm application object
* Program: kalarm
* Copyright © 2001-2016 by David Jarvie <djarvie@kde.org>
* Copyright © 2001-2017 by David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -183,7 +183,7 @@ class KAlarmApp : public QApplication
QString composeXTermCommand(const QString& command, const KAEvent&, const KAAlarm*,
int flags, QString& tempScriptFile) const;
QString createTempScriptFile(const QString& command, bool insertShell, const KAEvent&, const KAAlarm&) const;
void commandErrorMsg(const ShellProcess*, const KAEvent&, const KAAlarm*, int flags = 0);
void commandErrorMsg(const ShellProcess*, const KAEvent&, const KAAlarm*, int flags = 0, const QStringList& errmsgs = QStringList());
void purge(int daysToKeep);
QStringList scheduledAlarmList();
......
Markdown is supported
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