Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
KAlarm
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PIM
KAlarm
Commits
50d564fc
Commit
50d564fc
authored
Dec 12, 2002
by
David Jarvie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add email alarms.
Handle expired alarms. svn path=/trunk/kdepim/; revision=193617
parent
b0fb4163
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
1305 additions
and
809 deletions
+1305
-809
alarmlistview.h
alarmlistview.h
+17
-8
kalarmapp.cpp
kalarmapp.cpp
+775
-506
kalarmapp.h
kalarmapp.h
+125
-87
messagewin.cpp
messagewin.cpp
+128
-95
messagewin.h
messagewin.h
+49
-34
prefs.cpp
prefs.cpp
+94
-11
prefs.h
prefs.h
+16
-1
prefsettings.cpp
prefsettings.cpp
+31
-14
prefsettings.h
prefsettings.h
+70
-53
No files found.
alarmlistview.h
View file @
50d564fc
...
...
@@ -16,6 +16,10 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* As a special exception, permission is given to link this program
* with any edition of Qt, and distribute the resulting executable,
* without including the source code for Qt in the source distribution.
*/
#ifndef ALARMLISTVIEW_H
...
...
@@ -33,11 +37,11 @@ using namespace KCal;
class
AlarmListViewItem
;
struct
AlarmItemData
{
KAlarmEvent
event
;
QString
messageText
;
// message as displayed
QString
dateTimeText
;
// date/time as displayed
QString
repeatText
;
// repeat interval/type as displayed
int
messageWidth
;
// width required to display 'messageText'
KAlarmEvent
event
;
QString
messageText
;
// message as displayed
QString
dateTimeText
;
// date/time as displayed
QString
repeatText
;
// repeat interval/type as displayed
int
messageWidth
;
// width required to display 'messageText'
};
...
...
@@ -47,18 +51,20 @@ class AlarmListView : public KListView
public:
enum
{
TIME_COLUMN
,
REPEAT_COLUMN
,
COLOUR_COLUMN
,
MESSAGE_COLUMN
};
AlarmListView
(
QWidget
*
parent
=
0
L
,
const
char
*
name
=
0L
);
AlarmListView
(
QWidget
*
parent
=
0
,
const
char
*
name
=
0
);
virtual
void
clear
();
void
refresh
();
void
showExpired
(
bool
show
)
{
mShowExpired
=
show
;
}
AlarmListViewItem
*
addEntry
(
const
KAlarmEvent
&
,
bool
setSize
=
false
);
AlarmListViewItem
*
updateEntry
(
AlarmListViewItem
*
,
const
KAlarmEvent
&
newEvent
,
bool
setSize
=
false
);
void
deleteEntry
(
AlarmListViewItem
*
,
bool
setSize
=
false
);
const
KAlarmEvent
getEntry
(
AlarmListViewItem
*
item
)
const
{
return
getData
(
item
)
->
event
;
}
const
KAlarmEvent
&
getEntry
(
AlarmListViewItem
*
item
)
const
{
return
getData
(
item
)
->
event
;
}
AlarmListViewItem
*
getEntry
(
const
QString
&
eventID
);
const
AlarmItemData
*
getData
(
AlarmListViewItem
*
)
const
;
bool
expired
(
AlarmListViewItem
*
)
const
;
void
resizeLastColumn
();
int
itemHeight
();
bool
drawMessageInColour
()
const
{
return
drawMessageInColour_
;
}
bool
drawMessageInColour
()
const
{
return
drawMessageInColour_
;
}
void
setDrawMessageInColour
(
bool
inColour
)
{
drawMessageInColour_
=
inColour
;
}
AlarmListViewItem
*
selectedItem
()
const
{
return
(
AlarmListViewItem
*
)
KListView
::
selectedItem
();
}
AlarmListViewItem
*
currentItem
()
const
{
return
(
AlarmListViewItem
*
)
KListView
::
currentItem
();
}
...
...
@@ -69,6 +75,7 @@ class AlarmListView : public KListView
EntryMap
entries
;
int
lastColumnHeaderWidth_
;
bool
drawMessageInColour_
;
bool
mShowExpired
;
// true to show expired alarms
};
...
...
@@ -82,6 +89,8 @@ class AlarmListViewItem : public QListViewItem
static
QPixmap
*
textIcon
;
static
QPixmap
*
fileIcon
;
static
QPixmap
*
commandIcon
;
static
QPixmap
*
emailIcon
;
static
int
iconWidth
;
};
#endif // ALARMLISTVIEW_H
...
...
kalarmapp.cpp
View file @
50d564fc
This diff is collapsed.
Click to expand it.
kalarmapp.h
View file @
50d564fc
...
...
@@ -16,18 +16,27 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* As a special exception, permission is given to link this program
* with any edition of Qt, and distribute the resulting executable,
* without including the source code for Qt in the source distribution.
*/
#ifndef KALARMAPP_H
#define KALARMAPP_H
#include <qguardedptr.h>
class
QTimer
;
class
QDateTime
;
#include <kuniqueapplication.h>
#include <kurl.h>
class
KAction
;
class
KProcess
;
namespace
KCal
{
class
Event
;
}
#include "msgevent.h"
class
DcopHandler
;
class
AlarmCalendar
;
class
KAlarmMainWindow
;
class
MessageWin
;
...
...
@@ -41,110 +50,139 @@ extern const char* DAEMON_DCOP_OBJECT;
extern
const
char
*
GUI_DCOP_OBJECT_NAME
;
class
DcopHandler
:
public
QWidget
,
DCOPObject
{
Q_OBJECT
public:
DcopHandler
(
const
char
*
name
);
~
DcopHandler
()
{
}
virtual
bool
process
(
const
QCString
&
func
,
const
QByteArray
&
data
,
QCString
&
replyType
,
QByteArray
&
replyData
);
};
class
KAlarmApp
:
public
KUniqueApplication
{
Q_OBJECT
public:
~
KAlarmApp
();
virtual
int
newInstance
();
static
KAlarmApp
*
getInstance
();
AlarmCalendar
&
getCalendar
()
{
return
*
mCalendar
;
}
void
checkCalendar
()
{
initCheck
();
}
Settings
*
settings
()
{
return
mSettings
;
}
bool
KDEDesktop
()
const
{
return
mKDEDesktop
;
}
bool
runInSystemTray
()
const
;
bool
restoreSession
();
bool
sessionClosingDown
()
const
{
return
mSessionClosingDown
;
}
void
quitIf
()
{
quitIf
(
0
);
}
void
addWindow
(
TrayWindow
*
w
)
{
mTrayWindow
=
w
;
}
void
removeWindow
(
TrayWindow
*
);
TrayWindow
*
trayWindow
()
const
{
return
mTrayWindow
;
}
KAlarmMainWindow
*
trayMainWindow
()
const
;
bool
displayTrayIcon
(
bool
show
,
KAlarmMainWindow
*
=
0L
);
bool
trayIconDisplayed
()
const
{
return
!!
mTrayWindow
;
}
DaemonGuiHandler
*
daemonGuiHandler
()
const
{
return
mDaemonGuiHandler
;
}
virtual
int
newInstance
();
static
KAlarmApp
*
getInstance
();
AlarmCalendar
&
getCalendar
()
{
return
*
mCalendar
;
}
AlarmCalendar
*
expiredCalendar
(
bool
saveIfPurged
=
true
);
AlarmCalendar
&
displayCalendar
()
{
return
*
mDisplayCalendar
;
}
void
checkCalendar
()
{
initCheck
();
}
Settings
*
settings
()
{
return
mSettings
;
}
bool
KDEDesktop
()
const
{
return
mKDEDesktop
;
}
bool
wantRunInSystemTray
()
const
;
bool
restoreSession
();
bool
sessionClosingDown
()
const
{
return
mSessionClosingDown
;
}
void
quitIf
()
{
quitIf
(
0
);
}
void
addWindow
(
TrayWindow
*
w
)
{
mTrayWindow
=
w
;
}
void
removeWindow
(
TrayWindow
*
);
TrayWindow
*
trayWindow
()
const
{
return
mTrayWindow
;
}
KAlarmMainWindow
*
trayMainWindow
()
const
;
bool
displayTrayIcon
(
bool
show
,
KAlarmMainWindow
*
=
0
);
bool
trayIconDisplayed
()
const
{
return
!!
mTrayWindow
;
}
DaemonGuiHandler
*
daemonGuiHandler
()
const
{
return
mDaemonGuiHandler
;
}
ActionAlarmsEnabled
*
actionAlarmEnable
()
const
{
return
mActionAlarmEnable
;
}
KAction
*
actionPreferences
()
const
{
return
mActionPrefs
;
}
KAction
*
actionDaemonControl
()
const
{
return
mActionDaemonControl
;
}
void
resetDaemon
();
bool
isDaemonRunning
(
);
void
readDaemonCheckInterval
();
QSize
readConfigWindowSize
(
const
char
*
window
,
const
QSize
&
defaultSize
);
void
writeConfigWindowSize
(
const
char
*
window
,
const
QSize
&
);
virtual
void
commitData
(
QSessionManager
&
);
KAction
*
actionPreferences
()
const
{
return
mActionPrefs
;
}
KAction
*
actionDaemonControl
()
const
{
return
mActionDaemonControl
;
}
void
resetDaemon
();
bool
isDaemonRunning
(
bool
startDaemon
=
true
);
void
readDaemonCheckInterval
();
QSize
readConfigWindowSize
(
const
char
*
window
,
const
QSize
&
defaultSize
);
void
writeConfigWindowSize
(
const
char
*
window
,
const
QSize
&
);
virtual
void
commitData
(
QSessionManager
&
);
bool
addEvent
(
const
KAlarmEvent
&
,
KAlarmMainWindow
*
);
void
modifyEvent
(
const
QString
&
oldEventID
,
const
KAlarmEvent
&
newEvent
,
KAlarmMainWindow
*
);
void
updateEvent
(
const
KAlarmEvent
&
,
KAlarmMainWindow
*
);
void
deleteEvent
(
KAlarmEvent
&
,
KAlarmMainWindow
*
,
bool
tellDaemon
=
true
);
bool
execAlarm
(
KAlarmEvent
&
,
const
KAlarmAlarm
&
,
bool
reschedule
,
bool
allowDefer
=
true
);
void
rescheduleAlarm
(
KAlarmEvent
&
,
int
alarmID
);
void
deleteEvent
(
const
QString
&
eventID
)
{
handleEvent
(
eventID
,
EVENT_CANCEL
);
}
int
maxLateness
();
const
KCal
::
Event
*
getEvent
(
const
QString
&
eventID
);
bool
addEvent
(
const
KAlarmEvent
&
,
KAlarmMainWindow
*
);
void
modifyEvent
(
KAlarmEvent
&
oldEvent
,
const
KAlarmEvent
&
newEvent
,
KAlarmMainWindow
*
);
void
updateEvent
(
KAlarmEvent
&
,
KAlarmMainWindow
*
,
bool
archiveOnDelete
=
true
);
void
deleteEvent
(
KAlarmEvent
&
,
KAlarmMainWindow
*
,
bool
tellDaemon
=
true
,
bool
archive
=
true
);
void
deleteDisplayEvent
(
const
QString
&
eventID
)
const
;
void
undeleteEvent
(
KAlarmEvent
&
,
KAlarmMainWindow
*
);
void
archiveEvent
(
KAlarmEvent
&
);
void
startCalendarUpdate
();
void
endCalendarUpdate
();
void
calendarSave
(
bool
reload
=
true
);
void
*
execAlarm
(
KAlarmEvent
&
,
const
KAlarmAlarm
&
,
bool
reschedule
,
bool
allowDefer
=
true
);
void
alarmShowing
(
KAlarmEvent
&
,
KAlarmAlarm
::
Type
,
const
QDateTime
&
);
void
deleteEvent
(
const
QString
&
eventID
)
{
handleEvent
(
eventID
,
EVENT_CANCEL
);
}
void
commandMessage
(
KProcess
*
,
QWidget
*
parent
);
int
maxLateness
();
// Methods called indirectly by the DCOP interface
bool
scheduleEvent
(
const
QString
&
text
,
const
QDateTime
&
,
const
QColor
&
bg
,
int
flags
,
const
QString
&
audioFile
,
KAlarmAlarm
::
Type
,
KAlarmEvent
::
RecurType
,
int
repeatInterval
,
int
repeatCount
,
const
QDateTime
&
endTime
);
void
handleEvent
(
const
QString
&
calendarFile
,
const
QString
&
eventID
)
{
handleEvent
(
calendarFile
,
eventID
,
EVENT_HANDLE
);
}
void
triggerEvent
(
const
QString
&
calendarFile
,
const
QString
&
eventID
)
{
handleEvent
(
calendarFile
,
eventID
,
EVENT_TRIGGER
);
}
void
deleteEvent
(
const
QString
&
calendarFile
,
const
QString
&
eventID
)
{
handleEvent
(
calendarFile
,
eventID
,
EVENT_CANCEL
);
}
bool
scheduleEvent
(
const
QString
&
text
,
const
QDateTime
&
,
const
QColor
&
bg
,
int
flags
,
const
QString
&
audioFile
,
const
EmailAddressList
&
mailAddresses
,
const
QString
&
mailSubject
,
const
QStringList
&
mailAttachments
,
KAlarmEvent
::
Action
,
KAlarmEvent
::
RecurType
,
int
repeatInterval
,
int
repeatCount
,
const
QDateTime
&
endTime
);
void
handleEvent
(
const
QString
&
calendarFile
,
const
QString
&
eventID
)
{
handleEvent
(
calendarFile
,
eventID
,
EVENT_HANDLE
);
}
void
triggerEvent
(
const
QString
&
calendarFile
,
const
QString
&
eventID
)
{
handleEvent
(
calendarFile
,
eventID
,
EVENT_TRIGGER
);
}
void
deleteEvent
(
const
QString
&
calendarFile
,
const
QString
&
eventID
)
{
handleEvent
(
calendarFile
,
eventID
,
EVENT_CANCEL
);
}
static
int
isTextFile
(
const
KURL
&
);
static
int
isTextFile
(
const
KURL
&
);
public
slots
:
void
displayMainWindow
();
void
slotDaemonControl
();
void
displayMainWindow
();
void
slotDaemonControl
();
signals:
void
trayIconToggled
();
void
trayIconToggled
();
protected:
KAlarmApp
();
private
slots
:
void
slotPreferences
();
void
toggleAlarmsEnabled
();
void
slotSettingsChanged
();
void
slotPreferences
();
void
toggleAlarmsEnabled
();
void
slotSettingsChanged
();
void
slotCommandExited
(
KProcess
*
);
void
slotSystemTrayTimer
();
private:
enum
EventFunc
{
EVENT_HANDLE
,
EVENT_TRIGGER
,
EVENT_CANCEL
};
enum
AlarmFunc
{
ALARM_TRIGGER
,
ALARM_CANCEL
,
ALARM_RESCHEDULE
};
bool
initCheck
(
bool
calendarOnly
=
false
);
void
quitIf
(
int
exitCode
);
void
changeStartOfDay
();
void
setUpDcop
();
bool
stopDaemon
();
void
startDaemon
();
void
reloadDaemon
();
void
registerWithDaemon
();
void
handleEvent
(
const
QString
&
calendarFile
,
const
QString
&
eventID
,
EventFunc
);
bool
handleEvent
(
const
QString
&
eventID
,
EventFunc
);
void
handleAlarm
(
KAlarmEvent
&
,
KAlarmAlarm
&
,
AlarmFunc
,
bool
updateCalAndDisplay
);
struct
ProcData
{
ProcData
(
KProcess
*
p
,
KAlarmEvent
*
e
,
KAlarmAlarm
*
a
,
QCString
sh
)
:
process
(
p
),
event
(
e
),
alarm
(
a
),
shell
(
sh
),
messageBoxParent
(
0
)
{
}
~
ProcData
();
KProcess
*
process
;
KAlarmEvent
*
event
;
KAlarmAlarm
*
alarm
;
QCString
shell
;
QGuardedPtr
<
QWidget
>
messageBoxParent
;
};
bool
initCheck
(
bool
calendarOnly
=
false
);
void
quitIf
(
int
exitCode
);
void
redisplayAlarms
();
bool
checkSystemTray
();
void
changeStartOfDay
();
void
setUpDcop
();
bool
stopDaemon
();
void
startDaemon
();
void
reloadDaemon
();
void
registerWithDaemon
(
bool
reregister
);
void
handleEvent
(
const
QString
&
calendarFile
,
const
QString
&
eventID
,
EventFunc
);
bool
handleEvent
(
const
QString
&
eventID
,
EventFunc
);
void
rescheduleAlarm
(
KAlarmEvent
&
,
const
KAlarmAlarm
&
,
bool
updateCalAndDisplay
);
void
cancelAlarm
(
KAlarmEvent
&
,
KAlarmAlarm
::
Type
,
bool
updateCalAndDisplay
);
static
KAlarmApp
*
theInstance
;
// the one and only KAlarmApp instance
static
int
activeCount
;
// number of active instances without main windows
DcopHandler
*
mDcopHandler
;
// the parent of the main DCOP receiver object
DaemonGuiHandler
*
mDaemonGuiHandler
;
// the parent of the system tray DCOP receiver object
TrayWindow
*
mTrayWindow
;
// active system tray icon
AlarmCalendar
*
mCalendar
;
// the calendar containing all the alarms
ActionAlarmsEnabled
*
mActionAlarmEnable
;
// action to enable/disable alarms
KAction
*
mActionPrefs
;
// action to display the preferences dialog
KAction
*
mActionDaemonControl
;
// action to display the alarm daemon control dialog
Settings
*
mSettings
;
// program preferences
QDateTime
mLastDaemonCheck
;
// last time daemon checked alarms before check interval change
QDateTime
mNextDaemonCheck
;
// next time daemon will check alarms after check interval change
QTime
mStartOfDay
;
// start-of-day time currently in use
int
mDaemonCheckInterval
;
// daemon check interval (seconds)
bool
mDaemonRegistered
;
// true if we've registered with alarm daemon
bool
mKDEDesktop
;
// running on KDE desktop
bool
mDaemonRunning
;
// whether the alarm daemon is currently running
bool
mSessionClosingDown
;
// session manager is closing the application
bool
mOldRunInSystemTray
;
// running continuously in system tray was selected
static
KAlarmApp
*
theInstance
;
// the one and only KAlarmApp instance
static
int
activeCount
;
// number of active instances without main windows
DcopHandler
*
mDcopHandler
;
// the parent of the main DCOP receiver object
DaemonGuiHandler
*
mDaemonGuiHandler
;
// the parent of the system tray DCOP receiver object
TrayWindow
*
mTrayWindow
;
// active system tray icon
AlarmCalendar
*
mCalendar
;
// the calendar containing the active alarms
AlarmCalendar
*
mExpiredCalendar
;
// the calendar containing closed alarms
AlarmCalendar
*
mDisplayCalendar
;
// the calendar containing currently displaying alarms
ActionAlarmsEnabled
*
mActionAlarmEnable
;
// action to enable/disable alarms
KAction
*
mActionPrefs
;
// action to display the preferences dialog
KAction
*
mActionDaemonControl
;
// action to display the alarm daemon control dialog
Settings
*
mSettings
;
// program preferences
QDateTime
mLastDaemonCheck
;
// last time daemon checked alarms before check interval change
QDateTime
mNextDaemonCheck
;
// next time daemon will check alarms after check interval change
QTime
mStartOfDay
;
// start-of-day time currently in use
QColor
mOldExpiredColour
;
// expired alarms text colour
int
mOldExpiredKeepDays
;
// how long expired alarms are being kept
QPtrList
<
ProcData
>
mCommandProcesses
;
// currently active command alarm processes
int
mDaemonCheckInterval
;
// daemon check interval (seconds)
int
mCalendarUpdateCount
;
// nesting level of calendarUpdate calls
bool
mCalendarUpdateSave
;
// save() was called while mCalendarUpdateCount > 0
bool
mCalendarUpdateReload
;
// reloadDaemon() was called while mCalendarUpdateCount > 0
bool
mDaemonRegistered
;
// true if we've registered with alarm daemon
bool
mKDEDesktop
;
// running on KDE desktop
bool
mNoSystemTray
;
// no KDE system tray exists
bool
mSavedNoSystemTray
;
// mNoSystemTray before mCheckingSystemTray was true
bool
mCheckingSystemTray
;
// the existence of the system tray is being checked
bool
mDaemonRunning
;
// whether the alarm daemon is currently running
bool
mSessionClosingDown
;
// session manager is closing the application
bool
mOldRunInSystemTray
;
// running continuously in system tray was selected
bool
mDisableAlarmsIfStopped
;
// disable alarms whenever KAlarm is not running
};
...
...
messagewin.cpp
View file @
50d564fc
...
...
@@ -68,22 +68,24 @@ QPtrList<MessageWin> MessageWin::windowList;
* displayed.
*/
MessageWin
::
MessageWin
(
const
KAlarmEvent
&
evnt
,
const
KAlarmAlarm
&
alarm
,
bool
reschedule_event
,
bool
allowDefer
)
:
MainWindowBase
(
0
L
,
"MessageWin"
,
WStyle_StaysOnTop
|
WDestructiveClose
|
WGroupLeader
|
WStyle_ContextHelp
),
e
vent
(
evnt
),
:
MainWindowBase
(
0
,
"MessageWin"
,
WStyle_StaysOnTop
|
WDestructiveClose
|
WGroupLeader
|
WStyle_ContextHelp
),
mE
vent
(
evnt
),
message
(
alarm
.
cleanText
()),
font
(
theApp
()
->
settings
()
->
messageFont
()),
colour
(
alarm
.
colour
()),
dateTime
(
alarm
.
repeatAtLogin
()
?
evnt
.
firstAlarm
().
dateTime
()
:
alarm
.
dateTime
()),
colour
(
evnt
.
colour
()),
mDateTime
(
alarm
.
dateTime
()),
eventID
(
evnt
.
id
()),
audioFile
(
evnt
.
audioFile
()),
alarmID
(
alarm
.
id
()),
emailAddresses
(
evnt
.
emailAddresses
(
"
\n
"
)),
emailSubject
(
evnt
.
emailSubject
()),
alarmType
(
alarm
.
type
()),
flags
(
alarm
.
flags
()),
beep
(
alarm
.
beep
()),
confirmAck
(
ev
e
nt
.
confirmAck
()),
dateOnly
(
ev
e
nt
.
anyTime
()),
type
(
alarm
.
type
()),
beep
(
evnt
.
beep
()),
confirmAck
(
evnt
.
confirmAck
()),
dateOnly
(
evnt
.
anyTime
()),
action
(
alarm
.
action
()),
noDefer
(
!
allowDefer
||
alarm
.
repeatAtLogin
()),
deferButton
(
0
L
),
deferButton
(
0
),
restoreHeight
(
0
),
rescheduleEvent
(
reschedule_event
),
shown
(
false
),
...
...
@@ -92,7 +94,7 @@ MessageWin::MessageWin(const KAlarmEvent& evnt, const KAlarmAlarm& alarm, bool r
kdDebug
(
5950
)
<<
"MessageWin::MessageWin(event)"
<<
endl
;
setAutoSaveSettings
(
QString
::
fromLatin1
(
"MessageWin"
));
// save window sizes etc.
QSize
size
=
initView
();
if
(
type
==
KAlarmAlarm
::
FILE
&&
errorMsg
.
isNull
())
if
(
action
==
KAlarmAlarm
::
FILE
&&
errorMsg
.
isNull
())
size
=
theApp
()
->
readConfigWindowSize
(
"FileMessage"
,
size
);
resize
(
size
);
windowList
.
append
(
this
);
...
...
@@ -104,24 +106,27 @@ MessageWin::MessageWin(const KAlarmEvent& evnt, const KAlarmAlarm& alarm, bool r
* the whole event needs to be stored for updating the calendar file when it is
* displayed.
*/
MessageWin
::
MessageWin
(
const
QString
&
errmsg
,
const
KAlarmEvent
&
evnt
,
const
KAlarmAlarm
&
alarm
,
bool
reschedule_event
)
:
MainWindowBase
(
0
L
,
"MessageWin"
,
WStyle_StaysOnTop
|
WDestructiveClose
|
WGroupLeader
|
WStyle_ContextHelp
),
e
vent
(
evnt
),
MessageWin
::
MessageWin
(
const
KAlarmEvent
&
evnt
,
const
KAlarmAlarm
&
alarm
,
const
QString
&
errmsg
,
const
QString
&
errmsg2
,
bool
reschedule_event
)
:
MainWindowBase
(
0
,
"MessageWin"
,
WStyle_StaysOnTop
|
WDestructiveClose
|
WGroupLeader
|
WStyle_ContextHelp
),
mE
vent
(
evnt
),
message
(
alarm
.
cleanText
()),
font
(
theApp
()
->
settings
()
->
messageFont
()),
colour
(
Qt
::
white
),
dateTime
(
alarm
.
repeatAtLogin
()
?
evnt
.
firstAlarm
().
dateTime
()
:
alarm
.
dateTime
()),
mDateTime
(
alarm
.
dateTime
()),
eventID
(
evnt
.
id
()),
audioFile
(
evnt
.
audioFile
()),
alarmID
(
alarm
.
id
()),
emailAddresses
(
evnt
.
emailAddresses
(
"
\n
"
)),
emailSubject
(
evnt
.
emailSubject
()),
alarmType
(
alarm
.
type
()),
flags
(
alarm
.
flags
()),
beep
(
false
),
confirmAck
(
evnt
.
confirmAck
()),
dateOnly
(
evnt
.
anyTime
()),
type
(
alarm
.
type
()),
action
(
alarm
.
action
()),
errorMsg
(
errmsg
),
errorMsg2
(
errmsg2
),
noDefer
(
true
),
deferButton
(
0
L
),
deferButton
(
0
),
restoreHeight
(
0
),
rescheduleEvent
(
reschedule_event
),
shown
(
false
),
...
...
@@ -139,7 +144,7 @@ MessageWin::MessageWin(const QString& errmsg, const KAlarmEvent& evnt, const KAl
* The window is initialised by readProperties().
*/
MessageWin
::
MessageWin
()
:
MainWindowBase
(
0
L
,
"MessageWin"
,
WStyle_StaysOnTop
|
WDestructiveClose
),
:
MainWindowBase
(
0
,
"MessageWin"
,
WStyle_StaysOnTop
|
WDestructiveClose
),
rescheduleEvent
(
false
),
shown
(
true
),
deferClosing
(
false
)
...
...
@@ -157,6 +162,8 @@ MessageWin::~MessageWin()
windowList
.
remove
();
break
;
}
if
(
!
windowList
.
count
())
theApp
()
->
quitIf
();
}
/******************************************************************************
...
...
@@ -169,12 +176,12 @@ QSize MessageWin::initView()
setCentralWidget
(
topWidget
);
QVBoxLayout
*
topLayout
=
new
QVBoxLayout
(
topWidget
,
KDialog
::
marginHint
(),
KDialog
::
spacingHint
());
if
(
d
ateTime
.
isValid
())
if
(
mD
ateTime
.
isValid
())
{
// Alarm date/time
QLabel
*
label
=
new
QLabel
(
topWidget
);
label
->
setText
(
dateOnly
?
KGlobal
::
locale
()
->
formatDate
(
d
ateTime
.
date
(),
true
)
:
KGlobal
::
locale
()
->
formatDateTime
(
d
ateTime
));
label
->
setText
(
dateOnly
?
KGlobal
::
locale
()
->
formatDate
(
mD
ateTime
.
date
(),
true
)
:
KGlobal
::
locale
()
->
formatDateTime
(
mD
ateTime
));
label
->
setFrameStyle
(
QFrame
::
Box
|
QFrame
::
Raised
);
label
->
setFixedSize
(
label
->
sizeHint
());
topLayout
->
addWidget
(
label
,
0
,
Qt
::
AlignHCenter
);
...
...
@@ -182,25 +189,16 @@ QSize MessageWin::initView()
i18n
(
"The scheduled date/time for the message (as opposed to the actual time of display)."
));
}
QLabel
*
fileCommandLabel
=
0
;
if
(
type
==
KAlarmAlarm
::
FILE
||
type
==
KAlarmAlarm
::
COMMAND
)
switch
(
action
)
{
// Display the file name or command
fileCommandLabel
=
new
QLabel
(
message
,
topWidget
);
fileCommandLabel
->
setFrameStyle
(
QFrame
::
Box
|
QFrame
::
Raised
);
fileCommandLabel
->
setFixedSize
(
fileCommandLabel
->
sizeHint
());
topLayout
->
addWidget
(
fileCommandLabel
,
0
,
Qt
::
AlignHCenter
);
}
switch
(
type
)
{
case
KAlarmAlarm
::
COMMAND
:
{
QWhatsThis
::
add
(
fileCommandLabel
,
i18n
(
"The command to execute"
));
break
;
}
case
KAlarmAlarm
::
FILE
:
{
QWhatsThis
::
add
(
fileCommandLabel
,
i18n
(
"The file whose contents are displayed below"
));
// Display the file name
QLabel
*
label
=
new
QLabel
(
message
,
topWidget
);
label
->
setFrameStyle
(
QFrame
::
Box
|
QFrame
::
Raised
);
label
->
setFixedSize
(
label
->
sizeHint
());
QWhatsThis
::
add
(
label
,
i18n
(
"The file whose contents are displayed below"
));
topLayout
->
addWidget
(
label
,
0
,
Qt
::
AlignHCenter
);
// Display contents of file
bool
opened
=
false
;
...
...
@@ -249,7 +247,6 @@ QSize MessageWin::initView()
}
break
;
}
#ifdef KALARM_EMAIL
case
KAlarmAlarm
::
EMAIL
:
{
// Display the email addresses and subject
...
...
@@ -274,25 +271,34 @@ QSize MessageWin::initView()
grid
->
addWidget
(
label
,
1
,
1
,
Qt
::
AlignLeft
);
break
;
}
#endif
case
KAlarmAlarm
::
COMMAND
:
break
;
case
KAlarmAlarm
::
MESSAGE
:
default:
{
// Message label
QLabel
*
label
=
new
QLabel
(
message
,
topWidget
);
label
->
setFont
(
font
);
label
->
setPalette
(
QPalette
(
colour
,
colour
)
);
label
->
setFixedSize
(
label
->
sizeHint
()
);
QWhatsThis
::
add
(
label
,
i18n
(
"The alarm message"
));
int
lineSpacing
=
label
->
fontMetrics
().
lineSpacing
();
MessageText
*
text
=
new
MessageText
(
message
,
QString
::
null
,
topWidget
);
text
->
setFrameStyle
(
QFrame
::
NoFrame
);
text
->
setPaper
(
colour
);
text
->
setFont
(
font
);
QWhatsThis
::
add
(
text
,
i18n
(
"The alarm message"
));
int
lineSpacing
=
text
->
fontMetrics
().
lineSpacing
();
int
vspace
=
lineSpacing
/
2
-
marginKDE2
;
int
hspace
=
lineSpacing
-
marginKDE2
-
KDialog
::
marginHint
();
topLayout
->
addSpacing
(
vspace
);
QBoxLayout
*
layout
=
new
QHBoxLayout
(
topLayout
);
layout
->
addSpacing
(
hspace
);
layout
->
addWidget
(
label
,
0
,
Qt
::
AlignHCenter
);
layout
->
addSpacing
(
hspace
);
topLayout
->
addSpacing
(
vspace
);
topLayout
->
addStretch
();
// Don't include any horizontal margins if message is 2/3 screen width
if
(
text
->
sizeHint
().
width
()
>=
KWinModule
().
workArea
().
width
()
*
2
/
3
)
topLayout
->
addWidget
(
text
,
1
,
Qt
::
AlignHCenter
);
else
{
QBoxLayout
*
layout
=
new
QHBoxLayout
(
topLayout
);
layout
->
addSpacing
(
hspace
);
layout
->
addWidget
(
text
,
1
,
Qt
::
AlignHCenter
);
layout
->
addSpacing
(
hspace
);
}
topLayout
->
addStretch
();
break
;
}
}
...
...
@@ -301,16 +307,23 @@ QSize MessageWin::initView()
else
{
setCaption
(
i18n
(
"Error"
));
Q
H
BoxLayout
*
layout
=
new
QHBoxLayout
(
topLayout
);
QBoxLayout
*
layout
=
new
QHBoxLayout
(
topLayout
);
layout
->
setMargin
(
2
*
KDialog
::
marginHint
());
layout
->
addStretch
();
QLabel
*
label
=
new
QLabel
(
topWidget
);
label
->
setPixmap
(
DesktopIcon
(
"error"
));
label
->
setFixedSize
(
label
->
sizeHint
());
layout
->
addWidget
(
label
,
0
,
Qt
::
AlignRight
);
QBoxLayout
*
vlayout
=
new
QVBoxLayout
(
layout
);
label
=
new
QLabel
(
errorMsg
,
topWidget
);
label
->
setFixedSize
(
label
->
sizeHint
());
layout
->
addWidget
(
label
,
0
,
Qt
::
AlignLeft
);
vlayout
->
addWidget
(
label
,
0
,
Qt
::
AlignLeft
);
if
(
!
errorMsg2
.
isEmpty
())
{
label
=
new
QLabel
(
errorMsg2
,
topWidget
);
label
->
setFixedSize
(
label
->
sizeHint
());
vlayout
->
addWidget
(
label
,
0
,
Qt
::
AlignLeft
);
}
layout
->
addStretch
();
}
...
...
@@ -359,12 +372,12 @@ QSize MessageWin::initView()
okButton
->
setFixedSize
(
minbutsize
);
topLayout
->
activate
();
QSize
size
(
minbutsize
.
width
()
*
3
,
topLayout
->
sizeHint
().
height
());
QSize
size
(
minbutsize
.
width
()
*
3
,
sizeHint
().
height
());
setMinimumSize
(
size
);
KWin
::
setState
(
winId
(),
NET
::
Modal
|
NET
::
Sticky
|
NET
::
StaysOnTop
);
KWin
::
setOnAllDesktops
(
winId
(),
true
);
return
size
;
return
size
Hint
()
;
}
/******************************************************************************
...
...
@@ -376,47 +389,47 @@ void MessageWin::saveProperties(KConfig* config)
if
(
shown
)
{
config
->
writeEntry
(
QString
::
fromLatin1
(
"EventID"
),
eventID
);
config
->
writeEntry
(
QString
::
fromLatin1
(
"Alarm
ID"
),
alarmID
);
config
->
writeEntry
(
QString
::
fromLatin1
(
"Alarm
Type"
),
alarmType
);
config
->
writeEntry
(
QString
::
fromLatin1
(
"Message"
),
message
);
config
->
writeEntry
(
QString
::
fromLatin1
(
"Type"
),
(
errorMsg
.
isNull
()
?
type
:
-
1
));
config
->
writeEntry
(
QString
::
fromLatin1
(
"Type"
),
(
errorMsg
.
isNull
()
?
action
:
-
1
));
config
->
writeEntry
(
QString
::
fromLatin1
(
"Font"
),
font
);
config
->
writeEntry
(
QString
::
fromLatin1
(
"Colour"
),
colour
);
config
->
writeEntry
(
QString
::
fromLatin1
(
"ConfirmAck"
),
confirmAck
);
if
(
d
ateTime
.
isValid
())
if
(
mD
ateTime
.
isValid
())
{
config
->
writeEntry
(
QString
::
fromLatin1
(
"Time"
),
d
ateTime
);
config
->
writeEntry
(
QString
::
fromLatin1
(
"Time"
),
mD
ateTime
);
config
->
writeEntry
(
QString
::
fromLatin1
(
"DateOnly"
),
dateOnly
);
}
config
->
writeEntry
(
QString
::
fromLatin1
(
"Height"
),
height
());
config
->
writeEntry
(
QString
::
fromLatin1
(
"NoDefer"
),
noDefer
);
}
else
config
->
writeEntry
(
QString
::
fromLatin1
(
"Alarm
ID"
),
-
1
);
config
->
writeEntry
(
QString
::
fromLatin1
(
"Alarm
Type"
),
KAlarmAlarm
::
INVALID_ALARM
);
}
/******************************************************************************
* Read settings from the session managed config file.
* This function is automatically called whenever the app is being
*
restored.
Read in whatever was saved in saveProperties().
* This function is automatically called whenever the app is being
restored.
* Read in whatever was saved in saveProperties().
*/
void
MessageWin
::
readProperties
(
KConfig
*
config
)
{
eventID
=
config
->
readEntry
(
QString
::
fromLatin1
(
"EventID"
));
alarm
ID
=
config
->
readNumEntry
(
QString
::
fromLatin1
(
"AlarmID"
));
alarm
Type
=
KAlarmAlarm
::
Type
(
config
->
readNumEntry
(
QString
::
fromLatin1
(
"AlarmType"
)
));
message
=
config
->
readEntry
(
QString
::
fromLatin1
(
"Message"
));
int
t
=
config
->
readNumEntry
(
QString
::
fromLatin1
(
"Type"
));
// don't copy straight into an enum value in case -1 gets
l
runcated
int
t
=
config
->
readNumEntry
(
QString
::
fromLatin1
(
"Type"
));
// don't copy straight into an enum value in case -1 gets
t
runcated
if
(
t
<
0
)
errorMsg
=
""
;
// set non-null
type
=
KAlarmAlarm
::
Type
(
t
);
action
=
KAlarmAlarm
::
Action
(
t
);
font
=
config
->
readFontEntry
(
QString
::
fromLatin1
(
"Font"
));
colour
=
config
->
readColorEntry
(
QString
::
fromLatin1
(
"Colour"
));
confirmAck
=
config
->
readBoolEntry
(
QString
::
fromLatin1
(
"ConfirmAck"
));
QDateTime
invalidDateTime
;
dateTime
=
config
->
readDateTimeEntry
(
QString
::
fromLatin1
(
"Time"
),
&
invalidDateTime
);
mDateTime
=
config
->
readDateTimeEntry
(
QString
::
fromLatin1
(
"Time"
),
&
invalidDateTime
);
dateOnly
=
config
->
readBoolEntry
(
QString
::
fromLatin1
(
"DateOnly"
));
restoreHeight
=
config
->
readNumEntry
(
QString
::
fromLatin1
(
"Height"
));
noDefer
=
config
->
readBoolEntry
(
QString
::
fromLatin1
(
"NoDefer"
));
if
(
errorMsg
.
isNull
()
&&
alarm
ID
>
0
)
if
(
errorMsg
.
isNull
()
&&
alarm
Type
!=
KAlarmAlarm
::
INVALID_ALARM
)
initView
();
}
...
...
@@ -429,7 +442,7 @@ MessageWin* MessageWin::findEvent(const QString& eventID)
for
(
MessageWin
*
w
=
windowList
.
first
();
w
;
w
=
windowList
.
next
())
if
(
w
->
eventID
==
eventID
)
return
w
;