[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [plasma-mediacenter] /: Modify Picasa backend to work properly with overlay-based login
From: Shantanu Tushar <shantanu () kde ! org>
Date: 2014-03-01 7:07:07
Message-ID: E1WJe0p-0008Di-Rf () scm ! kde ! org
[Download RAW message or body]
Git commit 6405e05b081d7c959b2434633cd92376073f8c3d by Shantanu Tushar.
Committed on 01/03/2014 at 07:05.
Pushed by shantanu into branch 'master'.
Modify Picasa backend to work properly with overlay-based login
M +35 -1 browsingbackends/onlineservices/picasa/picasabackend.cpp
M +9 -0 browsingbackends/onlineservices/picasa/picasabackend.h
M +102 -96 browsingbackends/onlineservices/picasa/picasacomponents/PicasaSidePanel.qml
M +2 -2 shells/newshell/package/contents/ui/mediacenter.qml
http://commits.kde.org/plasma-mediacenter/6405e05b081d7c959b2434633cd92376073f8c3d
diff --git a/browsingbackends/onlineservices/picasa/picasabackend.cpp \
b/browsingbackends/onlineservices/picasa/picasabackend.cpp index 57d2735..11aae97 \
100644
--- a/browsingbackends/onlineservices/picasa/picasabackend.cpp
+++ b/browsingbackends/onlineservices/picasa/picasabackend.cpp
@@ -21,12 +21,18 @@
#include "picasabackend.h"
#include "picasamodel.h"
+#include <QTimer>
+
MEDIACENTER_EXPORT_BROWSINGBACKEND(PicasaBackend)
+namespace {
+ static const QString loginButtonText = i18n("Select Account");
+}
+
PicasaBackend::PicasaBackend(QObject* parent, const QVariantList& args):
MediaCenter::AbstractBrowsingBackend(parent, args)
{
- m_loginText = constructQmlSource("picasacomponents", "0.1", "PicasaSidePanel");
+ QTimer::singleShot(2000, this, SLOT(showLoginScreen()));
}
QString PicasaBackend::backendCategory() const
@@ -83,3 +89,31 @@ void PicasaBackend::setMediaBrowserSidePanel(QString text)
m_loginText = text;
emit mediaBrowserSidePanelChanged();
}
+
+void PicasaBackend::setLoginText(const QString& loginText)
+{
+ m_loginText = loginText;
+ emit mediaBrowserSidePanelChanged();
+}
+
+QVariantList PicasaBackend::buttons()
+{
+ return QVariantList() << loginButtonText;
+}
+
+void PicasaBackend::showLoginScreen()
+{
+ setLoginText(constructQmlSource("picasacomponents", "0.1", "PicasaSidePanel"));
+}
+
+void PicasaBackend::handleButtonClick(const QString& buttonName)
+{
+ if (buttonName == loginButtonText) {
+ showLoginScreen();
+ }
+}
+
+void PicasaBackend::hideLoginScreen()
+{
+ setLoginText(QString());
+}
diff --git a/browsingbackends/onlineservices/picasa/picasabackend.h \
b/browsingbackends/onlineservices/picasa/picasabackend.h index d2776a8..d5fc00a \
100644
--- a/browsingbackends/onlineservices/picasa/picasabackend.h
+++ b/browsingbackends/onlineservices/picasa/picasabackend.h
@@ -72,6 +72,10 @@ public:
*/
virtual bool initImpl();
+ virtual QVariantList buttons();
+
+ virtual void handleButtonClick(const QString& buttonName);
+
signals:
void loginSuccessful();
void loginFailed();
@@ -88,8 +92,13 @@ public Q_SLOTS:
* @param status determines the login status
*/
void updateLoginStatus(bool status);
+
+ void showLoginScreen();
+ void hideLoginScreen();
+
private:
QString m_loginText;
+ void setLoginText(const QString &loginText);
};
#endif
diff --git a/browsingbackends/onlineservices/picasa/picasacomponents/PicasaSidePanel.qml \
b/browsingbackends/onlineservices/picasa/picasacomponents/PicasaSidePanel.qml index \
39507b2..d15a46e 100755
--- a/browsingbackends/onlineservices/picasa/picasacomponents/PicasaSidePanel.qml
+++ b/browsingbackends/onlineservices/picasa/picasacomponents/PicasaSidePanel.qml
@@ -20,108 +20,112 @@
import QtQuick 1.1
import org.kde.plasma.components 0.1 as PlasmaComponents
-Rectangle {
- id: rootItem
- anchors.fill: parent
+FocusScope {
property QtObject backend
- color: "black"
- opacity: 0.7
-
- Text {
- id: picasaText
- y: rootItem.height / 9
- color: theme.textColor
- width: parent.width
- wrapMode: Text.Wrap
- font.pointSize: 12
- text: i18n ("Enter your Google credentials and browse through your picasa \
albums")
- }
- PlasmaComponents.TextField {
- id: userid
- y: rootItem.height / 3
- width: parent.width
- height: 30
- clearButtonShown: true
- placeholderText: i18n("Google account")
- focus: true
- KeyNavigation.tab: password
- }
-
- Item {
- id: margin1
- anchors.top: userid.bottom
- width: parent.width
- height: 20
- }
-
- PlasmaComponents.TextField {
- id: password
- anchors.top: margin1.bottom
- width: parent.width
- height: 30
- clearButtonShown: true
- placeholderText: i18n("Password")
- echoMode: TextInput.Password
- Keys.onPressed: {
- if(event.key==16777220) {
- enabled: userid.text != '' && password.text != ''
- loginFailedText.visible = false
- backend.login(userid.text, password.text, "album");
- busyIndicator.running = true;
- event.accepted=true;
- }
- }
- KeyNavigation.tab: loginButton
- }
-
- Item {
- id: margin2
- anchors.top: password.bottom
- width: parent.width
- height: 20
- }
-
- PlasmaComponents.Button {
- id: loginButton
- anchors.top: margin2.bottom
- width: 100
- height: 32
- text: i18n("Login")
- anchors.horizontalCenter: parent.horizontalCenter
- enabled: userid.text != '' && password.text != ''
- onClicked: {
- loginFailedText.visible = false
- backend.login(userid.text, password.text, "album");
- busyIndicator.running = true;
+ Item {
+ id: rootItem
+
+ width: 600; height: 400
+ anchors.centerIn: parent
+
+ Text {
+ id: picasaText
+ y: rootItem.height / 9
+ color: theme.textColor
+ width: parent.width
+ wrapMode: Text.Wrap
+ font.pointSize: 12
+ text: i18n ("Enter your Google credentials and browse through your \
picasa albums") }
- KeyNavigation.tab: userid
- }
- Item {
- id: margin3
- anchors.top: loginButton.bottom
- width: parent.width
- height: 20
- }
-
- PlasmaComponents.BusyIndicator {
- id: busyIndicator
- anchors.top: margin3.bottom
- visible: running
- anchors.horizontalCenter: parent.horizontalCenter
- }
+ PlasmaComponents.TextField {
+ id: userid
+ y: rootItem.height / 3
+ width: parent.width
+ height: 30
+ clearButtonShown: true
+ placeholderText: i18n("Google account")
+ focus: true
+ KeyNavigation.tab: password
+ }
+
+ Item {
+ id: margin1
+ anchors.top: userid.bottom
+ width: parent.width
+ height: 20
+ }
+
+ PlasmaComponents.TextField {
+ id: password
+ anchors.top: margin1.bottom
+ width: parent.width
+ height: 30
+ clearButtonShown: true
+ placeholderText: i18n("Password")
+ echoMode: TextInput.Password
+ Keys.onPressed: {
+ if(event.key==16777220) {
+ enabled: userid.text != '' && password.text != ''
+ loginFailedText.visible = false
+ backend.login(userid.text, password.text, "album");
+ busyIndicator.running = true;
+ event.accepted=true;
+ }
+ }
+ KeyNavigation.tab: loginButton
+ }
- Text {
- id: loginFailedText
- anchors.top: margin3.bottom
- width: parent.width
- font.pointSize: 12
- wrapMode: Text.Wrap
- text: i18n("Incorrect Username or Password")
- color: "red"
- visible: false
+ Item {
+ id: margin2
+ anchors.top: password.bottom
+ width: parent.width
+ height: 20
+ }
+
+ PlasmaComponents.Button {
+ id: loginButton
+ anchors.top: margin2.bottom
+ width: 100
+ height: 32
+ text: i18n("Login")
+ anchors.horizontalCenter: parent.horizontalCenter
+ enabled: userid.text != '' && password.text != ''
+ onClicked: {
+ loginFailedText.visible = false
+ backend.login(userid.text, password.text, "album");
+ busyIndicator.running = true;
+ }
+ KeyNavigation.tab: userid
+ }
+
+ Item {
+ id: margin3
+ anchors.top: loginButton.bottom
+ width: parent.width
+ height: 20
+ }
+
+ PlasmaComponents.BusyIndicator {
+ id: busyIndicator
+ anchors.top: margin3.bottom
+ visible: running
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ Text {
+ id: loginFailedText
+ anchors.top: margin3.bottom
+ width: parent.width
+ font.pointSize: 12
+ wrapMode: Text.Wrap
+ text: i18n("Incorrect Username or Password")
+ color: "red"
+ visible: false
+ }
}
+
onBackendChanged: {
backend.loginSuccessful.connect(loginSuccessful);
backend.loginFailed.connect(loginFailed);
@@ -134,4 +138,6 @@ Rectangle {
busyIndicator.running = false;
loginFailedText.visible = true
}
+
+ onVisibleChanged: if (!visible) backend.hideLoginScreen()
}
diff --git a/shells/newshell/package/contents/ui/mediacenter.qml \
b/shells/newshell/package/contents/ui/mediacenter.qml index a7ae9c7..e9321a6 100644
--- a/shells/newshell/package/contents/ui/mediacenter.qml
+++ b/shells/newshell/package/contents/ui/mediacenter.qml
@@ -209,8 +209,8 @@ Image {
onBackendOverlayChanged: {
if (backendOverlay) {
pmcPageStack.pushAndFocus(backendOverlay);
- } else {
- pmcPageStack.popAndFocus(getMediaBrowser());
+ } else if (pmcPageStack.currentPage != mediaBrowserInstance) {
+ root.goBack();
}
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic