mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-28 11:48:56 +03:00
Qt5.5 compatiblity patch for login flow V2 + UI improvment
Removes the right-click function for the "Re-open browser" buttons because they are not intuitive for the user. Adds a dedicated "Copy link" button. Implements Qt 5.5 fixes based on: https://github.com/nextcloud/desktop/pull/1392 Signed-off-by: Michael Schuster <michael@schuster.ms>
This commit is contained in:
parent
0e8c6a176b
commit
b792a627e2
9 changed files with 104 additions and 47 deletions
|
@ -46,21 +46,8 @@ Flow2AuthCredsPage::Flow2AuthCredsPage()
|
||||||
setTitle(WizardCommon::titleTemplate().arg(tr("Connect to %1").arg(Theme::instance()->appNameGUI())));
|
setTitle(WizardCommon::titleTemplate().arg(tr("Connect to %1").arg(Theme::instance()->appNameGUI())));
|
||||||
setSubTitle(WizardCommon::subTitleTemplate().arg(tr("Login in your browser (Login Flow v2)")));
|
setSubTitle(WizardCommon::subTitleTemplate().arg(tr("Login in your browser (Login Flow v2)")));
|
||||||
|
|
||||||
connect(_ui.openLinkButton, &QCommandLinkButton::clicked, [this] {
|
connect(_ui.openLinkButton, &QCommandLinkButton::clicked, this, &Flow2AuthCredsPage::slotOpenBrowser);
|
||||||
_ui.errorLabel->hide();
|
connect(_ui.copyLinkButton, &QCommandLinkButton::clicked, this, &Flow2AuthCredsPage::slotCopyLinkToClipboard);
|
||||||
if (_asyncAuth)
|
|
||||||
_asyncAuth->openBrowser();
|
|
||||||
});
|
|
||||||
_ui.openLinkButton->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
||||||
QObject::connect(_ui.openLinkButton, &QWidget::customContextMenuRequested, [this](const QPoint &pos) {
|
|
||||||
auto menu = new QMenu(_ui.openLinkButton);
|
|
||||||
menu->addAction(tr("Copy link to clipboard"), this, [this] {
|
|
||||||
if (_asyncAuth)
|
|
||||||
QApplication::clipboard()->setText(_asyncAuth->authorisationLink().toString(QUrl::FullyEncoded));
|
|
||||||
});
|
|
||||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
menu->popup(_ui.openLinkButton->mapToGlobal(pos));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Flow2AuthCredsPage::initializePage()
|
void Flow2AuthCredsPage::initializePage()
|
||||||
|
@ -146,4 +133,19 @@ bool Flow2AuthCredsPage::isComplete() const
|
||||||
return false; /* We can never go forward manually */
|
return false; /* We can never go forward manually */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Flow2AuthCredsPage::slotOpenBrowser()
|
||||||
|
{
|
||||||
|
if (_ui.errorLabel)
|
||||||
|
_ui.errorLabel->hide();
|
||||||
|
|
||||||
|
if (_asyncAuth)
|
||||||
|
_asyncAuth->openBrowser();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Flow2AuthCredsPage::slotCopyLinkToClipboard()
|
||||||
|
{
|
||||||
|
if (_asyncAuth)
|
||||||
|
QApplication::clipboard()->setText(_asyncAuth->authorisationLink().toString(QUrl::FullyEncoded));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace OCC
|
} // namespace OCC
|
||||||
|
|
|
@ -56,6 +56,10 @@ public:
|
||||||
QString _appPassword;
|
QString _appPassword;
|
||||||
QScopedPointer<Flow2Auth> _asyncAuth;
|
QScopedPointer<Flow2Auth> _asyncAuth;
|
||||||
Ui_Flow2AuthCredsPage _ui;
|
Ui_Flow2AuthCredsPage _ui;
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void slotOpenBrowser();
|
||||||
|
void slotCopyLinkToClipboard();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace OCC
|
} // namespace OCC
|
||||||
|
|
|
@ -53,7 +53,20 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCommandLinkButton" name="openLinkButton">
|
<widget class="QCommandLinkButton" name="openLinkButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Re-open Browser (or right-click to copy link)</string>
|
<string>Re-open Browser</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCommandLinkButton" name="copyLinkButton">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>50</weight>
|
||||||
|
<bold>false</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Copy link</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -50,21 +50,8 @@ Flow2AuthWidget::Flow2AuthWidget(Account *account, QWidget *parent)
|
||||||
|
|
||||||
WizardCommon::initErrorLabel(_ui.errorLabel);
|
WizardCommon::initErrorLabel(_ui.errorLabel);
|
||||||
|
|
||||||
connect(_ui.openLinkButton, &QCommandLinkButton::clicked, [this] {
|
connect(_ui.openLinkButton, &QCommandLinkButton::clicked, this, &Flow2AuthWidget::slotOpenBrowser);
|
||||||
_ui.errorLabel->hide();
|
connect(_ui.copyLinkButton, &QCommandLinkButton::clicked, this, &Flow2AuthWidget::slotCopyLinkToClipboard);
|
||||||
if (_asyncAuth)
|
|
||||||
_asyncAuth->openBrowser();
|
|
||||||
});
|
|
||||||
_ui.openLinkButton->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
||||||
QObject::connect(_ui.openLinkButton, &QWidget::customContextMenuRequested, [this](const QPoint &pos) {
|
|
||||||
auto menu = new QMenu(_ui.openLinkButton);
|
|
||||||
menu->addAction(tr("Copy link to clipboard"), this, [this] {
|
|
||||||
if (_asyncAuth)
|
|
||||||
QApplication::clipboard()->setText(_asyncAuth->authorisationLink().toString(QUrl::FullyEncoded));
|
|
||||||
});
|
|
||||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
menu->popup(_ui.openLinkButton->mapToGlobal(pos));
|
|
||||||
});
|
|
||||||
|
|
||||||
_asyncAuth.reset(new Flow2Auth(_account, this));
|
_asyncAuth.reset(new Flow2Auth(_account, this));
|
||||||
connect(_asyncAuth.data(), &Flow2Auth::result, this, &Flow2AuthWidget::asyncAuthResult, Qt::QueuedConnection);
|
connect(_asyncAuth.data(), &Flow2Auth::result, this, &Flow2AuthWidget::asyncAuthResult, Qt::QueuedConnection);
|
||||||
|
@ -110,4 +97,19 @@ Flow2AuthWidget::~Flow2AuthWidget() {
|
||||||
_user.clear();
|
_user.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Flow2AuthWidget::slotOpenBrowser()
|
||||||
|
{
|
||||||
|
if (_ui.errorLabel)
|
||||||
|
_ui.errorLabel->hide();
|
||||||
|
|
||||||
|
if (_asyncAuth)
|
||||||
|
_asyncAuth->openBrowser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Flow2AuthWidget::slotCopyLinkToClipboard()
|
||||||
|
{
|
||||||
|
if (_asyncAuth)
|
||||||
|
QApplication::clipboard()->setText(_asyncAuth->authorisationLink().toString(QUrl::FullyEncoded));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace OCC
|
||||||
|
|
|
@ -45,6 +45,10 @@ private:
|
||||||
QString _appPassword;
|
QString _appPassword;
|
||||||
QScopedPointer<Flow2Auth> _asyncAuth;
|
QScopedPointer<Flow2Auth> _asyncAuth;
|
||||||
Ui_Flow2AuthWidget _ui;
|
Ui_Flow2AuthWidget _ui;
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void slotOpenBrowser();
|
||||||
|
void slotCopyLinkToClipboard();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,20 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCommandLinkButton" name="openLinkButton">
|
<widget class="QCommandLinkButton" name="openLinkButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Re-open Browser (or right-click to copy link)</string>
|
<string>Re-open Browser</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCommandLinkButton" name="copyLinkButton">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>50</weight>
|
||||||
|
<bold>false</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Copy link</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -45,21 +45,8 @@ OwncloudOAuthCredsPage::OwncloudOAuthCredsPage()
|
||||||
setTitle(WizardCommon::titleTemplate().arg(tr("Connect to %1").arg(Theme::instance()->appNameGUI())));
|
setTitle(WizardCommon::titleTemplate().arg(tr("Connect to %1").arg(Theme::instance()->appNameGUI())));
|
||||||
setSubTitle(WizardCommon::subTitleTemplate().arg(tr("Login in your browser")));
|
setSubTitle(WizardCommon::subTitleTemplate().arg(tr("Login in your browser")));
|
||||||
|
|
||||||
connect(_ui.openLinkButton, &QCommandLinkButton::clicked, [this] {
|
connect(_ui.openLinkButton, &QCommandLinkButton::clicked, this, &OwncloudOAuthCredsPage::slotOpenBrowser);
|
||||||
_ui.errorLabel->hide();
|
connect(_ui.copyLinkButton, &QCommandLinkButton::clicked, this, &OwncloudOAuthCredsPage::slotCopyLinkToClipboard);
|
||||||
if (_asyncAuth)
|
|
||||||
_asyncAuth->openBrowser();
|
|
||||||
});
|
|
||||||
_ui.openLinkButton->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
||||||
QObject::connect(_ui.openLinkButton, &QWidget::customContextMenuRequested, [this](const QPoint &pos) {
|
|
||||||
auto menu = new QMenu(_ui.openLinkButton);
|
|
||||||
menu->addAction(tr("Copy link to clipboard"), this, [this] {
|
|
||||||
if (_asyncAuth)
|
|
||||||
QApplication::clipboard()->setText(_asyncAuth->authorisationLink().toString(QUrl::FullyEncoded));
|
|
||||||
});
|
|
||||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
menu->popup(_ui.openLinkButton->mapToGlobal(pos));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OwncloudOAuthCredsPage::initializePage()
|
void OwncloudOAuthCredsPage::initializePage()
|
||||||
|
@ -133,4 +120,19 @@ bool OwncloudOAuthCredsPage::isComplete() const
|
||||||
return false; /* We can never go forward manually */
|
return false; /* We can never go forward manually */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OwncloudOAuthCredsPage::slotOpenBrowser()
|
||||||
|
{
|
||||||
|
if (_ui.errorLabel)
|
||||||
|
_ui.errorLabel->hide();
|
||||||
|
|
||||||
|
if (_asyncAuth)
|
||||||
|
_asyncAuth->openBrowser();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OwncloudOAuthCredsPage::slotCopyLinkToClipboard()
|
||||||
|
{
|
||||||
|
if (_asyncAuth)
|
||||||
|
QApplication::clipboard()->setText(_asyncAuth->authorisationLink().toString(QUrl::FullyEncoded));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace OCC
|
} // namespace OCC
|
||||||
|
|
|
@ -57,6 +57,10 @@ public:
|
||||||
QString _refreshToken;
|
QString _refreshToken;
|
||||||
QScopedPointer<OAuth> _asyncAuth;
|
QScopedPointer<OAuth> _asyncAuth;
|
||||||
Ui_OwncloudOAuthCredsPage _ui;
|
Ui_OwncloudOAuthCredsPage _ui;
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void slotOpenBrowser();
|
||||||
|
void slotCopyLinkToClipboard();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace OCC
|
} // namespace OCC
|
||||||
|
|
|
@ -57,6 +57,19 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCommandLinkButton" name="copyLinkButton">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>50</weight>
|
||||||
|
<bold>false</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Copy link</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|
Loading…
Reference in a new issue