mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-30 08:20:27 +03:00
Sharedialog: Some more refinements after the merge of the branch.
- Some dialog changes: Made it less vertical space comsuming - Some variable cleanups - Allow to share files that are not within the synced dir by copying them to the root of a sync dir first.
This commit is contained in:
parent
d8b621d05f
commit
95f7e83c5c
5 changed files with 345 additions and 233 deletions
|
@ -4,10 +4,12 @@
|
|||
#include "account.h"
|
||||
#include "json.h"
|
||||
#include "folderman.h"
|
||||
#include "folder.h"
|
||||
#include "theme.h"
|
||||
#include "syncresult.h"
|
||||
|
||||
#include "QProgressIndicator.h"
|
||||
#include <QBuffer>
|
||||
#include <QMovie>
|
||||
#include <QMessageBox>
|
||||
#include <QFileIconProvider>
|
||||
|
||||
namespace {
|
||||
|
@ -25,11 +27,12 @@ ShareDialog::ShareDialog(const QString &sharePath, const QString &localPath, QWi
|
|||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
_ui->setupUi(this);
|
||||
_ui->pushButton_copy->setIcon(QIcon::fromTheme("edit-copy"));
|
||||
layout()->setSizeConstraint(QLayout::SetFixedSize);
|
||||
|
||||
_pi_link = new QProgressIndicator();
|
||||
// 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_date = new QProgressIndicator();
|
||||
_ui->horizontalLayout_shareLink->addWidget(_pi_link);
|
||||
_ui->horizontalLayout_password->addWidget(_pi_password);
|
||||
_ui->horizontalLayout_expire->addWidget(_pi_date);
|
||||
|
@ -48,15 +51,37 @@ ShareDialog::ShareDialog(const QString &sharePath, const QString &localPath, QWi
|
|||
QFileIconProvider icon_provider;
|
||||
QIcon icon = icon_provider.icon(f_info);
|
||||
_ui->label_icon->setPixmap(icon.pixmap(40,40));
|
||||
if (f_info.isDir()) {
|
||||
_ui->lineEdit_name->setText(f_info.dir().dirName());
|
||||
_ui->lineEdit_type->setText("Directory");
|
||||
|
||||
QString name;
|
||||
if( f_info.isDir() ) {
|
||||
name = QString("Share directory %2").arg(_localPath);
|
||||
} else {
|
||||
_ui->lineEdit_name->setText(f_info.fileName());
|
||||
_ui->lineEdit_type->setText("File");
|
||||
name = QString("Share file %1").arg(_localPath);
|
||||
}
|
||||
_ui->lineEdit_localPath->setText(_localPath);
|
||||
_ui->lineEdit_sharePath->setText(_sharePath);
|
||||
_ui->label_name->setText(name);
|
||||
_ui->label_sharePath->setWordWrap(true);
|
||||
_ui->label_sharePath->setText(tr("%1 path: %2").arg(Theme::instance()->appNameGUI()).arg(_sharePath));
|
||||
this->setWindowTitle(tr("%1 Sharing").arg(Theme::instance()->appNameGUI()));
|
||||
|
||||
// check if the file is already inside of a synced folder
|
||||
if( sharePath.isEmpty() ) {
|
||||
// The file is not yet in ownCloud. It must be copied into first.
|
||||
_ui->checkBox_shareLink->setEnabled(false);
|
||||
uploadExternalFile();
|
||||
}
|
||||
|
||||
// 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));
|
||||
|
||||
}
|
||||
|
||||
void ShareDialog::setExpireDate(const QDate &date)
|
||||
|
@ -88,10 +113,7 @@ void ShareDialog::slotExpireSet(const QString &reply)
|
|||
|
||||
qDebug() << Q_FUNC_INFO << "Status code: " << code;
|
||||
if (code != 100) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(message);
|
||||
msgBox.setWindowTitle(QString("Server replied with code %1").arg(code));
|
||||
msgBox.exec();
|
||||
displayError(code);
|
||||
}
|
||||
|
||||
_pi_date->stopAnimation();
|
||||
|
@ -139,10 +161,7 @@ void ShareDialog::slotPasswordSet(const QString &reply)
|
|||
qDebug() << Q_FUNC_INFO << "Status code: " << code;
|
||||
|
||||
if (code != 100) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(message);
|
||||
msgBox.setWindowTitle(QString("Server replied with code %1").arg(code));
|
||||
msgBox.exec();
|
||||
displayError(100);
|
||||
} else {
|
||||
/*
|
||||
* When setting/deleting a password from a share the old share is
|
||||
|
@ -157,7 +176,6 @@ void ShareDialog::slotPasswordSet(const QString &reply)
|
|||
|
||||
void ShareDialog::getShares()
|
||||
{
|
||||
this->setWindowTitle(tr("Sharing %1").arg(_sharePath));
|
||||
QUrl url = Account::concatUrlPath(AccountManager::instance()->account()->url(), QLatin1String("ocs/v1.php/apps/files_sharing/api/v1/shares"));
|
||||
QList<QPair<QString, QString> > params;
|
||||
params.append(qMakePair(QString::fromLatin1("format"), QString::fromLatin1("json")));
|
||||
|
@ -175,10 +193,7 @@ void ShareDialog::slotSharesFetched(const QString &reply)
|
|||
|
||||
qDebug() << Q_FUNC_INFO << "Status code: " << code;
|
||||
if (code != 100) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(message);
|
||||
msgBox.setWindowTitle(QString("Server replied with code %1").arg(code));
|
||||
msgBox.exec();
|
||||
displayError(code);
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
|
@ -223,10 +238,7 @@ void ShareDialog::slotDeleteShareFetched(const QString &reply)
|
|||
|
||||
qDebug() << Q_FUNC_INFO << "Status code: " << code;
|
||||
if (code != 100) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(message);
|
||||
msgBox.setWindowTitle(QString("Server replied with code %1").arg(code));
|
||||
msgBox.exec();
|
||||
displayError(code);
|
||||
}
|
||||
|
||||
_pi_link->stopAnimation();
|
||||
|
@ -272,10 +284,7 @@ void ShareDialog::slotCreateShareFetched(const QString &reply)
|
|||
int code = checkJsonReturnCode(reply, message);
|
||||
|
||||
if (code != 100) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(message);
|
||||
msgBox.setWindowTitle(QString("Server replied with code %1").arg(code));
|
||||
msgBox.exec();
|
||||
displayError(code);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -338,13 +347,125 @@ int ShareDialog::checkJsonReturnCode(const QString &reply, QString &message)
|
|||
return code;
|
||||
}
|
||||
|
||||
void ShareDialog::displayError(int code)
|
||||
{
|
||||
const QString errMsg = tr("OCS API error code: %1").arg(code);
|
||||
_ui->errorLabel->setText( errMsg );
|
||||
}
|
||||
|
||||
void ShareDialog::displayInfo( const QString& msg )
|
||||
{
|
||||
_ui->label_sharePath->setText(msg);
|
||||
}
|
||||
|
||||
bool ShareDialog::uploadExternalFile()
|
||||
{
|
||||
bool re = false;
|
||||
const QString folderName = QString("ownCloud"); // FIXME: get a proper folder name
|
||||
|
||||
Folder *folder = 0;
|
||||
Folder::Map folders = FolderMan::instance()->map();
|
||||
if( folders.isEmpty() ) {
|
||||
// no folder to work on.
|
||||
return false;
|
||||
}
|
||||
if( folders.contains( Theme::instance()->appNameGUI()) ) {
|
||||
folder = folders.value(Theme::instance()->appNameGUI());
|
||||
}
|
||||
if( !folder ) {
|
||||
folder = folders.value( folders.keys().at(0));
|
||||
}
|
||||
FolderMan::instance()->folder(folderName);
|
||||
if( ! folder ) {
|
||||
qDebug() << "Folder not defined: " << folderName;
|
||||
return false;
|
||||
}
|
||||
|
||||
QFileInfo fi(_localPath);
|
||||
if( fi.isDir() ) {
|
||||
// we can not do this for directories yet.
|
||||
displayInfo(tr("Sharing of external directories is not yet working."));
|
||||
return false;
|
||||
}
|
||||
_sharePath = folder->remotePath()+QLatin1Char('/')+fi.fileName();
|
||||
_folderAlias = folderName;
|
||||
|
||||
// connect the finish signal of the folder before the file to upload
|
||||
// is copied to the sync folder.
|
||||
connect( folder, SIGNAL(syncFinished(SyncResult)), this, SLOT(slotNextSyncFinished(SyncResult)) );
|
||||
|
||||
// copy the file
|
||||
_expectedSyncFile = folder->path()+fi.fileName();
|
||||
|
||||
QFileInfo target(_expectedSyncFile);
|
||||
if( target.exists() ) {
|
||||
_ui->label_sharePath->setText(tr("A sync file with the same name exists. "
|
||||
"The file can not be registered to sync."));
|
||||
// TODO: Add a file comparison here. If the existing file is still the same
|
||||
// then the file-to-copy we can share it.
|
||||
_sharePath.clear();
|
||||
} else {
|
||||
_uploadFails = 0;
|
||||
_ui->pi_share->startAnimation();
|
||||
QFile file( _localPath);
|
||||
if( file.copy(_expectedSyncFile) ) {
|
||||
// copying succeeded.
|
||||
re = true;
|
||||
displayInfo(tr("Waiting to upload..."));
|
||||
} else {
|
||||
displayInfo(tr("Unable to register in sync space."));
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
|
||||
void ShareDialog::slotNextSyncFinished( const SyncResult& result )
|
||||
{
|
||||
// FIXME: Check for state!
|
||||
SyncFileItemVector itemVector = result.syncFileItemVector();
|
||||
SyncFileItem targetItem;
|
||||
Folder *folder = FolderMan::instance()->folder(_folderAlias);
|
||||
const QString folderPath = folder->path();
|
||||
|
||||
_ui->pi_share->stopAnimation();
|
||||
|
||||
foreach( SyncFileItem item, itemVector ) {
|
||||
const QString fullSyncedFile = folderPath + item._file;
|
||||
if( item._direction == SyncFileItem::Up &&
|
||||
fullSyncedFile == _expectedSyncFile) {
|
||||
// found the item!
|
||||
targetItem = item;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if( targetItem.isEmpty() ) {
|
||||
// The item was not in this sync run. Lets wait for the next one. FIXME
|
||||
_uploadFails ++;
|
||||
if( _uploadFails > 2 ) {
|
||||
// stop the upload job
|
||||
displayInfo(tr("The file can not be synced."));
|
||||
}
|
||||
} else {
|
||||
// it's there and the sync was successful.
|
||||
// The server should be able to generate a share link now.
|
||||
// Enable the sharing link
|
||||
if( targetItem._status == SyncFileItem::Success ) {
|
||||
_ui->checkBox_shareLink->setEnabled(true);
|
||||
_ui->label_sharePath->setText(tr("%1 path: %2").arg(Theme::instance()->appNameGUI()).arg(_sharePath));
|
||||
} else {
|
||||
displayInfo(tr("Sync of registered file was not successful yet."));
|
||||
}
|
||||
}
|
||||
_expectedSyncFile.clear();
|
||||
}
|
||||
|
||||
|
||||
OcsShareJob::OcsShareJob(const QByteArray &verb, const QUrl &url, const QUrl &postData, AccountPtr account, QObject* parent)
|
||||
: AbstractNetworkJob(account, "", parent),
|
||||
_verb(verb),
|
||||
_url(url),
|
||||
_postData(postData)
|
||||
|
||||
{
|
||||
setIgnoreCredentialFailure(true);
|
||||
}
|
||||
|
@ -374,6 +495,4 @@ bool OcsShareJob::finished()
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ class AbstractCredentials;
|
|||
class Account;
|
||||
class QuotaInfo;
|
||||
class MirallAccessManager;
|
||||
class SyncResult;
|
||||
|
||||
class ShareDialog : public QDialog
|
||||
{
|
||||
|
@ -54,6 +55,10 @@ public:
|
|||
explicit ShareDialog(const QString &sharePath, const QString &localPath, QWidget *parent = 0);
|
||||
~ShareDialog();
|
||||
void getShares();
|
||||
|
||||
public slots:
|
||||
void slotNextSyncFinished( const SyncResult& result );
|
||||
|
||||
private slots:
|
||||
void slotSharesFetched(const QString &reply);
|
||||
void slotCreateShareFetched(const QString &reply);
|
||||
|
@ -66,9 +71,18 @@ private slots:
|
|||
void slotCheckBoxExpireClicked();
|
||||
void slotPasswordReturnPressed();
|
||||
private:
|
||||
void displayError(int code);
|
||||
void displayInfo( const QString& msg );
|
||||
|
||||
bool uploadExternalFile();
|
||||
|
||||
Ui::ShareDialog *_ui;
|
||||
QString _sharePath;
|
||||
QString _localPath;
|
||||
QString _folderAlias;
|
||||
int _uploadFails;
|
||||
QString _expectedSyncFile;
|
||||
|
||||
QList<QVariant> _shares;
|
||||
qulonglong _public_share_id;
|
||||
void setPassword(const QString &password);
|
||||
|
|
|
@ -6,214 +6,189 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>454</width>
|
||||
<height>558</height>
|
||||
<width>281</width>
|
||||
<height>385</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Share NewDocument.odt</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetFixedSize</enum>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Share Info</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_icon">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_name">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_name">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_type">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_type">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_localPath">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Local path:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_localPath">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_sharePath">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OwnCloud Path:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_sharePath">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_shareLink">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_shareLink">
|
||||
<property name="text">
|
||||
<string>Share link</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_shareLink" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
<property name="title">
|
||||
<string>Share Info</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<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>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_shareLink">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_copy">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_password">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_password">
|
||||
<property name="text">
|
||||
<string>Set password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<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>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_14">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_password">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<item row="0" column="2" rowspan="2">
|
||||
<widget class="QProgressIndicator" name="pi_share" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_expire">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_expire">
|
||||
<property name="text">
|
||||
<string>Set expiry date</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCalendarWidget" name="calendar"/>
|
||||
<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>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_shareLink">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_shareLink">
|
||||
<property name="text">
|
||||
<string>Share link</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QWidget" name="widget_shareLink" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_shareLink">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_copy">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_password">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_password">
|
||||
<property name="text">
|
||||
<string>Set password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_14">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_password">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_expire">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_expire">
|
||||
<property name="text">
|
||||
<string>Set expiry date</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCalendarWidget" name="calendar"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" 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>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="errorLabel">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
|
|
|
@ -398,26 +398,30 @@ void SocketApi::command_RETRIEVE_FILE_STATUS(const QString& argument, SocketType
|
|||
sendMessage(socket, message);
|
||||
}
|
||||
|
||||
void SocketApi::command_SHARE(const QString& argument, SocketType* socket)
|
||||
void SocketApi::command_SHARE(const QString& localFile, SocketType* socket)
|
||||
{
|
||||
if (!socket) {
|
||||
qDebug() << Q_FUNC_INFO << "No valid socket object.";
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << Q_FUNC_INFO << argument;
|
||||
qDebug() << Q_FUNC_INFO << localFile;
|
||||
|
||||
Folder *shareFolder = FolderMan::instance()->folderForPath(argument);
|
||||
Folder *shareFolder = FolderMan::instance()->folderForPath(localFile);
|
||||
if (!shareFolder) {
|
||||
const QString message = QLatin1String("SHARE:NOP:")+QDir::toNativeSeparators(argument);
|
||||
const QString message = QLatin1String("SHARE:OK:")+QDir::toNativeSeparators(localFile);
|
||||
// FIXME: We could send here a "SHARE:PROGRESS" message back as this op will probably
|
||||
// take longer. But currently we lack a way of getting a message once that has successfully
|
||||
// worked.
|
||||
emit shareCommandReceived(QString(), localFile);
|
||||
sendMessage(socket, message);
|
||||
} else {
|
||||
const QString message = QLatin1String("SHARE:OK:")+QDir::toNativeSeparators(argument);
|
||||
const QString message = QLatin1String("SHARE:OK:")+QDir::toNativeSeparators(localFile);
|
||||
sendMessage(socket, message);
|
||||
|
||||
const QString folderForPath = shareFolder->path();
|
||||
const QString path = shareFolder->remotePath() + argument.right(argument.count()-folderForPath.count()+1);
|
||||
emit shareCommandReceived(path, argument);
|
||||
const QString remotePath = shareFolder->remotePath() + localFile.right(localFile.count()-folderForPath.count()+1);
|
||||
emit shareCommandReceived(remotePath, localFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ private:
|
|||
|
||||
Q_INVOKABLE void command_RETRIEVE_FOLDER_STATUS(const QString& argument, SocketType* socket);
|
||||
Q_INVOKABLE void command_RETRIEVE_FILE_STATUS(const QString& argument, SocketType* socket);
|
||||
Q_INVOKABLE void command_SHARE(const QString& argument, SocketType* socket);
|
||||
Q_INVOKABLE void command_SHARE(const QString& localFile, SocketType* socket);
|
||||
|
||||
Q_INVOKABLE void command_VERSION(const QString& argument, SocketType* socket);
|
||||
|
||||
|
|
Loading…
Reference in a new issue