diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 67fe0019e..72f7df876 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -147,8 +147,8 @@ Application::Application(int &argc, char **argv) : slotAccountStateAdded(ai); } - connect(FolderMan::instance()->socketApi(), SIGNAL(shareCommandReceived(QString, bool)), - _gui, SLOT(slotShowShareDialog(QString, bool))); + connect(FolderMan::instance()->socketApi(), SIGNAL(shareCommandReceived(QString, QString)), + _gui, SLOT(slotShowShareDialog(QString, QString))); // startup procedure. connect(&_checkConnectionTimer, SIGNAL(timeout()), this, SLOT(slotCheckConnection())); diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index 53f6c6540..be283b2d9 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -636,10 +636,10 @@ void ownCloudGui::raiseDialog( QWidget *raiseWidget ) } -void ownCloudGui::slotShowShareDialog(const QString &path, const bool &isDir) +void ownCloudGui::slotShowShareDialog(const QString &sharePath, const QString &localPath) { qDebug() << Q_FUNC_INFO << "Opening share dialog"; - ShareDialog *w = new ShareDialog(path, isDir); + ShareDialog *w = new ShareDialog(sharePath, localPath); w->getShares(); w->setAttribute( Qt::WA_DeleteOnClose, true ); w->show(); diff --git a/src/gui/owncloudgui.h b/src/gui/owncloudgui.h index ec6878e03..18dccae87 100644 --- a/src/gui/owncloudgui.h +++ b/src/gui/owncloudgui.h @@ -70,7 +70,7 @@ public slots: void slotHelp(); void slotOpenPath(const QString& path); void slotAccountStateChanged(); - void slotShowShareDialog(const QString &path, const bool &isDir); + void slotShowShareDialog(const QString &sharePath, const QString &localPath); private slots: void slotDisplayIdle(); diff --git a/src/gui/sharedialog.cpp b/src/gui/sharedialog.cpp index 00e8389ae..ccd422224 100644 --- a/src/gui/sharedialog.cpp +++ b/src/gui/sharedialog.cpp @@ -8,6 +8,7 @@ #include #include #include +#include namespace { int SHARETYPE_PUBLIC = 3; @@ -15,11 +16,11 @@ namespace { namespace OCC { -ShareDialog::ShareDialog(const QString &path, const bool &isDir, QWidget *parent) : +ShareDialog::ShareDialog(const QString &sharePath, const QString &localPath, QWidget *parent) : QDialog(parent), _ui(new Ui::ShareDialog), - _path(path), - _isDir(isDir) + _sharePath(sharePath), + _localPath(localPath) { setAttribute(Qt::WA_DeleteOnClose); _ui->setupUi(this); @@ -47,6 +48,20 @@ ShareDialog::ShareDialog(const QString &path, const bool &isDir, QWidget *parent _ui->checkBox_password->hide(); _ui->checkBox_expire->hide(); _ui->calendar->hide(); + + QFileInfo f_info(_localPath); + 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"); + } else { + _ui->lineEdit_name->setText(f_info.fileName()); + _ui->lineEdit_type->setText("File"); + } + _ui->lineEdit_localPath->setText(_localPath); + _ui->lineEdit_sharePath->setText(_sharePath); } void ShareDialog::setExpireDate(const QString &date) @@ -94,18 +109,6 @@ void ShareDialog::slotCalendarClicked(const QDate &date) ShareDialog::setExpireDate(date.toString("yyyy-MM-dd")); } -QString ShareDialog::getPath() -{ - return _path; -} - -void ShareDialog::setPath(const QString &path, const bool &isDir) -{ - _path = path; - _isDir = isDir; - ShareDialog::getShares(); -} - ShareDialog::~ShareDialog() { delete _ui; @@ -162,11 +165,11 @@ void ShareDialog::slotPasswordSet(const QString &reply) void ShareDialog::getShares() { - this->setWindowTitle(tr("Sharing %1").arg(_path)); + 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 > params; params.append(qMakePair(QString::fromLatin1("format"), QString::fromLatin1("json"))); - params.append(qMakePair(QString::fromLatin1("path"), _path)); + params.append(qMakePair(QString::fromLatin1("path"), _sharePath)); url.setQueryItems(params); OcsShareJob *job = new OcsShareJob("GET", url, QUrl(), AccountManager::instance()->account(), this); connect(job, SIGNAL(jobFinished(QString)), this, SLOT(slotSharesFetched(QString))); @@ -256,7 +259,7 @@ void ShareDialog::slotCheckBoxShareLinkClicked() QList > getParams; QList > postParams; getParams.append(qMakePair(QString::fromLatin1("format"), QString::fromLatin1("json"))); - postParams.append(qMakePair(QString::fromLatin1("path"), _path)); + postParams.append(qMakePair(QString::fromLatin1("path"), _sharePath)); postParams.append(qMakePair(QString::fromLatin1("shareType"), QString::number(SHARETYPE_PUBLIC))); url.setQueryItems(getParams); postData.setQueryItems(postParams); diff --git a/src/gui/sharedialog.h b/src/gui/sharedialog.h index fb645f095..540d837ff 100644 --- a/src/gui/sharedialog.h +++ b/src/gui/sharedialog.h @@ -51,11 +51,9 @@ class ShareDialog : public QDialog Q_OBJECT public: - explicit ShareDialog(const QString &path, const bool &isDir, QWidget *parent = 0); + explicit ShareDialog(const QString &sharePath, const QString &localPath, QWidget *parent = 0); ~ShareDialog(); void getShares(); - void setPath(const QString &path, const bool &isDir); - QString getPath(); private slots: void slotSharesFetched(const QString &reply); void slotCreateShareFetched(const QString &reply); @@ -69,8 +67,8 @@ private slots: void slotPasswordReturnPressed(); private: Ui::ShareDialog *_ui; - QString _path; - bool _isDir; + QString _sharePath; + QString _localPath; QList _shares; qulonglong _public_share_id; void setPassword(const QString &password); diff --git a/src/gui/sharedialog.ui b/src/gui/sharedialog.ui index dd77b88cf..804270885 100644 --- a/src/gui/sharedialog.ui +++ b/src/gui/sharedialog.ui @@ -6,8 +6,8 @@ 0 0 - 441 - 418 + 454 + 532 @@ -19,6 +19,119 @@ QLayout::SetFixedSize + + + + Share Info + + + + + + + + TextLabel + + + + + + + + + + 75 + true + + + + Name: + + + + + + + true + + + true + + + + + + + + 75 + true + + + + Type: + + + + + + + true + + + + + + + + 75 + true + + + + Local path: + + + + + + + true + + + true + + + + + + + + 75 + true + + + + OwnCloud Path: + + + + + + + true + + + true + + + + + + + + + + diff --git a/src/gui/socketapi.cpp b/src/gui/socketapi.cpp index d0778d4e7..752e8c20a 100644 --- a/src/gui/socketapi.cpp +++ b/src/gui/socketapi.cpp @@ -415,10 +415,9 @@ void SocketApi::command_SHARE(const QString& argument, SocketType* socket) const QString message = QLatin1String("SHARE:OK:")+QDir::toNativeSeparators(argument); sendMessage(socket, message); - QFileInfo info(argument); const QString folderForPath = shareFolder->path(); const QString path = shareFolder->remotePath() + argument.right(argument.count()-folderForPath.count()+1); - emit shareCommandReceived(path, info.isDir()); + emit shareCommandReceived(path, argument); } } diff --git a/src/gui/socketapi.h b/src/gui/socketapi.h index f486e7586..e313c9c6a 100644 --- a/src/gui/socketapi.h +++ b/src/gui/socketapi.h @@ -58,7 +58,7 @@ public slots: void slotClearExcludesList(); signals: - void shareCommandReceived(const QString &path, const bool &isDir); + void shareCommandReceived(const QString &sharePath, const QString &localPath); private slots: void slotNewConnection();