diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index 5d6cb4160..d0f49c683 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -90,6 +90,11 @@ ownCloudGui::ownCloudGui(Application *parent) connect(_tray.data(), &Systray::shutdown, this, &ownCloudGui::slotShutdown); + connect(_tray.data(), &Systray::openShareDialog, + this, [=](const QString &sharePath, const QString &localPath) { + slotShowShareDialog(sharePath, localPath, ShareDialogStartPage::UsersAndGroups); + }); + ProgressDispatcher *pd = ProgressDispatcher::instance(); connect(pd, &ProgressDispatcher::progressInfo, this, &ownCloudGui::slotUpdateProgress); @@ -104,7 +109,6 @@ ownCloudGui::ownCloudGui(Application *parent) this, &ownCloudGui::slotShowOptionalTrayMessage); connect(Logger::instance(), &Logger::guiMessage, this, &ownCloudGui::slotShowGuiMessage); - } void ownCloudGui::createTray() diff --git a/src/gui/sharedialog.cpp b/src/gui/sharedialog.cpp index 91081e057..7064a8ffd 100644 --- a/src/gui/sharedialog.cpp +++ b/src/gui/sharedialog.cpp @@ -52,10 +52,6 @@ ShareDialog::ShareDialog(QPointer accountState, , _maxSharingPermissions(maxSharingPermissions) , _privateLinkUrl(accountState->account()->deprecatedPrivateLinkUrl(numericFileId).toString(QUrl::FullyEncoded)) , _startPage(startPage) - , _linkWidgetList({}) - , _emptyShareLinkWidget(nullptr) - , _userGroupWidget(nullptr) - , _progressIndicator(nullptr) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setAttribute(Qt::WA_DeleteOnClose); @@ -149,8 +145,11 @@ void ShareDialog::addLinkShareWidget(const QSharedPointer &linkShare) connect(linkShare.data(), &Share::serverError, _linkWidgetList.at(index), &ShareLinkWidget::slotServerError); connect(linkShare.data(), &Share::shareDeleted, _linkWidgetList.at(index), &ShareLinkWidget::slotDeleteShareFetched); - connect(_manager, &ShareManager::linkShareRequiresPassword, _linkWidgetList.at(index), &ShareLinkWidget::slotCreateShareRequiresPassword); - connect(_manager, &ShareManager::serverError, _linkWidgetList.at(index), &ShareLinkWidget::slotServerError); + + if(_manager) { + connect(_manager, &ShareManager::linkShareRequiresPassword, _linkWidgetList.at(index), &ShareLinkWidget::slotCreateShareRequiresPassword); + connect(_manager, &ShareManager::serverError, _linkWidgetList.at(index), &ShareLinkWidget::slotServerError); + } // Connect all shares signals to gui slots connect(this, &ShareDialog::toggleAnimation, _linkWidgetList.at(index), &ShareLinkWidget::slotToggleAnimation); @@ -295,13 +294,17 @@ void ShareDialog::showSharingUi() } if (theme->linkSharing()) { - _manager->fetchShares(_sharePath); + if(_manager) { + _manager->fetchShares(_sharePath); + } } } void ShareDialog::slotCreateLinkShare() { - _manager->createLinkShare(_sharePath, QString(), QString()); + if(_manager) { + _manager->createLinkShare(_sharePath, QString(), QString()); + } } void ShareDialog::slotLinkShareRequiresPassword() @@ -319,8 +322,10 @@ void ShareDialog::slotLinkShareRequiresPassword() return; } - // Try to create the link share again with the newly entered password - _manager->createLinkShare(_sharePath, QString(), password); + if(_manager) { + // Try to create the link share again with the newly entered password + _manager->createLinkShare(_sharePath, QString(), password); + } } void ShareDialog::slotDeleteShare() @@ -351,7 +356,7 @@ void ShareDialog::slotAccountStateChanged(int state) bool enabled = (state == AccountState::State::Connected); qCDebug(lcSharing) << "Account connected?" << enabled; - if (_userGroupWidget != nullptr) { + if (_userGroupWidget) { _userGroupWidget->setEnabled(enabled); } @@ -378,4 +383,4 @@ void ShareDialog::changeEvent(QEvent *e) QDialog::changeEvent(e); } -} +} // namespace OCC diff --git a/src/gui/sharedialog.h b/src/gui/sharedialog.h index 849dc6ec5..019f316a7 100644 --- a/src/gui/sharedialog.h +++ b/src/gui/sharedialog.h @@ -88,13 +88,14 @@ private: QByteArray _numericFileId; QString _privateLinkUrl; ShareDialogStartPage _startPage; - ShareManager *_manager; + ShareManager *_manager = nullptr; QList _linkWidgetList; - ShareLinkWidget* _emptyShareLinkWidget; - ShareUserGroupWidget *_userGroupWidget; - QProgressIndicator *_progressIndicator; + ShareLinkWidget* _emptyShareLinkWidget = nullptr; + ShareUserGroupWidget *_userGroupWidget = nullptr; + QProgressIndicator *_progressIndicator = nullptr; }; -} + +} // namespace OCC #endif // SHAREDIALOG_H diff --git a/src/gui/systray.h b/src/gui/systray.h index 8ec154d3d..6d55ca36f 100644 --- a/src/gui/systray.h +++ b/src/gui/systray.h @@ -68,6 +68,7 @@ signals: Q_INVOKABLE void hideWindow(); Q_INVOKABLE void showWindow(); + Q_INVOKABLE void openShareDialog(const QString &sharePath, const QString &localPath); public slots: void slotNewUserSelected(); diff --git a/src/gui/tray/ActivityListModel.cpp b/src/gui/tray/ActivityListModel.cpp index a5ec6f034..1aea5ee1c 100644 --- a/src/gui/tray/ActivityListModel.cpp +++ b/src/gui/tray/ActivityListModel.cpp @@ -43,8 +43,9 @@ ActivityListModel::ActivityListModel(AccountState *accountState, QObject *parent QHash ActivityListModel::roleNames() const { QHash roles; - roles[DisplayPathRole] = "displaypath"; + roles[DisplayPathRole] = "displayPath"; roles[PathRole] = "path"; + roles[AbsolutePathRole] = "absolutePath"; roles[LinkRole] = "link"; roles[MessageRole] = "message"; roles[ActionRole] = "type"; @@ -107,6 +108,25 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const } } 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: { QList customList; foreach (ActivityLink customItem, a._links) { diff --git a/src/gui/tray/ActivityListModel.h b/src/gui/tray/ActivityListModel.h index 37a766907..8f6fba4e2 100644 --- a/src/gui/tray/ActivityListModel.h +++ b/src/gui/tray/ActivityListModel.h @@ -50,6 +50,7 @@ public: MessageRole, DisplayPathRole, PathRole, + AbsolutePathRole, LinkRole, PointInTimeRole, AccountConnectedRole, diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml index fe699a225..d8fa79dc4 100644 --- a/src/gui/tray/Window.qml +++ b/src/gui/tray/Window.qml @@ -554,22 +554,41 @@ Window { height: Style.trayWindowHeaderHeight 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 { id: activityIcon - - Layout.leftMargin: 8 - Layout.rightMargin: 8 - Layout.preferredWidth: activityButton1.icon.width - Layout.preferredHeight: activityButton1.icon.height + anchors.left: activityItem.left + anchors.leftMargin: 8 + anchors.rightMargin: 8 + Layout.preferredWidth: shareButton.icon.width + Layout.preferredHeight: shareButton.icon.height verticalAlignment: Qt.AlignCenter cache: true source: icon sourceSize.height: 64 sourceSize.width: 64 } + Column { id: activityTextColumn - + anchors.left: activityIcon.right + anchors.leftMargin: 8 spacing: 4 Layout.alignment: Qt.AlignLeft Text { @@ -583,7 +602,9 @@ Window { Text { 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 width: Style.activityLabelBaseWidth + ((path === "") ? activityItem.height : 0) + ((link === "") ? activityItem.height : 0) - 8 elide: Text.ElideRight @@ -600,43 +621,26 @@ Window { color: "#808080" } } - Item { - id: activityItemFiller - Layout.fillWidth: true - } Button { - id: activityButton1 + id: shareButton + anchors.right: activityItem.right Layout.preferredWidth: (path === "") ? 0 : parent.height Layout.preferredHeight: parent.height Layout.alignment: Qt.AlignRight flat: true - hoverEnabled: false + hoverEnabled: true visible: (path === "") ? false : true display: AbstractButton.IconOnly - icon.source: "qrc:///client/theme/files.svg" + icon.source: "qrc:///client/theme/share.svg" icon.color: "transparent" - - onClicked: { - 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) + background: Rectangle { + color: parent.hovered ? Style.lightHover : "transparent" } + ToolTip.visible: hovered + ToolTip.delay: 1000 + ToolTip.text: qsTr("Open share dialog") + onClicked: systrayBackend.openShareDialog(displayPath,absolutePath) } } diff --git a/theme.qrc b/theme.qrc index 491c602f0..8ec17e8b3 100644 --- a/theme.qrc +++ b/theme.qrc @@ -160,5 +160,6 @@ theme/colored/Nextcloud-icon.svg theme/colored/Nextcloud-sidebar.svg theme/add.svg + theme/share.svg diff --git a/theme/Style/Style.qml b/theme/Style/Style.qml index 9d848bb07..5c173a917 100644 --- a/theme/Style/Style.qml +++ b/theme/Style/Style.qml @@ -7,6 +7,7 @@ QtObject { // Colors property color ncBlue: "#0082c9" property color ncBlueHover: "#009dd9" + property color lightHover: "#f7f7f7" // Fonts // We are using pixel size because this is cross platform comparable, point size isn't diff --git a/theme/share.svg b/theme/share.svg new file mode 100644 index 000000000..f8256230a --- /dev/null +++ b/theme/share.svg @@ -0,0 +1 @@ + \ No newline at end of file