2015-11-01 00:21:09 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Roeland Jago Douma <roeland@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
|
2016-10-25 12:00:07 +03:00
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2015-11-01 00:21:09 +03:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2015-11-05 11:58:16 +03:00
|
|
|
#ifndef SHAREUSERGROUPWIDGET_H
|
|
|
|
#define SHAREUSERGROUPWIDGET_H
|
2015-11-01 00:21:09 +03:00
|
|
|
|
|
|
|
#include "accountfwd.h"
|
2021-04-14 17:36:16 +03:00
|
|
|
#include "sharemanager.h"
|
2016-03-30 12:33:34 +03:00
|
|
|
#include "sharepermissions.h"
|
2020-12-03 21:32:21 +03:00
|
|
|
#include "sharee.h"
|
2021-10-22 12:16:38 +03:00
|
|
|
#include "profilepagewidget.h"
|
2015-11-01 00:21:09 +03:00
|
|
|
#include "QProgressIndicator.h"
|
|
|
|
#include <QDialog>
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QSharedPointer>
|
|
|
|
#include <QList>
|
2015-11-05 14:30:34 +03:00
|
|
|
#include <QVector>
|
2015-11-16 16:18:01 +03:00
|
|
|
#include <QTimer>
|
2021-10-22 12:16:38 +03:00
|
|
|
#include <qpushbutton.h>
|
2018-07-25 12:18:08 +03:00
|
|
|
#include <qscrollarea.h>
|
2015-11-05 00:00:35 +03:00
|
|
|
|
2015-11-25 13:26:21 +03:00
|
|
|
class QAction;
|
2015-11-05 00:00:35 +03:00
|
|
|
class QCompleter;
|
2015-11-11 13:51:33 +03:00
|
|
|
class QModelIndex;
|
2015-11-05 00:00:35 +03:00
|
|
|
|
2015-11-01 00:21:09 +03:00
|
|
|
namespace OCC {
|
|
|
|
|
|
|
|
namespace Ui {
|
2015-11-05 11:58:16 +03:00
|
|
|
class ShareUserGroupWidget;
|
2017-04-04 16:05:08 +03:00
|
|
|
class ShareUserLine;
|
2015-11-01 00:21:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
class AbstractCredentials;
|
|
|
|
class SyncResult;
|
|
|
|
class Share;
|
|
|
|
class ShareManager;
|
|
|
|
|
2021-10-22 12:16:38 +03:00
|
|
|
class AvatarEventFilter : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit AvatarEventFilter(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void clicked();
|
|
|
|
void contextMenu(const QPoint &globalPosition);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
|
|
|
};
|
|
|
|
|
2015-11-01 00:21:09 +03:00
|
|
|
/**
|
|
|
|
* @brief The ShareDialog (user/group) class
|
|
|
|
* @ingroup gui
|
|
|
|
*/
|
2015-11-05 11:58:16 +03:00
|
|
|
class ShareUserGroupWidget : public QWidget
|
2015-11-01 00:21:09 +03:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2015-11-05 11:58:16 +03:00
|
|
|
explicit ShareUserGroupWidget(AccountPtr account,
|
2015-11-01 00:21:09 +03:00
|
|
|
const QString &sharePath,
|
|
|
|
const QString &localPath,
|
2016-03-30 12:33:34 +03:00
|
|
|
SharePermissions maxSharingPermissions,
|
2017-09-15 15:24:34 +03:00
|
|
|
const QString &privateLinkUrl,
|
2018-11-11 12:56:22 +03:00
|
|
|
QWidget *parent = nullptr);
|
2021-08-17 13:39:31 +03:00
|
|
|
~ShareUserGroupWidget() override;
|
2021-12-06 22:29:47 +03:00
|
|
|
|
|
|
|
QVBoxLayout *shareUserGroupLayout();
|
2015-11-02 00:23:22 +03:00
|
|
|
|
2018-03-15 21:43:26 +03:00
|
|
|
signals:
|
|
|
|
void togglePublicLinkShare(bool);
|
2019-12-09 22:59:10 +03:00
|
|
|
void styleChanged();
|
2018-03-15 21:43:26 +03:00
|
|
|
|
2015-11-02 00:23:22 +03:00
|
|
|
public slots:
|
2015-11-01 00:21:09 +03:00
|
|
|
void getShares();
|
2021-04-20 17:36:42 +03:00
|
|
|
void slotShareCreated(const QSharedPointer<Share> &share);
|
2019-12-09 22:59:10 +03:00
|
|
|
void slotStyleChanged();
|
2015-11-01 00:21:09 +03:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void slotSharesFetched(const QList<QSharedPointer<Share>> &shares);
|
2015-11-02 00:23:22 +03:00
|
|
|
|
2015-11-05 00:00:35 +03:00
|
|
|
void on_shareeLineEdit_textChanged(const QString &text);
|
2020-12-03 21:32:21 +03:00
|
|
|
void searchForSharees(ShareeModel::LookupMode lookupMode);
|
2015-11-16 16:18:01 +03:00
|
|
|
void slotLineEditTextEdited(const QString &text);
|
2015-11-05 00:00:35 +03:00
|
|
|
|
2015-12-10 15:49:47 +03:00
|
|
|
void slotLineEditReturn();
|
2015-11-05 00:00:35 +03:00
|
|
|
void slotCompleterActivated(const QModelIndex &index);
|
2015-12-10 16:56:15 +03:00
|
|
|
void slotCompleterHighlighted(const QModelIndex &index);
|
2015-11-16 16:18:01 +03:00
|
|
|
void slotShareesReady();
|
2017-05-10 10:37:10 +03:00
|
|
|
void slotPrivateLinkShare();
|
2016-01-12 15:19:33 +03:00
|
|
|
void displayError(int code, const QString &message);
|
2015-11-02 00:23:22 +03:00
|
|
|
|
2017-05-10 10:37:10 +03:00
|
|
|
void slotPrivateLinkOpenBrowser();
|
|
|
|
void slotPrivateLinkCopy();
|
|
|
|
void slotPrivateLinkEmail();
|
|
|
|
|
2015-11-01 00:21:09 +03:00
|
|
|
private:
|
2019-12-09 22:59:10 +03:00
|
|
|
void customizeStyle();
|
|
|
|
|
2020-12-03 21:32:21 +03:00
|
|
|
void activateShareeLineEdit();
|
|
|
|
|
2015-11-05 11:58:16 +03:00
|
|
|
Ui::ShareUserGroupWidget *_ui;
|
2018-07-25 12:18:08 +03:00
|
|
|
QScrollArea *_parentScrollArea;
|
2021-12-06 22:29:47 +03:00
|
|
|
QVBoxLayout *_shareUserGroup;
|
2015-11-01 00:21:09 +03:00
|
|
|
AccountPtr _account;
|
|
|
|
QString _sharePath;
|
|
|
|
QString _localPath;
|
2017-05-10 10:37:10 +03:00
|
|
|
SharePermissions _maxSharingPermissions;
|
2017-09-15 15:24:34 +03:00
|
|
|
QString _privateLinkUrl;
|
2015-11-01 00:21:09 +03:00
|
|
|
|
2015-11-05 00:00:35 +03:00
|
|
|
QCompleter *_completer;
|
|
|
|
ShareeModel *_completerModel;
|
2015-11-16 16:18:01 +03:00
|
|
|
QTimer _completionTimer;
|
2015-11-05 00:00:35 +03:00
|
|
|
|
2015-11-01 00:21:09 +03:00
|
|
|
bool _isFile;
|
2016-01-12 16:35:35 +03:00
|
|
|
bool _disableCompleterActivated; // in order to avoid that we share the contents twice
|
2015-11-01 00:21:09 +03:00
|
|
|
ShareManager *_manager;
|
2016-04-29 15:11:27 +03:00
|
|
|
|
|
|
|
QProgressIndicator _pi_sharee;
|
2021-04-20 17:36:42 +03:00
|
|
|
|
|
|
|
QString _lastCreatedShareId;
|
2015-11-01 00:21:09 +03:00
|
|
|
};
|
|
|
|
|
2017-04-04 16:05:08 +03:00
|
|
|
/**
|
|
|
|
* The widget displayed for each user/group share
|
|
|
|
*/
|
|
|
|
class ShareUserLine : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2021-04-20 17:36:42 +03:00
|
|
|
explicit ShareUserLine(AccountPtr account,
|
|
|
|
QSharedPointer<UserGroupShare> Share,
|
2017-04-04 16:05:08 +03:00
|
|
|
SharePermissions maxSharingPermissions,
|
|
|
|
bool isFile,
|
2018-11-11 12:56:22 +03:00
|
|
|
QWidget *parent = nullptr);
|
2021-08-17 13:39:31 +03:00
|
|
|
~ShareUserLine() override;
|
2017-04-04 16:05:08 +03:00
|
|
|
|
|
|
|
QSharedPointer<Share> share() const;
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void visualDeletionDone();
|
|
|
|
void resizeRequested();
|
|
|
|
|
2019-12-09 22:59:10 +03:00
|
|
|
public slots:
|
|
|
|
void slotStyleChanged();
|
|
|
|
|
2021-04-20 17:36:42 +03:00
|
|
|
void focusPasswordLineEdit();
|
|
|
|
|
2017-04-04 16:05:08 +03:00
|
|
|
private slots:
|
|
|
|
void on_deleteShareButton_clicked();
|
|
|
|
void slotPermissionsChanged();
|
|
|
|
void slotEditPermissionsChanged();
|
2021-04-20 17:36:42 +03:00
|
|
|
void slotPasswordCheckboxChanged();
|
2017-04-04 16:05:08 +03:00
|
|
|
void slotDeleteAnimationFinished();
|
|
|
|
|
2021-04-20 17:36:42 +03:00
|
|
|
void refreshPasswordOptions();
|
|
|
|
|
|
|
|
void refreshPasswordLineEditPlaceholder();
|
|
|
|
|
|
|
|
void slotPasswordSet();
|
|
|
|
void slotPasswordSetError(int statusCode, const QString &message);
|
|
|
|
|
2017-04-04 16:05:08 +03:00
|
|
|
void slotShareDeleted();
|
|
|
|
void slotPermissionsSet();
|
2017-05-17 11:55:42 +03:00
|
|
|
|
2017-11-21 12:18:15 +03:00
|
|
|
void slotAvatarLoaded(QImage avatar);
|
2015-12-21 18:19:09 +03:00
|
|
|
|
2021-04-20 17:36:42 +03:00
|
|
|
void setPasswordConfirmed();
|
|
|
|
|
2021-04-24 13:46:53 +03:00
|
|
|
void slotLineEditPasswordReturnPressed();
|
2021-04-20 17:36:42 +03:00
|
|
|
|
2021-04-24 13:46:53 +03:00
|
|
|
void slotConfirmPasswordClicked();
|
2021-04-20 17:36:42 +03:00
|
|
|
|
2021-10-22 12:16:38 +03:00
|
|
|
void onAvatarContextMenu(const QPoint &globalPosition);
|
|
|
|
|
2017-04-04 16:05:08 +03:00
|
|
|
private:
|
|
|
|
void displayPermissions();
|
2015-12-21 18:19:09 +03:00
|
|
|
void loadAvatar();
|
2021-08-17 16:39:18 +03:00
|
|
|
void setDefaultAvatar(int avatarSize);
|
2019-12-09 22:59:10 +03:00
|
|
|
void customizeStyle();
|
2017-04-04 16:05:08 +03:00
|
|
|
|
2021-08-17 16:39:18 +03:00
|
|
|
QPixmap pixmapForShareeType(Sharee::Type type, const QColor &backgroundColor = QColor()) const;
|
|
|
|
QColor backgroundColorForShareeType(Sharee::Type type) const;
|
|
|
|
|
2021-04-14 17:36:16 +03:00
|
|
|
void showNoteOptions(bool show);
|
|
|
|
void toggleNoteOptions(bool enable);
|
|
|
|
void onNoteConfirmButtonClicked();
|
|
|
|
void setNote(const QString ¬e);
|
|
|
|
|
2021-04-15 14:06:53 +03:00
|
|
|
void toggleExpireDateOptions(bool enable);
|
2021-08-17 16:39:18 +03:00
|
|
|
void showExpireDateOptions(bool show, const QDate &initialDate = QDate());
|
2021-04-15 14:06:53 +03:00
|
|
|
void setExpireDate();
|
|
|
|
|
2021-04-24 13:57:54 +03:00
|
|
|
void togglePasswordSetProgressAnimation(bool show);
|
|
|
|
|
2021-04-16 14:17:09 +03:00
|
|
|
void enableProgessIndicatorAnimation(bool enable);
|
|
|
|
void disableProgessIndicatorAnimation();
|
|
|
|
|
2021-11-01 18:37:23 +03:00
|
|
|
QDate maxExpirationDateForShare(const Share::ShareType type, const QDate &fallbackDate) const;
|
|
|
|
bool enforceExpirationDateForShare(const Share::ShareType type) const;
|
|
|
|
|
2021-04-14 17:36:16 +03:00
|
|
|
Ui::ShareUserLine *_ui;
|
2021-04-20 17:36:42 +03:00
|
|
|
AccountPtr _account;
|
2021-04-14 17:36:16 +03:00
|
|
|
QSharedPointer<UserGroupShare> _share;
|
|
|
|
bool _isFile;
|
|
|
|
|
2021-10-22 12:16:38 +03:00
|
|
|
ProfilePageMenu _profilePageMenu;
|
|
|
|
|
2021-04-14 17:36:16 +03:00
|
|
|
// _permissionEdit is a checkbox
|
|
|
|
QAction *_permissionReshare;
|
|
|
|
QAction *_deleteShareButton;
|
|
|
|
QAction *_permissionCreate;
|
|
|
|
QAction *_permissionChange;
|
|
|
|
QAction *_permissionDelete;
|
|
|
|
QAction *_noteLinkAction;
|
2021-04-15 14:06:53 +03:00
|
|
|
QAction *_expirationDateLinkAction;
|
2021-04-20 17:36:42 +03:00
|
|
|
QAction *_passwordProtectLinkAction;
|
2017-04-04 16:05:08 +03:00
|
|
|
};
|
2015-11-01 00:21:09 +03:00
|
|
|
}
|
|
|
|
|
2015-11-05 11:58:16 +03:00
|
|
|
#endif // SHAREUSERGROUPWIDGET_H
|