MailImporter

selectthunderbirdprofilewidget.cpp
1/*
2 SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "selectthunderbirdprofilewidget.h"
8#include "ui_selectthunderbirdprofilewidget.h"
9
10#include <KLocalizedString>
11#include <QDialogButtonBox>
12#include <QPushButton>
13#include <QVBoxLayout>
14
15using namespace MailImporter;
16
17SelectThunderbirdProfileDialog::SelectThunderbirdProfileDialog(QWidget *parent)
18 : QDialog(parent)
19 , mSelectProfile(new SelectThunderbirdProfileWidget(this))
20{
21 setWindowTitle(i18nc("@title:window", "Select thunderbird profile"));
22 setModal(true);
23 auto topLayout = new QVBoxLayout(this);
24
25 mSelectProfile->setObjectName(QLatin1StringView("selectprofile"));
26 topLayout->addWidget(mSelectProfile);
27
29 buttonBox->setObjectName(QLatin1StringView("buttonBox"));
30 QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
31 okButton->setDefault(true);
33 connect(buttonBox, &QDialogButtonBox::accepted, this, &SelectThunderbirdProfileDialog::accept);
34 connect(buttonBox, &QDialogButtonBox::rejected, this, &SelectThunderbirdProfileDialog::reject);
35 topLayout->addWidget(buttonBox);
36}
37
38SelectThunderbirdProfileDialog::~SelectThunderbirdProfileDialog()
39{
40}
41
42void SelectThunderbirdProfileDialog::fillProfile(const QMap<QString, QString> &map, const QString &defaultProfile)
43{
44 mSelectProfile->fillProfile(map, defaultProfile);
45}
46
47QString SelectThunderbirdProfileDialog::selectedProfile() const
48{
49 return mSelectProfile->selectedProfile();
50}
51
52SelectThunderbirdProfileWidget::SelectThunderbirdProfileWidget(QWidget *parent)
53 : QWidget(parent)
54 , ui(new Ui::SelectThunderbirdProfileWidget)
55{
56 ui->setupUi(this);
57}
58
59SelectThunderbirdProfileWidget::~SelectThunderbirdProfileWidget()
60{
61 delete ui;
62}
63
64void SelectThunderbirdProfileWidget::fillProfile(const QMap<QString, QString> &map, const QString &defaultProfile)
65{
67 while (i != map.constEnd()) {
68 QString name = i.key();
69 if (i.value() == defaultProfile) {
70 name += i18n(" (default)");
71 }
72 ui->profile->addItem(name, i.value());
73 ++i;
74 }
75}
76
77QString SelectThunderbirdProfileWidget::selectedProfile() const
78{
79 return ui->profile->itemData(ui->profile->currentIndex()).toString();
80}
81
82#include "moc_selectthunderbirdprofilewidget.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
QString name(StandardAction id)
void setShortcut(const QKeySequence &key)
void setDefault(bool)
Key_Return
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void setupUi(QWidget *widget)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:02 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.