mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 05:25:50 +03:00
Merge pull request #4055 from owncloud/user_group_sharing
User group sharing
This commit is contained in:
commit
914a942e33
20 changed files with 1943 additions and 779 deletions
|
@ -23,6 +23,9 @@ set(client_UI
|
|||
protocolwidget.ui
|
||||
settingsdialog.ui
|
||||
sharedialog.ui
|
||||
sharelinkwidget.ui
|
||||
shareusergroupwidget.ui
|
||||
sharewidget.ui
|
||||
sslerrordialog.ui
|
||||
owncloudsetuppage.ui
|
||||
addcertificatedialog.ui
|
||||
|
@ -52,6 +55,7 @@ set(client_SRCS
|
|||
networksettings.cpp
|
||||
ocsjob.cpp
|
||||
ocssharejob.cpp
|
||||
ocsshareejob.cpp
|
||||
openfilemanager.cpp
|
||||
owncloudgui.cpp
|
||||
owncloudsetupwizard.cpp
|
||||
|
@ -60,6 +64,9 @@ set(client_SRCS
|
|||
settingsdialog.cpp
|
||||
share.cpp
|
||||
sharedialog.cpp
|
||||
sharelinkwidget.cpp
|
||||
shareusergroupwidget.cpp
|
||||
sharee.cpp
|
||||
socketapi.cpp
|
||||
sslbutton.cpp
|
||||
sslerrordialog.cpp
|
||||
|
|
46
src/gui/ocsshareejob.cpp
Normal file
46
src/gui/ocsshareejob.cpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* 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
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "ocsshareejob.h"
|
||||
|
||||
namespace OCC {
|
||||
|
||||
OcsShareeJob::OcsShareeJob(AccountPtr account, QObject *parent)
|
||||
: OcsJob(account, parent)
|
||||
{
|
||||
setPath("ocs/v1.php/apps/files_sharing/api/v1/sharees");
|
||||
connect(this, SIGNAL(jobFinished(QVariantMap)), SLOT(jobDone(QVariantMap)));
|
||||
|
||||
}
|
||||
|
||||
void OcsShareeJob::getSharees(const QString search,
|
||||
const QString itemType,
|
||||
int page,
|
||||
int perPage)
|
||||
{
|
||||
setVerb("GET");
|
||||
|
||||
addParam(QString::fromLatin1("search"), search);
|
||||
addParam(QString::fromLatin1("itemType"), itemType);
|
||||
addParam(QString::fromLatin1("page"), QString::number(page));
|
||||
addParam(QString::fromLatin1("perPage"), QString::number(perPage));
|
||||
|
||||
start();
|
||||
}
|
||||
|
||||
void OcsShareeJob::jobDone(const QVariantMap &reply)
|
||||
{
|
||||
emit shareeJobFinished(reply);
|
||||
}
|
||||
|
||||
}
|
58
src/gui/ocsshareejob.h
Normal file
58
src/gui/ocsshareejob.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* 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
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* 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 OCSSHAREEJOB_H
|
||||
#define OCSSHAREEJOB_H
|
||||
|
||||
#include "ocsjob.h"
|
||||
#include <QVariantMap>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
/**
|
||||
* @brief The OcsShareeJob class
|
||||
* @ingroup gui
|
||||
*
|
||||
* Fetching sharees from the OCS Sharee API
|
||||
*/
|
||||
class OcsShareeJob : public OcsJob {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
explicit OcsShareeJob(AccountPtr account, QObject *parent = 0);
|
||||
|
||||
/**
|
||||
* Get a list of sharees
|
||||
*
|
||||
* @param path Path to request shares for (default all shares)
|
||||
*/
|
||||
void getSharees(const QString search,
|
||||
const QString itemType,
|
||||
int page = 1,
|
||||
int perPage = 50);
|
||||
signals:
|
||||
/**
|
||||
* Result of the OCS request
|
||||
*
|
||||
* @param reply The reply
|
||||
*/
|
||||
void shareeJobFinished(const QVariantMap &reply);
|
||||
|
||||
private slots:
|
||||
void jobDone(const QVariantMap &reply);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OCSSHAREEJOB_H
|
|
@ -83,26 +83,50 @@ void OcsShareJob::setPublicUpload(const QString &shareId, bool publicUpload)
|
|||
start();
|
||||
}
|
||||
|
||||
void OcsShareJob::createShare(const QString &path, Share::ShareType shareType, const QString &password, const QDate &date)
|
||||
void OcsShareJob::setPermissions(const QString &shareId,
|
||||
const Share::Permissions permissions)
|
||||
{
|
||||
appendPath(shareId);
|
||||
setVerb("PUT");
|
||||
|
||||
addParam(QString::fromLatin1("permissions"), QString::number(permissions));
|
||||
_value = (int)permissions;
|
||||
|
||||
start();
|
||||
}
|
||||
|
||||
void OcsShareJob::createLinkShare(const QString &path,
|
||||
const QString &password)
|
||||
{
|
||||
setVerb("POST");
|
||||
|
||||
addParam(QString::fromLatin1("path"), path);
|
||||
addParam(QString::fromLatin1("shareType"), QString::number(static_cast<int>(shareType)));
|
||||
addParam(QString::fromLatin1("shareType"), QString::number(Share::TypeLink));
|
||||
|
||||
if (!password.isEmpty()) {
|
||||
addParam(QString::fromLatin1("password"), password);
|
||||
}
|
||||
|
||||
if (date.isValid()) {
|
||||
addParam(QString::fromLatin1("expireDate"), date.toString("yyyy-MM-dd"));
|
||||
}
|
||||
|
||||
addPassStatusCode(403);
|
||||
|
||||
start();
|
||||
}
|
||||
|
||||
void OcsShareJob::createShare(const QString& path,
|
||||
const Share::ShareType shareType,
|
||||
const QString& shareWith,
|
||||
const Share::Permissions permissions)
|
||||
{
|
||||
setVerb("POST");
|
||||
|
||||
addParam(QString::fromLatin1("path"), path);
|
||||
addParam(QString::fromLatin1("shareType"), QString::number(shareType));
|
||||
addParam(QString::fromLatin1("shareWith"), shareWith);
|
||||
addParam(QString::fromLatin1("permissions"), QString::number(permissions));
|
||||
|
||||
start();
|
||||
}
|
||||
|
||||
void OcsShareJob::jobDone(QVariantMap reply)
|
||||
{
|
||||
emit shareJobFinished(reply, _value);
|
||||
|
|
|
@ -73,15 +73,35 @@ public:
|
|||
*/
|
||||
void setPublicUpload(const QString &shareId, bool publicUpload);
|
||||
|
||||
/**
|
||||
* Set the permissions
|
||||
*
|
||||
* @param permissions
|
||||
*/
|
||||
void setPermissions(const QString &shareId,
|
||||
const Share::Permissions permissions);
|
||||
|
||||
/**
|
||||
* Create a new link share
|
||||
*
|
||||
* @param path The path of the file/folder to share
|
||||
* @param password Optionally a password for the share
|
||||
*/
|
||||
void createLinkShare(const QString& path,
|
||||
const QString& password = "");
|
||||
|
||||
/**
|
||||
* Create a new share
|
||||
*
|
||||
* @param path The path of the file/folder to share
|
||||
* @param shareType The type of share (user/group/link/federated)
|
||||
* @param password Optionally a password for the share
|
||||
* @param date Optionally an expire date for the share
|
||||
* @param shareWith The uid/gid/federated id to share with
|
||||
* @param permissions The permissions the share will have
|
||||
*/
|
||||
void createShare(const QString& path, Share::ShareType shareType, const QString& password = "", const QDate& date = QDate());
|
||||
void createShare(const QString& path,
|
||||
const Share::ShareType shareType,
|
||||
const QString& shareWith = "",
|
||||
const Share::Permissions permissions = Share::PermissionRead);
|
||||
|
||||
signals:
|
||||
/**
|
||||
|
|
|
@ -22,13 +22,15 @@ namespace OCC {
|
|||
Share::Share(AccountPtr account,
|
||||
const QString& id,
|
||||
const QString& path,
|
||||
ShareType shareType,
|
||||
Permissions permissions)
|
||||
const ShareType shareType,
|
||||
const Permissions permissions,
|
||||
const QSharedPointer<Sharee> shareWith)
|
||||
: _account(account),
|
||||
_id(id),
|
||||
_path(path),
|
||||
_shareType(shareType),
|
||||
_permissions(permissions)
|
||||
_permissions(permissions),
|
||||
_shareWith(shareWith)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -43,6 +45,25 @@ Share::ShareType Share::getShareType() const
|
|||
return _shareType;
|
||||
}
|
||||
|
||||
QSharedPointer<Sharee> Share::getShareWith() const
|
||||
{
|
||||
return _shareWith;
|
||||
}
|
||||
|
||||
void Share::setPermissions(Permissions permissions)
|
||||
{
|
||||
OcsShareJob *job = new OcsShareJob(_account, this);
|
||||
connect(job, SIGNAL(shareJobFinished(QVariantMap, QVariant)), SLOT(slotPermissionsSet(QVariantMap, QVariant)));
|
||||
connect(job, SIGNAL(ocsError(int, QString)), SLOT(slotOcsError(int, QString)));
|
||||
job->setPermissions(getId(), permissions);
|
||||
}
|
||||
|
||||
void Share::slotPermissionsSet(const QVariantMap &, const QVariant &value)
|
||||
{
|
||||
_permissions = (Permissions)value.toInt();
|
||||
emit permissionsSet();
|
||||
}
|
||||
|
||||
Share::Permissions Share::getPermissions() const
|
||||
{
|
||||
return _permissions;
|
||||
|
@ -112,7 +133,6 @@ void LinkShare::setPublicUpload(bool publicUpload)
|
|||
|
||||
void LinkShare::slotPublicUploadSet(const QVariantMap&, const QVariant &value)
|
||||
{
|
||||
//TODO FIX permission with names
|
||||
if (value.toBool()) {
|
||||
_permissions = PermissionRead | PermissionUpdate | PermissionCreate;
|
||||
} else {
|
||||
|
@ -163,7 +183,7 @@ void ShareManager::createLinkShare(const QString &path,
|
|||
OcsShareJob *job = new OcsShareJob(_account, this);
|
||||
connect(job, SIGNAL(shareJobFinished(QVariantMap, QVariant)), SLOT(slotLinkShareCreated(QVariantMap)));
|
||||
connect(job, SIGNAL(ocsError(int, QString)), SLOT(slotOcsError(int, QString)));
|
||||
job->createShare(path, Share::TypeLink, password);
|
||||
job->createLinkShare(path, password);
|
||||
}
|
||||
|
||||
void ShareManager::slotLinkShareCreated(const QVariantMap &reply)
|
||||
|
@ -187,6 +207,26 @@ void ShareManager::slotLinkShareCreated(const QVariantMap &reply)
|
|||
emit linkShareCreated(share);
|
||||
}
|
||||
|
||||
void ShareManager::createShare(const QString& path,
|
||||
const Share::ShareType shareType,
|
||||
const QString shareWith,
|
||||
const Share::Permissions permissions)
|
||||
{
|
||||
OcsShareJob *job = new OcsShareJob(_account, this);
|
||||
connect(job, SIGNAL(shareJobFinished(QVariantMap, QVariant)), SLOT(slotShareCreated(QVariantMap)));
|
||||
connect(job, SIGNAL(ocsError(int, QString)), SLOT(slotOcsError(int, QString)));
|
||||
job->createShare(path, shareType, shareWith, permissions);
|
||||
}
|
||||
|
||||
void ShareManager::slotShareCreated(const QVariantMap &reply)
|
||||
{
|
||||
//Parse share
|
||||
auto data = reply.value("ocs").toMap().value("data").toMap();
|
||||
QSharedPointer<Share> share(parseShare(data));
|
||||
|
||||
emit shareCreated(share);
|
||||
}
|
||||
|
||||
void ShareManager::fetchShares(const QString &path)
|
||||
{
|
||||
OcsShareJob *job = new OcsShareJob(_account, this);
|
||||
|
@ -213,11 +253,7 @@ void ShareManager::slotSharesFetched(const QVariantMap &reply)
|
|||
if (shareType == Share::TypeLink) {
|
||||
newShare = parseLinkShare(data);
|
||||
} else {
|
||||
newShare = QSharedPointer<Share>(new Share(_account,
|
||||
data.value("id").toString(),
|
||||
data.value("path").toString(),
|
||||
(Share::ShareType)shareType,
|
||||
(Share::Permissions)data.value("permissions").toInt()));
|
||||
newShare = parseShare(data);
|
||||
}
|
||||
|
||||
shares.append(QSharedPointer<Share>(newShare));
|
||||
|
@ -257,6 +293,20 @@ QSharedPointer<LinkShare> ShareManager::parseLinkShare(const QVariantMap &data)
|
|||
expireDate));
|
||||
}
|
||||
|
||||
QSharedPointer<Share> ShareManager::parseShare(const QVariantMap &data)
|
||||
{
|
||||
QSharedPointer<Sharee> sharee(new Sharee(data.value("share_with").toString(),
|
||||
data.value("share_with_displayname").toString(),
|
||||
(Sharee::Type)data.value("share_type").toInt()));
|
||||
|
||||
return QSharedPointer<Share>(new Share(_account,
|
||||
data.value("id").toString(),
|
||||
data.value("path").toString(),
|
||||
(Share::ShareType)data.value("share_type").toInt(),
|
||||
(Share::Permissions)data.value("permissions").toInt(),
|
||||
sharee));
|
||||
}
|
||||
|
||||
void ShareManager::slotOcsError(int statusCode, const QString &message)
|
||||
{
|
||||
emit serverError(statusCode, message);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#define SHARE_H
|
||||
|
||||
#include "accountfwd.h"
|
||||
#include "sharee.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QDate>
|
||||
|
@ -38,7 +39,7 @@ public:
|
|||
TypeUser = 0,
|
||||
TypeGroup = 1,
|
||||
TypeLink = 3,
|
||||
TypeRemote = 6,
|
||||
TypeRemote = 6
|
||||
};
|
||||
Q_DECLARE_FLAGS(ShareTypes, ShareType)
|
||||
|
||||
|
@ -60,8 +61,9 @@ public:
|
|||
explicit Share(AccountPtr account,
|
||||
const QString& id,
|
||||
const QString& path,
|
||||
ShareType shareType,
|
||||
Permissions permissions);
|
||||
const ShareType shareType,
|
||||
const Permissions permissions,
|
||||
const QSharedPointer<Sharee> shareWith = QSharedPointer<Sharee>(NULL));
|
||||
|
||||
/*
|
||||
* Get the id
|
||||
|
@ -73,6 +75,11 @@ public:
|
|||
*/
|
||||
ShareType getShareType() const;
|
||||
|
||||
/*
|
||||
* Get the shareWith
|
||||
*/
|
||||
QSharedPointer<Sharee> getShareWith() const;
|
||||
|
||||
/*
|
||||
* Get permissions
|
||||
*/
|
||||
|
@ -84,7 +91,7 @@ public:
|
|||
* On success the permissionsSet signal is emitted
|
||||
* In case of a server error the serverError signal is emitted.
|
||||
*/
|
||||
void setPermissions(int permissions);
|
||||
void setPermissions(Permissions permissions);
|
||||
|
||||
/**
|
||||
* Deletes a share
|
||||
|
@ -105,12 +112,14 @@ protected:
|
|||
QString _path;
|
||||
ShareType _shareType;
|
||||
Permissions _permissions;
|
||||
QSharedPointer<Sharee> _shareWith;
|
||||
|
||||
protected slots:
|
||||
void slotOcsError(int statusCode, const QString &message);
|
||||
|
||||
private slots:
|
||||
void slotDeleted();
|
||||
void slotPermissionsSet(const QVariantMap &, const QVariant &value);
|
||||
|
||||
};
|
||||
|
||||
|
@ -126,7 +135,7 @@ public:
|
|||
explicit LinkShare(AccountPtr account,
|
||||
const QString& id,
|
||||
const QString& path,
|
||||
Permissions permissions,
|
||||
const Permissions permissions,
|
||||
bool passwordSet,
|
||||
const QUrl& url,
|
||||
const QDate& expireDate);
|
||||
|
@ -216,6 +225,21 @@ public:
|
|||
void createLinkShare(const QString& path,
|
||||
const QString& password="");
|
||||
|
||||
/**
|
||||
* Tell the manager to create a new share
|
||||
*
|
||||
* @param path The path of the share relative to the user folder on the server
|
||||
* @param shareType The type of share (TypeUser, TypeGroup, TypeRemote)
|
||||
* @param Permissions The share permissions
|
||||
*
|
||||
* On success the signal shareCreated is emitted
|
||||
* In case of a server error the serverError signal is emitted
|
||||
*/
|
||||
void createShare(const QString& path,
|
||||
const Share::ShareType shareType,
|
||||
const QString shareWith,
|
||||
const Share::Permissions permissions);
|
||||
|
||||
/**
|
||||
* Fetch all the shares for path
|
||||
*
|
||||
|
@ -227,6 +251,7 @@ public:
|
|||
void fetchShares(const QString& path);
|
||||
|
||||
signals:
|
||||
void shareCreated(const QSharedPointer<Share> &share);
|
||||
void linkShareCreated(const QSharedPointer<LinkShare> &share);
|
||||
void linkShareRequiresPassword();
|
||||
void sharesFetched(const QList<QSharedPointer<Share>> &shares);
|
||||
|
@ -235,10 +260,12 @@ signals:
|
|||
private slots:
|
||||
void slotSharesFetched(const QVariantMap &reply);
|
||||
void slotLinkShareCreated(const QVariantMap &reply);
|
||||
void slotShareCreated(const QVariantMap &reply);
|
||||
void slotOcsError(int statusCode, const QString &message);
|
||||
|
||||
private:
|
||||
QSharedPointer<LinkShare> parseLinkShare(const QVariantMap &data);
|
||||
QSharedPointer<Share> parseShare(const QVariantMap &data);
|
||||
|
||||
AccountPtr _account;
|
||||
};
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/*
|
||||
* 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
|
||||
|
@ -13,91 +12,48 @@
|
|||
*/
|
||||
|
||||
#include "sharedialog.h"
|
||||
#include "sharelinkwidget.h"
|
||||
#include "shareusergroupwidget.h"
|
||||
#include "ui_sharedialog.h"
|
||||
|
||||
#include "account.h"
|
||||
#include "json.h"
|
||||
#include "folderman.h"
|
||||
#include "folder.h"
|
||||
#include "accountmanager.h"
|
||||
#include "theme.h"
|
||||
#include "configfile.h"
|
||||
#include "capabilities.h"
|
||||
|
||||
#include "theme.h"
|
||||
#include "thumbnailjob.h"
|
||||
#include "share.h"
|
||||
|
||||
#include "QProgressIndicator.h"
|
||||
#include <QBuffer>
|
||||
#include <QFileIconProvider>
|
||||
#include <QClipboard>
|
||||
#include <QFileInfo>
|
||||
#include <QFileIconProvider>
|
||||
#include <QDebug>
|
||||
#include <QPushButton>
|
||||
#include <QFrame>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
ShareDialog::ShareDialog(AccountPtr account, const QString &sharePath, const QString &localPath, bool resharingAllowed, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
QDialog(parent),
|
||||
_ui(new Ui::ShareDialog),
|
||||
_account(account),
|
||||
_sharePath(sharePath),
|
||||
_localPath(localPath),
|
||||
_passwordJobRunning(false),
|
||||
_manager(NULL),
|
||||
_share(NULL),
|
||||
_resharingAllowed(resharingAllowed)
|
||||
_resharingAllowed(resharingAllowed),
|
||||
_linkWidget(NULL),
|
||||
_userGroupWidget(NULL)
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setObjectName("SharingDialog"); // required as group for saveGeometry call
|
||||
|
||||
_ui->setupUi(this);
|
||||
|
||||
//Is this a file or folder?
|
||||
_isFile = QFileInfo(localPath).isFile();
|
||||
|
||||
_ui->pushButton_copy->setIcon(QIcon::fromTheme("edit-copy"));
|
||||
_ui->pushButton_copy->setEnabled(false);
|
||||
connect(_ui->pushButton_copy, SIGNAL(clicked(bool)), SLOT(slotPushButtonCopyLinkPressed()));
|
||||
|
||||
QPushButton *closeButton = _ui->buttonBox->button(QDialogButtonBox::Close);
|
||||
if( closeButton ) {
|
||||
connect( closeButton, SIGNAL(clicked()), this, SLOT(close()) );
|
||||
}
|
||||
|
||||
// the following progress indicator widgets are added to layouts which makes them
|
||||
// automatically deleted once the dialog dies.
|
||||
_pi_link = new QProgressIndicator();
|
||||
_pi_password = new QProgressIndicator();
|
||||
_pi_date = new QProgressIndicator();
|
||||
_pi_editing = new QProgressIndicator();
|
||||
_ui->horizontalLayout_shareLink->addWidget(_pi_link);
|
||||
_ui->horizontalLayout_password->addWidget(_pi_password);
|
||||
_ui->horizontalLayout_editing->addWidget(_pi_editing);
|
||||
// _ui->horizontalLayout_expire->addWidget(_pi_date);
|
||||
|
||||
connect(_ui->checkBox_shareLink, SIGNAL(clicked()), this, SLOT(slotCheckBoxShareLinkClicked()));
|
||||
connect(_ui->checkBox_password, SIGNAL(clicked()), this, SLOT(slotCheckBoxPasswordClicked()));
|
||||
connect(_ui->lineEdit_password, SIGNAL(returnPressed()), this, SLOT(slotPasswordReturnPressed()));
|
||||
connect(_ui->lineEdit_password, SIGNAL(textChanged(QString)), this, SLOT(slotPasswordChanged(QString)));
|
||||
connect(_ui->pushButton_setPassword, SIGNAL(clicked(bool)), SLOT(slotPasswordReturnPressed()));
|
||||
connect(_ui->checkBox_expire, SIGNAL(clicked()), this, SLOT(slotCheckBoxExpireClicked()));
|
||||
connect(_ui->calendar, SIGNAL(dateChanged(QDate)), SLOT(slotCalendarClicked(QDate)));
|
||||
connect(_ui->checkBox_editing, SIGNAL(clicked()), this, SLOT(slotCheckBoxEditingClicked()));
|
||||
|
||||
//Disable checkbox
|
||||
_ui->checkBox_shareLink->setEnabled(false);
|
||||
_pi_link->startAnimation();
|
||||
|
||||
_ui->pushButton_setPassword->setEnabled(false);
|
||||
_ui->widget_shareLink->hide();
|
||||
_ui->lineEdit_password->hide();
|
||||
_ui->pushButton_setPassword->hide();
|
||||
|
||||
_ui->calendar->setEnabled(false);
|
||||
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
|
||||
|
||||
// Set icon
|
||||
QFileInfo f_info(_localPath);
|
||||
QFileIconProvider icon_provider;
|
||||
QIcon icon = icon_provider.icon(f_info);
|
||||
_ui->label_icon->setPixmap(icon.pixmap(40,40));
|
||||
|
||||
// Set filename
|
||||
QFileInfo lPath(_localPath);
|
||||
QString fileName = lPath.fileName();
|
||||
_ui->label_name->setText(tr("%1").arg(fileName));
|
||||
|
@ -118,66 +74,27 @@ ShareDialog::ShareDialog(AccountPtr account, const QString &sharePath, const QSt
|
|||
}
|
||||
|
||||
this->setWindowTitle(tr("%1 Sharing").arg(Theme::instance()->appNameGUI()));
|
||||
_ui->checkBox_password->setText(tr("P&assword protect"));
|
||||
// check if the file is already inside of a synced folder
|
||||
if( sharePath.isEmpty() ) {
|
||||
// The file is not yet in an ownCloud synced folder. We could automatically
|
||||
// copy it over, but that is skipped as not all questions can be answered that
|
||||
// are involved in that, see https://github.com/owncloud/client/issues/2732
|
||||
//
|
||||
// _ui->checkBox_shareLink->setEnabled(false);
|
||||
// uploadExternalFile();
|
||||
qDebug() << Q_FUNC_INFO << "Unable to share files not in a sync folder.";
|
||||
return;
|
||||
|
||||
bool autoShare = true;
|
||||
|
||||
// We only do user/group sharing from 8.2.0
|
||||
if (account->serverVersionInt() >= ((8 << 16) + (2 << 8))) {
|
||||
_userGroupWidget = new ShareUserGroupWidget(account, sharePath, localPath, resharingAllowed, this);
|
||||
_ui->shareWidgetsLayout->addWidget(_userGroupWidget);
|
||||
|
||||
QFrame *hline = new QFrame(this);
|
||||
hline->setFrameShape(QFrame::HLine);
|
||||
_ui->shareWidgetsLayout->addWidget(hline);
|
||||
autoShare = false;
|
||||
}
|
||||
|
||||
// error label, red box and stuff
|
||||
_ui->errorLabel->setLineWidth(1);
|
||||
_ui->errorLabel->setFrameStyle(QFrame::Plain);
|
||||
_linkWidget = new ShareLinkWidget(account, sharePath, localPath, resharingAllowed, autoShare, this);
|
||||
_ui->shareWidgetsLayout->addWidget(_linkWidget);
|
||||
}
|
||||
|
||||
QPalette errPalette = _ui->errorLabel->palette();
|
||||
errPalette.setColor(QPalette::Active, QPalette::Base, QColor(0xaa, 0x4d, 0x4d));
|
||||
errPalette.setColor(QPalette::Active, QPalette::WindowText, QColor(0xaa, 0xaa, 0xaa));
|
||||
|
||||
_ui->errorLabel->setPalette(errPalette);
|
||||
_ui->errorLabel->setFrameShape(QFrame::Box);
|
||||
_ui->errorLabel->setContentsMargins(QMargins(12,12,12,12));
|
||||
_ui->errorLabel->hide();
|
||||
|
||||
|
||||
// Parse capabilities
|
||||
|
||||
// If password is enforced then don't allow users to disable it
|
||||
if (_account->capabilities().sharePublicLinkEnforcePassword()) {
|
||||
_ui->checkBox_password->setEnabled(false);
|
||||
}
|
||||
|
||||
// If expiredate is enforced do not allow disable and set max days
|
||||
if (_account->capabilities().sharePublicLinkEnforceExpireDate()) {
|
||||
_ui->checkBox_expire->setEnabled(false);
|
||||
_ui->calendar->setMaximumDate(QDate::currentDate().addDays(
|
||||
_account->capabilities().sharePublicLinkExpireDateDays()
|
||||
));
|
||||
}
|
||||
|
||||
// File can't have public upload set.
|
||||
if (_isFile) {
|
||||
_ui->checkBox_editing->setEnabled(false);
|
||||
} else {
|
||||
if (!_account->capabilities().sharePublicLinkAllowUpload()) {
|
||||
_ui->checkBox_editing->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the share manager and connect it properly
|
||||
*/
|
||||
_manager = new ShareManager(_account, this);
|
||||
|
||||
connect(_manager, SIGNAL(sharesFetched(QList<QSharedPointer<Share>>)), SLOT(slotSharesFetched(QList<QSharedPointer<Share>>)));
|
||||
connect(_manager, SIGNAL(linkShareCreated(QSharedPointer<LinkShare>)), SLOT(slotCreateShareFetched(const QSharedPointer<LinkShare>)));
|
||||
connect(_manager, SIGNAL(linkShareRequiresPassword()), SLOT(slotCreateShareRequiresPassword()));
|
||||
connect(_manager, SIGNAL(serverError(int, QString)), SLOT(displayError(int, QString)));
|
||||
ShareDialog::~ShareDialog()
|
||||
{
|
||||
delete _ui;
|
||||
}
|
||||
|
||||
void ShareDialog::done( int r ) {
|
||||
|
@ -186,383 +103,18 @@ void ShareDialog::done( int r ) {
|
|||
QDialog::done(r);
|
||||
}
|
||||
|
||||
void ShareDialog::setExpireDate(const QDate &date)
|
||||
{
|
||||
_pi_date->startAnimation();
|
||||
_share->setExpireDate(date);
|
||||
}
|
||||
|
||||
void ShareDialog::slotExpireSet()
|
||||
{
|
||||
_pi_date->stopAnimation();
|
||||
}
|
||||
|
||||
void ShareDialog::slotCalendarClicked(const QDate &date)
|
||||
{
|
||||
setExpireDate(date);
|
||||
}
|
||||
|
||||
ShareDialog::~ShareDialog()
|
||||
{
|
||||
delete _ui;
|
||||
}
|
||||
|
||||
void ShareDialog::slotPasswordReturnPressed()
|
||||
{
|
||||
setPassword(_ui->lineEdit_password->text());
|
||||
_ui->lineEdit_password->setText(QString());
|
||||
_ui->lineEdit_password->setPlaceholderText(tr("Password Protected"));
|
||||
_ui->lineEdit_password->clearFocus();
|
||||
}
|
||||
|
||||
void ShareDialog::slotPasswordChanged(const QString& newText)
|
||||
{
|
||||
// disable the set-password button
|
||||
_ui->pushButton_setPassword->setEnabled( newText.length() > 0 );
|
||||
}
|
||||
|
||||
void ShareDialog::setPassword(const QString &password)
|
||||
{
|
||||
_pi_link->startAnimation();
|
||||
_pi_password->startAnimation();
|
||||
|
||||
_ui->checkBox_password->setEnabled(false);
|
||||
_ui->lineEdit_password->setEnabled(false);
|
||||
|
||||
if( !_share.isNull() ) {
|
||||
_share->setPassword(password);
|
||||
} else {
|
||||
_ui->checkBox_shareLink->setEnabled(false);
|
||||
_manager->createLinkShare(_sharePath, password);
|
||||
}
|
||||
}
|
||||
|
||||
void ShareDialog::slotPasswordSet()
|
||||
{
|
||||
/*
|
||||
* When setting/deleting a password from a share the old share is
|
||||
* deleted and a new one is created. So we need to refetch the shares
|
||||
* at this point.
|
||||
*/
|
||||
getShares();
|
||||
|
||||
_pi_password->stopAnimation();
|
||||
}
|
||||
|
||||
void ShareDialog::getShares()
|
||||
{
|
||||
_manager->fetchShares(_sharePath);
|
||||
|
||||
if (QFileInfo(_localPath).isFile()) {
|
||||
ThumbnailJob *job2 = new ThumbnailJob(_sharePath, _account, this);
|
||||
connect(job2, SIGNAL(jobFinished(int, QByteArray)), SLOT(slotThumbnailFetched(int, QByteArray)));
|
||||
job2->start();
|
||||
}
|
||||
}
|
||||
|
||||
void ShareDialog::slotSharesFetched(const QList<QSharedPointer<Share>> &shares)
|
||||
{
|
||||
const QString versionString = _account->serverVersion();
|
||||
qDebug() << Q_FUNC_INFO << versionString << "Fetched" << shares.count() << "shares";
|
||||
|
||||
//Show link checkbox now
|
||||
_ui->checkBox_shareLink->setEnabled(true);
|
||||
_pi_link->stopAnimation();
|
||||
|
||||
Q_FOREACH(auto share, shares) {
|
||||
|
||||
if (share->getShareType() == Share::TypeLink) {
|
||||
_share = qSharedPointerDynamicCast<LinkShare>(share);
|
||||
_ui->pushButton_copy->show();
|
||||
|
||||
_ui->widget_shareLink->show();
|
||||
_ui->checkBox_shareLink->setChecked(true);
|
||||
|
||||
_ui->checkBox_password->setEnabled(true);
|
||||
if (_share->isPasswordSet()) {
|
||||
_ui->lineEdit_password->setEnabled(true);
|
||||
_ui->checkBox_password->setChecked(true);
|
||||
_ui->lineEdit_password->setPlaceholderText("********");
|
||||
_ui->lineEdit_password->show();
|
||||
_ui->pushButton_setPassword->show();
|
||||
} else {
|
||||
_ui->checkBox_password->setChecked(false);
|
||||
// _ui->lineEdit_password->setPlaceholderText("********");
|
||||
_ui->lineEdit_password->hide();
|
||||
_ui->pushButton_setPassword->hide();
|
||||
}
|
||||
|
||||
_ui->checkBox_expire->setEnabled(true);
|
||||
if (_share->getExpireDate().isValid()) {
|
||||
_ui->calendar->setDate(_share->getExpireDate());
|
||||
_ui->calendar->setMinimumDate(QDate::currentDate().addDays(1));
|
||||
_ui->calendar->setEnabled(true);
|
||||
_ui->checkBox_expire->setChecked(true);
|
||||
} else {
|
||||
_ui->calendar->setEnabled(false);
|
||||
_ui->checkBox_expire->setChecked(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Only directories can have public upload set
|
||||
* For public links the server sets CREATE and UPDATE permissions.
|
||||
*/
|
||||
if (!_isFile) {
|
||||
_ui->checkBox_editing->setEnabled(true);
|
||||
if (_share->getPublicUpload()) {
|
||||
_ui->checkBox_editing->setChecked(true);
|
||||
} else {
|
||||
_ui->checkBox_editing->setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
setShareLink(_share->getLink().toString());
|
||||
_ui->pushButton_copy->setEnabled(true);
|
||||
|
||||
// Connect all shares signals to gui slots
|
||||
connect(_share.data(), SIGNAL(expireDateSet()), SLOT(slotExpireSet()));
|
||||
connect(_share.data(), SIGNAL(publicUploadSet()), SLOT(slotPublicUploadSet()));
|
||||
connect(_share.data(), SIGNAL(passwordSet()), SLOT(slotPasswordSet()));
|
||||
connect(_share.data(), SIGNAL(shareDeleted()), SLOT(slotDeleteShareFetched()));
|
||||
connect(_share.data(), SIGNAL(serverError(int, QString)), SLOT(displayError(int, QString)));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( !_share.isNull() ) {
|
||||
setShareCheckBoxTitle(true);
|
||||
} else {
|
||||
// If there are no shares yet, check the checkbox to create a link automatically.
|
||||
// If its clear that resharing is not allowed, display an error
|
||||
if( !_resharingAllowed ) {
|
||||
displayError(tr("The file can not be shared because it was shared without sharing permission."));
|
||||
_ui->checkBox_shareLink->setEnabled(false);
|
||||
} else {
|
||||
_ui->checkBox_shareLink->setChecked(true);
|
||||
slotCheckBoxShareLinkClicked();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShareDialog::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
QDialog::resizeEvent(e);
|
||||
redrawElidedUrl();
|
||||
}
|
||||
|
||||
void ShareDialog::redrawElidedUrl()
|
||||
{
|
||||
QString u;
|
||||
|
||||
if( !_shareUrl.isEmpty() ) {
|
||||
QFontMetrics fm( _ui->_labelShareLink->font() );
|
||||
int linkLengthPixel = _ui->_labelShareLink->width();
|
||||
|
||||
const QUrl realUrl(_shareUrl);
|
||||
QString elidedUrl = fm.elidedText(_shareUrl, Qt::ElideRight, linkLengthPixel);
|
||||
|
||||
u = QString("<a href=\"%1\">%2</a>").arg(realUrl.toString(QUrl::None)).arg(elidedUrl);
|
||||
}
|
||||
_ui->_labelShareLink->setText(u);
|
||||
}
|
||||
|
||||
void ShareDialog::setShareLink( const QString& url )
|
||||
{
|
||||
// FIXME: shorten the url for output.
|
||||
const QUrl realUrl(url);
|
||||
if( realUrl.isValid() ) {
|
||||
_shareUrl = url;
|
||||
_ui->pushButton_copy->setEnabled(true);
|
||||
} else {
|
||||
_shareUrl.clear();
|
||||
_ui->_labelShareLink->setText(QString::null);
|
||||
}
|
||||
redrawElidedUrl();
|
||||
|
||||
}
|
||||
|
||||
void ShareDialog::slotDeleteShareFetched()
|
||||
{
|
||||
_share.clear();
|
||||
_pi_link->stopAnimation();
|
||||
_ui->lineEdit_password->clear();
|
||||
_ui->_labelShareLink->clear();
|
||||
_ui->pushButton_copy->setEnabled(false);
|
||||
_ui->widget_shareLink->hide();
|
||||
_ui->lineEdit_password->hide();
|
||||
_ui->pushButton_setPassword->setEnabled(false);
|
||||
_ui->pushButton_setPassword->hide();
|
||||
_ui->checkBox_expire->setChecked(false);
|
||||
_ui->checkBox_password->setChecked(false);
|
||||
_ui->calendar->setEnabled(false);
|
||||
|
||||
_shareUrl.clear();
|
||||
|
||||
setShareCheckBoxTitle(false);
|
||||
}
|
||||
|
||||
void ShareDialog::slotCheckBoxShareLinkClicked()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO <<( _ui->checkBox_shareLink->checkState() == Qt::Checked);
|
||||
if (_ui->checkBox_shareLink->checkState() == Qt::Checked) {
|
||||
_pi_link->startAnimation();
|
||||
|
||||
/*
|
||||
* Check the capabilities if the server requires a password for a share
|
||||
* Ask for it directly
|
||||
*/
|
||||
if (_account->capabilities().sharePublicLinkEnforcePassword()) {
|
||||
_pi_link->stopAnimation();
|
||||
_ui->checkBox_password->setChecked(true);
|
||||
_ui->checkBox_password->setEnabled(false);
|
||||
_ui->checkBox_password->setText(tr("Public shå requires a password"));
|
||||
_ui->checkBox_expire->setEnabled(false);
|
||||
_ui->checkBox_editing->setEnabled(false);
|
||||
_ui->lineEdit_password->setFocus();
|
||||
_ui->pushButton_copy->hide();
|
||||
_ui->widget_shareLink->show();
|
||||
|
||||
slotCheckBoxPasswordClicked();
|
||||
return;
|
||||
}
|
||||
|
||||
_ui->checkBox_shareLink->setEnabled(false);
|
||||
_manager->createLinkShare(_sharePath);
|
||||
} else {
|
||||
|
||||
if (!_share.isNull()) {
|
||||
// We have a share so delete it
|
||||
_pi_link->startAnimation();
|
||||
_share->deleteShare();
|
||||
} else {
|
||||
// No share object so we are deleting while a password is required
|
||||
_ui->widget_shareLink->hide();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ShareDialog::slotCreateShareFetched(const QSharedPointer<LinkShare> share)
|
||||
{
|
||||
_pi_link->stopAnimation();
|
||||
_pi_password->stopAnimation();
|
||||
|
||||
_share = share;
|
||||
getShares();
|
||||
}
|
||||
|
||||
void ShareDialog::slotCreateShareRequiresPassword()
|
||||
{
|
||||
// there needs to be a password
|
||||
_ui->checkBox_password->setChecked(true);
|
||||
_ui->checkBox_password->setEnabled(false);
|
||||
_ui->checkBox_password->setText(tr("Public shå requires a password"));
|
||||
_ui->lineEdit_password->setFocus();
|
||||
_ui->pushButton_copy->hide();
|
||||
_ui->widget_shareLink->show();
|
||||
_ui->checkBox_expire->setEnabled(false);
|
||||
_ui->checkBox_editing->setEnabled(false);
|
||||
|
||||
slotCheckBoxPasswordClicked();
|
||||
}
|
||||
|
||||
void ShareDialog::slotCheckBoxPasswordClicked()
|
||||
{
|
||||
if (_ui->checkBox_password->checkState() == Qt::Checked) {
|
||||
_ui->lineEdit_password->show();
|
||||
_ui->pushButton_setPassword->show();
|
||||
_ui->lineEdit_password->setPlaceholderText(tr("Please Set Password"));
|
||||
_ui->lineEdit_password->setFocus();
|
||||
} else {
|
||||
setPassword(QString());
|
||||
_ui->lineEdit_password->setPlaceholderText(QString());
|
||||
_pi_password->startAnimation();
|
||||
_ui->lineEdit_password->hide();
|
||||
_ui->pushButton_setPassword->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void ShareDialog::slotCheckBoxExpireClicked()
|
||||
{
|
||||
if (_ui->checkBox_expire->checkState() == Qt::Checked)
|
||||
{
|
||||
const QDate date = QDate::currentDate().addDays(1);
|
||||
setExpireDate(date);
|
||||
_ui->calendar->setDate(date);
|
||||
_ui->calendar->setMinimumDate(date);
|
||||
_ui->calendar->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
setExpireDate(QDate());
|
||||
_ui->calendar->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
extern void copyToPasteboard(const QString &string);
|
||||
#endif
|
||||
|
||||
void ShareDialog::slotPushButtonCopyLinkPressed()
|
||||
{
|
||||
#ifdef Q_OS_MAC
|
||||
copyToPasteboard(_shareUrl);
|
||||
#else
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
clipboard->setText(_shareUrl);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ShareDialog::slotCheckBoxEditingClicked()
|
||||
{
|
||||
ShareDialog::setPublicUpload(_ui->checkBox_editing->checkState() == Qt::Checked);
|
||||
}
|
||||
|
||||
void ShareDialog::setPublicUpload(bool publicUpload)
|
||||
{
|
||||
_ui->checkBox_editing->setEnabled(false);
|
||||
_pi_editing->startAnimation();
|
||||
|
||||
_share->setPublicUpload(publicUpload);
|
||||
}
|
||||
|
||||
void ShareDialog::slotPublicUploadSet()
|
||||
{
|
||||
_pi_editing->stopAnimation();
|
||||
_ui->checkBox_editing->setEnabled(true);
|
||||
}
|
||||
|
||||
void ShareDialog::setShareCheckBoxTitle(bool haveShares)
|
||||
{
|
||||
const QString noSharesTitle(tr("&Share link"));
|
||||
const QString haveSharesTitle(tr("&Share link"));
|
||||
|
||||
if( haveShares ) {
|
||||
_ui->checkBox_shareLink->setText( haveSharesTitle );
|
||||
} else {
|
||||
_ui->checkBox_shareLink->setText( noSharesTitle );
|
||||
ThumbnailJob *job = new ThumbnailJob(_sharePath, _account, this);
|
||||
connect(job, SIGNAL(jobFinished(int, QByteArray)), SLOT(slotThumbnailFetched(int, QByteArray)));
|
||||
job->start();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ShareDialog::displayError(int code, const QString &message)
|
||||
{
|
||||
const QString arg = QString("%1, %2").arg(code).arg(message);
|
||||
const QString errMsg = tr("OCS API error code: %1").arg(arg);
|
||||
displayError(errMsg);
|
||||
}
|
||||
|
||||
void ShareDialog::displayError(const QString& errMsg)
|
||||
{
|
||||
_ui->errorLabel->setText( errMsg );
|
||||
_ui->errorLabel->show();
|
||||
}
|
||||
|
||||
void ShareDialog::displayError(int code)
|
||||
{
|
||||
const QString errMsg = tr("OCS API error code: %1").arg(code);
|
||||
displayError(errMsg);
|
||||
_linkWidget->getShares();
|
||||
if (_userGroupWidget != NULL) {
|
||||
_userGroupWidget->getShares();
|
||||
}
|
||||
}
|
||||
|
||||
void ShareDialog::slotThumbnailFetched(const int &statusCode, const QByteArray &reply)
|
||||
|
@ -578,3 +130,4 @@ void ShareDialog::slotThumbnailFetched(const int &statusCode, const QByteArray &
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/*
|
||||
* 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
|
||||
|
@ -16,11 +15,9 @@
|
|||
#define SHAREDIALOG_H
|
||||
|
||||
#include "accountfwd.h"
|
||||
#include "QProgressIndicator.h"
|
||||
#include <QString>
|
||||
#include <QDialog>
|
||||
#include <QVariantMap>
|
||||
#include <QSharedPointer>
|
||||
#include <QList>
|
||||
#include <QWidget>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
|
@ -28,82 +25,37 @@ namespace Ui {
|
|||
class ShareDialog;
|
||||
}
|
||||
|
||||
class AbstractCredentials;
|
||||
class QuotaInfo;
|
||||
class SyncResult;
|
||||
class LinkShare;
|
||||
class Share;
|
||||
class ShareManager;
|
||||
class ShareLinkWidget;
|
||||
class ShareUserGroupWidget;
|
||||
|
||||
/**
|
||||
* @brief The ShareDialog class
|
||||
* @ingroup gui
|
||||
*/
|
||||
class ShareDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ShareDialog(AccountPtr account, const QString &sharePath, const QString &localPath,
|
||||
bool resharingAllowed, QWidget *parent = 0);
|
||||
explicit ShareDialog(AccountPtr account,
|
||||
const QString &sharePath,
|
||||
const QString &localPath,
|
||||
bool resharingAllowed,
|
||||
QWidget *parent = 0);
|
||||
~ShareDialog();
|
||||
|
||||
void getShares();
|
||||
|
||||
private slots:
|
||||
void slotSharesFetched(const QList<QSharedPointer<Share>> &shares);
|
||||
void slotCreateShareFetched(const QSharedPointer<LinkShare> share);
|
||||
void slotCreateShareRequiresPassword();
|
||||
void slotDeleteShareFetched();
|
||||
void slotPasswordSet();
|
||||
void slotExpireSet();
|
||||
void slotCalendarClicked(const QDate &date);
|
||||
void slotCheckBoxShareLinkClicked();
|
||||
void slotCheckBoxPasswordClicked();
|
||||
void slotCheckBoxExpireClicked();
|
||||
void slotPasswordReturnPressed();
|
||||
void slotPasswordChanged(const QString& newText);
|
||||
void slotPushButtonCopyLinkPressed();
|
||||
void slotThumbnailFetched(const int &statusCode, const QByteArray &reply);
|
||||
void slotCheckBoxEditingClicked();
|
||||
void slotPublicUploadSet();
|
||||
|
||||
void displayError(int code, const QString &message);
|
||||
|
||||
void done( int r );
|
||||
private:
|
||||
void setShareCheckBoxTitle(bool haveShares);
|
||||
void displayError(int code);
|
||||
void displayError(const QString& errMsg);
|
||||
void setShareLink( const QString& url );
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void redrawElidedUrl();
|
||||
void setPublicUpload(bool publicUpload);
|
||||
void slotThumbnailFetched(const int &statusCode, const QByteArray &reply);
|
||||
|
||||
private:
|
||||
Ui::ShareDialog *_ui;
|
||||
AccountPtr _account;
|
||||
QString _sharePath;
|
||||
QString _localPath;
|
||||
QString _shareUrl;
|
||||
#if 0
|
||||
QString _folderAlias;
|
||||
int _uploadFails;
|
||||
QString _expectedSyncFile;
|
||||
#endif
|
||||
|
||||
bool _passwordJobRunning;
|
||||
void setPassword(const QString &password);
|
||||
void setExpireDate(const QDate &date);
|
||||
|
||||
QProgressIndicator *_pi_link;
|
||||
QProgressIndicator *_pi_password;
|
||||
QProgressIndicator *_pi_date;
|
||||
QProgressIndicator *_pi_editing;
|
||||
|
||||
ShareManager *_manager;
|
||||
QSharedPointer<LinkShare> _share;
|
||||
|
||||
bool _resharingAllowed;
|
||||
bool _isFile;
|
||||
|
||||
ShareLinkWidget *_linkWidget;
|
||||
ShareUserGroupWidget *_userGroupWidget;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -6,23 +6,16 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>372</width>
|
||||
<height>277</height>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Share NewDocument.odt</string>
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QLabel" name="label_icon">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_name">
|
||||
<property name="sizePolicy">
|
||||
|
@ -42,9 +35,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="2">
|
||||
<widget class="QProgressIndicator" name="pi_share" native="true"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_sharePath">
|
||||
<property name="sizePolicy">
|
||||
|
@ -64,176 +54,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_shareLink">
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_shareLink">
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QLabel" name="label_icon">
|
||||
<property name="text">
|
||||
<string>Share link</string>
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QWidget" name="widget_shareLink" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_password">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_setPassword">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Set &password </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_expire">
|
||||
<property name="text">
|
||||
<string>Set &expiration date</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDateEdit" name="calendar">
|
||||
<property name="calendarPopup">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_password">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_password">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Set password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="_labelShareLink">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_copy">
|
||||
<property name="text">
|
||||
<string>Copy &link</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_editing">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_editing">
|
||||
<property name="text">
|
||||
<string>Allow editing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="shareWidgetsLayout"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
@ -246,20 +79,7 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="errorLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
|
||||
|
@ -273,19 +93,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>errorLabel</zorder>
|
||||
<zorder>widget_shareLink</zorder>
|
||||
<zorder>buttonBox</zorder>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QProgressIndicator</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>QProgressIndicator.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
180
src/gui/sharee.cpp
Normal file
180
src/gui/sharee.cpp
Normal file
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
* 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
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "sharee.h"
|
||||
#include "ocsshareejob.h"
|
||||
|
||||
namespace OCC {
|
||||
|
||||
Sharee::Sharee(const QString shareWith,
|
||||
const QString displayName,
|
||||
const Type type)
|
||||
: _shareWith(shareWith),
|
||||
_displayName(displayName),
|
||||
_type(type)
|
||||
{
|
||||
}
|
||||
|
||||
QString Sharee::format() const
|
||||
{
|
||||
QString formatted = _displayName;
|
||||
|
||||
if (_type == Type::Group) {
|
||||
formatted += QLatin1String(" (group)");
|
||||
} else if (_type == Type::Federated) {
|
||||
formatted += QLatin1String(" (remote)");
|
||||
}
|
||||
|
||||
return formatted;
|
||||
}
|
||||
|
||||
QString Sharee::shareWith() const
|
||||
{
|
||||
return _shareWith;
|
||||
}
|
||||
|
||||
QString Sharee::displayName() const
|
||||
{
|
||||
return _displayName;
|
||||
}
|
||||
|
||||
Sharee::Type Sharee::type() const
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
ShareeModel::ShareeModel(AccountPtr account,
|
||||
const QString search,
|
||||
const QString type,
|
||||
const QVector<QSharedPointer<Sharee>> &shareeBlacklist,
|
||||
QObject *parent)
|
||||
: QAbstractListModel(parent),
|
||||
_account(account),
|
||||
_search(search),
|
||||
_type(type),
|
||||
_shareeBlacklist(shareeBlacklist)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ShareeModel::fetch()
|
||||
{
|
||||
OcsShareeJob *job = new OcsShareeJob(_account, this);
|
||||
connect(job, SIGNAL(shareeJobFinished(QVariantMap)), SLOT(shareesFetched(QVariantMap)));
|
||||
job->getSharees(_search, _type, 1, 50);
|
||||
}
|
||||
|
||||
void ShareeModel::shareesFetched(const QVariantMap &reply)
|
||||
{
|
||||
auto data = reply.value("ocs").toMap().value("data").toMap();
|
||||
|
||||
QVector<QSharedPointer<Sharee>> newSharees;
|
||||
|
||||
/*
|
||||
* Todo properly loop all of this
|
||||
*/
|
||||
auto exact = data.value("exact").toMap();
|
||||
{
|
||||
auto users = exact.value("users").toList();
|
||||
foreach(auto user, users) {
|
||||
newSharees.append(parseSharee(user.toMap()));
|
||||
}
|
||||
auto groups = exact.value("groups").toList();
|
||||
foreach(auto group, groups) {
|
||||
newSharees.append(parseSharee(group.toMap()));
|
||||
}
|
||||
auto remotes = exact.value("remotes").toList();
|
||||
foreach(auto remote, remotes) {
|
||||
newSharees.append(parseSharee(remote.toMap()));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto users = data.value("users").toList();
|
||||
foreach(auto user, users) {
|
||||
newSharees.append(parseSharee(user.toMap()));
|
||||
}
|
||||
}
|
||||
{
|
||||
auto groups = data.value("groups").toList();
|
||||
foreach(auto group, groups) {
|
||||
newSharees.append(parseSharee(group.toMap()));
|
||||
}
|
||||
}
|
||||
{
|
||||
auto remotes = data.value("remotes").toList();
|
||||
foreach(auto remote, remotes) {
|
||||
newSharees.append(parseSharee(remote.toMap()));
|
||||
}
|
||||
}
|
||||
|
||||
// Filter sharees that we have already shared with
|
||||
QVector<QSharedPointer<Sharee>> filteredSharees;
|
||||
foreach(const auto &sharee, newSharees) {
|
||||
bool found = false;
|
||||
foreach(const auto &blacklistSharee, _shareeBlacklist) {
|
||||
if (sharee->type() == blacklistSharee->type() &&
|
||||
sharee->shareWith() == blacklistSharee->shareWith()) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found == false) {
|
||||
filteredSharees.append(sharee);
|
||||
}
|
||||
}
|
||||
|
||||
beginInsertRows(QModelIndex(), _sharees.size(), filteredSharees.size());
|
||||
_sharees += filteredSharees;
|
||||
endInsertRows();
|
||||
|
||||
shareesReady();
|
||||
}
|
||||
|
||||
QSharedPointer<Sharee> ShareeModel::parseSharee(const QVariantMap &data)
|
||||
{
|
||||
const QString displayName = data.value("label").toString();
|
||||
const QString shareWith = data.value("value").toMap().value("shareWith").toString();
|
||||
Sharee::Type type = (Sharee::Type)data.value("value").toMap().value("shareType").toInt();
|
||||
|
||||
return QSharedPointer<Sharee>(new Sharee(shareWith, shareWith, type));
|
||||
}
|
||||
|
||||
int ShareeModel::rowCount(const QModelIndex &) const
|
||||
{
|
||||
return _sharees.size();
|
||||
}
|
||||
|
||||
QVariant ShareeModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (index.row() < 0 || index.row() > _sharees.size()) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (role == Qt::DisplayRole || role == Qt::EditRole) {
|
||||
return _sharees.at(index.row())->format();
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QSharedPointer<Sharee> ShareeModel::getSharee(int at) {
|
||||
if (at < 0 || at > _sharees.size()) {
|
||||
return QSharedPointer<Sharee>(NULL);
|
||||
}
|
||||
|
||||
return _sharees.at(at);
|
||||
}
|
||||
|
||||
}
|
88
src/gui/sharee.h
Normal file
88
src/gui/sharee.h
Normal file
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* 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
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* 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 SHAREE_H
|
||||
#define SHAREE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QFlags>
|
||||
#include <QAbstractListModel>
|
||||
#include <QModelIndex>
|
||||
#include <QVariant>
|
||||
#include <QSharedPointer>
|
||||
#include <QVector>
|
||||
|
||||
#include "accountfwd.h"
|
||||
|
||||
namespace OCC {
|
||||
|
||||
class Sharee {
|
||||
public:
|
||||
|
||||
enum Type {
|
||||
User = 0,
|
||||
Group = 1,
|
||||
Federated = 6
|
||||
};
|
||||
Q_DECLARE_FLAGS(Types, Type)
|
||||
|
||||
explicit Sharee(const QString shareWith,
|
||||
const QString displayName,
|
||||
const Type type);
|
||||
|
||||
QString format() const;
|
||||
QString shareWith() const;
|
||||
QString displayName() const;
|
||||
Type type() const;
|
||||
|
||||
private:
|
||||
QString _shareWith;
|
||||
QString _displayName;
|
||||
Type _type;
|
||||
};
|
||||
|
||||
class ShareeModel : public QAbstractListModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ShareeModel(AccountPtr account,
|
||||
const QString search,
|
||||
const QString type,
|
||||
const QVector<QSharedPointer<Sharee>> &shareeBlacklist,
|
||||
QObject *parent = 0);
|
||||
|
||||
void fetch();
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
|
||||
QSharedPointer<Sharee> getSharee(int at);
|
||||
|
||||
signals:
|
||||
void shareesReady();
|
||||
|
||||
private slots:
|
||||
void shareesFetched(const QVariantMap &reply);
|
||||
|
||||
private:
|
||||
QSharedPointer<Sharee> parseSharee(const QVariantMap &data);
|
||||
|
||||
AccountPtr _account;
|
||||
QString _search;
|
||||
QString _type;
|
||||
|
||||
QVector<QSharedPointer<Sharee>> _sharees;
|
||||
QVector<QSharedPointer<Sharee>> _shareeBlacklist;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //SHAREE_H
|
520
src/gui/sharelinkwidget.cpp
Normal file
520
src/gui/sharelinkwidget.cpp
Normal file
|
@ -0,0 +1,520 @@
|
|||
/*
|
||||
* 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; version 2 of the License.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "sharelinkwidget.h"
|
||||
#include "ui_sharelinkwidget.h"
|
||||
#include "account.h"
|
||||
#include "capabilities.h"
|
||||
|
||||
#include "share.h"
|
||||
|
||||
#include "QProgressIndicator.h"
|
||||
#include <QBuffer>
|
||||
#include <QClipboard>
|
||||
#include <QFileInfo>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
ShareLinkWidget::ShareLinkWidget(AccountPtr account,
|
||||
const QString &sharePath,
|
||||
const QString &localPath,
|
||||
bool resharingAllowed,
|
||||
bool autoShare,
|
||||
QWidget *parent) :
|
||||
QWidget(parent),
|
||||
_ui(new Ui::ShareLinkWidget),
|
||||
_account(account),
|
||||
_sharePath(sharePath),
|
||||
_localPath(localPath),
|
||||
_passwordJobRunning(false),
|
||||
_manager(NULL),
|
||||
_share(NULL),
|
||||
_resharingAllowed(resharingAllowed),
|
||||
_autoShare(autoShare)
|
||||
{
|
||||
_ui->setupUi(this);
|
||||
|
||||
//Is this a file or folder?
|
||||
_isFile = QFileInfo(localPath).isFile();
|
||||
|
||||
_ui->pushButton_copy->setIcon(QIcon::fromTheme("edit-copy"));
|
||||
_ui->pushButton_copy->setEnabled(false);
|
||||
connect(_ui->pushButton_copy, SIGNAL(clicked(bool)), SLOT(slotPushButtonCopyLinkPressed()));
|
||||
|
||||
// the following progress indicator widgets are added to layouts which makes them
|
||||
// automatically deleted once the dialog dies.
|
||||
_pi_link = new QProgressIndicator();
|
||||
_pi_password = new QProgressIndicator();
|
||||
_pi_date = new QProgressIndicator();
|
||||
_pi_editing = new QProgressIndicator();
|
||||
_ui->horizontalLayout_shareLink->addWidget(_pi_link);
|
||||
_ui->horizontalLayout_password->addWidget(_pi_password);
|
||||
_ui->horizontalLayout_editing->addWidget(_pi_editing);
|
||||
// _ui->horizontalLayout_expire->addWidget(_pi_date);
|
||||
|
||||
connect(_ui->checkBox_shareLink, SIGNAL(clicked()), this, SLOT(slotCheckBoxShareLinkClicked()));
|
||||
connect(_ui->checkBox_password, SIGNAL(clicked()), this, SLOT(slotCheckBoxPasswordClicked()));
|
||||
connect(_ui->lineEdit_password, SIGNAL(returnPressed()), this, SLOT(slotPasswordReturnPressed()));
|
||||
connect(_ui->lineEdit_password, SIGNAL(textChanged(QString)), this, SLOT(slotPasswordChanged(QString)));
|
||||
connect(_ui->pushButton_setPassword, SIGNAL(clicked(bool)), SLOT(slotPasswordReturnPressed()));
|
||||
connect(_ui->checkBox_expire, SIGNAL(clicked()), this, SLOT(slotCheckBoxExpireClicked()));
|
||||
connect(_ui->calendar, SIGNAL(dateChanged(QDate)), SLOT(slotCalendarClicked(QDate)));
|
||||
connect(_ui->checkBox_editing, SIGNAL(clicked()), this, SLOT(slotCheckBoxEditingClicked()));
|
||||
|
||||
//Disable checkbox
|
||||
_ui->checkBox_shareLink->setEnabled(false);
|
||||
_pi_link->startAnimation();
|
||||
|
||||
_ui->pushButton_setPassword->setEnabled(false);
|
||||
_ui->widget_shareLink->hide();
|
||||
_ui->lineEdit_password->hide();
|
||||
_ui->pushButton_setPassword->hide();
|
||||
|
||||
_ui->calendar->setEnabled(false);
|
||||
|
||||
_ui->checkBox_password->setText(tr("P&assword protect"));
|
||||
// check if the file is already inside of a synced folder
|
||||
if( sharePath.isEmpty() ) {
|
||||
// The file is not yet in an ownCloud synced folder. We could automatically
|
||||
// copy it over, but that is skipped as not all questions can be answered that
|
||||
// are involved in that, see https://github.com/owncloud/client/issues/2732
|
||||
//
|
||||
// _ui->checkBox_shareLink->setEnabled(false);
|
||||
// uploadExternalFile();
|
||||
qDebug() << Q_FUNC_INFO << "Unable to share files not in a sync folder.";
|
||||
return;
|
||||
}
|
||||
|
||||
// error label, red box and stuff
|
||||
_ui->errorLabel->setLineWidth(1);
|
||||
_ui->errorLabel->setFrameStyle(QFrame::Plain);
|
||||
|
||||
QPalette errPalette = _ui->errorLabel->palette();
|
||||
errPalette.setColor(QPalette::Active, QPalette::Base, QColor(0xaa, 0x4d, 0x4d));
|
||||
errPalette.setColor(QPalette::Active, QPalette::WindowText, QColor(0xaa, 0xaa, 0xaa));
|
||||
|
||||
_ui->errorLabel->setPalette(errPalette);
|
||||
_ui->errorLabel->setFrameShape(QFrame::Box);
|
||||
_ui->errorLabel->setContentsMargins(QMargins(12,12,12,12));
|
||||
_ui->errorLabel->hide();
|
||||
|
||||
|
||||
// Parse capabilities
|
||||
|
||||
// If password is enforced then don't allow users to disable it
|
||||
if (_account->capabilities().sharePublicLinkEnforcePassword()) {
|
||||
_ui->checkBox_password->setEnabled(false);
|
||||
}
|
||||
|
||||
// If expiredate is enforced do not allow disable and set max days
|
||||
if (_account->capabilities().sharePublicLinkEnforceExpireDate()) {
|
||||
_ui->checkBox_expire->setEnabled(false);
|
||||
_ui->calendar->setMaximumDate(QDate::currentDate().addDays(
|
||||
_account->capabilities().sharePublicLinkExpireDateDays()
|
||||
));
|
||||
}
|
||||
|
||||
// File can't have public upload set.
|
||||
if (_isFile) {
|
||||
_ui->checkBox_editing->setEnabled(false);
|
||||
} else {
|
||||
if (!_account->capabilities().sharePublicLinkAllowUpload()) {
|
||||
_ui->checkBox_editing->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the share manager and connect it properly
|
||||
*/
|
||||
_manager = new ShareManager(_account, this);
|
||||
|
||||
connect(_manager, SIGNAL(sharesFetched(QList<QSharedPointer<Share>>)), SLOT(slotSharesFetched(QList<QSharedPointer<Share>>)));
|
||||
connect(_manager, SIGNAL(linkShareCreated(QSharedPointer<LinkShare>)), SLOT(slotCreateShareFetched(const QSharedPointer<LinkShare>)));
|
||||
connect(_manager, SIGNAL(linkShareRequiresPassword()), SLOT(slotCreateShareRequiresPassword()));
|
||||
connect(_manager, SIGNAL(serverError(int, QString)), SLOT(displayError(int, QString)));
|
||||
}
|
||||
|
||||
void ShareLinkWidget::setExpireDate(const QDate &date)
|
||||
{
|
||||
_pi_date->startAnimation();
|
||||
_share->setExpireDate(date);
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotExpireSet()
|
||||
{
|
||||
_pi_date->stopAnimation();
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotCalendarClicked(const QDate &date)
|
||||
{
|
||||
setExpireDate(date);
|
||||
}
|
||||
|
||||
ShareLinkWidget::~ShareLinkWidget()
|
||||
{
|
||||
delete _ui;
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotPasswordReturnPressed()
|
||||
{
|
||||
setPassword(_ui->lineEdit_password->text());
|
||||
_ui->lineEdit_password->setText(QString());
|
||||
_ui->lineEdit_password->setPlaceholderText(tr("Password Protected"));
|
||||
_ui->lineEdit_password->clearFocus();
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotPasswordChanged(const QString& newText)
|
||||
{
|
||||
// disable the set-password button
|
||||
_ui->pushButton_setPassword->setEnabled( newText.length() > 0 );
|
||||
}
|
||||
|
||||
void ShareLinkWidget::setPassword(const QString &password)
|
||||
{
|
||||
_pi_link->startAnimation();
|
||||
_pi_password->startAnimation();
|
||||
|
||||
_ui->checkBox_password->setEnabled(false);
|
||||
_ui->lineEdit_password->setEnabled(false);
|
||||
|
||||
if( !_share.isNull() ) {
|
||||
_share->setPassword(password);
|
||||
} else {
|
||||
_ui->checkBox_shareLink->setEnabled(false);
|
||||
_manager->createLinkShare(_sharePath, password);
|
||||
}
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotPasswordSet()
|
||||
{
|
||||
/*
|
||||
* When setting/deleting a password from a share the old share is
|
||||
* deleted and a new one is created. So we need to refetch the shares
|
||||
* at this point.
|
||||
*/
|
||||
getShares();
|
||||
|
||||
_pi_password->stopAnimation();
|
||||
}
|
||||
|
||||
void ShareLinkWidget::getShares()
|
||||
{
|
||||
_manager->fetchShares(_sharePath);
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotSharesFetched(const QList<QSharedPointer<Share>> &shares)
|
||||
{
|
||||
const QString versionString = _account->serverVersion();
|
||||
qDebug() << Q_FUNC_INFO << versionString << "Fetched" << shares.count() << "shares";
|
||||
|
||||
//Show link checkbox now
|
||||
_ui->checkBox_shareLink->setEnabled(true);
|
||||
_pi_link->stopAnimation();
|
||||
|
||||
Q_FOREACH(auto share, shares) {
|
||||
|
||||
if (share->getShareType() == Share::TypeLink) {
|
||||
_share = qSharedPointerDynamicCast<LinkShare>(share);
|
||||
_ui->pushButton_copy->show();
|
||||
|
||||
_ui->widget_shareLink->show();
|
||||
_ui->checkBox_shareLink->setChecked(true);
|
||||
|
||||
_ui->checkBox_password->setEnabled(true);
|
||||
if (_share->isPasswordSet()) {
|
||||
_ui->lineEdit_password->setEnabled(true);
|
||||
_ui->checkBox_password->setChecked(true);
|
||||
_ui->lineEdit_password->setPlaceholderText("********");
|
||||
_ui->lineEdit_password->show();
|
||||
_ui->pushButton_setPassword->show();
|
||||
} else {
|
||||
_ui->checkBox_password->setChecked(false);
|
||||
// _ui->lineEdit_password->setPlaceholderText("********");
|
||||
_ui->lineEdit_password->hide();
|
||||
_ui->pushButton_setPassword->hide();
|
||||
}
|
||||
|
||||
_ui->checkBox_expire->setEnabled(true);
|
||||
if (_share->getExpireDate().isValid()) {
|
||||
_ui->calendar->setDate(_share->getExpireDate());
|
||||
_ui->calendar->setMinimumDate(QDate::currentDate().addDays(1));
|
||||
_ui->calendar->setEnabled(true);
|
||||
_ui->checkBox_expire->setChecked(true);
|
||||
} else {
|
||||
_ui->calendar->setEnabled(false);
|
||||
_ui->checkBox_expire->setChecked(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Only directories can have public upload set
|
||||
* For public links the server sets CREATE and UPDATE permissions.
|
||||
*/
|
||||
if (!_isFile) {
|
||||
_ui->checkBox_editing->setEnabled(true);
|
||||
if (_share->getPublicUpload()) {
|
||||
_ui->checkBox_editing->setChecked(true);
|
||||
} else {
|
||||
_ui->checkBox_editing->setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
setShareLink(_share->getLink().toString());
|
||||
_ui->pushButton_copy->setEnabled(true);
|
||||
|
||||
// Connect all shares signals to gui slots
|
||||
connect(_share.data(), SIGNAL(expireDateSet()), SLOT(slotExpireSet()));
|
||||
connect(_share.data(), SIGNAL(publicUploadSet()), SLOT(slotPublicUploadSet()));
|
||||
connect(_share.data(), SIGNAL(passwordSet()), SLOT(slotPasswordSet()));
|
||||
connect(_share.data(), SIGNAL(shareDeleted()), SLOT(slotDeleteShareFetched()));
|
||||
connect(_share.data(), SIGNAL(serverError(int, QString)), SLOT(displayError(int, QString)));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( !_share.isNull() ) {
|
||||
setShareCheckBoxTitle(true);
|
||||
} else {
|
||||
// If its clear that resharing is not allowed, display an error
|
||||
if( !_resharingAllowed ) {
|
||||
displayError(tr("The file can not be shared because it was shared without sharing permission."));
|
||||
_ui->checkBox_shareLink->setEnabled(false);
|
||||
} else if (_autoShare) {
|
||||
_ui->checkBox_shareLink->setChecked(true);
|
||||
slotCheckBoxShareLinkClicked();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShareLinkWidget::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
QWidget::resizeEvent(e);
|
||||
redrawElidedUrl();
|
||||
}
|
||||
|
||||
void ShareLinkWidget::redrawElidedUrl()
|
||||
{
|
||||
QString u;
|
||||
|
||||
if( !_shareUrl.isEmpty() ) {
|
||||
QFontMetrics fm( _ui->_labelShareLink->font() );
|
||||
int linkLengthPixel = _ui->_labelShareLink->width();
|
||||
|
||||
const QUrl realUrl(_shareUrl);
|
||||
QString elidedUrl = fm.elidedText(_shareUrl, Qt::ElideRight, linkLengthPixel);
|
||||
|
||||
u = QString("<a href=\"%1\">%2</a>").arg(realUrl.toString(QUrl::None)).arg(elidedUrl);
|
||||
}
|
||||
_ui->_labelShareLink->setText(u);
|
||||
}
|
||||
|
||||
void ShareLinkWidget::setShareLink( const QString& url )
|
||||
{
|
||||
// FIXME: shorten the url for output.
|
||||
const QUrl realUrl(url);
|
||||
if( realUrl.isValid() ) {
|
||||
_shareUrl = url;
|
||||
_ui->pushButton_copy->setEnabled(true);
|
||||
} else {
|
||||
_shareUrl.clear();
|
||||
_ui->_labelShareLink->setText(QString::null);
|
||||
}
|
||||
redrawElidedUrl();
|
||||
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotDeleteShareFetched()
|
||||
{
|
||||
_share.clear();
|
||||
_pi_link->stopAnimation();
|
||||
_ui->lineEdit_password->clear();
|
||||
_ui->_labelShareLink->clear();
|
||||
_ui->pushButton_copy->setEnabled(false);
|
||||
_ui->widget_shareLink->hide();
|
||||
_ui->lineEdit_password->hide();
|
||||
_ui->pushButton_setPassword->setEnabled(false);
|
||||
_ui->pushButton_setPassword->hide();
|
||||
_ui->checkBox_expire->setChecked(false);
|
||||
_ui->checkBox_password->setChecked(false);
|
||||
_ui->calendar->setEnabled(false);
|
||||
|
||||
_shareUrl.clear();
|
||||
|
||||
setShareCheckBoxTitle(false);
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotCheckBoxShareLinkClicked()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO <<( _ui->checkBox_shareLink->checkState() == Qt::Checked);
|
||||
if (_ui->checkBox_shareLink->checkState() == Qt::Checked) {
|
||||
_pi_link->startAnimation();
|
||||
|
||||
/*
|
||||
* Check the capabilities if the server requires a password for a share
|
||||
* Ask for it directly
|
||||
*/
|
||||
if (_account->capabilities().sharePublicLinkEnforcePassword()) {
|
||||
_pi_link->stopAnimation();
|
||||
_ui->checkBox_password->setChecked(true);
|
||||
_ui->checkBox_password->setEnabled(false);
|
||||
_ui->checkBox_password->setText(tr("Public shå requires a password"));
|
||||
_ui->checkBox_expire->setEnabled(false);
|
||||
_ui->checkBox_editing->setEnabled(false);
|
||||
_ui->lineEdit_password->setFocus();
|
||||
_ui->pushButton_copy->hide();
|
||||
_ui->widget_shareLink->show();
|
||||
|
||||
slotCheckBoxPasswordClicked();
|
||||
return;
|
||||
}
|
||||
|
||||
_ui->checkBox_shareLink->setEnabled(false);
|
||||
_manager->createLinkShare(_sharePath);
|
||||
} else {
|
||||
|
||||
if (!_share.isNull()) {
|
||||
// We have a share so delete it
|
||||
_pi_link->startAnimation();
|
||||
_share->deleteShare();
|
||||
} else {
|
||||
// No share object so we are deleting while a password is required
|
||||
_ui->widget_shareLink->hide();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotCreateShareFetched(const QSharedPointer<LinkShare> share)
|
||||
{
|
||||
_pi_link->stopAnimation();
|
||||
_pi_password->stopAnimation();
|
||||
|
||||
_share = share;
|
||||
getShares();
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotCreateShareRequiresPassword()
|
||||
{
|
||||
// there needs to be a password
|
||||
_ui->checkBox_password->setChecked(true);
|
||||
_ui->checkBox_password->setEnabled(false);
|
||||
_ui->checkBox_password->setText(tr("Public shå requires a password"));
|
||||
_ui->lineEdit_password->setFocus();
|
||||
_ui->pushButton_copy->hide();
|
||||
_ui->widget_shareLink->show();
|
||||
_ui->checkBox_expire->setEnabled(false);
|
||||
_ui->checkBox_editing->setEnabled(false);
|
||||
|
||||
slotCheckBoxPasswordClicked();
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotCheckBoxPasswordClicked()
|
||||
{
|
||||
if (_ui->checkBox_password->checkState() == Qt::Checked) {
|
||||
_ui->lineEdit_password->show();
|
||||
_ui->pushButton_setPassword->show();
|
||||
_ui->lineEdit_password->setPlaceholderText(tr("Please Set Password"));
|
||||
_ui->lineEdit_password->setFocus();
|
||||
} else {
|
||||
setPassword(QString());
|
||||
_ui->lineEdit_password->setPlaceholderText(QString());
|
||||
_pi_password->startAnimation();
|
||||
_ui->lineEdit_password->hide();
|
||||
_ui->pushButton_setPassword->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotCheckBoxExpireClicked()
|
||||
{
|
||||
if (_ui->checkBox_expire->checkState() == Qt::Checked)
|
||||
{
|
||||
const QDate date = QDate::currentDate().addDays(1);
|
||||
setExpireDate(date);
|
||||
_ui->calendar->setDate(date);
|
||||
_ui->calendar->setMinimumDate(date);
|
||||
_ui->calendar->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
setExpireDate(QDate());
|
||||
_ui->calendar->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
extern void copyToPasteboard(const QString &string);
|
||||
#endif
|
||||
|
||||
void ShareLinkWidget::slotPushButtonCopyLinkPressed()
|
||||
{
|
||||
#ifdef Q_OS_MAC
|
||||
copyToPasteboard(_shareUrl);
|
||||
#else
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
clipboard->setText(_shareUrl);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotCheckBoxEditingClicked()
|
||||
{
|
||||
ShareLinkWidget::setPublicUpload(_ui->checkBox_editing->checkState() == Qt::Checked);
|
||||
}
|
||||
|
||||
void ShareLinkWidget::setPublicUpload(bool publicUpload)
|
||||
{
|
||||
_ui->checkBox_editing->setEnabled(false);
|
||||
_pi_editing->startAnimation();
|
||||
|
||||
_share->setPublicUpload(publicUpload);
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotPublicUploadSet()
|
||||
{
|
||||
_pi_editing->stopAnimation();
|
||||
_ui->checkBox_editing->setEnabled(true);
|
||||
}
|
||||
|
||||
void ShareLinkWidget::setShareCheckBoxTitle(bool haveShares)
|
||||
{
|
||||
const QString noSharesTitle(tr("&Share link"));
|
||||
const QString haveSharesTitle(tr("&Share link"));
|
||||
|
||||
if( haveShares ) {
|
||||
_ui->checkBox_shareLink->setText( haveSharesTitle );
|
||||
} else {
|
||||
_ui->checkBox_shareLink->setText( noSharesTitle );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ShareLinkWidget::displayError(int code, const QString &message)
|
||||
{
|
||||
const QString arg = QString("%1, %2").arg(code).arg(message);
|
||||
const QString errMsg = tr("OCS API error code: %1").arg(arg);
|
||||
displayError(errMsg);
|
||||
}
|
||||
|
||||
void ShareLinkWidget::displayError(const QString& errMsg)
|
||||
{
|
||||
_ui->errorLabel->setText( errMsg );
|
||||
_ui->errorLabel->show();
|
||||
}
|
||||
|
||||
void ShareLinkWidget::displayError(int code)
|
||||
{
|
||||
const QString errMsg = tr("OCS API error code: %1").arg(code);
|
||||
displayError(errMsg);
|
||||
}
|
||||
|
||||
}
|
114
src/gui/sharelinkwidget.h
Normal file
114
src/gui/sharelinkwidget.h
Normal file
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* 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; version 2 of the License.
|
||||
*
|
||||
* 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 "QProgressIndicator.h"
|
||||
#include <QDialog>
|
||||
#include <QVariantMap>
|
||||
#include <QSharedPointer>
|
||||
#include <QList>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
namespace Ui {
|
||||
class ShareLinkWidget;
|
||||
}
|
||||
|
||||
class AbstractCredentials;
|
||||
class QuotaInfo;
|
||||
class SyncResult;
|
||||
class LinkShare;
|
||||
class Share;
|
||||
class ShareManager;
|
||||
|
||||
/**
|
||||
* @brief The ShareDialog class
|
||||
* @ingroup gui
|
||||
*/
|
||||
class ShareLinkWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ShareLinkWidget(AccountPtr account,
|
||||
const QString &sharePath,
|
||||
const QString &localPath,
|
||||
bool resharingAllowed,
|
||||
bool autoShare = false,
|
||||
QWidget *parent = 0);
|
||||
~ShareLinkWidget();
|
||||
void getShares();
|
||||
|
||||
private slots:
|
||||
void slotSharesFetched(const QList<QSharedPointer<Share>> &shares);
|
||||
void slotCreateShareFetched(const QSharedPointer<LinkShare> share);
|
||||
void slotCreateShareRequiresPassword();
|
||||
void slotDeleteShareFetched();
|
||||
void slotPasswordSet();
|
||||
void slotExpireSet();
|
||||
void slotCalendarClicked(const QDate &date);
|
||||
void slotCheckBoxShareLinkClicked();
|
||||
void slotCheckBoxPasswordClicked();
|
||||
void slotCheckBoxExpireClicked();
|
||||
void slotPasswordReturnPressed();
|
||||
void slotPasswordChanged(const QString& newText);
|
||||
void slotPushButtonCopyLinkPressed();
|
||||
void slotCheckBoxEditingClicked();
|
||||
void slotPublicUploadSet();
|
||||
|
||||
void displayError(int code, const QString &message);
|
||||
|
||||
private:
|
||||
void setShareCheckBoxTitle(bool haveShares);
|
||||
void displayError(int code);
|
||||
void displayError(const QString& errMsg);
|
||||
void setShareLink( const QString& url );
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void redrawElidedUrl();
|
||||
void setPublicUpload(bool publicUpload);
|
||||
|
||||
Ui::ShareLinkWidget *_ui;
|
||||
AccountPtr _account;
|
||||
QString _sharePath;
|
||||
QString _localPath;
|
||||
QString _shareUrl;
|
||||
#if 0
|
||||
QString _folderAlias;
|
||||
int _uploadFails;
|
||||
QString _expectedSyncFile;
|
||||
#endif
|
||||
|
||||
bool _passwordJobRunning;
|
||||
void setPassword(const QString &password);
|
||||
void setExpireDate(const QDate &date);
|
||||
|
||||
QProgressIndicator *_pi_link;
|
||||
QProgressIndicator *_pi_password;
|
||||
QProgressIndicator *_pi_date;
|
||||
QProgressIndicator *_pi_editing;
|
||||
|
||||
ShareManager *_manager;
|
||||
QSharedPointer<LinkShare> _share;
|
||||
|
||||
bool _resharingAllowed;
|
||||
bool _isFile;
|
||||
bool _autoShare;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SHARELINKWIDGET_H
|
218
src/gui/sharelinkwidget.ui
Normal file
218
src/gui/sharelinkwidget.ui
Normal file
|
@ -0,0 +1,218 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OCC::ShareLinkWidget</class>
|
||||
<widget class="QWidget" name="OCC::ShareLinkWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>372</width>
|
||||
<height>212</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Share NewDocument.odt</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_shareLink">
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_shareLink">
|
||||
<property name="text">
|
||||
<string>Share link</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="errorLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QWidget" name="widget_shareLink" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_password">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_setPassword">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Set &password </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_expire">
|
||||
<property name="text">
|
||||
<string>Set &expiration date</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDateEdit" name="calendar">
|
||||
<property name="calendarPopup">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_password">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_password">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Set password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="_labelShareLink">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_copy">
|
||||
<property name="text">
|
||||
<string>Copy &link</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_editing">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_editing">
|
||||
<property name="text">
|
||||
<string>Allow editing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>errorLabel</zorder>
|
||||
<zorder>widget_shareLink</zorder>
|
||||
<zorder>verticalSpacer</zorder>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
241
src/gui/shareusergroupwidget.cpp
Normal file
241
src/gui/shareusergroupwidget.cpp
Normal file
|
@ -0,0 +1,241 @@
|
|||
/*
|
||||
* 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
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "shareusergroupwidget.h"
|
||||
#include "ui_shareusergroupwidget.h"
|
||||
#include "ui_sharewidget.h"
|
||||
#include "account.h"
|
||||
#include "json.h"
|
||||
#include "folderman.h"
|
||||
#include "folder.h"
|
||||
#include "accountmanager.h"
|
||||
#include "theme.h"
|
||||
#include "configfile.h"
|
||||
#include "capabilities.h"
|
||||
|
||||
#include "thumbnailjob.h"
|
||||
#include "share.h"
|
||||
#include "sharee.h"
|
||||
|
||||
#include "QProgressIndicator.h"
|
||||
#include <QBuffer>
|
||||
#include <QFileIconProvider>
|
||||
#include <QClipboard>
|
||||
#include <QFileInfo>
|
||||
#include <QCompleter>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
ShareUserGroupWidget::ShareUserGroupWidget(AccountPtr account, const QString &sharePath, const QString &localPath, bool resharingAllowed, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
_ui(new Ui::ShareUserGroupWidget),
|
||||
_account(account),
|
||||
_sharePath(sharePath),
|
||||
_localPath(localPath),
|
||||
_resharingAllowed(resharingAllowed)
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setObjectName("SharingDialogUG"); // required as group for saveGeometry call
|
||||
|
||||
_ui->setupUi(this);
|
||||
|
||||
//Is this a file or folder?
|
||||
_isFile = QFileInfo(localPath).isFile();
|
||||
|
||||
_completer = new QCompleter(this);
|
||||
_ui->shareeLineEdit->setCompleter(_completer);
|
||||
|
||||
_ui->searchPushButton->setEnabled(false);
|
||||
|
||||
_manager = new ShareManager(_account, this);
|
||||
connect(_manager, SIGNAL(sharesFetched(QList<QSharedPointer<Share>>)), SLOT(slotSharesFetched(QList<QSharedPointer<Share>>)));
|
||||
connect(_manager, SIGNAL(shareCreated(QSharedPointer<Share>)), SLOT(getShares()));
|
||||
connect(_ui->shareeLineEdit, SIGNAL(returnPressed()), SLOT(on_searchPushButton_clicked()));
|
||||
connect(_completer, SIGNAL(activated(QModelIndex)), SLOT(slotCompleterActivated(QModelIndex)));
|
||||
}
|
||||
|
||||
ShareUserGroupWidget::~ShareUserGroupWidget()
|
||||
{
|
||||
delete _ui;
|
||||
}
|
||||
|
||||
void ShareUserGroupWidget::on_shareeLineEdit_textChanged(const QString &text)
|
||||
{
|
||||
if (text == "") {
|
||||
_ui->searchPushButton->setEnabled(false);
|
||||
} else {
|
||||
_ui->searchPushButton->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void ShareUserGroupWidget::on_searchPushButton_clicked()
|
||||
{
|
||||
QVector<QSharedPointer<Sharee>> sharees;
|
||||
|
||||
// Add the current user to _sharees since we can't share with ourself
|
||||
QSharedPointer<Sharee> currentUser(new Sharee(_account->credentials()->user(), "", Sharee::Type::User));
|
||||
sharees.append(currentUser);
|
||||
|
||||
for(int i = 0; i < _ui->sharesLayout->count(); i++) {
|
||||
QWidget *w = _ui->sharesLayout->itemAt(i)->widget();
|
||||
|
||||
if (w != NULL) {
|
||||
const QSharedPointer<Sharee> x = dynamic_cast<ShareWidget *>(w)->share()->getShareWith();
|
||||
sharees.append(x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_sharees.append(currentUser);
|
||||
|
||||
|
||||
_completerModel = new ShareeModel(_account,
|
||||
_ui->shareeLineEdit->text(),
|
||||
_isFile ? QLatin1String("file") : QLatin1String("folder"),
|
||||
sharees,
|
||||
_completer);
|
||||
connect(_completerModel, SIGNAL(shareesReady()), SLOT(slotUpdateCompletion()));
|
||||
_completerModel->fetch();
|
||||
}
|
||||
|
||||
void ShareUserGroupWidget::slotUpdateCompletion() {
|
||||
_completer->setModel(_completerModel);
|
||||
_completer->complete();
|
||||
}
|
||||
|
||||
void ShareUserGroupWidget::getShares()
|
||||
{
|
||||
_manager->fetchShares(_sharePath);
|
||||
}
|
||||
|
||||
void ShareUserGroupWidget::slotSharesFetched(const QList<QSharedPointer<Share>> &shares)
|
||||
{
|
||||
/*
|
||||
* Delete all current widgets
|
||||
*/
|
||||
QLayoutItem *child;
|
||||
while ((child = _ui->sharesLayout->takeAt(0)) != 0) {
|
||||
delete child->widget();
|
||||
}
|
||||
|
||||
foreach(const auto &share, shares) {
|
||||
// We don't handle link shares
|
||||
if (share->getShareType() == Share::TypeLink) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ShareWidget *s = new ShareWidget(share, this);
|
||||
_ui->sharesLayout->addWidget(s);
|
||||
}
|
||||
}
|
||||
|
||||
void ShareUserGroupWidget::slotCompleterActivated(const QModelIndex & index) {
|
||||
auto sharee = _completerModel->getSharee(index.row());
|
||||
|
||||
if (sharee.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
_manager->createShare(_sharePath,
|
||||
(Share::ShareType)sharee->type(),
|
||||
sharee->shareWith(),
|
||||
Share::PermissionRead);
|
||||
|
||||
_completer->setModel(NULL);
|
||||
_ui->shareeLineEdit->setText(QString());
|
||||
}
|
||||
|
||||
ShareWidget::ShareWidget(QSharedPointer<Share> share,
|
||||
QWidget *parent) :
|
||||
QWidget(parent),
|
||||
_ui(new Ui::ShareWidget),
|
||||
_share(share)
|
||||
{
|
||||
_ui->setupUi(this);
|
||||
|
||||
_ui->sharedWith->setText(share->getShareWith()->format());
|
||||
|
||||
if (share->getPermissions() & Share::PermissionUpdate) {
|
||||
_ui->permissionUpdate->setCheckState(Qt::Checked);
|
||||
}
|
||||
if (share->getPermissions() & Share::PermissionCreate) {
|
||||
_ui->permissionCreate->setCheckState(Qt::Checked);
|
||||
}
|
||||
if (share->getPermissions() & Share::PermissionDelete) {
|
||||
_ui->permissionDelete->setCheckState(Qt::Checked);
|
||||
}
|
||||
if (share->getPermissions() & Share::PermissionShare) {
|
||||
_ui->permissionShare->setCheckState(Qt::Checked);
|
||||
}
|
||||
|
||||
connect(_ui->permissionUpdate, SIGNAL(clicked(bool)), SLOT(slotPermissionsChanged()));
|
||||
connect(_ui->permissionCreate, SIGNAL(clicked(bool)), SLOT(slotPermissionsChanged()));
|
||||
connect(_ui->permissionDelete, SIGNAL(clicked(bool)), SLOT(slotPermissionsChanged()));
|
||||
connect(_ui->permissionShare, SIGNAL(clicked(bool)), SLOT(slotPermissionsChanged()));
|
||||
|
||||
connect(share.data(), SIGNAL(permissionsSet()), SLOT(slotPermissionsSet()));
|
||||
connect(share.data(), SIGNAL(shareDeleted()), SLOT(slotShareDeleted()));
|
||||
}
|
||||
|
||||
void ShareWidget::on_deleteShareButton_clicked()
|
||||
{
|
||||
setEnabled(false);
|
||||
_share->deleteShare();
|
||||
}
|
||||
|
||||
ShareWidget::~ShareWidget()
|
||||
{
|
||||
delete _ui;
|
||||
}
|
||||
|
||||
void ShareWidget::slotPermissionsChanged()
|
||||
{
|
||||
setEnabled(false);
|
||||
|
||||
Share::Permissions permissions = Share::PermissionRead;
|
||||
|
||||
if (_ui->permissionUpdate->checkState() == Qt::Checked) {
|
||||
permissions |= Share::PermissionUpdate;
|
||||
}
|
||||
|
||||
if (_ui->permissionCreate->checkState() == Qt::Checked) {
|
||||
permissions |= Share::PermissionCreate;
|
||||
}
|
||||
|
||||
if (_ui->permissionDelete->checkState() == Qt::Checked) {
|
||||
permissions |= Share::PermissionDelete;
|
||||
}
|
||||
|
||||
if (_ui->permissionShare->checkState() == Qt::Checked) {
|
||||
permissions |= Share::PermissionShare;
|
||||
}
|
||||
|
||||
_share->setPermissions(permissions);
|
||||
}
|
||||
|
||||
void ShareWidget::slotShareDeleted()
|
||||
{
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
void ShareWidget::slotPermissionsSet()
|
||||
{
|
||||
setEnabled(true);
|
||||
}
|
||||
|
||||
QSharedPointer<Share> ShareWidget::share() const
|
||||
{
|
||||
return _share;
|
||||
}
|
||||
|
||||
}
|
115
src/gui/shareusergroupwidget.h
Normal file
115
src/gui/shareusergroupwidget.h
Normal file
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* 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
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* 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 SHAREUSERGROUPWIDGET_H
|
||||
#define SHAREUSERGROUPWIDGET_H
|
||||
|
||||
#include "accountfwd.h"
|
||||
#include "QProgressIndicator.h"
|
||||
#include <QDialog>
|
||||
#include <QWidget>
|
||||
#include <QVariantMap>
|
||||
#include <QSharedPointer>
|
||||
#include <QList>
|
||||
#include <QVector>
|
||||
|
||||
class QCompleter;
|
||||
|
||||
namespace OCC {
|
||||
|
||||
namespace Ui {
|
||||
class ShareUserGroupWidget;
|
||||
class ShareWidget;
|
||||
}
|
||||
|
||||
class AbstractCredentials;
|
||||
class QuotaInfo;
|
||||
class SyncResult;
|
||||
class Share;
|
||||
class Sharee;
|
||||
class ShareManager;
|
||||
class ShareeModel;
|
||||
|
||||
class ShareWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ShareWidget(QSharedPointer<Share> Share, QWidget *parent = 0);
|
||||
~ShareWidget();
|
||||
|
||||
QSharedPointer<Share> share() const;
|
||||
|
||||
signals:
|
||||
void shareDeleted(ShareWidget *share);
|
||||
|
||||
private slots:
|
||||
void on_deleteShareButton_clicked();
|
||||
void slotPermissionsChanged();
|
||||
|
||||
void slotShareDeleted();
|
||||
void slotPermissionsSet();
|
||||
|
||||
private:
|
||||
Ui::ShareWidget *_ui;
|
||||
QSharedPointer<Share> _share;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief The ShareDialog (user/group) class
|
||||
* @ingroup gui
|
||||
*/
|
||||
class ShareUserGroupWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ShareUserGroupWidget(AccountPtr account,
|
||||
const QString &sharePath,
|
||||
const QString &localPath,
|
||||
bool resharingAllowed,
|
||||
QWidget *parent = 0);
|
||||
~ShareUserGroupWidget();
|
||||
|
||||
public slots:
|
||||
void getShares();
|
||||
|
||||
private slots:
|
||||
void slotSharesFetched(const QList<QSharedPointer<Share>> &shares);
|
||||
|
||||
void on_shareeLineEdit_textChanged(const QString &text);
|
||||
void on_searchPushButton_clicked();
|
||||
|
||||
void slotUpdateCompletion();
|
||||
void slotCompleterActivated(const QModelIndex & index);
|
||||
|
||||
private:
|
||||
Ui::ShareUserGroupWidget *_ui;
|
||||
AccountPtr _account;
|
||||
QString _sharePath;
|
||||
QString _localPath;
|
||||
|
||||
QCompleter *_completer;
|
||||
ShareeModel *_completerModel;
|
||||
|
||||
bool _resharingAllowed;
|
||||
bool _isFile;
|
||||
|
||||
ShareManager *_manager;
|
||||
QVector<QSharedPointer<Sharee>> _sharees;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SHAREUSERGROUPWIDGET_H
|
65
src/gui/shareusergroupwidget.ui
Normal file
65
src/gui/shareusergroupwidget.ui
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OCC::ShareUserGroupWidget</class>
|
||||
<widget class="QWidget" name="OCC::ShareUserGroupWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>372</width>
|
||||
<height>271</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Share NewDocument.odt</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="shareeLineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="searchPushButton">
|
||||
<property name="text">
|
||||
<string>Search</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Shares</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="sharesLayout"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
77
src/gui/sharewidget.ui
Normal file
77
src/gui/sharewidget.ui
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OCC::ShareWidget</class>
|
||||
<widget class="QWidget" name="OCC::ShareWidget">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="sharedWith">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Permissions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="permissionUpdate">
|
||||
<property name="text">
|
||||
<string>Update</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="permissionCreate">
|
||||
<property name="text">
|
||||
<string>Create</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="permissionDelete">
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="permissionShare">
|
||||
<property name="text">
|
||||
<string>Share</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="deleteShareButton">
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -55,6 +55,7 @@ public slots:
|
|||
|
||||
signals:
|
||||
void shareCommandReceived(const QString &sharePath, const QString &localPath, bool resharingAllowed);
|
||||
void shareUserGroupCommandReceived(const QString &sharePath, const QString &localPath, bool resharingAllowed);
|
||||
|
||||
private slots:
|
||||
void slotNewConnection();
|
||||
|
|
Loading…
Reference in a new issue