mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 15:06:08 +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,
|
||||
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()
|
||||
|
|
|
@ -52,10 +52,6 @@ ShareDialog::ShareDialog(QPointer<AccountState> 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> &linkShare)
|
|||
|
||||
connect(linkShare.data(), &Share::serverError, _linkWidgetList.at(index), &ShareLinkWidget::slotServerError);
|
||||
connect(linkShare.data(), &Share::shareDeleted, _linkWidgetList.at(index), &ShareLinkWidget::slotDeleteShareFetched);
|
||||
|
||||
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,14 +294,18 @@ void ShareDialog::showSharingUi()
|
|||
}
|
||||
|
||||
if (theme->linkSharing()) {
|
||||
if(_manager) {
|
||||
_manager->fetchShares(_sharePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShareDialog::slotCreateLinkShare()
|
||||
{
|
||||
if(_manager) {
|
||||
_manager->createLinkShare(_sharePath, QString(), QString());
|
||||
}
|
||||
}
|
||||
|
||||
void ShareDialog::slotLinkShareRequiresPassword()
|
||||
{
|
||||
|
@ -319,9 +322,11 @@ void ShareDialog::slotLinkShareRequiresPassword()
|
|||
return;
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -88,13 +88,14 @@ private:
|
|||
QByteArray _numericFileId;
|
||||
QString _privateLinkUrl;
|
||||
ShareDialogStartPage _startPage;
|
||||
ShareManager *_manager;
|
||||
ShareManager *_manager = nullptr;
|
||||
|
||||
QList<ShareLinkWidget*> _linkWidgetList;
|
||||
ShareLinkWidget* _emptyShareLinkWidget;
|
||||
ShareUserGroupWidget *_userGroupWidget;
|
||||
QProgressIndicator *_progressIndicator;
|
||||
ShareLinkWidget* _emptyShareLinkWidget = nullptr;
|
||||
ShareUserGroupWidget *_userGroupWidget = nullptr;
|
||||
QProgressIndicator *_progressIndicator = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
#endif // SHAREDIALOG_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();
|
||||
|
|
|
@ -43,8 +43,9 @@ ActivityListModel::ActivityListModel(AccountState *accountState, QObject *parent
|
|||
QHash<int, QByteArray> ActivityListModel::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> 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<QVariant> customList;
|
||||
foreach (ActivityLink customItem, a._links) {
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
MessageRole,
|
||||
DisplayPathRole,
|
||||
PathRole,
|
||||
AbsolutePathRole,
|
||||
LinkRole,
|
||||
PointInTimeRole,
|
||||
AccountConnectedRole,
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -160,5 +160,6 @@
|
|||
<file>theme/colored/Nextcloud-icon.svg</file>
|
||||
<file>theme/colored/Nextcloud-sidebar.svg</file>
|
||||
<file>theme/add.svg</file>
|
||||
<file>theme/share.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -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
|
||||
|
|
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