Welcome to mirror list, hosted at ThFree Co, Russian Federation.

sharelinkwidget.h « gui « src - github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7ecd9691e443e2ba346df53ce13ac8cef0605f11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
 * Copyright (C) by Roeland Jago Douma <roeland@famdouma.nl>
 * Copyright (C) 2015 by Klaas Freitag <freitag@owncloud.com>
 *
 * 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 2 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.
 */

#ifndef SHARELINKWIDGET_H
#define SHARELINKWIDGET_H

#include "accountfwd.h"
#include "sharepermissions.h"
#include "QProgressIndicator.h"
#include <QDialog>
#include <QSharedPointer>
#include <QList>
#include <QToolButton>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QWidgetAction>

class QMenu;
class QTableWidgetItem;

namespace OCC {

namespace Ui {
    class ShareLinkWidget;
}

class AbstractCredentials;
class SyncResult;
class LinkShare;
class Share;
class ElidedLabel;

/**
 * @brief The ShareDialog class
 * @ingroup gui
 */
class ShareLinkWidget : public QWidget
{
    Q_OBJECT

public:
    explicit ShareLinkWidget(AccountPtr account,
        const QString &sharePath,
        const QString &localPath,
        SharePermissions maxSharingPermissions,
        QWidget *parent = nullptr);
    ~ShareLinkWidget() override;

    void toggleButton(bool show);
    void setupUiOptions();

    void setLinkShare(QSharedPointer<LinkShare> linkShare);
    QSharedPointer<LinkShare> getLinkShare();

    void focusPasswordLineEdit();

public slots:
    void slotDeleteShareFetched();
    void slotToggleShareLinkAnimation(const bool start);
    void slotServerError(const int code, const QString &message);
    void slotCreateShareRequiresPassword(const QString &message);
    void slotStyleChanged();

private slots:
    void slotCreateShareLink(const bool clicked);
    void slotCopyLinkShare(const bool clicked) const;    

    void slotCreatePassword();
    void slotPasswordSet();
    void slotPasswordSetError(const int code, const QString &message);

    void slotCreateNote();
    void slotNoteSet();

    void slotSetExpireDate();
    void slotExpireDateSet();

    void slotContextMenuButtonClicked();
    void slotLinkContextMenuActionTriggered(QAction *action);
    
    void slotCreateLabel();
    void slotLabelSet();

signals:
    void createLinkShare();
    void deleteLinkShare();
    void visualDeletionDone();
    void createPassword(const QString &password);
    void createPasswordProcessed();

private:
    void displayError(const QString &errMsg);
    
    void togglePasswordOptions(const bool enable = true);
    void toggleNoteOptions(const bool enable = true);
    void toggleExpireDateOptions(const bool enable = true);
    void toggleButtonAnimation(QToolButton *button, QProgressIndicator *progressIndicator, const QAction *checkedAction) const;

    /** Confirm with the user and then delete the share */
    void confirmAndDeleteShare();

    /** Retrieve a share's name, accounting for _namesSupported */
    [[nodiscard]] QString shareName() const;

    void customizeStyle();
    
    void displayShareLinkLabel();

    Ui::ShareLinkWidget *_ui;
    AccountPtr _account;
    QString _sharePath;
    QString _localPath;
    QString _shareUrl;

    QSharedPointer<LinkShare> _linkShare;

    bool _isFile;
    bool _passwordRequired;
    bool _expiryRequired;
    bool _namesSupported;
    bool _noteRequired;

    QMenu *_linkContextMenu;
    QAction *_readOnlyLinkAction;
    QAction *_allowEditingLinkAction;
    QAction *_allowUploadEditingLinkAction;
    QAction *_allowUploadLinkAction;
    QAction *_passwordProtectLinkAction;
    QAction *_expirationDateLinkAction;
    QScopedPointer<QAction> _unshareLinkAction;
    QScopedPointer<QAction> _addAnotherLinkAction;
    QAction *_noteLinkAction;
    QHBoxLayout *_shareLinkLayout{};
    QLabel *_shareLinkLabel{};
    ElidedLabel *_shareLinkElidedLabel{};
    QLineEdit *_shareLinkEdit{};
    QToolButton *_shareLinkButton{};
    QProgressIndicator *_shareLinkProgressIndicator{};
    QWidget *_shareLinkDefaultWidget{};
    QWidgetAction *_shareLinkWidgetAction{};
};
}

#endif // SHARELINKWIDGET_H