mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 05:25:50 +03:00
Merge pull request #1940 from nextcloud/traywindow-listview-actions
Implemented share functionality in tray window and changed buttons
This commit is contained in:
commit
a80d0b0f0f
10 changed files with 92 additions and 53 deletions
|
@ -90,6 +90,11 @@ ownCloudGui::ownCloudGui(Application *parent)
|
||||||
connect(_tray.data(), &Systray::shutdown,
|
connect(_tray.data(), &Systray::shutdown,
|
||||||
this, &ownCloudGui::slotShutdown);
|
this, &ownCloudGui::slotShutdown);
|
||||||
|
|
||||||
|
connect(_tray.data(), &Systray::openShareDialog,
|
||||||
|
this, [=](const QString &sharePath, const QString &localPath) {
|
||||||
|
slotShowShareDialog(sharePath, localPath, ShareDialogStartPage::UsersAndGroups);
|
||||||
|
});
|
||||||
|
|
||||||
ProgressDispatcher *pd = ProgressDispatcher::instance();
|
ProgressDispatcher *pd = ProgressDispatcher::instance();
|
||||||
connect(pd, &ProgressDispatcher::progressInfo, this,
|
connect(pd, &ProgressDispatcher::progressInfo, this,
|
||||||
&ownCloudGui::slotUpdateProgress);
|
&ownCloudGui::slotUpdateProgress);
|
||||||
|
@ -104,7 +109,6 @@ ownCloudGui::ownCloudGui(Application *parent)
|
||||||
this, &ownCloudGui::slotShowOptionalTrayMessage);
|
this, &ownCloudGui::slotShowOptionalTrayMessage);
|
||||||
connect(Logger::instance(), &Logger::guiMessage,
|
connect(Logger::instance(), &Logger::guiMessage,
|
||||||
this, &ownCloudGui::slotShowGuiMessage);
|
this, &ownCloudGui::slotShowGuiMessage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ownCloudGui::createTray()
|
void ownCloudGui::createTray()
|
||||||
|
|
|
@ -52,10 +52,6 @@ ShareDialog::ShareDialog(QPointer<AccountState> accountState,
|
||||||
, _maxSharingPermissions(maxSharingPermissions)
|
, _maxSharingPermissions(maxSharingPermissions)
|
||||||
, _privateLinkUrl(accountState->account()->deprecatedPrivateLinkUrl(numericFileId).toString(QUrl::FullyEncoded))
|
, _privateLinkUrl(accountState->account()->deprecatedPrivateLinkUrl(numericFileId).toString(QUrl::FullyEncoded))
|
||||||
, _startPage(startPage)
|
, _startPage(startPage)
|
||||||
, _linkWidgetList({})
|
|
||||||
, _emptyShareLinkWidget(nullptr)
|
|
||||||
, _userGroupWidget(nullptr)
|
|
||||||
, _progressIndicator(nullptr)
|
|
||||||
{
|
{
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
@ -149,8 +145,11 @@ void ShareDialog::addLinkShareWidget(const QSharedPointer<LinkShare> &linkShare)
|
||||||
|
|
||||||
connect(linkShare.data(), &Share::serverError, _linkWidgetList.at(index), &ShareLinkWidget::slotServerError);
|
connect(linkShare.data(), &Share::serverError, _linkWidgetList.at(index), &ShareLinkWidget::slotServerError);
|
||||||
connect(linkShare.data(), &Share::shareDeleted, _linkWidgetList.at(index), &ShareLinkWidget::slotDeleteShareFetched);
|
connect(linkShare.data(), &Share::shareDeleted, _linkWidgetList.at(index), &ShareLinkWidget::slotDeleteShareFetched);
|
||||||
|
|
||||||
|
if(_manager) {
|
||||||
connect(_manager, &ShareManager::linkShareRequiresPassword, _linkWidgetList.at(index), &ShareLinkWidget::slotCreateShareRequiresPassword);
|
connect(_manager, &ShareManager::linkShareRequiresPassword, _linkWidgetList.at(index), &ShareLinkWidget::slotCreateShareRequiresPassword);
|
||||||
connect(_manager, &ShareManager::serverError, _linkWidgetList.at(index), &ShareLinkWidget::slotServerError);
|
connect(_manager, &ShareManager::serverError, _linkWidgetList.at(index), &ShareLinkWidget::slotServerError);
|
||||||
|
}
|
||||||
|
|
||||||
// Connect all shares signals to gui slots
|
// Connect all shares signals to gui slots
|
||||||
connect(this, &ShareDialog::toggleAnimation, _linkWidgetList.at(index), &ShareLinkWidget::slotToggleAnimation);
|
connect(this, &ShareDialog::toggleAnimation, _linkWidgetList.at(index), &ShareLinkWidget::slotToggleAnimation);
|
||||||
|
@ -295,14 +294,18 @@ void ShareDialog::showSharingUi()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theme->linkSharing()) {
|
if (theme->linkSharing()) {
|
||||||
|
if(_manager) {
|
||||||
_manager->fetchShares(_sharePath);
|
_manager->fetchShares(_sharePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ShareDialog::slotCreateLinkShare()
|
void ShareDialog::slotCreateLinkShare()
|
||||||
{
|
{
|
||||||
|
if(_manager) {
|
||||||
_manager->createLinkShare(_sharePath, QString(), QString());
|
_manager->createLinkShare(_sharePath, QString(), QString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ShareDialog::slotLinkShareRequiresPassword()
|
void ShareDialog::slotLinkShareRequiresPassword()
|
||||||
{
|
{
|
||||||
|
@ -319,9 +322,11 @@ void ShareDialog::slotLinkShareRequiresPassword()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(_manager) {
|
||||||
// Try to create the link share again with the newly entered password
|
// Try to create the link share again with the newly entered password
|
||||||
_manager->createLinkShare(_sharePath, QString(), password);
|
_manager->createLinkShare(_sharePath, QString(), password);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ShareDialog::slotDeleteShare()
|
void ShareDialog::slotDeleteShare()
|
||||||
{
|
{
|
||||||
|
@ -351,7 +356,7 @@ void ShareDialog::slotAccountStateChanged(int state)
|
||||||
bool enabled = (state == AccountState::State::Connected);
|
bool enabled = (state == AccountState::State::Connected);
|
||||||
qCDebug(lcSharing) << "Account connected?" << enabled;
|
qCDebug(lcSharing) << "Account connected?" << enabled;
|
||||||
|
|
||||||
if (_userGroupWidget != nullptr) {
|
if (_userGroupWidget) {
|
||||||
_userGroupWidget->setEnabled(enabled);
|
_userGroupWidget->setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,4 +383,4 @@ void ShareDialog::changeEvent(QEvent *e)
|
||||||
QDialog::changeEvent(e);
|
QDialog::changeEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace OCC
|
||||||
|
|
|
@ -88,13 +88,14 @@ private:
|
||||||
QByteArray _numericFileId;
|
QByteArray _numericFileId;
|
||||||
QString _privateLinkUrl;
|
QString _privateLinkUrl;
|
||||||
ShareDialogStartPage _startPage;
|
ShareDialogStartPage _startPage;
|
||||||
ShareManager *_manager;
|
ShareManager *_manager = nullptr;
|
||||||
|
|
||||||
QList<ShareLinkWidget*> _linkWidgetList;
|
QList<ShareLinkWidget*> _linkWidgetList;
|
||||||
ShareLinkWidget* _emptyShareLinkWidget;
|
ShareLinkWidget* _emptyShareLinkWidget = nullptr;
|
||||||
ShareUserGroupWidget *_userGroupWidget;
|
ShareUserGroupWidget *_userGroupWidget = nullptr;
|
||||||
QProgressIndicator *_progressIndicator;
|
QProgressIndicator *_progressIndicator = nullptr;
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
} // namespace OCC
|
||||||
|
|
||||||
#endif // SHAREDIALOG_H
|
#endif // SHAREDIALOG_H
|
||||||
|
|
|
@ -68,6 +68,7 @@ signals:
|
||||||
|
|
||||||
Q_INVOKABLE void hideWindow();
|
Q_INVOKABLE void hideWindow();
|
||||||
Q_INVOKABLE void showWindow();
|
Q_INVOKABLE void showWindow();
|
||||||
|
Q_INVOKABLE void openShareDialog(const QString &sharePath, const QString &localPath);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slotNewUserSelected();
|
void slotNewUserSelected();
|
||||||
|
|
|
@ -43,8 +43,9 @@ ActivityListModel::ActivityListModel(AccountState *accountState, QObject *parent
|
||||||
QHash<int, QByteArray> ActivityListModel::roleNames() const
|
QHash<int, QByteArray> ActivityListModel::roleNames() const
|
||||||
{
|
{
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
roles[DisplayPathRole] = "displaypath";
|
roles[DisplayPathRole] = "displayPath";
|
||||||
roles[PathRole] = "path";
|
roles[PathRole] = "path";
|
||||||
|
roles[AbsolutePathRole] = "absolutePath";
|
||||||
roles[LinkRole] = "link";
|
roles[LinkRole] = "link";
|
||||||
roles[MessageRole] = "message";
|
roles[MessageRole] = "message";
|
||||||
roles[ActionRole] = "type";
|
roles[ActionRole] = "type";
|
||||||
|
@ -107,6 +108,25 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
|
case AbsolutePathRole: {
|
||||||
|
const auto folder = FolderMan::instance()->folder(a._folder);
|
||||||
|
QString relPath(a._file);
|
||||||
|
if (!a._file.isEmpty()) {
|
||||||
|
if (folder) {
|
||||||
|
relPath.prepend(folder->remotePath());
|
||||||
|
}
|
||||||
|
list = FolderMan::instance()->findFileInLocalFolders(relPath, ast->account());
|
||||||
|
if (!list.empty()) {
|
||||||
|
return list.at(0);
|
||||||
|
} else {
|
||||||
|
qWarning("File not local folders while processing absolute path request.");
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qWarning("Received an absolute path request for an activity without a file path.");
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
case ActionsLinksRole: {
|
case ActionsLinksRole: {
|
||||||
QList<QVariant> customList;
|
QList<QVariant> customList;
|
||||||
foreach (ActivityLink customItem, a._links) {
|
foreach (ActivityLink customItem, a._links) {
|
||||||
|
|
|
@ -50,6 +50,7 @@ public:
|
||||||
MessageRole,
|
MessageRole,
|
||||||
DisplayPathRole,
|
DisplayPathRole,
|
||||||
PathRole,
|
PathRole,
|
||||||
|
AbsolutePathRole,
|
||||||
LinkRole,
|
LinkRole,
|
||||||
PointInTimeRole,
|
PointInTimeRole,
|
||||||
AccountConnectedRole,
|
AccountConnectedRole,
|
||||||
|
|
|
@ -554,22 +554,41 @@ Window {
|
||||||
height: Style.trayWindowHeaderHeight
|
height: Style.trayWindowHeaderHeight
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
enabled: (path !== "")
|
||||||
|
anchors.left: activityItem.left
|
||||||
|
anchors.right: ((shareButton.visible) ? shareButton.left : activityItem.right)
|
||||||
|
height: parent.height
|
||||||
|
anchors.margins: 2
|
||||||
|
hoverEnabled: true
|
||||||
|
onClicked: Qt.openUrlExternally(path)
|
||||||
|
ToolTip.visible: hovered
|
||||||
|
ToolTip.delay: 1000
|
||||||
|
ToolTip.text: qsTr("Open sync item locally")
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
color: (parent.containsMouse ? Style.lightHover : "transparent")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: activityIcon
|
id: activityIcon
|
||||||
|
anchors.left: activityItem.left
|
||||||
Layout.leftMargin: 8
|
anchors.leftMargin: 8
|
||||||
Layout.rightMargin: 8
|
anchors.rightMargin: 8
|
||||||
Layout.preferredWidth: activityButton1.icon.width
|
Layout.preferredWidth: shareButton.icon.width
|
||||||
Layout.preferredHeight: activityButton1.icon.height
|
Layout.preferredHeight: shareButton.icon.height
|
||||||
verticalAlignment: Qt.AlignCenter
|
verticalAlignment: Qt.AlignCenter
|
||||||
cache: true
|
cache: true
|
||||||
source: icon
|
source: icon
|
||||||
sourceSize.height: 64
|
sourceSize.height: 64
|
||||||
sourceSize.width: 64
|
sourceSize.width: 64
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: activityTextColumn
|
id: activityTextColumn
|
||||||
|
anchors.left: activityIcon.right
|
||||||
|
anchors.leftMargin: 8
|
||||||
spacing: 4
|
spacing: 4
|
||||||
Layout.alignment: Qt.AlignLeft
|
Layout.alignment: Qt.AlignLeft
|
||||||
Text {
|
Text {
|
||||||
|
@ -583,7 +602,9 @@ Window {
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: activityTextInfo
|
id: activityTextInfo
|
||||||
text: (type === "Activity" || type === "File" || type === "Sync") ? displaypath : message
|
text: (type === "Activity" || type === "Sync") ? displayPath
|
||||||
|
: (type === "File") ? subject
|
||||||
|
: message
|
||||||
height: (text === "") ? 0 : activityTextTitle.height
|
height: (text === "") ? 0 : activityTextTitle.height
|
||||||
width: Style.activityLabelBaseWidth + ((path === "") ? activityItem.height : 0) + ((link === "") ? activityItem.height : 0) - 8
|
width: Style.activityLabelBaseWidth + ((path === "") ? activityItem.height : 0) + ((link === "") ? activityItem.height : 0) - 8
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
|
@ -600,43 +621,26 @@ Window {
|
||||||
color: "#808080"
|
color: "#808080"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Item {
|
|
||||||
id: activityItemFiller
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
Button {
|
Button {
|
||||||
id: activityButton1
|
id: shareButton
|
||||||
|
anchors.right: activityItem.right
|
||||||
|
|
||||||
Layout.preferredWidth: (path === "") ? 0 : parent.height
|
Layout.preferredWidth: (path === "") ? 0 : parent.height
|
||||||
Layout.preferredHeight: parent.height
|
Layout.preferredHeight: parent.height
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
flat: true
|
flat: true
|
||||||
hoverEnabled: false
|
hoverEnabled: true
|
||||||
visible: (path === "") ? false : true
|
visible: (path === "") ? false : true
|
||||||
display: AbstractButton.IconOnly
|
display: AbstractButton.IconOnly
|
||||||
icon.source: "qrc:///client/theme/files.svg"
|
icon.source: "qrc:///client/theme/share.svg"
|
||||||
icon.color: "transparent"
|
icon.color: "transparent"
|
||||||
|
background: Rectangle {
|
||||||
onClicked: {
|
color: parent.hovered ? Style.lightHover : "transparent"
|
||||||
Qt.openUrlExternally(path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Button {
|
|
||||||
id: activityButton2
|
|
||||||
|
|
||||||
Layout.preferredWidth: (link === "") ? 0 : parent.height
|
|
||||||
Layout.preferredHeight: parent.height
|
|
||||||
Layout.alignment: Qt.AlignRight
|
|
||||||
flat: true
|
|
||||||
hoverEnabled: false
|
|
||||||
visible: (link === "") ? false : true
|
|
||||||
display: AbstractButton.IconOnly
|
|
||||||
icon.source: "qrc:///client/theme/public.svg"
|
|
||||||
icon.color: "transparent"
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
Qt.openUrlExternally(link)
|
|
||||||
}
|
}
|
||||||
|
ToolTip.visible: hovered
|
||||||
|
ToolTip.delay: 1000
|
||||||
|
ToolTip.text: qsTr("Open share dialog")
|
||||||
|
onClicked: systrayBackend.openShareDialog(displayPath,absolutePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,5 +160,6 @@
|
||||||
<file>theme/colored/Nextcloud-icon.svg</file>
|
<file>theme/colored/Nextcloud-icon.svg</file>
|
||||||
<file>theme/colored/Nextcloud-sidebar.svg</file>
|
<file>theme/colored/Nextcloud-sidebar.svg</file>
|
||||||
<file>theme/add.svg</file>
|
<file>theme/add.svg</file>
|
||||||
|
<file>theme/share.svg</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -7,6 +7,7 @@ QtObject {
|
||||||
// Colors
|
// Colors
|
||||||
property color ncBlue: "#0082c9"
|
property color ncBlue: "#0082c9"
|
||||||
property color ncBlueHover: "#009dd9"
|
property color ncBlueHover: "#009dd9"
|
||||||
|
property color lightHover: "#f7f7f7"
|
||||||
|
|
||||||
// Fonts
|
// Fonts
|
||||||
// We are using pixel size because this is cross platform comparable, point size isn't
|
// We are using pixel size because this is cross platform comparable, point size isn't
|
||||||
|
|
1
theme/share.svg
Normal file
1
theme/share.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" version="1.1" viewBox="0 0 16 16"><circle cx="3.5" cy="8" r="2.5"/><circle cy="12.5" cx="12.5" r="2.5"/><circle cx="12.5" cy="3.5" r="2.5"/><path d="m3.5 8 9 4.5m-9-4.5 9-4.5" stroke="#000" stroke-width="2" fill="none"/></svg>
|
After Width: | Height: | Size: 289 B |
Loading…
Reference in a new issue