blob: 11961e7b2d3c26682271e039f7c6669eec3abc04 [file] [log] [blame]
Isa Nanic6e4a39a2018-12-04 14:26:02 -05001/***************************************************************************
2 * Copyright (C) 2018 by Savoir-faire Linux *
3 * Author: Isa Nanic <isa.nanic@savoirfairelinux.com> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program. If not, see <https://www.gnu.org/licenses/>. *
17 **************************************************************************/
18
19#pragma once
20#include <QScrollArea>
Isa Nanic6e4a39a2018-12-04 14:26:02 -050021#include <QMovie>
22
23#include "navwidget.h"
Isa Nanic6e4a39a2018-12-04 14:26:02 -050024#include "lrcinstance.h"
25
26#include "advancedsettingswidget.h"
27#include "bannedlistmodel.h"
28
29#include "linkdevwidget.h"
30#include "ui_linkdevwidget.h"
31
32 // general settings
33#include "api/datatransfermodel.h"
34#include "typedefs.h"
35
36// av settings
37#include "video/devicemodel.h"
38
39
40namespace Ui {
41 class SettingsWidget;
42}
43
44class SettingsWidget : public NavWidget
45{
46 Q_OBJECT
47 SettingsWidget(const SettingsWidget& cpy);
48
49public:
50 explicit SettingsWidget(QWidget* parent = nullptr);
51 ~SettingsWidget();
52 void resize(int size);
53
Andreas Traczykfc33a492018-12-14 13:53:13 -050054 // NavWidget
55 virtual void navigated(bool to);
56
Isa Nanic6e4a39a2018-12-04 14:26:02 -050057public slots:
58 void updateSettings(int size);
59
60private:
61 enum Button {accountSettingsButton, generalSettingsButton, avSettingsButton};
62 enum RegName {BLANK, INVALIDFORM, TAKEN, FREE, SEARCHING};
63 enum List {DevList, BannedContacts};
64
65 void setSelected(Button sel);
66 void updateAccountInfoDisplayed();
67
68 void resizeEvent(QResizeEvent* event);
Isa Nanic6e4a39a2018-12-04 14:26:02 -050069
70 Ui::SettingsWidget* ui;
71
72 // ************************* Account Settings *************************
73 void passwordClicked();
74 void avatarClicked();
75
76 void afterNameLookup(lrc::api::account::LookupStatus status, const std::string& regName);
77 QString registeredName_;
78
79 bool validateRegNameForm(const QString& regName);
80
81 AdvancedSettingsWidget* advancedSettingsWidget_;
82 QScrollArea* scrollArea_;
83 Button pastButton_ = Button::generalSettingsButton;
84 bool advancedSettingsDropped_ = false;
85 bool bannedContactsShown_ = false;
86
87 int avatarSize_;
88
89 void setRegNameUi(RegName stat);
90 bool regNameBtn_ = false;
91
92 const int itemHeight_ = 55;
93
94 void removeDeviceSlot(int index);
95 void unban(int index);
96
97 void setConnections();
98 QMovie* gif;
99
100 LinkDevWidget* linkDevWidget;
101
Isa Nanic6e4a39a2018-12-04 14:26:02 -0500102private slots:
103 void leaveSettingsSlot();
104 void verifyRegisteredNameSlot();
105 void beforeNameLookup();
106 void receiveRegNameSlot(const std::string& accountID, lrc::api::account::LookupStatus status,
107 const std::string& address, const std::string& name);
108 void regNameRegisteredSlot();
109 void setAccEnableSlot(int state);
110 void delAccountSlot();
111
112 void toggleAdvancedSettings();
113 void toggleBannedContacts();
114 void exportAccountSlot();
115
116 void updateAndShowDevicesSlot();
117 void updateAndShowBannedContactsSlot();
118
119 void showLinkDevSlot();
120 void showCurrentAccountSlot();
121
122 void setButtonIconSlot(int frame);
123
124
Isa Nanic6e4a39a2018-12-04 14:26:02 -0500125 // ************************* General Settings *************************
126private:
127 void populateGeneralSettings();
Andreas Traczykfc33a492018-12-14 13:53:13 -0500128 QMetaObject::Connection accountAddedConnection_;
129
Isa Nanic6e4a39a2018-12-04 14:26:02 -0500130private slots:
131 void setNotificationsSlot(int state);
132 void checkForUpdateSlot();
133 void setClosedOrMinSlot(int state);
134 void openDownloadFolderSlot();
135 void setAlwaysRecordingSlot(int state);
136 void openRecordFolderSlot();
137 void setUpdateIntervalSlot(int value);
138 void setUpdateAutomaticSlot(int state);
139
140 // ************************* Audio/Visual Settings *************************
141private:
142 void populateAVSettings();
Isa Nanic054ef9a2018-12-11 11:56:28 -0500143 void saveSizeIndex();
Isa Nanic6e4a39a2018-12-04 14:26:02 -0500144 Video::DeviceModel* deviceModel_;
145 void showPreview();
146 bool isLoading_;
Isa Nanic054ef9a2018-12-11 11:56:28 -0500147 int currentResIndex = -1;
148
149 void startVideo();
150 void stopVideo();
Isa Nanic6e4a39a2018-12-04 14:26:02 -0500151
152private slots:
153 void deviceIndexChanged(int index);
154 void deviceBoxCurrentIndexChangedSlot(int index);
155 void sizeBoxCurrentIndexChangedSlot(int index);
156 void outputDevIndexChangedSlot(int index);
157 void inputdevIndexChangedSlot(int index);
158
159};