blob: a85316984aa26a9f287bcbe27ce5f21a5364bbfb [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);
67 bool avSettingsHaveAppeared = false;
68
69 Ui::SettingsWidget* ui;
70
71 // ************************* Account Settings *************************
72 void passwordClicked();
73 void avatarClicked();
74
75 void afterNameLookup(lrc::api::account::LookupStatus status, const std::string& regName);
76 QString registeredName_;
77
78 bool validateRegNameForm(const QString& regName);
79
80 AdvancedSettingsWidget* advancedSettingsWidget_;
81 QScrollArea* scrollArea_;
82 Button pastButton_ = Button::generalSettingsButton;
83 bool advancedSettingsDropped_ = false;
84 bool bannedContactsShown_ = false;
85
86 int avatarSize_;
87
88 void setRegNameUi(RegName stat);
89 bool regNameBtn_ = false;
90
91 const int itemHeight_ = 55;
92
93 void removeDeviceSlot(int index);
94 void unban(int index);
95
96 void setConnections();
97 QMovie* gif;
98
99 LinkDevWidget* linkDevWidget;
100
Isa Nanic6e4a39a2018-12-04 14:26:02 -0500101private slots:
102 void leaveSettingsSlot();
103 void verifyRegisteredNameSlot();
104 void beforeNameLookup();
105 void receiveRegNameSlot(const std::string& accountID, lrc::api::account::LookupStatus status,
106 const std::string& address, const std::string& name);
107 void regNameRegisteredSlot();
108 void setAccEnableSlot(int state);
109 void delAccountSlot();
110
111 void toggleAdvancedSettings();
112 void toggleBannedContacts();
113 void exportAccountSlot();
114
115 void updateAndShowDevicesSlot();
116 void updateAndShowBannedContactsSlot();
117
118 void showLinkDevSlot();
119 void showCurrentAccountSlot();
120
121 void setButtonIconSlot(int frame);
122
123
124
125 // ************************* General Settings *************************
126private:
127 void populateGeneralSettings();
128
129 QSettings* settings_;
130
131private 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();
144 Video::DeviceModel* deviceModel_;
145 void showPreview();
146 bool isLoading_;
147
148private slots:
149 void deviceIndexChanged(int index);
150 void deviceBoxCurrentIndexChangedSlot(int index);
151 void sizeBoxCurrentIndexChangedSlot(int index);
152 void outputDevIndexChangedSlot(int index);
153 void inputdevIndexChangedSlot(int index);
154
155};