Isa Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 1 | /*************************************************************************** |
| 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 Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 21 | #include <QMovie> |
| 22 | |
| 23 | #include "navwidget.h" |
Isa Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 24 | #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 | |
| 40 | namespace Ui { |
| 41 | class SettingsWidget; |
| 42 | } |
| 43 | |
| 44 | class SettingsWidget : public NavWidget |
| 45 | { |
| 46 | Q_OBJECT |
| 47 | SettingsWidget(const SettingsWidget& cpy); |
| 48 | |
| 49 | public: |
| 50 | explicit SettingsWidget(QWidget* parent = nullptr); |
| 51 | ~SettingsWidget(); |
| 52 | void resize(int size); |
| 53 | |
Andreas Traczyk | fc33a49 | 2018-12-14 13:53:13 -0500 | [diff] [blame] | 54 | // NavWidget |
| 55 | virtual void navigated(bool to); |
Andreas Traczyk | 6ace34f | 2018-12-14 14:31:23 -0500 | [diff] [blame] | 56 | virtual void updateCustomUI(); |
Andreas Traczyk | fc33a49 | 2018-12-14 13:53:13 -0500 | [diff] [blame] | 57 | |
Isa Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 58 | public slots: |
| 59 | void updateSettings(int size); |
| 60 | |
| 61 | private: |
| 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 Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 70 | |
| 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 Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 103 | private 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 Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 126 | // ************************* General Settings ************************* |
| 127 | private: |
| 128 | void populateGeneralSettings(); |
Andreas Traczyk | fc33a49 | 2018-12-14 13:53:13 -0500 | [diff] [blame] | 129 | QMetaObject::Connection accountAddedConnection_; |
| 130 | |
Isa Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 131 | private 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 ************************* |
| 142 | private: |
| 143 | void populateAVSettings(); |
Isa Nanic | 054ef9a | 2018-12-11 11:56:28 -0500 | [diff] [blame] | 144 | void saveSizeIndex(); |
Isa Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 145 | Video::DeviceModel* deviceModel_; |
| 146 | void showPreview(); |
| 147 | bool isLoading_; |
Isa Nanic | 054ef9a | 2018-12-11 11:56:28 -0500 | [diff] [blame] | 148 | int currentResIndex = -1; |
| 149 | |
| 150 | void startVideo(); |
| 151 | void stopVideo(); |
Isa Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 152 | |
| 153 | private 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 | }; |