Incidenceeditor

freebusyurldialog.cpp
1/*
2 SPDX-FileCopyrightText: 2004 Cornelius Schumacher <schumacher@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
5*/
6
7#include "freebusyurldialog.h"
8
9#include <KLineEdit>
10#include <KLocalizedString>
11
12#include <KConfig>
13#include <KConfigGroup>
14#include <QBoxLayout>
15#include <QDialogButtonBox>
16#include <QFrame>
17#include <QLabel>
18#include <QPushButton>
19#include <QStandardPaths>
20#include <QVBoxLayout>
21
22using namespace IncidenceEditorNG;
23
24FreeBusyUrlDialog::FreeBusyUrlDialog(const AttendeeData::Ptr &attendee, QWidget *parent)
25 : QDialog(parent)
26{
27 setModal(true);
28 setWindowTitle(i18nc("@title:window", "Edit Free/Busy Location"));
29 auto mainLayout = new QVBoxLayout(this);
30
31 auto topFrame = new QFrame(this);
33 mainLayout->addWidget(topFrame);
34 QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
36 connect(buttonBox, &QDialogButtonBox::rejected, this, &FreeBusyUrlDialog::reject);
37 mainLayout->addWidget(buttonBox);
38 okButton->setDefault(true);
39
40 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
41 topLayout->setContentsMargins(0, 0, 0, 0);
42
43 mWidget = new FreeBusyUrlWidget(attendee, topFrame);
44 topLayout->addWidget(mWidget);
45
46 mWidget->loadConfig();
47 connect(okButton, &QPushButton::clicked, this, &FreeBusyUrlDialog::slotOk);
48}
49
50void FreeBusyUrlDialog::slotOk()
51{
52 mWidget->saveConfig();
53 accept();
54}
55
56FreeBusyUrlWidget::FreeBusyUrlWidget(const AttendeeData::Ptr &attendee, QWidget *parent)
57 : QWidget(parent)
58 , mUrlEdit(new KLineEdit(this))
59 , mAttendee(attendee)
60{
61 QBoxLayout *topLayout = new QVBoxLayout(this);
62
63 auto label = new QLabel(xi18n("Location of Free/Busy information for %1 <placeholder>%2</placeholder>:", mAttendee->name(), mAttendee->email()), this);
64 topLayout->addWidget(label);
65
66 mUrlEdit->setFocus();
67 mUrlEdit->setWhatsThis(i18nc("@info:whatsthis", "Enter the location of the Free/Busy information for the attendee."));
68 mUrlEdit->setToolTip(i18nc("@info:tooltip", "Enter the location of the information."));
69 topLayout->addWidget(mUrlEdit);
70}
71
72FreeBusyUrlWidget::~FreeBusyUrlWidget() = default;
73
74static QString freeBusyUrlStore()
75{
76 return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/korganizer/freebusyurls");
77}
78
79void FreeBusyUrlWidget::loadConfig()
80{
81 KConfig config(freeBusyUrlStore());
82 mUrlEdit->setText(config.group(mAttendee->email()).readEntry("url"));
83}
84
85void FreeBusyUrlWidget::saveConfig()
86{
87 const QString url = mUrlEdit->text();
88 KConfig config(freeBusyUrlStore());
89 config.group(mAttendee->email()).writeEntry("url", url);
90}
91
92#include "moc_freebusyurldialog.cpp"
virtual void setText(const QString &)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString xi18n(const char *text, const TYPE &arg...)
QString label(StandardShortcut id)
void clicked(bool checked)
void setShortcut(const QKeySequence &key)
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
virtual void accept()
void setContentsMargins(const QMargins &margins)
void setDefault(bool)
QString writableLocation(StandardLocation type)
Key_Return
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:58:15 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.