settingswidget.h 4.99 KB
Newer Older
1
/***************************************************************************
2
 * Copyright (C) 2019-2019 by Savoir-faire Linux                           *
Andreas Traczyk's avatar
Andreas Traczyk committed
3 4
 * Author: Isa Nanic <isa.nanic@savoirfairelinux.com>                      *
 * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>              *
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 *                                                                         *
 * This program is free software; you can redistribute it and/or modify    *
 * it under the terms of the GNU General Public License as published by    *
 * the Free Software Foundation; either version 3 of the License, or       *
 * (at your option) any later version.                                     *
 *                                                                         *
 * This program is distributed in the hope that it will be useful,         *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
 * GNU General Public License for more details.                            *
 *                                                                         *
 * You should have received a copy of the GNU General Public License       *
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.   *
 **************************************************************************/
#pragma once
Andreas Traczyk's avatar
Andreas Traczyk committed
20

21
#include <QMovie>
Andreas Traczyk's avatar
Andreas Traczyk committed
22
#include <QScrollArea>
23 24

#include "lrcinstance.h"
Andreas Traczyk's avatar
Andreas Traczyk committed
25
#include "navwidget.h"
26 27

#include "advancedsettingswidget.h"
28
#include "advancedsipsettingwidget.h"
29
#include "bannedlistmodel.h"
Andreas Traczyk's avatar
Andreas Traczyk committed
30 31
#include "linkdevicedialog.h"
#include "photoboothwidget.h"
32 33 34 35 36

#include "api/datatransfermodel.h"
#include "typedefs.h"
#include "video/devicemodel.h"

Andreas Traczyk's avatar
Andreas Traczyk committed
37
namespace Ui {
38
class SettingsWidget;
39 40
}

Andreas Traczyk's avatar
Andreas Traczyk committed
41
class SettingsWidget : public NavWidget {
42 43 44 45 46 47 48
    Q_OBJECT
    SettingsWidget(const SettingsWidget& cpy);

public:
    explicit SettingsWidget(QWidget* parent = nullptr);
    ~SettingsWidget();

49 50
    // NavWidget
    virtual void navigated(bool to);
Andreas Traczyk's avatar
Andreas Traczyk committed
51
    virtual void updateCustomUI();
52 53
public slots:
    virtual void slotAccountOnBoarded();
54

55
private:
Andreas Traczyk's avatar
Andreas Traczyk committed
56
    Ui::SettingsWidget* ui;
57

Andreas Traczyk's avatar
Andreas Traczyk committed
58 59 60 61 62 63 64 65 66 67 68 69 70 71
    enum Button {
        accountSettingsButton,
        generalSettingsButton,
        mediaSettingsButton
    };
    enum RegName {
        BLANK,
        INVALIDFORM,
        TAKEN,
        FREE,
        SEARCHING
    };

    void setAvatar(PhotoboothWidget* avatarWidget);
72 73 74
    void setSelected(Button sel);
    void updateAccountInfoDisplayed();
    void resizeEvent(QResizeEvent* event);
Andreas Traczyk's avatar
Andreas Traczyk committed
75
    bool sipPasswordHidden_{false};
76 77 78
    void passwordClicked();
    void afterNameLookup(lrc::api::account::LookupStatus status, const std::string& regName);
    bool validateRegNameForm(const QString& regName);
Andreas Traczyk's avatar
Andreas Traczyk committed
79 80 81 82 83 84 85 86 87 88 89 90
    void setRegNameUi(RegName stat);
    void removeDeviceSlot(int index);
    void unban(int index);
    void setConnections();
    void populateGeneralSettings();
    void populateAVSettings();
    void setFormatListForDevice(Video::Device* device);
    void showPreview();
    void startVideo();
    void stopVideo();
    void toggleVideoSettings(bool enabled);
    void toggleVideoPreview(bool enabled);
91

Andreas Traczyk's avatar
Andreas Traczyk committed
92 93
    QString registeredName_;
    lrc::api::account::ConfProperties_t confProps_;
94 95 96 97
    AdvancedSettingsWidget* advancedSettingsWidget_;
    QScrollArea* scrollArea_;
    Button pastButton_ = Button::generalSettingsButton;
    bool advancedSettingsDropped_ = false;
Andreas Traczyk's avatar
Andreas Traczyk committed
98 99 100
    QList<QPair<int, int>> formatIndexList_;
    Video::DeviceModel* deviceModel_;
    QString currentDeviceName_;
101 102 103
    AdvancedSIPSettingsWidget* advancedSIPSettingsWidget_;
    QScrollArea* scrollSIPArea_;
    bool advancedSIPSettingsDropped_ = false;
104
    int avatarSize_;
105
    int avatarSIPSize_;
106 107 108
    bool regNameBtn_ = false;
    const int itemHeight_ = 55;

Andreas Traczyk's avatar
Andreas Traczyk committed
109 110 111 112
    QMovie* lookupSpinnerMovie_;
    QPixmap statusSuccessPixmap_;
    QPixmap statusInvalidPixmap_;
    QPixmap statusErrorPixmap_;
113 114 115 116 117 118 119

private slots:
    void leaveSettingsSlot();
    void verifyRegisteredNameSlot();
    void beforeNameLookup();
    void receiveRegNameSlot(const std::string& accountID, lrc::api::account::LookupStatus status,
        const std::string& address, const std::string& name);
Andreas Traczyk's avatar
Andreas Traczyk committed
120
    void slotRegisterName();
121 122
    void setAccEnableSlot(int state);
    void delAccountSlot();
123
    void toggleAdvancedSIPSettings();
124 125 126 127 128 129
    void toggleAdvancedSettings();
    void toggleBannedContacts();
    void exportAccountSlot();
    void updateAndShowDevicesSlot();
    void updateAndShowBannedContactsSlot();
    void showLinkDevSlot();
Andreas Traczyk's avatar
Andreas Traczyk committed
130
    void slotSetNotifications(bool state);
131
    void checkForUpdateSlot();
Andreas Traczyk's avatar
Andreas Traczyk committed
132
    void slotSetClosedOrMin(bool state);
133
    void openDownloadFolderSlot();
Andreas Traczyk's avatar
Andreas Traczyk committed
134
    void slotSetAlwaysRecording(bool state);
135 136
    void openRecordFolderSlot();
    void setUpdateIntervalSlot(int value);
Andreas Traczyk's avatar
Andreas Traczyk committed
137
    void slotSetUpdateAutomatic(bool state);
138 139
    void outputDevIndexChangedSlot(int index);
    void inputdevIndexChangedSlot(int index);
140 141 142
    void deviceModelIndexChanged(int index);
    void slotDeviceBoxCurrentIndexChanged(int index);
    void slotFormatBoxCurrentIndexChanged(int index);
143
};