blob: 65870b4c97513a62ed6a19aa3cd3a4b7ae194301 [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);
Andreas Traczyk6ace34f2018-12-14 14:31:23 -050056 virtual void updateCustomUI();
Andreas Traczykfc33a492018-12-14 13:53:13 -050057
Isa Nanic6e4a39a2018-12-04 14:26:02 -050058public slots:
59 void updateSettings(int size);
60
61private:
62 enum Button {accountSettingsButton, generalSettingsButton, avSettingsButton};
63 enum RegName {BLANK, INVALIDFORM, TAKEN, FREE, SEARCHING};
64 enum List {DevList, BannedContacts};
65
66 void setSelected(Button sel);
67 void updateAccountInfoDisplayed();
68
69 void resizeEvent(QResizeEvent* event);
Isa Nanic6e4a39a2018-12-04 14:26:02 -050070
71 Ui::SettingsWidget* ui;
72
73 // ************************* Account Settings *************************
74 void passwordClicked();
75 void avatarClicked();
76
77 void afterNameLookup(lrc::api::account::LookupStatus status, const std::string& regName);
78 QString registeredName_;
79
80 bool validateRegNameForm(const QString& regName);
81
82 AdvancedSettingsWidget* advancedSettingsWidget_;
83 QScrollArea* scrollArea_;
84 Button pastButton_ = Button::generalSettingsButton;
85 bool advancedSettingsDropped_ = false;
86 bool bannedContactsShown_ = false;
87
88 int avatarSize_;
89
90 void setRegNameUi(RegName stat);
91 bool regNameBtn_ = false;
92
93 const int itemHeight_ = 55;
94
95 void removeDeviceSlot(int index);
96 void unban(int index);
97
98 void setConnections();
99 QMovie* gif;
100
101 LinkDevWidget* linkDevWidget;
102
Isa Nanic6e4a39a2018-12-04 14:26:02 -0500103private slots:
104 void leaveSettingsSlot();
105 void verifyRegisteredNameSlot();
106 void beforeNameLookup();
107 void receiveRegNameSlot(const std::string& accountID, lrc::api::account::LookupStatus status,
108 const std::string& address, const std::string& name);
109 void regNameRegisteredSlot();
110 void setAccEnableSlot(int state);
111 void delAccountSlot();
112
113 void toggleAdvancedSettings();
114 void toggleBannedContacts();
115 void exportAccountSlot();
116
117 void updateAndShowDevicesSlot();
118 void updateAndShowBannedContactsSlot();
119
120 void showLinkDevSlot();
121 void showCurrentAccountSlot();
122
123 void setButtonIconSlot(int frame);
124
125
Isa Nanic6e4a39a2018-12-04 14:26:02 -0500126 // ************************* General Settings *************************
127private:
128 void populateGeneralSettings();
Andreas Traczykfc33a492018-12-14 13:53:13 -0500129 QMetaObject::Connection accountAddedConnection_;
130
Isa Nanic6e4a39a2018-12-04 14:26:02 -0500131private slots:
132 void setNotificationsSlot(int state);
133 void checkForUpdateSlot();
134 void setClosedOrMinSlot(int state);
135 void openDownloadFolderSlot();
136 void setAlwaysRecordingSlot(int state);
137 void openRecordFolderSlot();
138 void setUpdateIntervalSlot(int value);
139 void setUpdateAutomaticSlot(int state);
140
141 // ************************* Audio/Visual Settings *************************
142private:
143 void populateAVSettings();
Isa Nanic054ef9a2018-12-11 11:56:28 -0500144 void saveSizeIndex();
Isa Nanic6e4a39a2018-12-04 14:26:02 -0500145 Video::DeviceModel* deviceModel_;
146 void showPreview();
147 bool isLoading_;
Isa Nanic054ef9a2018-12-11 11:56:28 -0500148 int currentResIndex = -1;
149
150 void startVideo();
151 void stopVideo();
Isa Nanic6e4a39a2018-12-04 14:26:02 -0500152
153private slots:
154 void deviceIndexChanged(int index);
155 void deviceBoxCurrentIndexChangedSlot(int index);
156 void sizeBoxCurrentIndexChangedSlot(int index);
157 void outputDevIndexChangedSlot(int index);
158 void inputdevIndexChangedSlot(int index);
159
160};