mirror of https://github.com/nextcloud/desktop
Add ability to copy internal link from share dialog
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
This commit is contained in:
parent
d0364e697a
commit
624213956e
|
@ -27,6 +27,7 @@ set(theme_dir ${CMAKE_SOURCE_DIR}/theme)
|
|||
set(client_UI_SRCS
|
||||
accountsettings.ui
|
||||
conflictdialog.ui
|
||||
internallinkwidget.ui
|
||||
invalidfilenamedialog.ui
|
||||
foldercreationdialog.ui
|
||||
folderwizardsourcepage.ui
|
||||
|
@ -80,6 +81,7 @@ set(client_SRCS
|
|||
folderwizard.cpp
|
||||
generalsettings.cpp
|
||||
legalnotice.cpp
|
||||
internallinkwidget.cpp
|
||||
ignorelisteditor.cpp
|
||||
ignorelisttablewidget.cpp
|
||||
lockwatcher.cpp
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* Copyright (C) 2022 by Claudio Cambra <claudio.cambra@nextcloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include "internallinkwidget.h"
|
||||
#include "accountstate.h"
|
||||
#include "folderman.h"
|
||||
#include "theme.h"
|
||||
|
||||
#include "QProgressIndicator.h"
|
||||
#include <QClipboard>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
Q_LOGGING_CATEGORY(lcInternalLink, "nextcloud.gui.internallink", QtInfoMsg)
|
||||
|
||||
InternalLinkWidget::InternalLinkWidget(const QString &localPath,
|
||||
QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, _localPath(localPath)
|
||||
{
|
||||
_ui->setupUi(this);
|
||||
|
||||
const auto folder = FolderMan::instance()->folderForPath(_localPath);
|
||||
const auto folderRelativePath = _localPath.mid(folder->cleanPath().length() + 1);
|
||||
const auto serverRelativePath = QDir(folder->remotePath()).filePath(folderRelativePath);
|
||||
|
||||
const auto bindLinkSlot = [this](QString link) { slotLinkFetched(link); };
|
||||
|
||||
fetchPrivateLinkUrl(
|
||||
folder->accountState()->account(),
|
||||
serverRelativePath,
|
||||
{},
|
||||
this,
|
||||
bindLinkSlot
|
||||
);
|
||||
|
||||
_ui->copyInternalLinkButton->setEnabled(false);
|
||||
_ui->internalLinkProgressIndicator->setVisible(true);
|
||||
_ui->internalLinkProgressIndicator->startAnimation();
|
||||
|
||||
connect(_ui->copyInternalLinkButton, &QPushButton::clicked, this, &InternalLinkWidget::slotCopyInternalLink);
|
||||
}
|
||||
|
||||
void InternalLinkWidget::slotLinkFetched(const QString &url)
|
||||
{
|
||||
_internalUrl = url;
|
||||
_ui->copyInternalLinkButton->setEnabled(true);
|
||||
_ui->internalLinkProgressIndicator->setVisible(false);
|
||||
_ui->internalLinkProgressIndicator->stopAnimation();
|
||||
_ui->horizontalSpacer->changeSize(0, 0);
|
||||
_ui->horizontalSpacer_2->changeSize(0, 0);
|
||||
}
|
||||
|
||||
void InternalLinkWidget::slotCopyInternalLink() const
|
||||
{
|
||||
QApplication::clipboard()->setText(_internalUrl);
|
||||
}
|
||||
|
||||
void InternalLinkWidget::setupUiOptions()
|
||||
{
|
||||
customizeStyle();
|
||||
}
|
||||
|
||||
void InternalLinkWidget::slotStyleChanged()
|
||||
{
|
||||
customizeStyle();
|
||||
}
|
||||
|
||||
void InternalLinkWidget::customizeStyle()
|
||||
{
|
||||
_ui->copyInternalLinkButton->setIcon(Theme::createColorAwareIcon(":/client/theme/copy.svg"));
|
||||
_ui->internalLinkIconLabel->setPixmap(Theme::createColorAwarePixmap(":/client/theme/external.svg"));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (C) 2022 by Claudio Cambra <claudio.cambra@nextcloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef INTERNALLINKWIDGET_H
|
||||
#define INTERNALLINKWIDGET_H
|
||||
|
||||
#include "QProgressIndicator.h"
|
||||
#include <QList>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "ui_internallinkwidget.h"
|
||||
|
||||
namespace OCC {
|
||||
|
||||
/**
|
||||
* @brief The ShareDialog class
|
||||
* @ingroup gui
|
||||
*/
|
||||
class InternalLinkWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InternalLinkWidget(const QString &localPath,
|
||||
QWidget *parent = nullptr);
|
||||
~InternalLinkWidget() override = default;
|
||||
|
||||
void setupUiOptions();
|
||||
|
||||
public slots:
|
||||
void slotStyleChanged();
|
||||
|
||||
private slots:
|
||||
void slotLinkFetched(const QString &url);
|
||||
void slotCopyInternalLink() const;
|
||||
|
||||
private:
|
||||
void customizeStyle();
|
||||
|
||||
std::unique_ptr<Ui::InternalLinkWidget> _ui = std::make_unique<Ui::InternalLinkWidget>();
|
||||
QString _localPath;
|
||||
QString _internalUrl;
|
||||
|
||||
QPushButton *_copyInternalLinkButton{};
|
||||
};
|
||||
}
|
||||
|
||||
#endif // INTERNALLINKWIDGET_H
|
|
@ -0,0 +1,168 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OCC::InternalLinkWidget</class>
|
||||
<widget class="QWidget" name="OCC::InternalLinkWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>238</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="internalLinkIconLabel">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../../theme.qrc">:/client/theme/external.svg</pixmap>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalTextLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="internalLinkLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Internal link</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="infoMessage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(118, 118, 118)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Only works for users with access to this folder</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QProgressIndicator" name="internalLinkProgressIndicator" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>27</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="copyInternalLinkButton">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../theme.qrc">
|
||||
<normaloff>:/client/theme/copy.svg</normaloff>:/client/theme/copy.svg</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QProgressIndicator</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>QProgressIndicator.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../theme.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -16,6 +16,7 @@
|
|||
#include "sharedialog.h"
|
||||
#include "sharee.h"
|
||||
#include "sharelinkwidget.h"
|
||||
#include "internallinkwidget.h"
|
||||
#include "shareusergroupwidget.h"
|
||||
#include "passwordinputdialog.h"
|
||||
|
||||
|
@ -142,6 +143,11 @@ ShareDialog::ShareDialog(QPointer<AccountState> accountState,
|
|||
_scrollAreaLayout = new QVBoxLayout(_scrollAreaViewPort);
|
||||
_scrollAreaLayout->setContentsMargins(0, 0, 0, 0);
|
||||
_ui->scrollArea->setWidget(_scrollAreaViewPort);
|
||||
|
||||
_internalLinkWidget = new InternalLinkWidget(localPath, this);
|
||||
_ui->verticalLayout->addWidget(_internalLinkWidget);
|
||||
_internalLinkWidget->setupUiOptions();
|
||||
connect(this, &ShareDialog::styleChanged, _internalLinkWidget, &InternalLinkWidget::slotStyleChanged);
|
||||
}
|
||||
|
||||
ShareLinkWidget *ShareDialog::addLinkShareWidget(const QSharedPointer<LinkShare> &linkShare)
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace Ui {
|
|||
}
|
||||
|
||||
class ShareLinkWidget;
|
||||
class InternalLinkWidget;
|
||||
class ShareUserGroupWidget;
|
||||
class ShareManager;
|
||||
class LinkShare;
|
||||
|
@ -96,6 +97,7 @@ private:
|
|||
|
||||
QList<ShareLinkWidget*> _linkWidgetList;
|
||||
ShareLinkWidget* _emptyShareLinkWidget = nullptr;
|
||||
InternalLinkWidget* _internalLinkWidget = nullptr;
|
||||
ShareUserGroupWidget *_userGroupWidget = nullptr;
|
||||
QProgressIndicator *_progressIndicator = nullptr;
|
||||
|
||||
|
|
|
@ -202,6 +202,7 @@
|
|||
<file>theme/share.svg</file>
|
||||
<file>theme/reply.svg</file>
|
||||
<file>theme/magnifying-glass.svg</file>
|
||||
<file>theme/external.svg</file>
|
||||
<file>theme/colored/user-status-online.svg</file>
|
||||
<file>theme/colored/user-status-invisible.svg</file>
|
||||
<file>theme/colored/user-status-away.svg</file>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M3.2 2C2.53 2 2 2.54 2 3.2v9.6c0 .67.53 1.2 1.2 1.2h9.6c.67 0 1.2-.53 1.2-1.2V8.98l-1.2-1.2v5.02H3.2V3.2h5.02L7.08 2.06 7.02 2H3.2z"/><path d="M8.14 1l2.29 2.29L7 6.7 9.29 9l3.42-3.43L15 7.86V1z"/></svg>
|
After Width: | Height: | Size: 275 B |
Loading…
Reference in New Issue