42 #include "kspeechinterface.h"
44 #include <kstandarddirs.h>
46 #include <kstandardguiitem.h>
47 #include <kaboutdata.h>
50 #include <kiconloader.h>
52 #include <ktextbrowser.h>
53 #include <ksystemtimezone.h>
54 #include <kglobalsettings.h>
55 #include <kmimetype.h>
56 #include <ktextedit.h>
57 #include <kwindowsystem.h>
58 #include <kio/netaccess.h>
59 #include <knotification.h>
60 #include <kpushbutton.h>
61 #include <ksqueezedtextlabel.h>
62 #include <phonon/mediaobject.h>
63 #include <phonon/audiooutput.h>
64 #include <phonon/volumefadereffect.h>
66 #include <ktoolinvocation.h>
73 #include <QtDBus/QtDBus>
83 #include <QGridLayout>
84 #include <QVBoxLayout>
85 #include <QHBoxLayout>
86 #include <QResizeEvent>
87 #include <QCloseEvent>
88 #include <QDesktopWidget>
89 #include <QMutexLocker>
95 using namespace KCalCore;
99 using namespace KAlarmCal;
102 enum FullScreenType { NoFullScreen = 0, FullScreen = 1, FullScreenActive = 2 };
103 static FullScreenType haveFullScreenWindow(
int screen);
107 #ifdef KMAIL_SUPPORTED
108 #include "kmailinterface.h"
109 static const QLatin1String KMAIL_DBUS_SERVICE(
"org.kde.kmail");
122 MessageText(
QWidget* parent = 0)
127 setFrameStyle(NoFrame);
128 setLineWrapMode(NoWrap);
130 int scrollBarHeight()
const {
return horizontalScrollBar()->height(); }
131 int scrollBarWidth()
const {
return verticalScrollBar()->width(); }
132 void setBackgroundColour(
const QColor& c)
134 QPalette pal = viewport()->palette();
135 pal.
setColor(viewport()->backgroundRole(), c);
136 viewport()->setPalette(pal);
138 virtual QSize sizeHint()
const
140 const QSizeF docsize = document()->size();
141 return QSize(static_cast<int>(docsize.
width() + 0.99) + verticalScrollBar()->width(),
142 static_cast<int>(docsize.
height() + 0.99) + horizontalScrollBar()->height());
144 bool newLine()
const {
return mNewLine; }
145 void setNewLine(
bool nl) { mNewLine = nl; }
154 static const Qt::WidgetAttribute
WidgetFlags = Qt::WA_DeleteOnClose;
169 bool MessageWin::mRedisplayed =
false;
183 :
MainWindowBase(0, static_cast<Qt::WindowFlags>(
WFLAGS |
WFLAGS2 | ((flags & ALWAYS_HIDE) || getWorkAreaAndModal() ? Qt::WindowType(0) : Qt::X11BypassWindowManagerHint))),
184 mMessage(event->cleanText()),
185 mFont(event->font()),
186 mBgColour(event->bgColour()),
187 mFgColour(event->fgColour()),
189 mEventItemId(event->itemId()),
192 mEventId(event->id()),
194 mAudioFile(event->audioFile()),
195 mVolume(event->soundVolume()),
196 mFadeVolume(event->fadeVolume()),
197 mFadeSeconds(qMin(event->fadeSeconds(), 86400)),
198 mDefaultDeferMinutes(event->deferDefaultMinutes()),
199 mAlarmType(alarm.type()),
200 mAction(event->actionSubType()),
201 #ifdef KMAIL_SUPPORTED
202 mKMailSerialNumber(event->kmailSerialNumber()),
204 mKMailSerialNumber(0),
206 mCommandError(event->commandError()),
208 mAudioRepeatPause(event->repeatSoundPause()),
209 mConfirmAck(event->confirmAck()),
213 mOriginalEvent(*event),
215 mCollection(
AlarmCalendar::resources()->collectionForEvent(mEventItemId)),
217 mResource(
AlarmCalendar::resources()->resourceForEvent(mEventId)),
226 mDontShowAgainCheck(0),
229 mAlwaysHide(flags & ALWAYS_HIDE),
232 mNoPostAction(alarm.type() & KAAlarm::REMINDER_ALARM),
234 mBeep(event->beep()),
235 mSpeak(event->speak()),
236 mRescheduleEvent(!(flags & NO_RESCHEDULE)),
239 mNoCloseConfirm(false),
240 mDisableDeferral(false)
242 kDebug() << (
void*)
this <<
"event" << mEventId;
243 setAttribute(static_cast<Qt::WidgetAttribute>(
WidgetFlags));
244 setWindowModality(Qt::WindowModal);
246 if (alarm.type() & KAAlarm::REMINDER_ALARM)
248 if (event->reminderMinutes() < 0)
250 event->previousOccurrence(alarm.dateTime(
false).effectiveKDateTime(), mDateTime,
false);
251 if (!mDateTime.isValid() &&
event->repeatAtLogin())
252 mDateTime = alarm.dateTime().addSecs(event->reminderMinutes() * 60);
255 mDateTime =
event->mainDateTime(
true);
258 mDateTime = alarm.dateTime(
true);
266 mShowEdit = !mEventId.
isEmpty() && !readonly;
267 mNoDefer = readonly || (flags &
NO_DEFER) || alarm.repeatAtLogin();
274 if (event->autoClose())
275 mCloseTime = alarm.dateTime().effectiveKDateTime().toUtc().dateTime().
addSecs(event->lateCancel() * 60);
293 && KAlarm::dontShowErrors(
EventId(event), dontShowAgain))
296 && KAlarm::dontShowErrors(event.id(), dontShowAgain))
301 for (
int i = 0, end = mWindowList.
count(); i < end; ++i)
305 if (w->mErrorWindow && w->mEventId ==
EventId(event)
306 && w->mErrorMsgs == errmsgs && w->mDontShowAgain == dontShowAgain)
308 if (w->mErrorWindow && w->mEventId == event.id()
309 && w->mErrorMsgs == errmsgs && w->mDontShowAgain == dontShowAgain)
314 (
new MessageWin(&event, alarmDateTime, errmsgs, dontShowAgain))->
show();
325 mMessage(event->cleanText()),
326 mDateTime(alarmDateTime),
328 mEventItemId(event->itemId()),
331 mEventId(event->id()),
333 mAlarmType(KAAlarm::MAIN_ALARM),
334 mAction(event->actionSubType()),
335 mKMailSerialNumber(0),
336 mCommandError(KAEvent::CMD_NO_ERROR),
338 mDontShowAgain(dontShowAgain),
345 mOriginalEvent(*event),
356 mDontShowAgainCheck(0),
364 mRescheduleEvent(false),
367 mNoCloseConfirm(false),
368 mDisableDeferral(false)
370 kDebug() <<
"errmsg";
371 setAttribute(static_cast<Qt::WidgetAttribute>(
WidgetFlags));
372 setWindowModality(Qt::WindowModal);
374 getWorkAreaAndModal();
392 mDontShowAgainCheck(0),
399 mRescheduleEvent(false),
402 mNoCloseConfirm(false),
403 mDisableDeferral(false)
405 kDebug() << (
void*)
this <<
"restore";
407 setWindowModality(Qt::WindowModal);
409 getWorkAreaAndModal();
418 kDebug() << (
void*)
this << mEventId;
420 mAudioThread->quit();
421 mErrorMessages.
remove(mEventId);
425 if (!mNoPostAction && !mEvent.postAction().isEmpty())
435 void MessageWin::initView()
437 const bool reminder = (!mErrorWindow && (mAlarmType & KAAlarm::REMINDER_ALARM));
438 const int leading = fontMetrics().leading();
439 setCaption((mAlarmType & KAAlarm::REMINDER_ALARM) ? i18nc(
"@title:window",
"Reminder") : i18nc(
"@title:window",
"Message"));
441 setCentralWidget(topWidget);
443 topLayout->
setMargin(KDialog::marginHint());
444 topLayout->
setSpacing(KDialog::spacingHint());
447 labelPalette.
setColor(backgroundRole(), labelPalette.
color(QPalette::Window));
451 mTimeLabel =
new QLabel(topWidget);
452 mTimeLabel->
setText(dateTimeToDisplay());
456 topLayout->
addWidget(mTimeLabel, 0, Qt::AlignHCenter);
457 mTimeLabel->
setWhatsThis(i18nc(
"@info:whatsthis",
"The scheduled date/time for the message (as opposed to the actual time of display)."));
459 if (mDateTime.isValid())
467 QString s = i18nc(
"@info",
"Reminder");
486 KSqueezedTextLabel* label =
new KSqueezedTextLabel(mMessage, topWidget);
487 label->setFrameStyle(QFrame::StyledPanel);
488 label->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
489 label->setPalette(labelPalette);
490 label->setAutoFillBackground(
true);
491 label->setWhatsThis(i18nc(
"@info:whatsthis",
"The file whose contents are displayed below"));
492 topLayout->
addWidget(label, 0, Qt::AlignHCenter);
498 const KUrl url(mMessage);
501 QFile qfile(tmpFile);
503 if (!(dir = info.isDir()))
506 KTextBrowser* view =
new KTextBrowser(topWidget);
507 view->setFrameStyle(QFrame::NoFrame);
508 view->setWordWrapMode(QTextOption::NoWrap);
509 QPalette pal = view->viewport()->palette();
510 pal.
setColor(view->viewport()->backgroundRole(), mBgColour);
511 view->viewport()->setPalette(pal);
512 view->setTextColor(mFgColour);
513 view->setCurrentFont(mFont);
514 KMimeType::Ptr mime = KMimeType::findByUrl(url);
516 mime = KMimeType::findByFileContent(tmpFile);
517 switch (KAlarm::fileType(mime))
522 case KAlarm::TextFormatted:
523 view->QTextBrowser::setSource(tmpFile);
528 if (qfile.open(QIODevice::ReadOnly))
532 view->setPlainText(str.readAll());
538 view->setMinimumSize(view->sizeHint());
545 int h = 20*view->fontMetrics().lineSpacing() + 2*view->frameWidth();
546 view->resize(
QSize(h, h).expandedTo(view->sizeHint()));
547 view->setWhatsThis(i18nc(
"@info:whatsthis",
"The contents of the file to be displayed"));
549 KIO::NetAccess::removeTempFile(tmpFile);
555 mErrorMsgs += dir ? i18nc(
"@info",
"File is a folder") : exists ? i18nc(
"@info",
"Failed to open file") : i18nc(
"@info",
"File not found");
559 case KAEvent::MESSAGE:
563 MessageText*
text =
new MessageText(topWidget);
564 text->setAutoFillBackground(
true);
565 text->setBackgroundColour(mBgColour);
566 text->setTextColor(mFgColour);
567 text->setCurrentFont(mFont);
568 text->insertPlainText(mMessage);
569 const int lineSpacing = text->fontMetrics().lineSpacing();
570 const QSize s = text->sizeHint();
572 text->setMaximumHeight(h + text->scrollBarHeight());
573 text->setMinimumHeight(qMin(h, lineSpacing*4));
574 text->setMaximumWidth(s.
width() + text->scrollBarWidth());
575 text->setWhatsThis(i18nc(
"@info:whatsthis",
"The alarm message"));
576 const int vspace = lineSpacing/2;
577 const int hspace = lineSpacing - KDialog::marginHint();
582 topLayout->
addWidget(text, 1, Qt::AlignHCenter);
587 layout->
addWidget(text, 1, Qt::AlignHCenter);
595 case KAEvent::COMMAND:
597 mCommandText =
new MessageText(topWidget);
598 mCommandText->setBackgroundColour(mBgColour);
599 mCommandText->setTextColor(mFgColour);
600 mCommandText->setCurrentFont(mFont);
602 mCommandText->setWhatsThis(i18nc(
"@info:whatsthis",
"The output of the alarm's command"));
611 if (reminder && mEvent.reminderMinutes() > 0)
614 mRemainingText =
new QLabel(topWidget);
619 if (mDateTime.isDateOnly() || KDateTime::currentLocalDate().daysTo(mDateTime.date()) > 0)
621 setRemainingTextDay();
626 setRemainingTextMinute();
629 topLayout->
addWidget(mRemainingText, 0, Qt::AlignHCenter);
630 topLayout->
addSpacing(KDialog::spacingHint());
644 frame->
setWhatsThis(i18nc(
"@info:whatsthis",
"The email to send"));
645 topLayout->
addWidget(frame, 0, Qt::AlignHCenter);
650 QLabel* label =
new QLabel(i18nc(
"@info Email addressee",
"To:"), frame);
652 grid->
addWidget(label, 0, 0, Qt::AlignLeft);
655 grid->
addWidget(label, 0, 1, Qt::AlignLeft);
657 label =
new QLabel(i18nc(
"@info Email subject",
"Subject:"), frame);
659 grid->
addWidget(label, 1, 0, Qt::AlignLeft);
660 label =
new QLabel(mEvent.emailSubject(), frame);
662 grid->
addWidget(label, 1, 1, Qt::AlignLeft);
665 case KAEvent::COMMAND:
667 case KAEvent::MESSAGE:
674 if (!mErrorMsgs.
count())
683 setCaption(i18nc(
"@title:window",
"Error"));
685 layout->
setMargin(2*KDialog::marginHint());
691 layout->
addWidget(label, 0, Qt::AlignRight);
696 label =
new QLabel(*it, topWidget);
698 vlayout->
addWidget(label, 0, Qt::AlignLeft);
703 mDontShowAgainCheck =
new QCheckBox(i18nc(
"@option:check",
"Do not display this error message again for this alarm"), topWidget);
705 topLayout->
addWidget(mDontShowAgainCheck, 0, Qt::AlignLeft);
715 mOkButton =
new PushButton(KStandardGuiItem::close(), topWidget);
717 mOkButton->clearFocus();
718 mOkButton->setFocusPolicy(Qt::ClickFocus);
719 mOkButton->setFixedSize(mOkButton->sizeHint());
720 connect(mOkButton, SIGNAL(clicked()), SLOT(slotOk()));
721 grid->
addWidget(mOkButton, 0, gridIndex++, Qt::AlignHCenter);
722 mOkButton->setWhatsThis(i18nc(
"@info:whatsthis",
"Acknowledge the alarm"));
727 mEditButton =
new PushButton(i18nc(
"@action:button",
"&Edit..."), topWidget);
728 mEditButton->setFocusPolicy(Qt::ClickFocus);
729 mEditButton->setFixedSize(mEditButton->sizeHint());
730 connect(mEditButton, SIGNAL(clicked()), SLOT(slotEdit()));
731 grid->
addWidget(mEditButton, 0, gridIndex++, Qt::AlignHCenter);
732 mEditButton->setWhatsThis(i18nc(
"@info:whatsthis",
"Edit the alarm."));
736 mDeferButton =
new PushButton(i18nc(
"@action:button",
"&Defer..."), topWidget);
737 mDeferButton->setFocusPolicy(Qt::ClickFocus);
738 mDeferButton->setFixedSize(mDeferButton->sizeHint());
739 connect(mDeferButton, SIGNAL(clicked()), SLOT(slotDefer()));
740 grid->
addWidget(mDeferButton, 0, gridIndex++, Qt::AlignHCenter);
741 mDeferButton->setWhatsThis(i18nc(
"@info:whatsthis",
"<para>Defer the alarm until later.</para>"
742 "<para>You will be prompted to specify when the alarm should be redisplayed.</para>"));
745 mDeferButton->hide();
747 setDeferralLimit(mEvent);
749 if (!mAudioFile.
isEmpty() && (mVolume || mFadeVolume > 0))
754 mSilenceButton->setIcon(KIcon(pixmap));
755 grid->
addWidget(mSilenceButton, 0, gridIndex++, Qt::AlignHCenter);
756 mSilenceButton->setToolTip(i18nc(
"@info:tooltip",
"Stop sound"));
757 mSilenceButton->setWhatsThis(i18nc(
"@info:whatsthis",
"Stop playing the sound"));
759 mSilenceButton->setEnabled(
false);
762 KIconLoader iconLoader;
763 if (mKMailSerialNumber)
766 const QPixmap pixmap = iconLoader.loadIcon(
QLatin1String(
"internet-mail"), KIconLoader::MainToolbar);
768 mKMailButton->setIcon(KIcon(pixmap));
769 connect(mKMailButton, SIGNAL(clicked()), SLOT(slotShowKMailMessage()));
770 grid->
addWidget(mKMailButton, 0, gridIndex++, Qt::AlignHCenter);
771 mKMailButton->setToolTip(i18nc(
"@info:tooltip Locate this email in KMail",
"Locate in <application>KMail</application>"));
772 mKMailButton->setWhatsThis(i18nc(
"@info:whatsthis",
"Locate and highlight this email in <application>KMail</application>"));
776 const QPixmap pixmap = iconLoader.loadIcon(KGlobal::mainComponent().aboutData()->appName(), KIconLoader::MainToolbar);
778 mKAlarmButton->setIcon(KIcon(pixmap));
779 connect(mKAlarmButton, SIGNAL(clicked()), SLOT(displayMainWindow()));
780 grid->
addWidget(mKAlarmButton, 0, gridIndex++, Qt::AlignHCenter);
781 mKAlarmButton->setToolTip(i18nc(
"@info:tooltip",
"Activate <application>KAlarm</application>"));
782 mKAlarmButton->setWhatsThis(i18nc(
"@info:whatsthis",
"Activate <application>KAlarm</application>"));
784 int butsize = mKAlarmButton->sizeHint().height();
786 butsize = qMax(butsize, mSilenceButton->sizeHint().height());
788 butsize = qMax(butsize, mKMailButton->sizeHint().height());
789 mKAlarmButton->setFixedSize(butsize, butsize);
791 mSilenceButton->setFixedSize(butsize, butsize);
793 mKMailButton->setFixedSize(butsize, butsize);
797 mOkButton->setEnabled(
false);
798 if (mDeferButton->isVisible())
799 mDeferButton->setEnabled(
false);
801 mEditButton->setEnabled(
false);
803 mKMailButton->setEnabled(
false);
804 mKAlarmButton->setEnabled(
false);
808 const bool modal = !(windowFlags() & Qt::X11BypassWindowManagerHint);
809 const unsigned long wstate = (modal ? NET::Modal : 0) | NET::Sticky | NET::StaysOnTop;
811 KWindowSystem::setState(winid, wstate);
812 KWindowSystem::setOnAllDesktops(winid,
true);
822 int count = mWindowList.
count();
823 if (excludeAlwaysHidden)
827 if (win->mAlwaysHide)
836 return mDeferButton && mDeferButton->isVisible();
847 mDeferButton->show();
848 setDeferralLimit(mEvent);
860 mDateTime = alarm.dateTime(
true);
861 mNoPostAction =
false;
862 mAlarmType = alarm.type();
863 if (event.autoClose())
864 mCloseTime = alarm.dateTime().effectiveKDateTime().toUtc().dateTime().
addSecs(event.lateCancel() * 60);
865 setCaption(i18nc(
"@title:window",
"Message"));
866 mTimeLabel->
setText(dateTimeToDisplay());
868 mRemainingText->
hide();
872 centralWidget()->layout()->activate();
873 setMinimumHeight(
sizeHint().height());
885 mDateTime = (alarm.type() & KAAlarm::REMINDER_ALARM) ? event.mainDateTime(
true) : alarm.dateTime(
true);
886 if (mDateTime.isValid())
888 mTimeLabel->
setText(dateTimeToDisplay());
896 QString MessageWin::dateTimeToDisplay()
899 if (mDateTime.isValid())
901 if (mDateTime.isDateOnly())
902 tm = KGlobal::locale()->formatDate(mDateTime.date(), KLocale::ShortDate);
905 bool showZone =
false;
906 if (mDateTime.timeType() == KDateTime::UTC
907 || (mDateTime.timeType() == KDateTime::TimeZone && !mDateTime.isLocalZone()))
914 KDateTime local = mDateTime.kDateTime();
915 local.setTimeSpec(KDateTime::Spec::LocalZone());
918 tm = KGlobal::locale()->formatDateTime(mDateTime.kDateTime(), KLocale::ShortDate, KLocale::DateTimeFormatOptions(showZone ? KLocale::TimeZone : 0));
928 void MessageWin::setRemainingTextDay()
931 const int days = KDateTime::currentLocalDate().daysTo(mDateTime.date());
932 if (days <= 0 && !mDateTime.isDateOnly())
936 setRemainingTextMinute();
942 text = i18nc(
"@info",
"Today");
944 text = i18ncp(
"@info",
"Tomorrow",
"in %1 days' time", days);
946 text = i18ncp(
"@info",
"in 1 week's time",
"in %1 weeks' time", days/7);
955 void MessageWin::setRemainingTextMinute()
958 const int mins = (KDateTime::currentUtcDateTime().secsTo(mDateTime.effectiveKDateTime()) + 59) / 60;
960 text = i18ncp(
"@info",
"in 1 minute's time",
"in %1 minutes' time", (mins > 0 ? mins : 0));
961 else if (mins % 60 == 0)
962 text = i18ncp(
"@info",
"in 1 hour's time",
"in %1 hours' time", mins/60);
965 QString hourText = i18ncp(
"@item:intext inserted into 'in ... %1 minute's time' below",
"1 hour",
"%1 hours", mins/60);
966 text = i18ncp(
"@info '%2' is the previous message '1 hour'/'%1 hours'",
"in %2 1 minute's time",
"in %2 %1 minutes' time", mins%60, hourText);
982 if (mCommandText->newLine())
984 const int nl = data.
endsWith(
'\n') ? 1 : 0;
985 mCommandText->setNewLine(nl);
997 if (mShown && !mErrorWindow && !mAlwaysHide)
1000 config.writeEntry(
"EventID", mEventId.eventId());
1001 config.writeEntry(
"EventItemID", mEventItemId);
1003 config.writeEntry(
"EventID", mEventId);
1005 config.writeEntry(
"AlarmType", static_cast<int>(mAlarmType));
1006 if (mAlarmType == KAAlarm::INVALID_ALARM)
1007 kError() <<
"Invalid alarm: id=" << mEventId <<
", alarm count=" << mEvent.alarmCount();
1008 config.writeEntry(
"Message", mMessage);
1009 config.writeEntry(
"Type", static_cast<int>(mAction));
1010 config.writeEntry(
"Font", mFont);
1011 config.writeEntry(
"BgColour", mBgColour);
1012 config.writeEntry(
"FgColour", mFgColour);
1013 config.writeEntry(
"ConfirmAck", mConfirmAck);
1014 if (mDateTime.isValid())
1017 config.writeEntry(
"Time", mDateTime.effectiveDateTime());
1018 config.writeEntry(
"DateOnly", mDateTime.isDateOnly());
1020 if (mDateTime.isUtc())
1024 const KTimeZone tz = mDateTime.timeZone();
1028 config.writeEntry(
"TimeZone", zone);
1031 config.writeEntry(
"Expiry", mCloseTime);
1032 if (mAudioRepeatPause >= 0 && mSilenceButton && mSilenceButton->isEnabled())
1035 config.writePathEntry(
"AudioFile", mAudioFile);
1036 config.writeEntry(
"Volume", static_cast<int>(mVolume * 100));
1037 config.writeEntry(
"AudioPause", mAudioRepeatPause);
1039 config.writeEntry(
"Speak", mSpeak);
1040 config.writeEntry(
"Height", height());
1041 config.writeEntry(
"DeferMins", mDefaultDeferMinutes);
1042 config.writeEntry(
"NoDefer", mNoDefer);
1043 config.writeEntry(
"NoPostAction", mNoPostAction);
1044 config.writeEntry(
"KMailSerial", static_cast<qulonglong>(mKMailSerialNumber));
1045 config.writeEntry(
"CmdErr", static_cast<int>(mCommandError));
1046 config.writeEntry(
"DontShowAgain", mDontShowAgain);
1049 config.writeEntry(
"Invalid",
true);
1059 mInvalid = config.readEntry(
"Invalid",
false);
1060 QString eventId = config.readEntry(
"EventID");
1062 mEventItemId = config.readEntry(
"EventItemID", Akonadi::Item::Id(-1));
1066 mAlarmType =
static_cast<KAAlarm::Type
>(config.readEntry(
"AlarmType", 0));
1067 if (mAlarmType == KAAlarm::INVALID_ALARM)
1070 kError() <<
"Invalid alarm: id=" << eventId;
1072 mMessage = config.readEntry(
"Message");
1073 mAction =
static_cast<KAEvent::SubAction
>(config.readEntry(
"Type", 0));
1074 mFont = config.readEntry(
"Font",
QFont());
1075 mBgColour = config.readEntry(
"BgColour",
QColor(Qt::white));
1076 mFgColour = config.readEntry(
"FgColour",
QColor(Qt::black));
1077 mConfirmAck = config.readEntry(
"ConfirmAck",
false);
1079 QDateTime dt = config.readEntry(
"Time", invalidDateTime);
1080 const QString zone = config.readEntry(
"TimeZone");
1082 mDateTime = KDateTime(dt, KDateTime::ClockTime);
1086 mDateTime = KDateTime(dt, KDateTime::UTC);
1090 KTimeZone tz = KSystemTimeZones::zone(zone);
1091 mDateTime = KDateTime(dt, (tz.isValid() ? tz : KSystemTimeZones::local()));
1093 const bool dateOnly = config.readEntry(
"DateOnly",
false);
1095 mDateTime.setDateOnly(
true);
1096 mCloseTime = config.readEntry(
"Expiry", invalidDateTime);
1098 mAudioFile = config.readPathEntry(
"AudioFile",
QString());
1099 mVolume =
static_cast<float>(config.readEntry(
"Volume", 0)) / 100;
1103 mAudioRepeatPause = config.readEntry(
"AudioPause", 0);
1105 mSpeak = config.readEntry(
"Speak",
false);
1106 mRestoreHeight = config.readEntry(
"Height", 0);
1107 mDefaultDeferMinutes = config.readEntry(
"DeferMins", 0);
1108 mNoDefer = config.readEntry(
"NoDefer",
false);
1109 mNoPostAction = config.readEntry(
"NoPostAction",
true);
1110 mKMailSerialNumber =
static_cast<unsigned long>(config.readEntry(
"KMailSerial",
QVariant(QVariant::ULongLong)).toULongLong());
1111 mCommandError = KAEvent::CmdErrType(config.readEntry(
"CmdErr", static_cast<int>(KAEvent::CMD_NO_ERROR)));
1112 mDontShowAgain = config.readEntry(
"DontShowAgain",
QString());
1116 mCollection = Akonadi::Collection();
1117 mEventId =
EventId(mCollection.id(), eventId);
1121 kDebug() << eventId;
1122 if (mAlarmType != KAAlarm::INVALID_ALARM)
1134 SLOT(showRestoredAlarm()));
1147 void MessageWin::showRestoredAlarm()
1149 kDebug() << mEventId;
1158 void MessageWin::redisplayAlarm()
1162 mEventId.setCollectionId(mCollection.id());
1164 kDebug() << mEventId;
1168 kDebug() <<
"Deleting duplicate window:" << mEventId;
1184 retrieveEvent(mEvent, mCollection, mShowEdit, mNoDefer);
1186 retrieveEvent(mEvent, mResource, mShowEdit, mNoDefer);
1188 mNoDefer = !mNoDefer;
1204 mRedisplayed =
true;
1210 Akonadi::Collection collection;
1212 AlarmResource* resource;
1214 const Event::List events = cal->
kcalEvents();
1215 for (
int i = 0, end = events.count(); i < end; ++i)
1219 reinstateFromDisplaying(events[i], event, collection, showEdit, showDefer);
1222 event.setItemId(
id);
1225 reinstateFromDisplaying(events[i], event, resource, showEdit, showDefer);
1226 const QString eventId =
event.id();
1229 kDebug() <<
"Message window already exists:" << eventId;
1233 const KAAlarm alarm =
event.convertDisplayingAlarm();
1234 if (alarm.type() == KAAlarm::INVALID_ALARM)
1236 kError() <<
"Invalid alarm: id=" << eventId;
1239 kDebug() << eventId;
1240 const bool login = alarm.repeatAtLogin();
1244 win->mCollection = collection;
1247 win->mResource = resource;
1248 const bool rw = resource && resource->writable();
1250 win->mShowEdit = rw ? showEdit :
false;
1251 win->mNoDefer = (rw && !login) ? !showDefer :
true;
1264 bool MessageWin::retrieveEvent(KAEvent& event, Akonadi::Collection& resource,
bool& showEdit,
bool& showDefer)
1266 bool MessageWin::retrieveEvent(KAEvent& event, AlarmResource*& resource,
bool& showEdit,
bool& showDefer)
1274 if (!reinstateFromDisplaying(kcalEvent, event, resource, showEdit, showDefer))
1281 if (archiveCol.isValid())
1290 event.setCategory(CalEvent::ACTIVE);
1292 if (mEventId.eventId() !=
event.id())
1293 kError() <<
"Wrong event ID";
1294 event.setEventId(mEventId.eventId());
1295 resource = Akonadi::Collection();
1297 if (mEventId != event.id())
1298 kError() <<
"Wrong event ID";
1299 event.setEventId(mEventId);
1304 kDebug() <<
event.id() <<
": success";
1314 bool MessageWin::reinstateFromDisplaying(
const Event::Ptr& kcalEvent, KAEvent& event, Akonadi::Collection& collection,
bool& showEdit,
bool& showDefer)
1316 bool MessageWin::reinstateFromDisplaying(
const Event* kcalEvent, KAEvent& event, AlarmResource*& resource,
bool& showEdit,
bool& showDefer)
1322 Akonadi::Collection::Id collectionId;
1323 event.reinstateFromDisplaying(kcalEvent, collectionId, showEdit, showDefer);
1324 event.setCollectionId(collectionId);
1326 kDebug() <<
EventId(event) <<
": success";
1329 event.reinstateFromDisplaying(kcalEvent, resourceID, showEdit, showDefer);
1330 resource = AlarmResources::instance()->resourceWithId(resourceID);
1331 if (resource && !resource->isOpen())
1333 kDebug() <<
event.id() <<
": success";
1343 void MessageWin::alarmShowing(KAEvent& event)
1345 kDebug() <<
event.id() <<
"," << KAAlarm::debugType(mAlarmType);
1350 kError() <<
"Event ID not found:" <<
event.id();
1354 const KAAlarm alarm =
event.alarm(mAlarmType);
1355 if (!alarm.isValid())
1357 kError() <<
"Alarm type not found:" <<
event.id() <<
":" << mAlarmType;
1366 dispEvent.setDisplaying(event, mAlarmType, collection.id(),
1367 mDateTime.effectiveKDateTime(), mShowEdit, !mNoDefer);
1369 KAEvent* dispEvent =
new KAEvent;
1370 const AlarmResource* resource = AlarmResources::instance()->resource(kcalEvent);
1371 dispEvent->setDisplaying(event, mAlarmType, (resource ? resource->identifier() :
QString()),
1372 mDateTime.effectiveKDateTime(), mShowEdit, !mNoDefer);
1378 cal->deleteDisplayEvent(dispEvent.id());
1406 if (scatter == isSpread(desk.
topLeft()))
1413 int x = desk.
left();
1416 for (
int errmsgs = 0; errmsgs < 2; ++errmsgs)
1420 for (
int i = 0, end = mWindowList.
count(); i < end; ++i)
1423 if ((!errmsgs && w->mErrorWindow)
1424 || (errmsgs && !w->mErrorWindow))
1426 const QSize sz = w->frameGeometry().size();
1436 if (ytmp < desk.
top())
1441 if (ytmp + sz.
height() > ynext)
1442 ynext = ytmp + sz.
height();
1449 for (
int i = 0, end = mWindowList.
count(); i < end; ++i)
1450 mWindowList[i]->move(desk.
topLeft());
1459 bool MessageWin::isSpread(
const QPoint& topLeft)
1461 for (
int i = 0, end = mWindowList.
count(); i < end; ++i)
1463 if (mWindowList[i]->pos() != topLeft)
1481 for (
int i = 0, end = mWindowList.count(); i < end; ++i)
1484 if (w != exclude && w->mEventId == eventId && !w->mErrorWindow)
1494 void MessageWin::playAudio()
1500 KNotification::beep();
1504 if (!mVolume && mFadeVolume <= 0)
1520 void MessageWin::slotSpeak()
1533 if (!kspeech->say(mMessage, 0))
1535 kDebug() <<
"SayMessage() D-Bus error";
1550 void MessageWin::startAudio()
1556 connect(mAudioThread, SIGNAL(destroyed(
QObject*)), SLOT(audioTerminating()));
1561 mAudioThread =
new AudioThread(
this, mAudioFile, mVolume, mFadeVolume, mFadeSeconds, mAudioRepeatPause);
1562 connect(mAudioThread, SIGNAL(readyToPlay()), SLOT(playReady()));
1563 connect(mAudioThread, SIGNAL(finished()), SLOT(playFinished()));
1565 connect(mSilenceButton, SIGNAL(clicked()), mAudioThread, SLOT(quit()));
1569 mAudioThread->start();
1578 return mAudioThread;
1588 mAudioThread->stop(wait);
1595 void MessageWin::audioTerminating()
1603 void MessageWin::playReady()
1606 mSilenceButton->setEnabled(
true);
1612 void MessageWin::playFinished()
1615 mSilenceButton->setEnabled(
false);
1618 const QString errmsg = mAudioThread->error();
1625 delete mAudioThread.
data();
1637 mFadeVolume(fadeVolume),
1638 mFadeSeconds(fadeSeconds),
1639 mRepeatPause(repeatPause),
1643 kError() <<
"mAudioOwner already set";
1655 delete mAudioObject;
1693 const QString audioFile = mFile;
1697 if (source.
type() == Phonon::MediaSource::Invalid)
1699 mError = i18nc(
"@info",
"Cannot open audio file: <filename>%1</filename>", audioFile);
1701 kError() <<
"Open failure:" << audioFile;
1709 if (mVolume >= 0 || mFadeVolume >= 0)
1711 const float vol = (mVolume >= 0) ? mVolume : output->
volume();
1712 const float maxvol = qMax(vol, mFadeVolume);
1714 if (mFadeVolume >= 0 && mFadeSeconds > 0)
1716 Phonon::VolumeFaderEffect* fader =
new Phonon::VolumeFaderEffect(mAudioObject);
1717 fader->setVolume(mFadeVolume / maxvol);
1718 fader->fadeTo(mVolume / maxvol, mFadeSeconds * 1000);
1722 connect(mAudioObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), SLOT(playStateChanged(Phonon::State)), Qt::DirectConnection);
1723 connect(mAudioObject, SIGNAL(
finished()), SLOT(checkAudioPlay()), Qt::DirectConnection);
1724 mPlayedOnce =
false;
1744 void AudioThread::checkAudioPlay()
1759 if (mRepeatPause < 0)
1766 if (mRepeatPause > 0)
1779 kDebug() <<
"start";
1780 mAudioObject->
play();
1788 void AudioThread::playStateChanged(Phonon::State newState)
1790 if (newState == Phonon::ErrorState)
1796 kError() <<
"Play failure:" << mFile <<
":" << err;
1797 mError = i18nc(
"@info",
"<para>Error playing audio file: <filename>%1</filename></para><para>%2</para>", mFile, err);
1807 void AudioThread::stopPlay()
1812 mAudioObject->
stop();
1814 for (
int i = 0; i < effects.
count(); ++i)
1819 delete mAudioObject;
1850 mAlarmType = alarm.type();
1855 if (!mDeferDlg || Preferences::modalMessages())
1860 if (mDeferButton->isVisible())
1862 mDeferButton->setEnabled(
true);
1863 setDeferralLimit(*event);
1866 alarmShowing(*event);
1881 int delay = KDateTime::currentUtcDateTime().dateTime().secsTo(mCloseTime);
1888 if (Preferences::messageButtonDelay() == 0)
1890 MainWindowBase::show();
1901 case KAEvent::MESSAGE:
1902 desired = MainWindowBase::sizeHint();
1904 case KAEvent::COMMAND:
1908 const QSize texthint = mCommandText->sizeHint();
1909 int w = texthint.
width() + 2*KDialog::marginHint();
1912 const int ypadding = height() - mCommandText->height();
1918 return MainWindowBase::sizeHint();
1923 const QSize frameThickness = frameGeometry().size() - geometry().size();
1924 return desired.
boundedTo(desktop - frameThickness);
1934 MainWindowBase::showEvent(se);
1935 if (mShown || !mInitialised)
1937 if (mErrorWindow || mAlarmType == KAAlarm::INVALID_ALARM)
1950 bool execComplete =
true;
1952 if (mAction == KAEvent::FILE && !mErrorMsgs.
count())
1953 KAlarm::readConfigWindowSize(
"FileMessage", s);
1957 const QRect frame = frameGeometry();
1959 mButtonDelay = Preferences::messageButtonDelay() * 1000;
1964 mPositioning =
true;
1966 execComplete =
false;
1982 const QRect rect = geometry();
1984 const QRect button(mOkButton->mapToParent(
QPoint(0, 0)), mOkButton->mapToParent(mOkButton->rect().bottomRight()));
1985 const int buttonLeft = button.
left() + rect.
left() - frame.
left();
1986 const int buttonRight = width() - button.
right() + frame.
right() - rect.
right();
1987 const int buttonTop = button.
top() + rect.
top() - frame.
top();
1988 const int buttonBottom = height() - button.
bottom() + frame.
bottom() - rect.
bottom();
1990 const int centrex = (desk.
width() + buttonLeft - buttonRight) / 2;
1991 const int centrey = (desk.
height() + buttonTop - buttonBottom) / 2;
1992 const int x = (cursor.
x() < centrex) ? desk.
right() - frame.
width() : desk.
left();
1993 const int y = (cursor.
y() < centrey) ? desk.
bottom() - frame.
height() : desk.
top();
1997 QRect buttons = mOkButton->geometry().unite(mKAlarmButton->geometry());
2000 if ((abs(cursor.
x() - buttons.
left()) < minDistance
2001 || abs(cursor.
x() - buttons.
right()) < minDistance)
2002 && (abs(cursor.
y() - buttons.
top()) < minDistance
2003 || abs(cursor.
y() - buttons.
bottom()) < minDistance))
2006 if (x != frame.
left() || y != frame.
top())
2008 mPositioning =
true;
2010 execComplete =
false;
2028 MainWindowBase::moveEvent(e);
2033 mPositioning =
false;
2043 void MessageWin::frameDrawn()
2045 if (!mErrorWindow && mAction == KAEvent::MESSAGE)
2058 void MessageWin::displayComplete()
2061 if (mRescheduleEvent)
2062 alarmShowing(mEvent);
2067 if (mButtonDelay > 0)
2077 void MessageWin::enableButtons()
2079 mOkButton->setEnabled(
true);
2080 mKAlarmButton->setEnabled(
true);
2081 if (mDeferButton->isVisible() && !mDisableDeferral)
2082 mDeferButton->setEnabled(
true);
2084 mEditButton->setEnabled(
true);
2086 mKMailButton->setEnabled(
true);
2103 else if (isVisible())
2108 if (mShown && mAction == KAEvent::FILE && !mErrorMsgs.
count())
2109 KAlarm::writeConfigWindowSize(
"FileMessage", re->
size());
2110 MainWindowBase::resizeEvent(re);
2121 if (!mErrorWindow && !
theApp()->sessionClosingDown())
2123 if (mConfirmAck && !mNoCloseConfirm)
2127 i18nc(
"@action:button",
"Acknowledge Alarm"), KGuiItem(i18nc(
"@action:button",
"Acknowledge")), KStandardGuiItem::cancel())
2128 != KMessageBox::Yes)
2138 KAlarm::deleteDisplayEvent(CalEvent::uid(mEventId.eventId(), CalEvent::DISPLAYING));
2140 KAlarm::deleteDisplayEvent(CalEvent::uid(mEventId, CalEvent::DISPLAYING));
2144 MainWindowBase::closeEvent(ce);
2150 void MessageWin::slotOk()
2152 if (mDontShowAgainCheck && mDontShowAgainCheck->
isChecked())
2153 KAlarm::setDontShowErrors(mEventId, mDontShowAgain);
2157 #ifdef KMAIL_SUPPORTED
2162 void MessageWin::slotShowKMailMessage()
2165 if (!mKMailSerialNumber)
2167 const QString err = KAlarm::runKMail(
false);
2176 kError() <<
"kmail D-Bus call failed:" << reply.
error().
message();
2177 else if (!reply.
value())
2178 KAMessageBox::sorry(
this, i18nc(
"@info",
"Unable to locate this email in <application>KMail</application>"));
2192 void MessageWin::slotEdit()
2197 KWindowSystem::setMainWindow(mEditDlg, winId());
2198 KWindowSystem::setOnAllDesktops(mEditDlg->winId(),
false);
2199 setButtonsReadOnly(
true);
2200 connect(mEditDlg, SIGNAL(accepted()), SLOT(editCloseOk()));
2201 connect(mEditDlg, SIGNAL(rejected()), SLOT(editCloseCancel()));
2202 connect(mEditDlg, SIGNAL(destroyed(
QObject*)), SLOT(editCloseCancel()));
2203 connect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)), SLOT(activeWindowChanged(WId)));
2205 mainWin->
editAlarm(mEditDlg, mOriginalEvent);
2207 mainWin->
editAlarm(mEditDlg, mOriginalEvent, mResource);
2215 void MessageWin::editCloseOk()
2218 mNoCloseConfirm =
true;
2226 void MessageWin::editCloseCancel()
2229 setButtonsReadOnly(
false);
2237 void MessageWin::activeWindowChanged(WId win)
2239 if (mEditDlg && win == winId())
2240 KWindowSystem::activateWindow(mEditDlg->winId());
2246 void MessageWin::setButtonsReadOnly(
bool ro)
2261 void MessageWin::setDeferralLimit(
const KAEvent& event)
2263 mDeferLimit =
event.deferralLimit().effectiveKDateTime().toUtc().dateTime();
2265 mDisableDeferral =
false;
2266 checkDeferralLimit();
2278 void MessageWin::checkDeferralLimit()
2280 if (!mDeferButton->isEnabled() || !mDeferLimit.
isValid())
2282 int n = KDateTime::currentLocalDate().daysTo(KDateTime(mDeferLimit, KDateTime::LocalZone).
date());
2289 n = KDateTime::currentUtcDateTime().dateTime().secsTo(mDeferLimit);
2296 mDeferButton->setEnabled(
false);
2297 mDisableDeferral =
true;
2304 void MessageWin::slotDefer()
2308 mDeferDlg->
setDeferMinutes(mDefaultDeferMinutes > 0 ? mDefaultDeferMinutes : Preferences::defaultDeferTime());
2310 if (!Preferences::modalMessages())
2312 if (mDeferDlg->exec() == QDialog::Accepted)
2322 kDebug() <<
"Deferring event" << mEventId;
2323 KAEvent newev(*event);
2324 newev.defer(dateTime, (mAlarmType & KAAlarm::REMINDER_ALARM),
true);
2325 newev.setDeferDefaultMinutes(delayMins);
2326 KAlarm::updateEvent(newev, mDeferDlg,
true);
2327 if (newev.deferred())
2328 mNoPostAction =
true;
2334 Akonadi::Collection collection;
2336 AlarmResource* resource = 0;
2341 if (!retrieveEvent(event, collection, showEdit, showDefer))
2343 if (!retrieveEvent(event, resource, showEdit, showDefer))
2348 KAMessageBox::error(
this, i18nc(
"@info",
"<para>Cannot defer alarm:</para><para>Alarm not found.</para>"));
2352 mDeferButton->setEnabled(
false);
2353 mEditButton->setEnabled(
false);
2356 kDebug() <<
"Deferring retrieved event" << mEventId;
2357 event.defer(dateTime, (mAlarmType & KAAlarm::REMINDER_ALARM),
true);
2358 event.setDeferDefaultMinutes(delayMins);
2359 event.setCommandError(mCommandError);
2363 KAlarm::addEvent(event, &collection, mDeferDlg, KAlarm::USE_EVENT_ID);
2365 KAlarm::addEvent(event, resource, mDeferDlg, KAlarm::USE_EVENT_ID);
2367 if (event.deferred())
2368 mNoPostAction =
true;
2371 event.setCategory(CalEvent::ARCHIVED);
2372 KAlarm::deleteEvent(event,
false);
2374 if (
theApp()->wantShowInSystemTray())
2380 mNoCloseConfirm =
true;
2393 void MessageWin::displayMainWindow()
2396 KAlarm::displayMainWindowSelected(mEventItemId);
2398 KAlarm::displayMainWindowSelected(mEventId);
2407 bool MessageWin::haveErrorMessage(
unsigned msg)
const
2409 if (!mErrorMessages.
contains(mEventId))
2410 mErrorMessages.
insert(mEventId, 0);
2411 const bool result = (mErrorMessages[mEventId] & msg);
2412 mErrorMessages[mEventId] |= msg;
2416 void MessageWin::clearErrorMessage(
unsigned msg)
const
2418 if (mErrorMessages.
contains(mEventId))
2420 if (mErrorMessages[mEventId] == msg)
2421 mErrorMessages.
remove(mEventId);
2423 mErrorMessages[mEventId] &= ~msg;
2438 bool MessageWin::getWorkAreaAndModal()
2441 const bool modal = Preferences::modalMessages();
2444 const int numScreens = desktop->
numScreens();
2457 for (
int s = 0; s < numScreens; ++s)
2459 const FullScreenType full = findFullScreenWindows(screenRects, screenTypes);
2460 if (full == NoFullScreen || screenTypes[mScreenNumber] == NoFullScreen)
2462 for (
int s = 0; s < numScreens; ++s)
2464 if (screenTypes[s] == NoFullScreen)
2474 for (
int s = 0; s < numScreens; ++s)
2476 if (screenTypes[s] == FullScreen)
2486 int inactiveScreen = -1;
2487 FullScreenType full = haveFullScreenWindow(mScreenNumber);
2488 kDebug()<<
"full="<<full<<
", screen="<<mScreenNumber;
2489 if (full == NoFullScreen)
2491 if (full == FullScreen)
2492 inactiveScreen = mScreenNumber;
2493 for (
int s = 0; s < numScreens; ++s)
2495 if (s != mScreenNumber)
2497 full = haveFullScreenWindow(s);
2498 if (full == NoFullScreen)
2504 if (full == FullScreen && inactiveScreen < 0)
2508 if (inactiveScreen >= 0)
2512 mScreenNumber = inactiveScreen;
2521 const WId activeId = KWindowSystem::activeWindow();
2522 const KWindowInfo wi = KWindowSystem::windowInfo(activeId, NET::WMState);
2523 if (wi.valid() && wi.hasState(NET::FullScreen))
2534 FullScreenType haveFullScreenWindow(
int screen)
2536 FullScreenType type = NoFullScreen;
2538 const NETRootInfo rootInfo(display, NET::ClientList | NET::ActiveWindow, screen);
2539 const Window rootWindow = rootInfo.rootWindow();
2540 const Window activeWindow = rootInfo.activeWindow();
2541 const Window* windows = rootInfo.clientList();
2542 const int windowCount = rootInfo.clientListCount();
2543 kDebug()<<
"Screen"<<screen<<
": Window count="<<windowCount<<
", active="<<activeWindow<<
", geom="<<qApp->desktop()->screenGeometry(screen);
2546 for (
int w = 0; w < windowCount; ++w)
2548 NETWinInfo winInfo(display, windows[w], rootWindow, NET::WMState|NET::WMGeometry);
2549 winInfo.kdeGeometry(frame, geom);
2550 const QRect fr(frame.pos.x, frame.pos.y, frame.size.width, frame.size.height);
2551 const QRect gm(geom.pos.x, geom.pos.y, geom.size.width, geom.size.height);
2552 if (winInfo.state() & NET::FullScreen)
2554 kDebug()<<
"Found FULL SCREEN: "<<windows[w]<<
", geom="<<gm<<
", frame="<<fr;
2556 if (windows[w] == activeWindow)
2557 return FullScreenActive;
2570 FullScreenType result = NoFullScreen;
2571 screenTypes.
fill(NoFullScreen);
2573 const NETRootInfo rootInfo(display, NET::ClientList | NET::ActiveWindow, 0);
2574 const Window rootWindow = rootInfo.rootWindow();
2575 const Window activeWindow = rootInfo.activeWindow();
2576 const Window* windows = rootInfo.clientList();
2577 const int windowCount = rootInfo.clientListCount();
2578 kDebug()<<
"Virtual desktops: Window count="<<windowCount<<
", active="<<activeWindow<<
", geom="<<qApp->desktop()->screenGeometry(0);
2581 for (
int w = 0; w < windowCount; ++w)
2583 NETWinInfo winInfo(display, windows[w], rootWindow, NET::WMState | NET::WMGeometry);
2584 if (winInfo.state() & NET::FullScreen)
2587 const bool active = (windows[w] == activeWindow);
2588 winInfo.kdeGeometry(netframe, netgeom);
2589 const QRect winRect(netgeom.pos.x, netgeom.pos.y, netgeom.size.width, netgeom.size.height);
2590 kDebug()<<
"Found FULL SCREEN: "<<windows[w]<<
", geom="<<winRect;
2591 for (
int s = 0, count = screenRects.
count(); s < count; ++s)
2593 if (screenRects[s].contains(winRect))
2595 kDebug()<<
"FULL SCREEN on screen"<<s<<
", active="<<active;
2597 screenTypes[s] = result = FullScreenActive;
2600 if (screenTypes[s] == NoFullScreen)
2601 screenTypes[s] = FullScreen;
2602 if (result == NoFullScreen)
2603 result = FullScreen;
2614 #include "moc_messagewin_p.cpp"
2615 #include "moc_messagewin.cpp"
QSize boundedTo(const QSize &otherSize) const
virtual void resizeEvent(QResizeEvent *)
void rescheduleAlarm(KAEvent &e, const KAAlarm &a)
static Akonadi::Collection getStandard(CalEvent::Type, bool useDefault=false)
Return the standard collection for a specified mime type.
void setHeight(int height)
virtual void moveEvent(QMoveEvent *)
bool deleteEvent(const QString &eventID, bool save=false)
virtual QSize sizeHint() const
bool contains(const Key &key) const
void setColor(ColorGroup group, ColorRole role, const QColor &color)
static int isWritableEnabled(const Akonadi::Collection &, CalEvent::Type)
Return whether a collection is both enabled and fully writable for a given alarm type, i.e.
static bool isAudioPlaying()
AudioThread(MessageWin *parent, const QString &audioFile, float volume, float fadeVolume, int fadeSeconds, int repeatPause)
static void connect(QObject *receiver, const char *member)
bool eventReadOnly(const QString &uniqueID) const
virtual QByteArray text(quint32 serialNumber) const =0
static bool spread(bool scatter)
KCal::Event * kcalEvent(const QString &uniqueId)
The MainWindowBase class is a base class for KAlarm's main window and message window.
QVector< T > & fill(const T &value, int size)
void setPixmap(const QPixmap &)
static AlarmCalendar * resources()
const QColor & color(ColorGroup group, ColorRole role) const
virtual QSize sizeHint() const
static void error(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Options(Notify|WindowModal))
void translate(int dx, int dy)
void setAlignment(QFlags< Qt::AlignmentFlag >)
bool addEvent(KAEvent *, QWidget *promptParent=0, bool useEventID=false, AlarmResource *=0, bool noPrompt=false, bool *cancelled=0)
QDBusConnection sessionBus()
static const Qt::WidgetAttribute WidgetFlags
void setDeferMinutes(int mins)
virtual void closeEvent(QCloseEvent *)
AlarmResource * resourceForEvent(const QString &eventID) const
void setFrameStyle(int style)
void addSpacing(int size)
QString toString(QFlags< QUrl::FormattingOption > options) const
Akonadi::Collection collectionById(Akonadi::Collection::Id) const
static MessageWin * findEvent(const QString &eventId, MessageWin *exclude=0)
void setSpacing(int spacing)
the KAlarm application object
void setTimeSpec(Qt::TimeSpec spec)
void editAlarm(EditAlarmDlg *, const KAEvent &, AlarmResource *)
MessageWin: A window to display an alarm or error message.
int count(const T &value) const
QString fromLocal8Bit(const char *str, int size)
bool removeEffect(Effect *effect)
void append(const T &value)
QString & insert(int position, QChar ch)
static const Qt::WindowFlags WFLAGS2
virtual void saveProperties(KConfigGroup &)
ShellProcess * execCommandAlarm(const KAEvent &, const KAAlarm &, const QObject *receiver=0, const char *slot=0)
static KTimeZone timeZone(bool reload=false)
void notifyAudioPlaying(bool playing)
static AkonadiModel * instance()
static const int proximityMultiple
int removeAll(const T &value)
static void stopAudio(bool wait=false)
displays an alarm message
static EditAlarmDlg * create(bool Template, Type, QWidget *parent=0, GetResourceType=RES_PROMPT)
static const Qt::WindowFlags WFLAGS
static void disconnect(QObject *receiver, const char *member=0)
static void connect(QObject *receiver, const char *member)
void setText(const QString &)
const DateTime & dateTime()
static void detailedError(QWidget *parent, const QString &text, const QString &details, const QString &caption=QString(), Options options=Options(Notify|WindowModal))
void setMargin(int margin)
QString toLocalFile() const
static int instanceCount(bool excludeAlwaysHidden=false)
static void redisplayAlarms()
Akonadi::Item::Id findItemId(const KAEvent &)
Search for an event's item ID.
virtual QSize sizeHint() const
Path createPath(MediaNode *source, MediaNode *sink)
const QSize & size() const
QList< Effect * > effects() const
Effect * insertEffect(const EffectDescription &desc, Effect *insertBefore)
void showDateTime(const KAEvent &, const KAAlarm &)
Unique event identifier for Akonadi.
KCal::Event::List kcalEvents(CalEvent::Type s=CalEvent::EMPTY)
const DateTime & getDateTime() const
void repeat(const KAAlarm &)
bool wait(unsigned long time)
static int warningYesNo(QWidget *parent, const QString &text, const QString &caption=QString(), const KGuiItem &buttonYes=KStandardGuiItem::yes(), const KGuiItem &buttonNo=KStandardGuiItem::no(), const QString &dontAskAgainName=QString(), Options options=Options(Notify|Dangerous|WindowModal))
void addStretch(int stretch)
static void sorry(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Options(Notify|WindowModal))
void setColumnStretch(int column, int stretch)
QThread * currentThread()
void setLimit(const DateTime &)
static void showError(const KAEvent &, const DateTime &alarmDateTime, const QStringList &errmsgs, const QString &dontShowAgain=QString())
void cancelReminder(const KAEvent &, const KAAlarm &)
static void disconnect(QObject *receiver, const char *member=0)
virtual QSize sizeHint() const
int count(const T &value) const
virtual void readProperties(const KConfigGroup &)
bool displayTrayIcon(bool show, MainWindow *=0)
QString fromLatin1(const char *str, int size)
Provides read and write access to calendar files and resources.
static AlarmCalendar * displayCalendarOpen()
iterator insert(const Key &key, const T &value)
static const int proximityButtonDelay
void stop(bool wait=false)
OrgKdeKSpeechInterface * kspeechInterface(QString &error) const
const_iterator constEnd() const
const_iterator constBegin() const
KAEvent * event(const QString &uniqueId)
QDateTime addSecs(int s) const
static MainWindow * mainMainWindow()
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QRect desktopWorkArea(int screen)
const QDBusError & error()
virtual void showEvent(QShowEvent *)
Akonadi::Collection collectionForItem(Akonadi::Item::Id) const
static AlarmCalendar * displayCalendar()
void setSpacing(int spacing)
void setSpreadWindowsState(bool spread)
bool endsWith(const QByteArray &ba) const
void exit(int returnCode)
void addLayout(QLayout *layout, int stretch)
void alarmCompleted(const KAEvent &)
static MessageWin * mAudioOwner
int remove(const Key &key)