Akonadi

tagmanagementdialog.cpp
1 /*
2  This file is part of Akonadi
3 
4  SPDX-FileCopyrightText: 2014 Christian Mollekopf <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #include "tagmanagementdialog.h"
10 #include "ui_tagmanagementdialog.h"
11 
12 #include "controlgui.h"
13 #include "monitor.h"
14 #include "tagmodel.h"
15 
16 #include <KConfigGroup>
17 #include <KLocalizedString>
18 #include <KSharedConfig>
19 
20 using namespace Akonadi;
21 
22 class Akonadi::TagManagementDialogPrivate
23 {
24 public:
25  explicit TagManagementDialogPrivate(QDialog *parent)
26  : q(parent)
27  {
28  }
29 
30  void writeConfig() const;
31  void readConfig() const;
32 
33  Ui::TagManagementDialog ui;
34  QDialog *const q;
35  QDialogButtonBox *buttonBox = nullptr;
36 };
37 
38 void TagManagementDialogPrivate::writeConfig() const
39 {
40  KConfigGroup group(KSharedConfig::openStateConfig(), "TagManagementDialog");
41  group.writeEntry("Size", q->size());
42 }
43 
44 void TagManagementDialogPrivate::readConfig() const
45 {
46  KConfigGroup group(KSharedConfig::openStateConfig(), "TagManagementDialog");
47  const QSize sizeDialog = group.readEntry("Size", QSize(500, 400));
48  if (sizeDialog.isValid()) {
49  q->resize(sizeDialog);
50  }
51 }
52 
53 TagManagementDialog::TagManagementDialog(QWidget *parent)
54  : QDialog(parent)
55  , d(new TagManagementDialogPrivate(this))
56 {
57  auto monitor = new Monitor(this);
58  monitor->setObjectName(QStringLiteral("TagManagementDialogMonitor"));
59  monitor->setTypeMonitored(Monitor::Tags);
60 
61  d->ui.setupUi(this);
62  d->ui.tagEditWidget->setModel(new TagModel(monitor, this));
63  d->ui.tagEditWidget->setSelectionEnabled(false);
64 
65  d->readConfig();
66 
68 }
69 
70 TagManagementDialog::~TagManagementDialog()
71 {
72  d->writeConfig();
73 }
74 
75 QDialogButtonBox *TagManagementDialog::buttons() const
76 {
77  return d->buttonBox;
78 }
static void widgetNeedsAkonadi(QWidget *widget)
Disable the given widget when Akonadi is not operational and show an error overlay (given enough spac...
Definition: controlgui.cpp:243
bool isValid() const const
void readConfig()
Monitors an item or collection for changes.
Definition: monitor.h:71
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jun 30 2022 03:51:47 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.