1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/*
* templatepickdlg.cpp - dialogue to choose an alarm template
* Program: kalarm
* Copyright © 2004,2008 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kalarm.h"
#include <layout.h>
#include <tqwhatsthis.h>
#include <klocale.h>
#include <kdebug.h>
#include "functions.h"
#include "shellprocess.h"
#include "templatelistview.h"
#include "templatepickdlg.moc"
static const char TMPL_PICK_DIALOG_NAME[] = "TemplatePickDialog";
TemplatePickDlg::TemplatePickDlg(TQWidget* parent, const char* name)
: KDialogBase(KDialogBase::Plain, i18n("Choose Alarm Template"), Ok|Cancel, Ok, parent, name)
{
TQWidget* topWidget = plainPage();
TQBoxLayout* topLayout = new TQVBoxLayout(topWidget);
topLayout->setSpacing(spacingHint());
// Display the list of templates, but exclude command alarms if in kiosk mode.
bool includeCmdAlarms = ShellProcess::authorised();
mTemplateList = new TemplateListView(includeCmdAlarms, i18n("Select a template to base the new alarm on."), topWidget, "list");
mTemplateList->setSelectionMode(TQListView::Single);
mTemplateList->refresh(); // populate the template list
connect(mTemplateList, TQT_SIGNAL(selectionChanged()), TQT_SLOT(slotSelectionChanged()));
// Require a real double click (even if KDE is in single-click mode) to accept the selection
connect(mTemplateList, TQT_SIGNAL(doubleClicked(TQListViewItem*, const TQPoint&, int)), TQT_SLOT(slotOk()));
topLayout->addWidget(mTemplateList);
slotSelectionChanged(); // enable or disable the OK button
TQSize s;
if (KAlarm::readConfigWindowSize(TMPL_PICK_DIALOG_NAME, s))
resize(s);
}
/******************************************************************************
* Return the currently selected alarm template, or 0 if none.
*/
const KAEvent* TemplatePickDlg::selectedTemplate() const
{
return mTemplateList->selectedEvent();
}
/******************************************************************************
* Called when the template selection changes.
* Enable/disable the OK button depending on whether anything is selected.
*/
void TemplatePickDlg::slotSelectionChanged()
{
enableButtonOK(mTemplateList->selectedItem());
}
/******************************************************************************
* Called when the dialog's size has changed.
* Records the new size in the config file.
*/
void TemplatePickDlg::resizeEvent(TQResizeEvent* re)
{
if (isVisible())
KAlarm::writeConfigWindowSize(TMPL_PICK_DIALOG_NAME, re->size());
KDialog::resizeEvent(re);
}
|