blob: 485cb537e77d3806a11e8d27c0943ecd8ebd4ed2 [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>
21#include <QSettings>
22#include <QMovie>
23
24#include "navwidget.h"
Isa Nanic6e4a39a2018-12-04 14:26:02 -050025#include "lrcinstance.h"
26
27#include "advancedsettingswidget.h"
28#include "bannedlistmodel.h"
29
30#include "linkdevwidget.h"
31#include "ui_linkdevwidget.h"
32
33 // general settings
34#include "api/datatransfermodel.h"
35#include "typedefs.h"
36
37// av settings
38#include "video/devicemodel.h"
39
40
41namespace Ui {
42 class SettingsWidget;
43}
44
45class SettingsWidget : public NavWidget
46{
47 Q_OBJECT
48 SettingsWidget(const SettingsWidget& cpy);
49
50public:
51 explicit SettingsWidget(QWidget* parent = nullptr);
52 ~SettingsWidget();
53 void resize(int size);
54
55public slots:
56 void updateSettings(int size);
57
58private:
59 enum Button {accountSettingsButton, generalSettingsButton, avSettingsButton};
60 enum RegName {BLANK, INVALIDFORM, TAKEN, FREE, SEARCHING};
61 enum List {DevList, BannedContacts};
62
63 void setSelected(Button sel);
64 void updateAccountInfoDisplayed();
65
66 void resizeEvent(QResizeEvent* event);
Isa Nanic6e4a39a2018-12-04 14:26:02 -050067
68 Ui::SettingsWidget* ui;
69
70 // ************************* Account Settings *************************
71 void passwordClicked();
72 void avatarClicked();
73
74 void afterNameLookup(lrc::api::account::LookupStatus status, const std::string& regName);
75 QString registeredName_;
76
77 bool validateRegNameForm(const QString& regName);
78
79 AdvancedSettingsWidget* advancedSettingsWidget_;
80 QScrollArea* scrollArea_;
81 Button pastButton_ = Button::generalSettingsButton;
82 bool advancedSettingsDropped_ = false;
83 bool bannedContactsShown_ = false;
84
85 int avatarSize_;
86
87 void setRegNameUi(RegName stat);
88 bool regNameBtn_ = false;
89
90 const int itemHeight_ = 55;
91
92 void removeDeviceSlot(int index);
93 void unban(int index);
94
95 void setConnections();
96 QMovie* gif;
97
98 LinkDevWidget* linkDevWidget;
99
Isa Nanic6e4a39a2018-12-04 14:26:02 -0500100private slots:
101 void leaveSettingsSlot();
102 void verifyRegisteredNameSlot();
103 void beforeNameLookup();
104 void receiveRegNameSlot(const std::string& accountID, lrc::api::account::LookupStatus status,
105 const std::string& address, const std::string& name);
106 void regNameRegisteredSlot();
107 void setAccEnableSlot(int state);
108 void delAccountSlot();
109
110 void toggleAdvancedSettings();
111 void toggleBannedContacts();
112 void exportAccountSlot();
113
114 void updateAndShowDevicesSlot();
115 void updateAndShowBannedContactsSlot();
116
117 void showLinkDevSlot();
118 void showCurrentAccountSlot();
119
120 void setButtonIconSlot(int frame);
121
122
Isa Nanic6e4a39a2018-12-04 14:26:02 -0500123 // ************************* General Settings *************************
124private:
125 void populateGeneralSettings();
126
127 QSettings* settings_;
128
129private slots:
130 void setNotificationsSlot(int state);
131 void checkForUpdateSlot();
132 void setClosedOrMinSlot(int state);
133 void openDownloadFolderSlot();
134 void setAlwaysRecordingSlot(int state);
135 void openRecordFolderSlot();
136 void setUpdateIntervalSlot(int value);
137 void setUpdateAutomaticSlot(int state);
138
139 // ************************* Audio/Visual Settings *************************
140private:
141 void populateAVSettings();
Isa Nanic054ef9a2018-12-11 11:56:28 -0500142 void saveSizeIndex();
Isa Nanic6e4a39a2018-12-04 14:26:02 -0500143 Video::DeviceModel* deviceModel_;
144 void showPreview();
145 bool isLoading_;
Isa Nanic054ef9a2018-12-11 11:56:28 -0500146 int currentResIndex = -1;
147
148 void startVideo();
149 void stopVideo();
Isa Nanic6e4a39a2018-12-04 14:26:02 -0500150
151private slots:
152 void deviceIndexChanged(int index);
153 void deviceBoxCurrentIndexChangedSlot(int index);
154 void sizeBoxCurrentIndexChangedSlot(int index);
155 void outputDevIndexChangedSlot(int index);
156 void inputdevIndexChangedSlot(int index);
157
158};