File indexing completed on 2024-04-14 14:26:42

0001 /*
0002     knewstuff3/ui/uploaddialog.cpp.
0003     SPDX-FileCopyrightText: 2002 Cornelius Schumacher <schumacher@kde.org>
0004     SPDX-FileCopyrightText: 2009 Jeremy Whiting <jpwhiting@kde.org>
0005     SPDX-FileCopyrightText: 2009-2010 Frederik Gladhorn <gladhorn@kde.org>
0006 
0007     SPDX-License-Identifier: LGPL-2.1-or-later
0008 */
0009 
0010 #include "uploaddialog.h"
0011 
0012 #if KNEWSTUFF_BUILD_DEPRECATED_SINCE(5, 80)
0013 
0014 #include "knewstuff_debug.h"
0015 #include "uploaddialog_p.h"
0016 
0017 #include <QDialogButtonBox>
0018 #include <QQmlContext>
0019 #include <QQuickItem>
0020 #include <QQuickView>
0021 #include <QVBoxLayout>
0022 
0023 using namespace KNS3;
0024 
0025 bool UploadDialogPrivate::init(const QString &configfile)
0026 {
0027     bool success = true;
0028 
0029     QQuickView *view = new QQuickView;
0030     QVBoxLayout *layout = new QVBoxLayout();
0031     layout->setContentsMargins(0, 0, 0, 0);
0032     layout->setSpacing(0);
0033     q->setLayout(layout);
0034     q->layout()->addWidget(QWidget::createWindowContainer(view, q));
0035     QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, q);
0036     QObject::connect(buttonBox, &QDialogButtonBox::rejected, q, &UploadDialog::accept);
0037     q->layout()->addWidget(buttonBox);
0038 
0039     view->rootContext()->setContextProperty(QStringLiteral("knsrcfile"), configfile);
0040     view->setSource(QUrl(QStringLiteral("qrc:///uploaddialog.qml")));
0041     QQuickItem *item = view->rootObject();
0042     // If there is an error on the QML side of things we get a nullptr
0043     if (item) {
0044         q->resize(view->rootObject()->implicitWidth(), view->rootObject()->implicitHeight());
0045         // Forward relevant signals
0046         QObject::connect(item, SIGNAL(closed()), q, SLOT(accept()));
0047     } else {
0048         qCDebug(KNEWSTUFF) << "Failed to load the UploadDialog components. The QML Engine reported the following errors:" << view->errors();
0049         success = false;
0050     }
0051     return success;
0052 }
0053 
0054 UploadDialog::UploadDialog(QWidget *parent)
0055     : QDialog(parent)
0056     , d(new UploadDialogPrivate(this))
0057 {
0058     const QString name = QCoreApplication::applicationName();
0059     init(name + QStringLiteral(".knsrc"));
0060 }
0061 
0062 UploadDialog::UploadDialog(const QString &configFile, QWidget *parent)
0063     : QDialog(parent)
0064     , d(new UploadDialogPrivate(this))
0065 {
0066     init(configFile);
0067 }
0068 
0069 UploadDialog::~UploadDialog()
0070 {
0071     delete d;
0072 }
0073 
0074 bool UploadDialog::init(const QString &configfile)
0075 {
0076     return d->init(configfile);
0077 }
0078 
0079 void UploadDialog::setUploadFile(const QUrl &)
0080 {
0081 }
0082 
0083 void UploadDialog::setUploadName(const QString &)
0084 {
0085 }
0086 
0087 void UploadDialog::selectCategory(const QString &)
0088 {
0089 }
0090 
0091 void UploadDialog::setChangelog(const QString &)
0092 {
0093 }
0094 
0095 void UploadDialog::setDescription(const QString &)
0096 {
0097 }
0098 
0099 void UploadDialog::setPriceEnabled(bool)
0100 {
0101 }
0102 
0103 void UploadDialog::setPrice(double)
0104 {
0105 }
0106 
0107 void UploadDialog::setPriceReason(const QString &)
0108 {
0109 }
0110 
0111 void UploadDialog::setVersion(const QString &)
0112 {
0113 }
0114 
0115 void UploadDialog::setPreviewImageFile(uint, const QUrl &)
0116 {
0117 }
0118 
0119 void UploadDialog::accept()
0120 {
0121     QDialog::accept();
0122 }
0123 
0124 #endif
0125 
0126 #include "moc_uploaddialog.cpp"