Commit 1f7d6fe7 authored by David Faure's avatar David Faure

icaldir resource: Make resource name configurable.

I want to see "Todos", not "akonadi_icaldir_resource_0" in korganizer's calendar list.
parent c336f978
......@@ -33,7 +33,7 @@
using namespace Akonadi;
SettingsDialog::SettingsDialog(WId windowId)
SettingsDialog::SettingsDialog(const QString &resourceName, WId windowId)
: QDialog()
{
QWidget *mainWidget = new QWidget(this);
......@@ -56,11 +56,13 @@ SettingsDialog::SettingsDialog(WId windowId)
connect(mOkButton, &QPushButton::clicked, this, &SettingsDialog::save);
connect(ui.kcfg_Name, &QLineEdit::textChanged, this, &SettingsDialog::validate);
connect(ui.kcfg_Path, &KUrlRequester::textChanged, this, &SettingsDialog::validate);
connect(ui.kcfg_ReadOnly, &QCheckBox::toggled, this, &SettingsDialog::validate);
QTimer::singleShot(0, this, &SettingsDialog::validate);
ui.kcfg_Name->setText(resourceName);
ui.kcfg_Path->setUrl(QUrl::fromLocalFile(Settings::self()->path()));
ui.kcfg_AutosaveInterval->setSuffix(ki18np(" minute", " minutes"));
mManager = new KConfigDialogManager(this, Settings::self());
......@@ -77,7 +79,8 @@ void SettingsDialog::save()
void SettingsDialog::validate()
{
const QUrl currentUrl = ui.kcfg_Path->url();
if (currentUrl.isEmpty()) {
const QString name = ui.kcfg_Name->text();
if (currentUrl.isEmpty() || name.isEmpty()) {
mOkButton->setEnabled(false);
return;
}
......@@ -91,3 +94,8 @@ void SettingsDialog::validate()
}
mOkButton->setEnabled(true);
}
QString SettingsDialog::resourceName() const
{
return ui.kcfg_Name->text();
}
......@@ -34,7 +34,9 @@ class SettingsDialog : public QDialog
{
Q_OBJECT
public:
explicit SettingsDialog(WId windowId);
explicit SettingsDialog(const QString &resourceName, WId windowId);
QString resourceName() const;
private Q_SLOTS:
void save();
......
......@@ -102,9 +102,10 @@ void ICalDirResource::aboutToQuit()
void ICalDirResource::configure(WId windowId)
{
SettingsDialog dlg(windowId);
SettingsDialog dlg(name(), windowId);
dlg.setWindowIcon(QIcon::fromTheme(QStringLiteral("text-calendar")));
if (dlg.exec()) {
setName(dlg.resourceName());
initializeICalDirectory();
loadIncidences();
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>547</width>
<height>386</height>
<width>414</width>
<height>410</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
......@@ -33,6 +33,20 @@
<string>Directory</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Calendar Name:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="kcfg_Name"/>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
......@@ -44,7 +58,7 @@
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Di&amp;rectory:</string>
<string>Directory:</string>
</property>
<property name="buddy">
<cstring>kcfg_Path</cstring>
......@@ -179,17 +193,17 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KPluralHandlingSpinBox</class>
<extends>QSpinBox</extends>
<header>kpluralhandlingspinbox.h</header>
</customwidget>
<customwidget>
<class>KUrlRequester</class>
<extends>QFrame</extends>
<extends>QWidget</extends>
<header>kurlrequester.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>KPluralHandlingSpinBox</class>
<extends>QSpinBox</extends>
<header>KPluralHandlingSpinBox</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment