File indexing completed on 2025-01-05 03:53:42

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2011-04-12
0007  * Description : A tool to export items to Rajce web service
0008  *
0009  * SPDX-FileCopyrightText: 2011      by Lukas Krejci <krejci.l at centrum dot cz>
0010  * SPDX-FileCopyrightText: 2011-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #include "rajcewindow.h"
0017 
0018 // Qt includes
0019 
0020 #include <QAction>
0021 #include <QMenu>
0022 #include <QCloseEvent>
0023 
0024 // KDE includes
0025 
0026 #include <klocalizedstring.h>
0027 
0028 // Local includes
0029 
0030 #include "rajcewidget.h"
0031 
0032 namespace DigikamGenericRajcePlugin
0033 {
0034 
0035 RajceWindow::RajceWindow(DInfoInterface* const iface, QWidget* const /*parent*/)
0036     : WSToolDialog(nullptr, QLatin1String("RajceExport Dialog"))
0037 {
0038     m_widget = new RajceWidget(iface, this);
0039     m_widget->readSettings();
0040 
0041     setMainWidget(m_widget);
0042     setModal(false);
0043     setWindowTitle(i18nc("@title:window", "Export to Rajce.net"));
0044 
0045     startButton()->setText(i18nc("@action:button", "Start Upload"));
0046     startButton()->setToolTip(i18nc("@info:tooltip, button", "Start upload to Rajce.net"));
0047 
0048     m_widget->setMinimumSize(700, 500);
0049 
0050     connect(startButton(), SIGNAL(clicked()),
0051             m_widget, SLOT(slotStartUpload()));
0052 
0053     connect(this, SIGNAL(finished(int)),
0054             this, SLOT(slotFinished()));
0055 
0056     connect(m_widget, SIGNAL(signalLoginStatusChanged(bool)),
0057             this, SLOT(slotSetUploadButtonEnabled(bool)));
0058 
0059     startButton()->setEnabled(false);
0060 }
0061 
0062 RajceWindow::~RajceWindow()
0063 {
0064 }
0065 
0066 void RajceWindow::reactivate()
0067 {
0068     m_widget->reactivate();
0069     show();
0070 }
0071 
0072 void RajceWindow::slotSetUploadButtonEnabled(bool enabled)
0073 {
0074     startButton()->setEnabled(enabled);
0075 }
0076 
0077 void RajceWindow::slotFinished()
0078 {
0079     m_widget->cancelUpload();
0080     m_widget->writeSettings();
0081 }
0082 
0083 void RajceWindow::closeEvent(QCloseEvent* e)
0084 {
0085     if (!e)
0086     {
0087         return;
0088     }
0089 
0090     slotFinished();
0091     e->accept();
0092 }
0093 
0094 } // namespace DigikamGenericRajcePlugin
0095 
0096 #include "moc_rajcewindow.cpp"