File indexing completed on 2025-01-05 04:47:11
0001 /* 0002 This file is part of Akonadi 0003 0004 SPDX-FileCopyrightText: 2014 Christian Mollekopf <mollekopf@kolabsys.com> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #include "tagmanagementdialog.h" 0010 #include "ui_tagmanagementdialog.h" 0011 0012 #include "controlgui.h" 0013 #include "monitor.h" 0014 #include "tagmodel.h" 0015 0016 #include <KConfigGroup> 0017 #include <KLocalizedString> 0018 #include <KSharedConfig> 0019 0020 using namespace Akonadi; 0021 namespace 0022 { 0023 static const char myTagManagementDialogGroupName[] = "TagManagementDialog"; 0024 } 0025 class Akonadi::TagManagementDialogPrivate 0026 { 0027 public: 0028 explicit TagManagementDialogPrivate(QDialog *parent) 0029 : q(parent) 0030 { 0031 } 0032 0033 void writeConfig() const; 0034 void readConfig() const; 0035 0036 Ui::TagManagementDialog ui; 0037 QDialog *const q; 0038 QDialogButtonBox *buttonBox = nullptr; 0039 }; 0040 0041 void TagManagementDialogPrivate::writeConfig() const 0042 { 0043 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myTagManagementDialogGroupName)); 0044 group.writeEntry("Size", q->size()); 0045 } 0046 0047 void TagManagementDialogPrivate::readConfig() const 0048 { 0049 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myTagManagementDialogGroupName)); 0050 const QSize sizeDialog = group.readEntry("Size", QSize(500, 400)); 0051 if (sizeDialog.isValid()) { 0052 q->resize(sizeDialog); 0053 } 0054 } 0055 0056 TagManagementDialog::TagManagementDialog(QWidget *parent) 0057 : QDialog(parent) 0058 , d(new TagManagementDialogPrivate(this)) 0059 { 0060 auto monitor = new Monitor(this); 0061 monitor->setObjectName(QLatin1StringView("TagManagementDialogMonitor")); 0062 monitor->setTypeMonitored(Monitor::Tags); 0063 0064 d->ui.setupUi(this); 0065 d->ui.tagEditWidget->setModel(new TagModel(monitor, this)); 0066 d->ui.tagEditWidget->setSelectionEnabled(false); 0067 0068 d->readConfig(); 0069 0070 ControlGui::widgetNeedsAkonadi(this); 0071 } 0072 0073 TagManagementDialog::~TagManagementDialog() 0074 { 0075 d->writeConfig(); 0076 } 0077 0078 QDialogButtonBox *TagManagementDialog::buttons() const 0079 { 0080 return d->buttonBox; 0081 } 0082 0083 #include "moc_tagmanagementdialog.cpp"