File indexing completed on 2024-12-22 04:45:58

0001 /*
0002    SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 #include "importdataselectaccountpage.h"
0007 #include <KLocalizedString>
0008 #include <KUrlRequester>
0009 #include <QLabel>
0010 #include <QVBoxLayout>
0011 
0012 ImportDataSelectAccountPage::ImportDataSelectAccountPage(QWidget *parent)
0013     : QWizardPage(parent)
0014     , mUrlRequester(new KUrlRequester(this))
0015 {
0016     auto mainLayout = new QVBoxLayout(this);
0017     mainLayout->setObjectName(QStringLiteral("mainLayout"));
0018 
0019     auto hboxLayout = new QHBoxLayout;
0020     hboxLayout->setObjectName(QStringLiteral("hboxLayout"));
0021     hboxLayout->setContentsMargins({});
0022     mainLayout->addLayout(hboxLayout);
0023 
0024     mUrlRequester->setObjectName(QStringLiteral("mUrlRequester"));
0025     mUrlRequester->setNameFilter(QStringLiteral("*.zip"));
0026     connect(mUrlRequester, &KUrlRequester::urlSelected, this, [this]() {
0027         Q_EMIT completeChanged();
0028     });
0029     connect(mUrlRequester, &KUrlRequester::textChanged, this, [this]() {
0030         Q_EMIT completeChanged();
0031     });
0032 
0033     auto label = new QLabel(i18n("Select Zip file:"), this);
0034     label->setObjectName(QStringLiteral("label"));
0035     hboxLayout->addWidget(label);
0036     hboxLayout->addWidget(mUrlRequester);
0037 }
0038 
0039 ImportDataSelectAccountPage::~ImportDataSelectAccountPage() = default;
0040 
0041 QUrl ImportDataSelectAccountPage::zipFileUrl() const
0042 {
0043     return mUrlRequester->url();
0044 }
0045 
0046 bool ImportDataSelectAccountPage::verifySelectedUrl() const
0047 {
0048     const auto url = mUrlRequester->url();
0049     return (url.isValid() && !url.toLocalFile().isEmpty());
0050 }
0051 
0052 bool ImportDataSelectAccountPage::validatePage()
0053 {
0054     return verifySelectedUrl();
0055 }
0056 
0057 bool ImportDataSelectAccountPage::isComplete() const
0058 {
0059     return verifySelectedUrl();
0060 }
0061 
0062 #include "moc_importdataselectaccountpage.cpp"