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

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2005-17-06
0007  * Description : a tool to export images to Smugmug web service
0008  *
0009  * SPDX-FileCopyrightText: 2005-2008 by Vardhman Jain <vardhman at gmail dot com>
0010  * SPDX-FileCopyrightText: 2008-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  * SPDX-FileCopyrightText: 2008-2009 by Luka Renko <lure at kubuntu dot org>
0012  * SPDX-FileCopyrightText: 2018      by Thanh Trung Dinh <dinhthanhtrung1996 at gmail dot com>
0013  *
0014  * SPDX-License-Identifier: GPL-2.0-or-later
0015  *
0016  * ============================================================ */
0017 
0018 #ifndef DIGIKAM_SMUG_WINDOW_H
0019 #define DIGIKAM_SMUG_WINDOW_H
0020 
0021 // Qt includes
0022 
0023 #include <QList>
0024 #include <QUrl>
0025 #include <QCloseEvent>
0026 
0027 // Local includes
0028 
0029 #include "wstooldialog.h"
0030 #include "wslogindialog.h"
0031 #include "smugitem.h"
0032 #include "dinfointerface.h"
0033 
0034 using namespace Digikam;
0035 
0036 namespace DigikamGenericSmugPlugin
0037 {
0038 
0039 class SmugWindow : public WSToolDialog
0040 {
0041     Q_OBJECT
0042 
0043 public:
0044 
0045     explicit SmugWindow(DInfoInterface* const iface,
0046                         QWidget* const parent,
0047                         bool import = false,
0048                         const QString& nickName = QString());
0049     ~SmugWindow() override;
0050 
0051     /**
0052      * Use this method to (re-)activate the dialog after it has been created
0053      * to display it. This also loads the currently selected images.
0054      */
0055     void reactivate();
0056 
0057 Q_SIGNALS:
0058 
0059     void updateHostApp(const QUrl& url);
0060 
0061 protected:
0062 
0063     void closeEvent(QCloseEvent*) override;
0064 
0065 private Q_SLOTS:
0066 
0067     void slotBusy(bool val);
0068     void slotLoginProgress(int step, int maxStep, const QString& label);
0069     void slotLoginDone(int errCode, const QString& errMsg);
0070     void slotAddPhotoDone(int errCode, const QString& errMsg);
0071 
0072     void slotGetPhotoDone(int errCode,
0073                           const QString& errMsg,
0074                           const QByteArray& photoData);
0075 
0076     void slotCreateAlbumDone(int errCode,
0077                              const QString& errMsg,
0078                              qint64 newAlbumID,
0079                              const QString& newAlbumKey);
0080 
0081     void slotListAlbumsDone(int errCode,
0082                             const QString& errMsg,
0083                             const QList <SmugAlbum>& albumsList);
0084 
0085     void slotListPhotosDone(int errCode,
0086                             const QString& errMsg,
0087                             const QList <SmugPhoto>& photosList);
0088 
0089     void slotListAlbumTmplDone(int errCode,
0090                                const QString& errMsg,
0091                                const QList <SmugAlbumTmpl>& albumTList);
0092 
0093 /*  Categories now are deprecated in API v2
0094 
0095     void slotListCategoriesDone(int errCode,
0096                                 const QString& errMsg,
0097                                 const QList <SmugCategory>& categoriesList);
0098 
0099     void slotListSubCategoriesDone(int errCode,
0100                                    const QString& errMsg,
0101                                    const QList <SmugCategory>& categoriesList);
0102 */
0103 
0104     void slotUserChangeRequest(bool anonymous);
0105     void slotReloadAlbumsRequest();
0106     void slotNewAlbumRequest();
0107 
0108     void slotStartTransfer();
0109     void slotCancelClicked();
0110     void slotStopAndCloseProgressBar();
0111     void slotDialogFinished();
0112 
0113     void slotImageListChanged();
0114 
0115     void slotTemplateSelectionChanged(int index);
0116 
0117 /*  Categories now are deprecated in API v2
0118 
0119     void slotCategorySelectionChanged(int index);
0120 */
0121 
0122 private:
0123 
0124     bool prepareImageForUpload(const QString& imgPath) const;
0125     void uploadNextPhoto();
0126     void downloadNextPhoto();
0127 
0128     void readSettings();
0129     void writeSettings();
0130 
0131     void authenticate();
0132 
0133     void buttonStateChange(bool state);
0134     void setUiInProgressState(bool inProgress);
0135 
0136 private:
0137 
0138     class Private;
0139     Private* const d;
0140 };
0141 
0142 } // namespace Digikam
0143 
0144 #endif // DIGIKAM_SMUG_WINDOW_H