• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kalarm

  • sources
  • kde-4.14
  • kdepim
  • kalarm
resourceconfigdialog.cpp
Go to the documentation of this file.
1 /*
2  * resourceconfigdialog.cpp - KAlarm resource configuration dialog
3  * Program: kalarm
4  * Copyright © 2006-2011 by David Jarvie <djarvie@kde.org>
5  * Based on configdialog.cpp in kdelibs/kresources,
6  * Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
7  * Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
8  * Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23  */
24 
25 #include "alarmresource.h"
26 #include "resourceconfigdialog.moc"
27 #include "messagebox.h"
28 
29 #include <kresources/factory.h>
30 
31 #include <klocale.h>
32 #include <klineedit.h>
33 
34 #include <QGroupBox>
35 #include <QLabel>
36 #include <QCheckBox>
37 #include <QVBoxLayout>
38 #include <QGridLayout>
39 
40 using namespace KRES;
41 
42 ResourceConfigDialog::ResourceConfigDialog(QWidget* parent, AlarmResource* resource)
43  : KDialog(parent), mResource(resource)
44 {
45  Factory* factory = Factory::self(QLatin1String("alarms"));
46 
47  QFrame* main = new QFrame(this);
48  setMainWidget(main);
49  setCaption(i18nc("@title:window", "Calendar Configuration"));
50  setButtons(Ok | Cancel);
51  setDefaultButton(Ok);
52  setModal(true);
53 
54  QVBoxLayout* mainLayout = new QVBoxLayout(main);
55  mainLayout->setSpacing(spacingHint());
56 
57  QGroupBox* generalGroupBox = new QGroupBox(main);
58  QGridLayout* gbLayout = new QGridLayout;
59  gbLayout->setSpacing(spacingHint());
60  generalGroupBox->setLayout(gbLayout);
61 
62  generalGroupBox->setTitle(i18nc("@title:group", "General Settings"));
63 
64  gbLayout->addWidget(new QLabel(i18nc("@label:textbox Calendar name", "Name:"), generalGroupBox), 0, 0);
65 
66  mName = new KLineEdit();
67  gbLayout->addWidget(mName, 0, 1);
68 
69  mReadOnly = new QCheckBox(i18nc("@option:check", "Read-only"), generalGroupBox);
70  gbLayout->addWidget(mReadOnly, 1, 0, 1, 2);
71 
72  mName->setText(mResource->resourceName());
73  mReadOnly->setChecked(mResource->readOnly());
74 
75  mainLayout->addWidget(generalGroupBox);
76 
77  QGroupBox* resourceGroupBox = new QGroupBox(main);
78  QGridLayout* resourceLayout = new QGridLayout;
79  resourceLayout->setSpacing(spacingHint());
80  resourceGroupBox->setLayout(resourceLayout);
81 
82  resourceGroupBox->setTitle(i18nc("@title:group", "<resource>%1</resource> Calendar Settings",
83  factory->typeName(resource->type())));
84  mainLayout->addWidget(resourceGroupBox);
85 
86  mainLayout->addStretch();
87 
88  mConfigWidget = factory->configWidget(resource->type(), resourceGroupBox);
89  if (mConfigWidget)
90  {
91  resourceLayout->addWidget(mConfigWidget);
92  mConfigWidget->setInEditMode(false);
93  mConfigWidget->loadSettings(mResource);
94  mConfigWidget->show();
95  connect(mConfigWidget, SIGNAL(setReadOnly(bool)), SLOT(setReadOnly(bool)));
96  }
97 
98  connect(mName, SIGNAL(textChanged(QString)), SLOT(slotNameChanged(QString)));
99 
100  slotNameChanged(mName->text());
101  setMinimumSize(sizeHint());
102 }
103 
104 void ResourceConfigDialog::setInEditMode(bool value)
105 {
106  if (mConfigWidget)
107  mConfigWidget->setInEditMode(value);
108 }
109 
110 void ResourceConfigDialog::slotNameChanged(const QString& text)
111 {
112  enableButtonOk(!text.isEmpty());
113 }
114 
115 void ResourceConfigDialog::setReadOnly(bool value)
116 {
117  mReadOnly->setChecked(value);
118 }
119 
120 void ResourceConfigDialog::accept()
121 {
122  if (mName->text().isEmpty())
123  {
124  KAMessageBox::sorry(this, i18nc("@info", "Please enter a calendar name."));
125  return;
126  }
127 
128  mResource->startReconfig();
129  mResource->setResourceName(mName->text());
130  mResource->setReadOnly(mReadOnly->isChecked());
131 
132  if (mConfigWidget)
133  {
134  // First save generic information
135  // Also save setting of specific resource type
136  mConfigWidget->saveSettings(mResource);
137  }
138  mResource->applyReconfig();
139 
140  KDialog::accept();
141 }
142 
143 // vim: et sw=4:
ResourceConfigDialog::setReadOnly
void setReadOnly(bool value)
Definition: resourceconfigdialog.cpp:115
QWidget
QGridLayout::addWidget
void addWidget(QWidget *widget, int row, int column, QFlags< Qt::AlignmentFlag > alignment)
text
virtual QByteArray text(quint32 serialNumber) const =0
QGridLayout
KDialog
QGridLayout::setSpacing
void setSpacing(int spacing)
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QWidget::setLayout
void setLayout(QLayout *layout)
QGroupBox
ResourceConfigDialog::ResourceConfigDialog
ResourceConfigDialog(QWidget *parent, AlarmResource *resource)
Definition: resourceconfigdialog.cpp:42
QCheckBox
QString::isEmpty
bool isEmpty() const
QVBoxLayout
messagebox.h
QString
QFrame
QAbstractButton::setChecked
void setChecked(bool)
KLineEdit
QLatin1String
QBoxLayout::addStretch
void addStretch(int stretch)
KAMessageBox::sorry
static void sorry(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Options(Notify|WindowModal))
QGroupBox::setTitle
void setTitle(const QString &title)
main
int main(int argc, char *argv[])
Definition: main.cpp:37
QLabel
ResourceConfigDialog::setInEditMode
void setInEditMode(bool value)
Definition: resourceconfigdialog.cpp:104
ResourceConfigDialog::accept
void accept()
Definition: resourceconfigdialog.cpp:120
ResourceConfigDialog::slotNameChanged
void slotNameChanged(const QString &text)
Definition: resourceconfigdialog.cpp:110
QBoxLayout::setSpacing
void setSpacing(int spacing)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kalarm

Skip menu "kalarm"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal