Sharedialog: Show general info about a share

A start with some general share info in the share dialog.
This commit is contained in:
Roeland Jago Douma 2015-01-16 14:48:56 +01:00
parent 0fba4eee98
commit 71560ace71
8 changed files with 146 additions and 33 deletions

View file

@ -147,8 +147,8 @@ Application::Application(int &argc, char **argv) :
slotAccountStateAdded(ai); slotAccountStateAdded(ai);
} }
connect(FolderMan::instance()->socketApi(), SIGNAL(shareCommandReceived(QString, bool)), connect(FolderMan::instance()->socketApi(), SIGNAL(shareCommandReceived(QString, QString)),
_gui, SLOT(slotShowShareDialog(QString, bool))); _gui, SLOT(slotShowShareDialog(QString, QString)));
// startup procedure. // startup procedure.
connect(&_checkConnectionTimer, SIGNAL(timeout()), this, SLOT(slotCheckConnection())); connect(&_checkConnectionTimer, SIGNAL(timeout()), this, SLOT(slotCheckConnection()));

View file

@ -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"; qDebug() << Q_FUNC_INFO << "Opening share dialog";
ShareDialog *w = new ShareDialog(path, isDir); ShareDialog *w = new ShareDialog(sharePath, localPath);
w->getShares(); w->getShares();
w->setAttribute( Qt::WA_DeleteOnClose, true ); w->setAttribute( Qt::WA_DeleteOnClose, true );
w->show(); w->show();

View file

@ -70,7 +70,7 @@ public slots:
void slotHelp(); void slotHelp();
void slotOpenPath(const QString& path); void slotOpenPath(const QString& path);
void slotAccountStateChanged(); void slotAccountStateChanged();
void slotShowShareDialog(const QString &path, const bool &isDir); void slotShowShareDialog(const QString &sharePath, const QString &localPath);
private slots: private slots:
void slotDisplayIdle(); void slotDisplayIdle();

View file

@ -8,6 +8,7 @@
#include <QBuffer> #include <QBuffer>
#include <QMovie> #include <QMovie>
#include <QMessageBox> #include <QMessageBox>
#include <QFileIconProvider>
namespace { namespace {
int SHARETYPE_PUBLIC = 3; int SHARETYPE_PUBLIC = 3;
@ -15,11 +16,11 @@ namespace {
namespace OCC { namespace OCC {
ShareDialog::ShareDialog(const QString &path, const bool &isDir, QWidget *parent) : ShareDialog::ShareDialog(const QString &sharePath, const QString &localPath, QWidget *parent) :
QDialog(parent), QDialog(parent),
_ui(new Ui::ShareDialog), _ui(new Ui::ShareDialog),
_path(path), _sharePath(sharePath),
_isDir(isDir) _localPath(localPath)
{ {
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
_ui->setupUi(this); _ui->setupUi(this);
@ -47,6 +48,20 @@ ShareDialog::ShareDialog(const QString &path, const bool &isDir, QWidget *parent
_ui->checkBox_password->hide(); _ui->checkBox_password->hide();
_ui->checkBox_expire->hide(); _ui->checkBox_expire->hide();
_ui->calendar->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) void ShareDialog::setExpireDate(const QString &date)
@ -94,18 +109,6 @@ void ShareDialog::slotCalendarClicked(const QDate &date)
ShareDialog::setExpireDate(date.toString("yyyy-MM-dd")); 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() ShareDialog::~ShareDialog()
{ {
delete _ui; delete _ui;
@ -162,11 +165,11 @@ void ShareDialog::slotPasswordSet(const QString &reply)
void ShareDialog::getShares() 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")); QUrl url = Account::concatUrlPath(AccountManager::instance()->account()->url(), QLatin1String("ocs/v1.php/apps/files_sharing/api/v1/shares"));
QList<QPair<QString, QString> > params; QList<QPair<QString, QString> > params;
params.append(qMakePair(QString::fromLatin1("format"), QString::fromLatin1("json"))); 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); url.setQueryItems(params);
OcsShareJob *job = new OcsShareJob("GET", url, QUrl(), AccountManager::instance()->account(), this); OcsShareJob *job = new OcsShareJob("GET", url, QUrl(), AccountManager::instance()->account(), this);
connect(job, SIGNAL(jobFinished(QString)), this, SLOT(slotSharesFetched(QString))); connect(job, SIGNAL(jobFinished(QString)), this, SLOT(slotSharesFetched(QString)));
@ -256,7 +259,7 @@ void ShareDialog::slotCheckBoxShareLinkClicked()
QList<QPair<QString, QString> > getParams; QList<QPair<QString, QString> > getParams;
QList<QPair<QString, QString> > postParams; QList<QPair<QString, QString> > postParams;
getParams.append(qMakePair(QString::fromLatin1("format"), QString::fromLatin1("json"))); 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))); postParams.append(qMakePair(QString::fromLatin1("shareType"), QString::number(SHARETYPE_PUBLIC)));
url.setQueryItems(getParams); url.setQueryItems(getParams);
postData.setQueryItems(postParams); postData.setQueryItems(postParams);

View file

@ -51,11 +51,9 @@ class ShareDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit ShareDialog(const QString &path, const bool &isDir, QWidget *parent = 0); explicit ShareDialog(const QString &sharePath, const QString &localPath, QWidget *parent = 0);
~ShareDialog(); ~ShareDialog();
void getShares(); void getShares();
void setPath(const QString &path, const bool &isDir);
QString getPath();
private slots: private slots:
void slotSharesFetched(const QString &reply); void slotSharesFetched(const QString &reply);
void slotCreateShareFetched(const QString &reply); void slotCreateShareFetched(const QString &reply);
@ -69,8 +67,8 @@ private slots:
void slotPasswordReturnPressed(); void slotPasswordReturnPressed();
private: private:
Ui::ShareDialog *_ui; Ui::ShareDialog *_ui;
QString _path; QString _sharePath;
bool _isDir; QString _localPath;
QList<QVariant> _shares; QList<QVariant> _shares;
qulonglong _public_share_id; qulonglong _public_share_id;
void setPassword(const QString &password); void setPassword(const QString &password);

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>441</width> <width>454</width>
<height>418</height> <height>532</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -19,6 +19,119 @@
<property name="sizeConstraint"> <property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum> <enum>QLayout::SetFixedSize</enum>
</property> </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> <item>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>

View file

@ -415,10 +415,9 @@ void SocketApi::command_SHARE(const QString& argument, SocketType* socket)
const QString message = QLatin1String("SHARE:OK:")+QDir::toNativeSeparators(argument); const QString message = QLatin1String("SHARE:OK:")+QDir::toNativeSeparators(argument);
sendMessage(socket, message); sendMessage(socket, message);
QFileInfo info(argument);
const QString folderForPath = shareFolder->path(); const QString folderForPath = shareFolder->path();
const QString path = shareFolder->remotePath() + argument.right(argument.count()-folderForPath.count()+1); const QString path = shareFolder->remotePath() + argument.right(argument.count()-folderForPath.count()+1);
emit shareCommandReceived(path, info.isDir()); emit shareCommandReceived(path, argument);
} }
} }

View file

@ -58,7 +58,7 @@ public slots:
void slotClearExcludesList(); void slotClearExcludesList();
signals: signals:
void shareCommandReceived(const QString &path, const bool &isDir); void shareCommandReceived(const QString &sharePath, const QString &localPath);
private slots: private slots:
void slotNewConnection(); void slotNewConnection();