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);
}
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()));

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

View file

@ -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();

View file

@ -8,6 +8,7 @@
#include <QBuffer>
#include <QMovie>
#include <QMessageBox>
#include <QFileIconProvider>
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<QPair<QString, QString> > 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<QPair<QString, QString> > getParams;
QList<QPair<QString, QString> > 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);

View file

@ -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<QVariant> _shares;
qulonglong _public_share_id;
void setPassword(const QString &password);

View file

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

View file

@ -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();