Pimcommon

selectmulticollectiondialog.cpp
1/*
2 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "selectmulticollectiondialog.h"
8#include "selectmulticollectionwidget.h"
9
10#include <KConfigGroup>
11#include <KLocalizedString>
12#include <KSharedConfig>
13#include <KWindowConfig>
14#include <QDialogButtonBox>
15#include <QPushButton>
16#include <QVBoxLayout>
17#include <QWindow>
18
19using namespace PimCommon;
20
21class PimCommon::SelectMultiCollectionDialogPrivate
22{
23public:
24 SelectMultiCollectionDialogPrivate() = default;
25
26 SelectMultiCollectionWidget *mSelectMultiCollection = nullptr;
27};
28
29namespace
30{
31static const char myConfigSelectMultiCollectionDialog[] = "SelectMultiCollectionDialog";
32}
33
34SelectMultiCollectionDialog::SelectMultiCollectionDialog(const QString &mimetype, const QList<Akonadi::Collection::Id> &selectedCollection, QWidget *parent)
35 : QDialog(parent)
36 , d(new PimCommon::SelectMultiCollectionDialogPrivate)
37{
38 initialize(mimetype, selectedCollection);
39}
40
41SelectMultiCollectionDialog::SelectMultiCollectionDialog(const QString &mimetype, QWidget *parent)
42 : QDialog(parent)
43 , d(new PimCommon::SelectMultiCollectionDialogPrivate)
44{
45 initialize(mimetype);
46}
47
48SelectMultiCollectionDialog::~SelectMultiCollectionDialog()
49{
50 writeConfig();
51}
52
53void SelectMultiCollectionDialog::initialize(const QString &mimetype, const QList<Akonadi::Collection::Id> &selectedCollection)
54{
55 setWindowTitle(i18nc("@title:window", "Select Multiple Folders"));
57 auto mainLayout = new QVBoxLayout(this);
58 QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
59 okButton->setDefault(true);
63
64 d->mSelectMultiCollection = new SelectMultiCollectionWidget(mimetype, selectedCollection, this);
65 mainLayout->addWidget(d->mSelectMultiCollection);
66 mainLayout->addWidget(buttonBox);
67 readConfig();
68}
69
70void SelectMultiCollectionDialog::writeConfig()
71{
72 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myConfigSelectMultiCollectionDialog));
74}
75
76void SelectMultiCollectionDialog::readConfig()
77{
78 create(); // ensure a window is created
79 windowHandle()->resize(QSize(800, 600));
80 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myConfigSelectMultiCollectionDialog));
82 resize(windowHandle()->size()); // workaround for QTBUG-40584
83}
84
85QList<Akonadi::Collection> SelectMultiCollectionDialog::selectedCollection() const
86{
87 return d->mSelectMultiCollection->selectedCollection();
88}
89
90#include "moc_selectmulticollectiondialog.cpp"
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void initialize(StandardShortcut id)
KCONFIGGUI_EXPORT void saveWindowSize(const QWindow *window, KConfigGroup &config, KConfigGroup::WriteConfigFlags options=KConfigGroup::Normal)
KCONFIGGUI_EXPORT void restoreWindowSize(QWindow *window, const KConfigGroup &config)
folderdialogacltab.h
void setShortcut(const QKeySequence &key)
virtual void accept()
virtual void reject()
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void setDefault(bool)
Key_Return
void create(WId window, bool initializeWindow, bool destroyOldWindow)
void resize(const QSize &)
QWindow * windowHandle() const const
void setWindowTitle(const QString &)
void resize(const QSize &newSize)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:14:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.