Commit cbecc836 authored by David Jarvie's avatar David Jarvie
Browse files

Bug 315401: Add option for a command alarm to not notify execution errors

parent 5a1d70e4
Pipeline #27344 passed with stage
in 8 minutes and 56 seconds
......@@ -5,6 +5,7 @@ KAlarm Change Log
+ Enable selection of multiple calendar files in Import Alarms dialogue.
+ Show alarm calendars sorted by name in calendars list.
+ Return to last used tab in Configuration dialogue when it is reopened.
+ Add option for a command alarm to not notify execution errors [KDE Bug 315401]
+ Fix handling of calendar update or save errors when making alarm changes.
+ Fix possible calendar file corruption if disk is full (requires KDE Frameworks 5.72) [KDE Bug 370708]
+ Allow drag-and-drop of email onto display alarm text edit field.
......
......@@ -769,6 +769,11 @@ void EditCommandAlarmDlg::type_init(QWidget* parent, QVBoxLayout* frameLayout)
connect(mCmdEdit, &CommandEdit::changed, this, &EditCommandAlarmDlg::contentsChanged);
frameLayout->addWidget(mCmdEdit);
mCmdDontShowError = new CheckBox(i18nc("@option:check", "Do not notify errors"), parent);
mCmdDontShowError->setWhatsThis(i18nc("@info:whatsthis", "Do not show error error message if the command fails."));
frameLayout->addWidget(mCmdDontShowError, 0, Qt::AlignLeft);
connect(mCmdDontShowError, &CheckBox::toggled, this, &EditCommandAlarmDlg::contentsChanged);
// What to do with command output
mCmdOutputBox = new QGroupBox(i18nc("@title:group", "Command Output"), parent);
......@@ -845,6 +850,7 @@ void EditCommandAlarmDlg::type_initValues(const KAEvent* event)
if (logType == mCmdLogToFile)
mCmdLogFileEdit->setText(event->logFile()); // set file name before setting radio button
logType->setChecked(true);
mCmdDontShowError->setChecked(event->commandHideError());
}
else
{
......@@ -852,6 +858,7 @@ void EditCommandAlarmDlg::type_initValues(const KAEvent* event)
mCmdEdit->setScript(Preferences::defaultCmdScript());
mCmdLogFileEdit->setText(Preferences::defaultCmdLogFile()); // set file name before setting radio button
mCmdOutputGroup->setButton(Preferences::defaultCmdLogType());
mCmdDontShowError->setChecked(false);
}
slotCmdScriptToggled(mCmdEdit->isScript());
}
......@@ -886,6 +893,7 @@ void EditCommandAlarmDlg::setReadOnly(bool readOnly)
if (!isTemplate() && !ShellProcess::authorised())
readOnly = true; // don't allow editing of existing command alarms in kiosk mode
mCmdEdit->setReadOnly(readOnly);
mCmdDontShowError->setReadOnly(readOnly);
mCmdExecInTerm->setReadOnly(readOnly);
mCmdLogToFile->setReadOnly(readOnly);
mCmdDiscardOutput->setReadOnly(readOnly);
......@@ -898,9 +906,10 @@ void EditCommandAlarmDlg::setReadOnly(bool readOnly)
void EditCommandAlarmDlg::saveState(const KAEvent* event)
{
EditAlarmDlg::saveState(event);
mSavedCmdScript = mCmdEdit->isScript();
mSavedCmdOutputRadio = mCmdOutputGroup->checkedButton();
mSavedCmdLogFile = mCmdLogFileEdit->text();
mSavedCmdScript = mCmdEdit->isScript();
mSavedCmdDontShowError = mCmdDontShowError->isChecked();
mSavedCmdOutputRadio = mCmdOutputGroup->checkedButton();
mSavedCmdLogFile = mCmdLogFileEdit->text();
}
/******************************************************************************
......@@ -911,8 +920,9 @@ void EditCommandAlarmDlg::saveState(const KAEvent* event)
*/
bool EditCommandAlarmDlg::type_stateChanged() const
{
if (mSavedCmdScript != mCmdEdit->isScript()
|| mSavedCmdOutputRadio != mCmdOutputGroup->checkedButton())
if (mSavedCmdScript != mCmdEdit->isScript()
|| mSavedCmdOutputRadio != mCmdOutputGroup->checkedButton()
|| mSavedCmdDontShowError != mCmdDontShowError->isChecked())
return true;
if (mCmdOutputGroup->checkedButton() == mCmdLogToFile)
{
......@@ -942,6 +952,7 @@ KAEvent::Flags EditCommandAlarmDlg::getAlarmFlags() const
KAEvent::Flags flags = EditAlarmDlg::getAlarmFlags();
if (mCmdEdit->isScript()) flags |= KAEvent::SCRIPT;
if (mCmdOutputGroup->checkedButton() == mCmdExecInTerm) flags |= KAEvent::EXEC_IN_XTERM;
if (mCmdDontShowError->isChecked()) flags |= KAEvent::DONT_SHOW_ERROR;
return flags;
}
......
/*
* editdlgtypes.h - dialogues to create or edit alarm or alarm template types
* Program: kalarm
* Copyright © 2001-2019 David Jarvie <djarvie@kde.org>
* Copyright © 2001-2020 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
......@@ -175,6 +175,7 @@ class EditCommandAlarmDlg : public EditAlarmDlg
private:
// Command alarm options
CommandEdit* mCmdEdit;
CheckBox* mCmdDontShowError;
QGroupBox* mCmdOutputBox;
ButtonGroup* mCmdOutputGroup; // what to do with command output
RadioButton* mCmdExecInTerm;
......@@ -185,6 +186,7 @@ class EditCommandAlarmDlg : public EditAlarmDlg
// Initial state of all controls
bool mSavedCmdScript; // mCmdEdit->isScript() status
bool mSavedCmdDontShowError; // mCmdDontShowError value
QAbstractButton* mSavedCmdOutputRadio; // selected button in mCmdOutputGroup
QString mSavedCmdLogFile; // mCmdLogFileEdit value
};
......
......@@ -2583,21 +2583,26 @@ void KAlarmApp::commandErrorMsg(const ShellProcess* proc, const KAEvent& event,
}
else
{
dontShowAgain = QStringLiteral("Exec");
if (!event.commandHideError())
dontShowAgain = QStringLiteral("Exec");
cmderr = KAEvent::CMD_ERROR;
}
// Record the alarm's error status
setEventCommandError(event, cmderr);
// Display an error message
if (proc)
if (!dontShowAgain.isEmpty())
{
errmsgs += proc->errorMessage();
if (!(flags & ProcData::TEMP_FILE))
errmsgs += proc->command();
dontShowAgain += QString::number(proc->status());
// Display an error message
if (proc)
{
errmsgs += proc->errorMessage();
if (!(flags & ProcData::TEMP_FILE))
errmsgs += proc->command();
dontShowAgain += QString::number(proc->status());
}
MessageWin::showError(event, (alarm ? alarm->dateTime() : DateTime()), errmsgs, dontShowAgain);
}
MessageWin::showError(event, (alarm ? alarm->dateTime() : DateTime()), errmsgs, dontShowAgain);
}
/******************************************************************************
......
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