Debian Codegraph @

src/gui/settingsDialog/uploader/ImgurUploaderSettings.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2019 Damir Porobic <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #ifndef KSNIP_IMGURUPLOADERSETTINGS_H
21 #define KSNIP_IMGURUPLOADERSETTINGS_H
22
23 #include <QGroupBox>
24 #include <QCheckBox>
25 #include <QLineEdit>
26 #include <QLabel>
27 #include <QGridLayout>
28 #include <QPushButton>
29 #include <QDesktopServices>
30
31 #include "src/backend/config/IConfig.h"
32 #include "src/backend/uploader/imgur/ImgurWrapper.h"
33 #include "src/gui/ImgurHistoryDialog.h"
34 #include "src/widgets/CustomLineEdit.h"
35 #include "src/common/constants/DefaultValues.h"
36
37 class ImgurUploaderSettings : public QGroupBox
38 {
39 Q_OBJECT
40 public:
41 explicit ImgurUploaderSettings(const QSharedPointer<IConfig> &config);
42 ~ImgurUploaderSettings() override = default;
43 void saveSettings();
44
45 private:
46 QSharedPointer<IConfig> mConfig;
47 QCheckBox *mForceAnonymousCheckbox;
48 QCheckBox *mDirectLinkToImageCheckbox;
49 QCheckBox *mAlwaysCopyToClipboardCheckBox;
50 QCheckBox *mOpenLinkInBrowserCheckbox;
51 QLineEdit *mClientIdLineEdit;
52 QLineEdit *mClientSecretLineEdit;
53 QLineEdit *mPinLineEdit;
54 QLineEdit *mUsernameLineEdit;
55 CustomLineEdit *mBaseUrlLineEdit;
56 CustomLineEdit *mUploadTitleEdit;
57 CustomLineEdit *mUploadDescriptionEdit;
58 QLabel *mUsernameLabel;
59 QLabel *mBaseUrlLabel;
60 QLabel *mUploadTitleLabel;
61 QLabel *mUploadDescriptionLabel;
62 QPushButton *mGetPinButton;
63 QPushButton *mGetTokenButton;
64 QPushButton *mClearTokenButton;
65 QPushButton *mHistoryButton;
66 ImgurWrapper *mImgurWrapper;
67 QGridLayout *mLayout;
68
69 void initGui();
70 void loadConfig();
71
72 private slots:
73 void requestImgurPin();
74 void getImgurToken();
75 void clearImgurToken();
76 void imgurClientEntered(const QString &text);
77 void imgurTokenUpdated(const QString &accessToken, const QString &refreshToken, const QString &username);
78 void imgurTokenError(QNetworkReply::NetworkError networkError, const QString &message);
79 void showImgurHistoryDialog();
80 void usernameChanged();
81 };
82
83 #endif //KSNIP_IMGURUPLOADERSETTINGS_H