File indexing completed on 2025-01-05 04:54:18

0001 /*
0002    SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 #include "selectednotefolderdialog.h"
0007 
0008 #include <Akonadi/NoteUtils>
0009 
0010 #include <KConfigGroup>
0011 #include <KLocalizedString>
0012 #include <KSharedConfig>
0013 #include <KWindowConfig>
0014 #include <QWindow>
0015 
0016 using namespace NoteShared;
0017 
0018 SelectedNotefolderDialog::SelectedNotefolderDialog(QWidget *parent)
0019     : Akonadi::CollectionDialog(parent)
0020 {
0021     const QStringList mimeTypes(Akonadi::NoteUtils::noteMimeType());
0022     setMimeTypeFilter(mimeTypes);
0023     // setAccessRightsFilter( Akonadi::Collection::CanCreateItem );
0024     setWindowTitle(i18nc("@title:window", "Select Note Folder"));
0025     setDescription(i18nc("@info", "Select the folder where the note will be saved:"));
0026     changeCollectionDialogOptions(Akonadi::CollectionDialog::KeepTreeExpanded);
0027     setUseFolderByDefault(false);
0028     readConfig();
0029 }
0030 
0031 SelectedNotefolderDialog::~SelectedNotefolderDialog()
0032 {
0033     writeConfig();
0034 }
0035 namespace
0036 {
0037 static const char mySelectedNotefolderDialogName[] = "SelectedNotefolderDialog";
0038 }
0039 void SelectedNotefolderDialog::readConfig()
0040 {
0041     create(); // ensure a window is created
0042     windowHandle()->resize(QSize(600, 400));
0043     KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(mySelectedNotefolderDialogName));
0044     KWindowConfig::restoreWindowSize(windowHandle(), group);
0045     resize(windowHandle()->size()); // workaround for QTBUG-40584
0046 }
0047 
0048 void SelectedNotefolderDialog::writeConfig()
0049 {
0050     KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(mySelectedNotefolderDialogName));
0051     KWindowConfig::saveWindowSize(windowHandle(), group);
0052     group.sync();
0053 }
0054 
0055 #include "moc_selectednotefolderdialog.cpp"