Commit 301c85b7 authored by David Jarvie's avatar David Jarvie
Browse files

Don't show restored alarm windows while notifications are inhibited

parent b69a6e8c
Pipeline #38405 passed with stage
in 19 minutes and 3 seconds
......@@ -305,8 +305,10 @@ bool KAlarmApp::restoreSession()
win->restore(i, false);
if (win->isValid())
{
if (Resources::allCreated())
if (Resources::allCreated() && !mNotificationsInhibited)
win->show();
else
mRestoredWindows += win;
}
else
delete win;
......@@ -338,6 +340,31 @@ bool KAlarmApp::restoreSession()
return true;
}
/******************************************************************************
* If resources have been created and notifications are not inhibited,
* show message windows restored at startup which are waiting to be displayed,
* and redisplay alarms showing when the program crashed or was killed.
*/
void KAlarmApp::showRestoredWindows()
{
if (!mNotificationsInhibited && Resources::allCreated())
{
if (!mRestoredWindows.isEmpty())
{
// Display message windows restored at startup.
for (MessageWindow* win : mRestoredWindows)
win->show();
mRestoredWindows.clear();
}
if (mRedisplayAlarms)
{
// Display alarms which were showing when the program crashed or was killed.
mRedisplayAlarms = false;
MessageDisplay::redisplayAlarms();
}
}
}
/******************************************************************************
* Called to start a new instance of the unique QApplication.
* Reply: exit code (>= 0), or -1 to continue execution.
......@@ -656,13 +683,8 @@ int KAlarmApp::activateInstance(const QStringList& args, const QString& workingD
*/
if (ResourcesCalendar::instance())
{
if (Resources::allCreated())
{
mRedisplayAlarms = false;
MessageDisplay::redisplayAlarms();
}
else
mRedisplayAlarms = true;
mRedisplayAlarms = true;
showRestoredWindows();
}
}
......@@ -1338,11 +1360,7 @@ void KAlarmApp::slotResourcesTimeout()
*/
void KAlarmApp::slotResourcesCreated()
{
if (mRedisplayAlarms)
{
mRedisplayAlarms = false;
MessageDisplay::redisplayAlarms();
}
showRestoredWindows(); // display message windows restored at startup.
checkWritableCalendar();
checkArchivedCalendar();
processQueue();
......@@ -1426,8 +1444,8 @@ void KAlarmApp::slotEditAlarmById()
createOnlyMainWindow(); // prevent the application from quitting
if (mEditingCmdLineAlarm & 0x10)
{
mRedisplayAlarms = false;
MessageDisplay::redisplayAlarms();
mRedisplayAlarms = true;
showRestoredWindows();
}
mEditingCmdLineAlarm = 2; // indicate edit completion
QTimer::singleShot(0, this, &KAlarmApp::processQueue);
......@@ -1558,7 +1576,10 @@ void KAlarmApp::slotFDOPropertiesChanged(const QString& interface,
qCDebug(KALARM_LOG) << "KAlarmApp::slotFDOPropertiesChanged: Notifications inhibited ->" << inhibited;
mNotificationsInhibited = inhibited;
if (!mNotificationsInhibited)
{
showRestoredWindows(); // display message windows restored at startup.
QTimer::singleShot(0, this, &KAlarmApp::processQueue);
}
}
}
}
......
......@@ -26,6 +26,7 @@ namespace KCal { class Event; }
class Resource;
class DBusHandler;
class MainWindow;
class MessageWindow;
class TrayWindow;
class ShellProcess;
......@@ -213,6 +214,7 @@ private:
bool initialiseTimerResources();
bool initCheck(bool calendarOnly = false);
bool quitIf(int exitCode, bool force = false);
void showRestoredWindows();
void createOnlyMainWindow();
bool checkSystemTray();
void startProcessQueue();
......@@ -257,8 +259,9 @@ private:
int mArchivedPurgeDays {-1}; // how long to keep archived alarms, 0 = don't keep, -1 = keep indefinitely
int mPurgeDaysQueued {-1}; // >= 0 to purge the archive calendar from KAlarmApp::processLoop()
QVector<ResourceId> mPendingPurges; // new resources which may need to be purged when populated
QList<ProcData*> mCommandProcesses; // currently active command alarm processes
QVector<ProcData*> mCommandProcesses; // currently active command alarm processes
QQueue<ActionQEntry> mActionQueue; // queued commands and actions
QVector<MessageWindow*> mRestoredWindows; // message windows restored at startup, waiting to be displayed
int mEditingCmdLineAlarm {0}; // whether currently editing alarm specified on command line
int mPendingQuitCode; // exit code for a pending quit
bool mPendingQuit {false}; // quit once the D-Bus command and shell command queues have been processed
......
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