mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
[Sharing] Reorganized sharedialog code
Now we have 1 simple dialog that includes 2 widgets. * ShareLinkWidget (for link shares) * ShareUserGroupWidget (for user/group shares) The ShareUserGroupWidget is only included if the server version is >= 8.2.0 For <8.2.0 the old behavior is preserved
This commit is contained in:
parent
90cbd461ab
commit
3e4612a1f0
17 changed files with 1027 additions and 1007 deletions
|
@ -23,8 +23,9 @@ set(client_UI
|
|||
protocolwidget.ui
|
||||
settingsdialog.ui
|
||||
sharedialog.ui
|
||||
shareusergroupdialog.ui
|
||||
sharedialogshare.ui
|
||||
sharelinkwidget.ui
|
||||
shareusergroupwidget.ui
|
||||
sharewidget.ui
|
||||
sslerrordialog.ui
|
||||
owncloudsetuppage.ui
|
||||
addcertificatedialog.ui
|
||||
|
@ -63,7 +64,8 @@ set(client_SRCS
|
|||
settingsdialog.cpp
|
||||
share.cpp
|
||||
sharedialog.cpp
|
||||
shareusergroupdialog.cpp
|
||||
sharelinkwidget.cpp
|
||||
shareusergroupwidget.cpp
|
||||
sharee.cpp
|
||||
socketapi.cpp
|
||||
sslbutton.cpp
|
||||
|
|
|
@ -174,8 +174,6 @@ Application::Application(int &argc, char **argv) :
|
|||
|
||||
connect(FolderMan::instance()->socketApi(), SIGNAL(shareCommandReceived(QString, QString, bool)),
|
||||
_gui, SLOT(slotShowShareDialog(QString, QString, bool)));
|
||||
connect(FolderMan::instance()->socketApi(), SIGNAL(shareUserGroupCommandReceived(QString, QString, bool)),
|
||||
_gui, SLOT(slotShowShareUserGroupDialog(QString, QString, bool)));
|
||||
|
||||
// startup procedure.
|
||||
connect(&_checkConnectionTimer, SIGNAL(timeout()), this, SLOT(slotCheckConnection()));
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "progressdispatcher.h"
|
||||
#include "owncloudsetupwizard.h"
|
||||
#include "sharedialog.h"
|
||||
#include "shareusergroupdialog.h"
|
||||
#if defined(Q_OS_MAC)
|
||||
# include "settingsdialogmac.h"
|
||||
# include "macwindow.h" // qtmacgoodies
|
||||
|
@ -781,26 +780,5 @@ void ownCloudGui::slotShowShareDialog(const QString &sharePath, const QString &l
|
|||
raiseDialog(w);
|
||||
}
|
||||
|
||||
void ownCloudGui::slotShowShareUserGroupDialog(const QString &sharePath, const QString &localPath, bool resharingAllowed)
|
||||
{
|
||||
const auto folder = FolderMan::instance()->folderForPath(localPath);
|
||||
if (!folder) {
|
||||
qDebug() << "Could not open share dialog for" << localPath << "no responsible folder found";
|
||||
return;
|
||||
}
|
||||
|
||||
// For https://github.com/owncloud/client/issues/3783
|
||||
_settingsDialog->hide();
|
||||
|
||||
const auto accountState = folder->accountState();
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "Opening share dialog" << sharePath << localPath;
|
||||
ShareUserGroupDialog *w = new ShareUserGroupDialog(accountState->account(), sharePath, localPath, resharingAllowed);
|
||||
w->getShares();
|
||||
w->setAttribute( Qt::WA_DeleteOnClose, true );
|
||||
raiseDialog(w);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // end namespace
|
||||
|
|
|
@ -77,7 +77,6 @@ public slots:
|
|||
void slotOpenPath(const QString& path);
|
||||
void slotAccountStateChanged();
|
||||
void slotShowShareDialog(const QString &sharePath, const QString &localPath, bool resharingAllowed);
|
||||
void slotShowShareUserGroupDialog(const QString &sharePath, const QString &localPath, bool resharingAllowed);
|
||||
|
||||
private slots:
|
||||
void slotDisplayIdle();
|
||||
|
|
|
@ -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,24 +12,20 @@
|
|||
*/
|
||||
|
||||
#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 {
|
||||
|
||||
|
@ -40,64 +35,25 @@ ShareDialog::ShareDialog(AccountPtr account, const QString &sharePath, const QSt
|
|||
_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();
|
||||
ThumbnailJob *job = new ThumbnailJob(_sharePath, _account, this);
|
||||
connect(job, SIGNAL(jobFinished(int, QByteArray)), SLOT(slotThumbnailFetched(int, QByteArray)));
|
||||
job->start();
|
||||
}
|
||||
|
||||
_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);
|
||||
_linkWidget->getShares();
|
||||
if (_userGroupWidget != NULL) {
|
||||
_userGroupWidget->getShares();
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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>
|
||||
<layout class="QVBoxLayout" name="shareWidgetsLayout"/>
|
||||
</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="3" column="1">
|
||||
<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>
|
||||
|
|
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>
|
|
@ -1,133 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OCC::ShareUserGroupDialog</class>
|
||||
<widget class="QDialog" name="OCC::ShareUserGroupDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>372</width>
|
||||
<height>505</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Share NewDocument.odt</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<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">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>share label</string>
|
||||
</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">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ownCloud Path:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</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">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<layout class="QVBoxLayout" name="sharesLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Shares</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<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>
|
||||
</layout>
|
||||
</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>
|
|
@ -11,9 +11,9 @@
|
|||
* for more details.
|
||||
*/
|
||||
|
||||
#include "shareusergroupdialog.h"
|
||||
#include "ui_shareusergroupdialog.h"
|
||||
#include "ui_sharedialogshare.h"
|
||||
#include "shareusergroupwidget.h"
|
||||
#include "ui_shareusergroupwidget.h"
|
||||
#include "ui_sharewidget.h"
|
||||
#include "account.h"
|
||||
#include "json.h"
|
||||
#include "folderman.h"
|
||||
|
@ -36,9 +36,9 @@
|
|||
|
||||
namespace OCC {
|
||||
|
||||
ShareUserGroupDialog::ShareUserGroupDialog(AccountPtr account, const QString &sharePath, const QString &localPath, bool resharingAllowed, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
_ui(new Ui::ShareUserGroupDialog),
|
||||
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),
|
||||
|
@ -64,18 +64,12 @@ ShareUserGroupDialog::ShareUserGroupDialog(AccountPtr account, const QString &sh
|
|||
connect(_completer, SIGNAL(activated(QModelIndex)), SLOT(slotCompleterActivated(QModelIndex)));
|
||||
}
|
||||
|
||||
void ShareUserGroupDialog::done( int r ) {
|
||||
ConfigFile cfg;
|
||||
cfg.saveGeometry(this);
|
||||
QDialog::done(r);
|
||||
}
|
||||
|
||||
ShareUserGroupDialog::~ShareUserGroupDialog()
|
||||
ShareUserGroupWidget::~ShareUserGroupWidget()
|
||||
{
|
||||
delete _ui;
|
||||
}
|
||||
|
||||
void ShareUserGroupDialog::on_shareeLineEdit_textChanged(const QString &text)
|
||||
void ShareUserGroupWidget::on_shareeLineEdit_textChanged(const QString &text)
|
||||
{
|
||||
if (text == "") {
|
||||
_ui->searchPushButton->setEnabled(false);
|
||||
|
@ -84,7 +78,7 @@ void ShareUserGroupDialog::on_shareeLineEdit_textChanged(const QString &text)
|
|||
}
|
||||
}
|
||||
|
||||
void ShareUserGroupDialog::on_searchPushButton_clicked()
|
||||
void ShareUserGroupWidget::on_searchPushButton_clicked()
|
||||
{
|
||||
_completerModel = new ShareeModel(_account,
|
||||
_ui->shareeLineEdit->text(),
|
||||
|
@ -94,18 +88,18 @@ void ShareUserGroupDialog::on_searchPushButton_clicked()
|
|||
_completerModel->fetch();
|
||||
}
|
||||
|
||||
void ShareUserGroupDialog::slotUpdateCompletion() {
|
||||
void ShareUserGroupWidget::slotUpdateCompletion() {
|
||||
_completer->setModel(_completerModel);
|
||||
_ui->shareeLineEdit->setCompleter(_completer);
|
||||
_completer->complete();
|
||||
}
|
||||
|
||||
void ShareUserGroupDialog::getShares()
|
||||
void ShareUserGroupWidget::getShares()
|
||||
{
|
||||
_manager->fetchShares(_sharePath);
|
||||
}
|
||||
|
||||
void ShareUserGroupDialog::slotSharesFetched(const QList<QSharedPointer<Share>> &shares)
|
||||
void ShareUserGroupWidget::slotSharesFetched(const QList<QSharedPointer<Share>> &shares)
|
||||
{
|
||||
const QString versionString = _account->serverVersion();
|
||||
qDebug() << Q_FUNC_INFO << versionString << "Fetched" << shares.count() << "shares";
|
||||
|
@ -121,13 +115,13 @@ void ShareUserGroupDialog::slotSharesFetched(const QList<QSharedPointer<Share>>
|
|||
continue;
|
||||
}
|
||||
|
||||
ShareDialogShare *s = new ShareDialogShare(share, this);
|
||||
ShareWidget *s = new ShareWidget(share, this);
|
||||
_ui->sharesLayout->addWidget(s);
|
||||
}
|
||||
_ui->sharesLayout->invalidate();
|
||||
}
|
||||
|
||||
void ShareUserGroupDialog::slotCompleterActivated(const QModelIndex & index) {
|
||||
void ShareUserGroupWidget::slotCompleterActivated(const QModelIndex & index) {
|
||||
auto sharee = _completerModel->getSharee(index.row());
|
||||
|
||||
if (sharee.isNull()) {
|
||||
|
@ -140,10 +134,10 @@ void ShareUserGroupDialog::slotCompleterActivated(const QModelIndex & index) {
|
|||
Share::PermissionRead);
|
||||
}
|
||||
|
||||
ShareDialogShare::ShareDialogShare(QSharedPointer<Share> share,
|
||||
ShareWidget::ShareWidget(QSharedPointer<Share> share,
|
||||
QWidget *parent) :
|
||||
QWidget(parent),
|
||||
_ui(new Ui::ShareDialogShare),
|
||||
_ui(new Ui::ShareWidget),
|
||||
_share(share)
|
||||
{
|
||||
_ui->setupUi(this);
|
||||
|
@ -172,18 +166,18 @@ ShareDialogShare::ShareDialogShare(QSharedPointer<Share> share,
|
|||
connect(share.data(), SIGNAL(shareDeleted()), SLOT(slotShareDeleted()));
|
||||
}
|
||||
|
||||
void ShareDialogShare::on_deleteShareButton_clicked()
|
||||
void ShareWidget::on_deleteShareButton_clicked()
|
||||
{
|
||||
setEnabled(false);
|
||||
_share->deleteShare();
|
||||
}
|
||||
|
||||
ShareDialogShare::~ShareDialogShare()
|
||||
ShareWidget::~ShareWidget()
|
||||
{
|
||||
delete _ui;
|
||||
}
|
||||
|
||||
void ShareDialogShare::slotPermissionsChanged()
|
||||
void ShareWidget::slotPermissionsChanged()
|
||||
{
|
||||
setEnabled(false);
|
||||
|
||||
|
@ -208,12 +202,12 @@ void ShareDialogShare::slotPermissionsChanged()
|
|||
_share->setPermissions(permissions);
|
||||
}
|
||||
|
||||
void ShareDialogShare::slotShareDeleted()
|
||||
void ShareWidget::slotShareDeleted()
|
||||
{
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
void ShareDialogShare::slotPermissionsSet()
|
||||
void ShareWidget::slotPermissionsSet()
|
||||
{
|
||||
setEnabled(true);
|
||||
}
|
|
@ -11,8 +11,8 @@
|
|||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef SHAREDIALOG_UG_H
|
||||
#define SHAREDIALOG_UG_H
|
||||
#ifndef SHAREUSERGROUPWIDGET_H
|
||||
#define SHAREUSERGROUPWIDGET_H
|
||||
|
||||
#include "accountfwd.h"
|
||||
#include "QProgressIndicator.h"
|
||||
|
@ -28,8 +28,8 @@ class QCompleter;
|
|||
namespace OCC {
|
||||
|
||||
namespace Ui {
|
||||
class ShareUserGroupDialog;
|
||||
class ShareDialogShare;
|
||||
class ShareUserGroupWidget;
|
||||
class ShareWidget;
|
||||
}
|
||||
|
||||
class AbstractCredentials;
|
||||
|
@ -39,16 +39,16 @@ class Share;
|
|||
class ShareManager;
|
||||
class ShareeModel;
|
||||
|
||||
class ShareDialogShare : public QWidget
|
||||
class ShareWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ShareDialogShare(QSharedPointer<Share> Share, QWidget *parent = 0);
|
||||
~ShareDialogShare();
|
||||
explicit ShareWidget(QSharedPointer<Share> Share, QWidget *parent = 0);
|
||||
~ShareWidget();
|
||||
|
||||
signals:
|
||||
void shareDeleted(ShareDialogShare *share);
|
||||
void shareDeleted(ShareWidget *share);
|
||||
|
||||
private slots:
|
||||
void on_deleteShareButton_clicked();
|
||||
|
@ -58,7 +58,7 @@ private slots:
|
|||
void slotPermissionsSet();
|
||||
|
||||
private:
|
||||
Ui::ShareDialogShare *_ui;
|
||||
Ui::ShareWidget *_ui;
|
||||
QSharedPointer<Share> _share;
|
||||
};
|
||||
|
||||
|
@ -67,25 +67,23 @@ private:
|
|||
* @brief The ShareDialog (user/group) class
|
||||
* @ingroup gui
|
||||
*/
|
||||
class ShareUserGroupDialog : public QDialog
|
||||
class ShareUserGroupWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ShareUserGroupDialog(AccountPtr account,
|
||||
explicit ShareUserGroupWidget(AccountPtr account,
|
||||
const QString &sharePath,
|
||||
const QString &localPath,
|
||||
bool resharingAllowed,
|
||||
QWidget *parent = 0);
|
||||
~ShareUserGroupDialog();
|
||||
~ShareUserGroupWidget();
|
||||
|
||||
public slots:
|
||||
void getShares();
|
||||
|
||||
private slots:
|
||||
void slotSharesFetched(const QList<QSharedPointer<Share>> &shares);
|
||||
void done( int r );
|
||||
|
||||
|
||||
void on_shareeLineEdit_textChanged(const QString &text);
|
||||
void on_searchPushButton_clicked();
|
||||
|
@ -94,7 +92,7 @@ private slots:
|
|||
void slotCompleterActivated(const QModelIndex & index);
|
||||
|
||||
private:
|
||||
Ui::ShareUserGroupDialog *_ui;
|
||||
Ui::ShareUserGroupWidget *_ui;
|
||||
AccountPtr _account;
|
||||
QString _sharePath;
|
||||
QString _localPath;
|
||||
|
@ -110,4 +108,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
#endif // SHAREDIALOG_UG_H
|
||||
#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>
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OCC::ShareDialogShare</class>
|
||||
<widget class="QWidget" name="OCC::ShareDialogShare">
|
||||
<class>OCC::ShareWidget</class>
|
||||
<widget class="QWidget" name="OCC::ShareWidget">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
|
@ -404,51 +404,6 @@ void SocketApi::command_SHARE(const QString& localFile, QIODevice* socket)
|
|||
}
|
||||
}
|
||||
|
||||
void SocketApi::command_SHARE_USER_GROUP(const QString& localFile, QIODevice* socket)
|
||||
{
|
||||
if (!socket) {
|
||||
qDebug() << Q_FUNC_INFO << "No valid socket object.";
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << Q_FUNC_INFO << localFile;
|
||||
|
||||
Folder *shareFolder = FolderMan::instance()->folderForPath(localFile);
|
||||
if (!shareFolder) {
|
||||
const QString message = QLatin1String("SHARE:NOP:")+QDir::toNativeSeparators(localFile);
|
||||
// files that are not within a sync folder are not synced.
|
||||
sendMessage(socket, message);
|
||||
} else if (!shareFolder->accountState()->isConnected()) {
|
||||
const QString message = QLatin1String("SHARE:NOTCONNECTED:")+QDir::toNativeSeparators(localFile);
|
||||
// if the folder isn't connected, don't open the share dialog
|
||||
sendMessage(socket, message);
|
||||
} else {
|
||||
const QString folderForPath = shareFolder->path();
|
||||
const QString remotePath = shareFolder->remotePath() + localFile.right(localFile.count()-folderForPath.count()+1);
|
||||
|
||||
// Can't share root folder
|
||||
if (QDir::cleanPath(remotePath) == "/") {
|
||||
const QString message = QLatin1String("SHARE:CANNOTSHAREROOT:")+QDir::toNativeSeparators(localFile);
|
||||
sendMessage(socket, message);
|
||||
return;
|
||||
}
|
||||
|
||||
SyncJournalFileRecord rec = dbFileRecord_capi(shareFolder, localFile);
|
||||
|
||||
bool allowReshare = true; // lets assume the good
|
||||
if( rec.isValid() ) {
|
||||
// check the permission: Is resharing allowed?
|
||||
if( !rec._remotePerm.contains('R') ) {
|
||||
allowReshare = false;
|
||||
}
|
||||
}
|
||||
const QString message = QLatin1String("SHARE:OK:")+QDir::toNativeSeparators(localFile);
|
||||
sendMessage(socket, message);
|
||||
|
||||
emit shareUserGroupCommandReceived(remotePath, localFile, allowReshare);
|
||||
}
|
||||
}
|
||||
|
||||
void SocketApi::command_VERSION(const QString&, QIODevice* socket)
|
||||
{
|
||||
sendMessage(socket, QLatin1String("VERSION:" MIRALL_VERSION_STRING ":" MIRALL_SOCKET_API_VERSION));
|
||||
|
|
|
@ -75,7 +75,6 @@ private:
|
|||
Q_INVOKABLE void command_RETRIEVE_FOLDER_STATUS(const QString& argument, QIODevice* socket);
|
||||
Q_INVOKABLE void command_RETRIEVE_FILE_STATUS(const QString& argument, QIODevice* socket);
|
||||
Q_INVOKABLE void command_SHARE(const QString& localFile, QIODevice* socket);
|
||||
Q_INVOKABLE void command_SHARE_USER_GROUP(const QString& localFile, QIODevice* socket);
|
||||
|
||||
Q_INVOKABLE void command_VERSION(const QString& argument, QIODevice* socket);
|
||||
|
||||
|
|
Loading…
Reference in a new issue