Pimcommon

completionordereditor.cpp
1/** -*- c++ -*-
2 * completionordereditor.cpp
3 *
4 * SPDX-FileCopyrightText: 2004 David Faure <faure@kde.org>
5 * SPDX-FileCopyrightText: 2010 Tobias Koenig <tokoe@kde.org>
6 *
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
9
10#include "completionordereditor.h"
11using namespace Qt::Literals::StringLiterals;
12
13#include "completionorderwidget.h"
14#include <KLDAPCore/LdapClient>
15#include <KLDAPCore/LdapClientSearch>
16
17#include <kldapcore/ldapserver.h>
18
19#include <KConfigGroup>
20#include <KLocalizedString>
21#include <KSharedConfig>
22#include <KWindowConfig>
23#include <QDialogButtonBox>
24#include <QPushButton>
25#include <QVBoxLayout>
26#include <QWindow>
27
28using namespace PimCommon;
29namespace
30{
31static const char myCompletionOrderEditorGroupName[] = "CompletionOrderEditor";
32}
33class PimCommon::CompletionOrderEditorPrivate
34{
35public:
36 CompletionOrderEditorPrivate() = default;
37
38 CompletionOrderWidget *mCompletionOrderWidget = nullptr;
39};
40
41CompletionOrderEditor::CompletionOrderEditor(KLDAPCore::LdapClientSearch *ldapSearch, QWidget *parent)
42 : QDialog(parent)
43 , d(new PimCommon::CompletionOrderEditorPrivate)
44{
45 setWindowTitle(i18nc("@title:window", "Edit Completion Order"));
46 auto mainLayout = new QVBoxLayout(this);
47
48 d->mCompletionOrderWidget = new CompletionOrderWidget(this);
49 d->mCompletionOrderWidget->setObjectName("completionorderwidget"_L1);
50
51 mainLayout->addWidget(d->mCompletionOrderWidget);
52
53 d->mCompletionOrderWidget->setLdapClientSearch(ldapSearch);
54
55 d->mCompletionOrderWidget->loadCompletionItems();
56
58 QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
59 okButton->setDefault(true);
61 connect(buttonBox, &QDialogButtonBox::accepted, this, &CompletionOrderEditor::slotOk);
62 connect(buttonBox, &QDialogButtonBox::rejected, this, &CompletionOrderEditor::reject);
63 mainLayout->addWidget(buttonBox);
64
65 readConfig();
66}
67
68CompletionOrderEditor::~CompletionOrderEditor()
69{
70 writeConfig();
71}
72
73void CompletionOrderEditor::readConfig()
74{
75 create(); // ensure a window is created
76 windowHandle()->resize(QSize(600, 400));
77 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myCompletionOrderEditorGroupName));
79 resize(windowHandle()->size()); // workaround for QTBUG-40584
80}
81
82void CompletionOrderEditor::writeConfig()
83{
84 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myCompletionOrderEditorGroupName));
86}
87
88void CompletionOrderEditor::slotOk()
89{
90 d->mCompletionOrderWidget->save();
91 accept();
92}
93
94#include "moc_completionordereditor.cpp"
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
QString i18nc(const char *context, const char *text, const TYPE &arg...)
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()
void setDefault(bool)
Key_Return
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void create(WId window, bool initializeWindow, bool destroyOldWindow)
void resize(const QSize &)
QWindow * windowHandle() const const
void resize(const QSize &newSize)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 4 2024 11:53:31 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.