[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [gluon/player-qmldesktop-snizzo] player/desktop: Added support for registering new users. Still not
From: Claudio Desideri <happy.snizzo () gmail ! com>
Date: 2013-06-27 15:10:16
Message-ID: E1UsDpw-0003qJ-FF () scm ! kde ! org
[Download RAW message or body]
Git commit f58bf8a219ac57949f8215101017200a52c22c96 by Claudio Desideri.
Committed on 27/06/2013 at 15:10.
Pushed by desideri into branch 'player-qmldesktop-snizzo'.
Added support for registering new users. Still not complete, result string missing.
M +2 -0 player/desktop/CMakeLists.txt
M +2 -24 player/desktop/loginform.cpp
M +1 -5 player/desktop/loginform.h
M +14 -13 player/desktop/main.cpp
M +52 -4 player/desktop/mainwindow.cpp
M +24 -14 player/desktop/mainwindow.h
M +12 -2 player/desktop/qml/loginscreen.qml
M +8 -3 player/desktop/qml/main.qml
A +134 -0 player/desktop/qml/registeruser.qml [License: UNKNOWN] *
A +32 -0 player/desktop/registeruserform.cpp [License: UNKNOWN] *
C +8 -21 player/desktop/registeruserform.h [from: player/desktop/loginform.h - \
066% similarity] [License: UNKNOWN] *
The files marked with a * at the end have a non valid license. Please read: \
http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are \
listed at that page.
http://commits.kde.org/gluon/f58bf8a219ac57949f8215101017200a52c22c96
diff --git a/player/desktop/CMakeLists.txt b/player/desktop/CMakeLists.txt
index 72a98a1..901f9e8 100644
--- a/player/desktop/CMakeLists.txt
+++ b/player/desktop/CMakeLists.txt
@@ -18,6 +18,7 @@ set(desktop_SRCS
loginform.cpp
main.cpp
mainwindow.cpp
+ registeruserform.cpp
)
kde4_add_executable(gluonplayer-desktop ${desktop_SRCS})
@@ -31,6 +32,7 @@ if(NOT APPLE)
install(FILES qml/main.qml
qml/loginscreen.qml
+ qml/registeruser.qml
DESTINATION ${BIN_INSTALL_DIR}/qml
COMPONENT gluonplayerdesktop)
endif()
diff --git a/player/desktop/loginform.cpp b/player/desktop/loginform.cpp
index 018cfa2..f6b831c 100644
--- a/player/desktop/loginform.cpp
+++ b/player/desktop/loginform.cpp
@@ -9,37 +9,20 @@
#include <attica/provider.h>
+#include "mainwindow.h"
+
LoginForm::LoginForm()
{
m_loggedIn = false;
- connect( GluonPlayer::ServiceProvider::instance(), \
SIGNAL(initializationFinished()), SLOT(initDone()) );
- connect( GluonPlayer::ServiceProvider::instance(), SIGNAL(initializeFailed()), \
SLOT(initFailed()) );
connect( GluonPlayer::ServiceProvider::instance(), SIGNAL(loginFinished()), \
SLOT(loginDone()) );
connect( GluonPlayer::ServiceProvider::instance(), SIGNAL(loginFailed(QString)), \
SLOT(loginFailed()) );
-
- initialize();
}
LoginForm::~LoginForm()
{
}
-void LoginForm::initialize()
-{
- GluonPlayer::ServiceProvider::instance()->init();
-}
-
-void LoginForm::initDone()
-{
- loadCredentials();
-}
-
-void LoginForm::initFailed()
-{
- kDebug() << "Initialization failed";
-}
-
void LoginForm::doLogin(QString m_username, QString m_password)
{
if( m_loggedIn )
@@ -80,8 +63,3 @@ void LoginForm::loginFailed()
{
qDebug() << "login failed!";
}
-
-void LoginForm::loadCredentials()
-{
-
-}
diff --git a/player/desktop/loginform.h b/player/desktop/loginform.h
index 29f7ca0..d4e270b 100644
--- a/player/desktop/loginform.h
+++ b/player/desktop/loginform.h
@@ -37,13 +37,8 @@ class LoginForm : public QObject
void loginDone();
void logoutDone();
void loginFailed();
- void initDone();
- void initFailed();
- void loadCredentials();
private:
- void initialize();
-
bool m_loggedIn;
Attica::ProviderManager m_manager;
@@ -51,3 +46,4 @@ class LoginForm : public QObject
};
#endif // LOGINFORM_H
+
diff --git a/player/desktop/main.cpp b/player/desktop/main.cpp
index 62b7605..9f3efba 100644
--- a/player/desktop/main.cpp
+++ b/player/desktop/main.cpp
@@ -7,17 +7,18 @@
int main (int argc, char *argv[])
{
- KAboutData aboutData( "gluonplayerdesktop", 0,
- ki18n("Gluon Player"), "0.1",
- ki18n("Hello world from the gluon player :)"),
- KAboutData::License_GPL,
- ki18n("Copyright (c) 2007 to_be_written") );
- KCmdLineArgs::init( argc, argv, &aboutData );
-
- KApplication app;
-
- MainWindow* window = new MainWindow();
- window->show();
-
- return app.exec();
+ KAboutData aboutData( "gluonplayerdesktop", 0,
+ ki18n("Gluon Player"), "0.1",
+ ki18n("Hello world from the gluon player :)"),
+ KAboutData::License_GPL,
+ ki18n("Copyright (c) 2007 to_be_written") );
+ KCmdLineArgs::init( argc, argv, &aboutData );
+
+ KApplication app;
+
+ MainWindow* window = new MainWindow();
+ window->show();
+
+ return app.exec();
}
+
diff --git a/player/desktop/mainwindow.cpp b/player/desktop/mainwindow.cpp
index 4745196..d4865c6 100644
--- a/player/desktop/mainwindow.cpp
+++ b/player/desktop/mainwindow.cpp
@@ -10,12 +10,22 @@
#include <QDir>
#include <QtDeclarative>
+#include "loginform.h"
+#include "registeruserform.h"
+
MainWindow::MainWindow(QWidget *parent) : KXmlGuiWindow(parent)
{
+ //needed by the ocs server
+ connect( GluonPlayer::ServiceProvider::instance(), \
SIGNAL(initializationFinished()), SLOT(initDone()) ); + connect( \
GluonPlayer::ServiceProvider::instance(), SIGNAL(initializeFailed()), \
SLOT(initFailed()) ); +
setupActions();
createQmlView();
}
+/**
+ * Set every menu item to their respective actions
+ */
void MainWindow::setupActions()
{
KAction * fileAction = new KAction(this);
@@ -37,16 +47,18 @@ void MainWindow::setupActions()
KStandardAction::quit(kapp, SLOT(quit()), actionCollection());
- setupGUI(Default, QDir::currentPath()+"/gluonplayerdesktopui.rc");
+ setupGUI(Default, QDir::currentPath()+"/bin/gluonplayerdesktopui.rc");
}
-/*
- * Create a QML view to be displayed as central widget
+/**
+ * Create a QML view to be displayed as central widget.
+ * This view supports the kdeclarative engine with all the plasma components.
*/
void MainWindow::createQmlView()
{
qmlRegisterType<LoginForm>("GluonComponents", 1,0, "LoginForm");
+ qmlRegisterType<RegisterUserForm>("GluonComponents", 1,0, "RegisterUserForm");
qml_view = new QDeclarativeView (this);
@@ -57,10 +69,46 @@ void MainWindow::createQmlView()
qml_view->rootContext()->setContextProperty("mainwindow", this);
qml_view->rootContext()->setContextProperty("_gluon_player_qml_version", "0.1");
- qml_view->setSource (QUrl::fromLocalFile ("bin/qml/loginscreen.qml"));
+ loadQml(QString("main.qml"));
qml_view->setResizeMode (QDeclarativeView::SizeRootObjectToView);
resize (300, 300);
setCentralWidget (qml_view);
rootObject = qml_view->rootObject();
}
+
+/**
+ * Load a particular qml file, used to change view by the application
+ *
+ * @param filename the path to the QML file to be loaded
+ */
+void MainWindow::loadQml(QString filename)
+{
+ qml_view->setSource (QUrl::fromLocalFile ("bin/qml/"+filename));
+}
+
+/**
+ * Used to initialize the attica connection to the OCS server.
+ * Must be called before the first request.
+ */
+void MainWindow::initAttica()
+{
+ GluonPlayer::ServiceProvider::instance()->init();
+}
+
+/**
+ * Handle the case in which attica could connect to the specified OCS server
+ */
+void MainWindow::initDone()
+{
+ kDebug() << "INFO: successfully connected to OCS server";
+}
+
+/**
+ * Handle the case in which attica could not connect to the specified OCS server
+ */
+void MainWindow::initFailed()
+{
+ kDebug() << "WARNING: could not connect to OCS server";
+}
+
diff --git a/player/desktop/mainwindow.h b/player/desktop/mainwindow.h
index 988afbf..c6ee088 100644
--- a/player/desktop/mainwindow.h
+++ b/player/desktop/mainwindow.h
@@ -10,21 +10,31 @@
#include <KTextEdit>
#include <kdeclarative.h>
-#include "loginform.h"
-
+#include <player/lib/serviceprovider.h>
+#include <attica/providermanager.h>
+#include <attica/provider.h>
+
+
class MainWindow : public KXmlGuiWindow
{
- public:
- MainWindow(QWidget *parent=0);
-
- private:
- //variables
- KDeclarative kdeclarative;
- QDeclarativeView *qml_view;
- QGraphicsObject *rootObject;
- //methods
- void setupActions();
- void createQmlView();
+ public:
+ MainWindow(QWidget *parent=0);
+
+ public slots:
+ void loadQml(QString filename);
+
+ private:
+ //variables
+ KDeclarative kdeclarative;
+ QDeclarativeView *qml_view;
+ QGraphicsObject *rootObject;
+ //methods
+ void setupActions();
+ void createQmlView();
+ void initAttica();
+ void initDone();
+ void initFailed();
};
-
+
#endif
+
diff --git a/player/desktop/qml/loginscreen.qml b/player/desktop/qml/loginscreen.qml
index 870d558..78560cf 100644
--- a/player/desktop/qml/loginscreen.qml
+++ b/player/desktop/qml/loginscreen.qml
@@ -56,14 +56,24 @@ Item {
PlasmaComponents.Label{
anchors.right: parent.right;
- text: "Have you forgot your password?";
+ color: "blue";
+ text: "Recover your password";
font.pixelSize: 7;
+ MouseArea{
+ anchors.fill: parent
+ onClicked: print("TODO: implement recover password on qml/loginscreen.qml");
+ }
}
PlasmaComponents.Label{
+ color: "blue";
anchors.right: parent.right
- text: "Still not registered?"
+ text: "Register an account";
font.pixelSize: 7
+ MouseArea{
+ anchors.fill: parent
+ onClicked: pageStack.push(Qt.createComponent("registeruser.qml"))
+ }
}
Row {
diff --git a/player/desktop/qml/main.qml b/player/desktop/qml/main.qml
index 28eb90a..864701c 100644
--- a/player/desktop/qml/main.qml
+++ b/player/desktop/qml/main.qml
@@ -3,8 +3,13 @@ import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.components 0.1 as PlasmaComponents
Item {
- PlasmaComponents.ButtonRow {
- PlasmaComponents.Button { text: "Left" }
- PlasmaComponents.Button { text: "Right" }
+
+ PlasmaComponents.PageStack {
+ id: pageStack
+ anchors { left: parent.left; right: parent.right; top: parent.top; bottom: \
toolBar.top } +
+ Component.onCompleted:{
+ pageStack.push(Qt.createComponent("loginscreen.qml"))
}
+ }
}
diff --git a/player/desktop/qml/registeruser.qml \
b/player/desktop/qml/registeruser.qml new file mode 100755
index 0000000..b0883fd
--- /dev/null
+++ b/player/desktop/qml/registeruser.qml
@@ -0,0 +1,134 @@
+import QtQuick 1.1
+import org.kde.plasma.core 0.1 as PlasmaCore
+import org.kde.plasma.extras 0.1 as PlasmaExtras
+import org.kde.plasma.components 0.1 as PlasmaComponents
+import GluonComponents 1.0
+
+Item {
+
+ RegisterUserForm{
+ id: registerUserFormProxy;
+ }
+
+ Column {
+ anchors.horizontalCenter: parent.horizontalCenter;
+ anchors.verticalCenter: parent.verticalCenter;
+
+ anchors.right: parent.right;
+ anchors.left: parent.left;
+ anchors.top: parent.top;
+ anchors.bottom: parent.bottom;
+
+ anchors.margins: 20;
+
+ spacing: 5;
+
+ PlasmaExtras.Title {
+ text: "Sign up!"
+ anchors.horizontalCenter: parent.horizontalCenter;
+ }
+
+ PlasmaExtras.Paragraph {
+ text: "Through this wizard you'll register a new account on the GamingFreedom \
network. + This account will work either for Gluon Creator, Gluon Player, \
www.gamingfreedom.org and any Gluon affiliate." + anchors.horizontalCenter: \
parent.horizontalCenter; + }
+
+ Row {
+ anchors.right : parent.right;
+ anchors.left : parent.left;
+
+ PlasmaComponents.Label {
+ text: "Username:";
+ anchors.left : parent.left;
+ }
+ PlasmaComponents.TextField {
+ id: register_login;
+ anchors.right : parent.right;
+ }
+ }
+ Row {
+ anchors.right : parent.right;
+ anchors.left : parent.left;
+
+ PlasmaComponents.Label {
+ text: "Password:";
+ anchors.left : parent.left;
+ }
+ PlasmaComponents.TextField {
+ id: register_password;
+ anchors.right : parent.right;
+ }
+ }
+ Row {
+ anchors.right : parent.right;
+ anchors.left : parent.left;
+
+ PlasmaComponents.Label {
+ text: "";
+ anchors.left : parent.left;
+ }
+ PlasmaComponents.TextField {
+ id: register_password2;
+ anchors.right : parent.right;
+ }
+ }
+ Row {
+ anchors.right : parent.right;
+ anchors.left : parent.left;
+
+ PlasmaComponents.Label {
+ text: "First name:";
+ anchors.left : parent.left;
+ }
+ PlasmaComponents.TextField {
+ id: register_firstname;
+ anchors.right : parent.right;
+ }
+ }
+ Row {
+ anchors.right : parent.right;
+ anchors.left : parent.left;
+
+ PlasmaComponents.Label {
+ text: "Last name:";
+ anchors.left : parent.left;
+ }
+ PlasmaComponents.TextField {
+ id: register_lastname;
+ anchors.right : parent.right;
+ }
+ }
+ Row {
+ anchors.right : parent.right;
+ anchors.left : parent.left;
+
+ PlasmaComponents.Label {
+ text: "E-mail:";
+ anchors.left : parent.left;
+ }
+ PlasmaComponents.TextField {
+ id: register_email;
+ anchors.right : parent.right;
+ }
+ }
+
+ Row {
+ anchors.right : parent.right;
+ anchors.left : parent.left;
+
+ PlasmaComponents.Button {
+ text: "Cancel";
+ width : 100;
+ anchors.left : parent.left;
+ onClicked: pageStack.pop();
+ }
+ PlasmaComponents.Button {
+ text: "Send";
+ width : 100;
+ anchors.right : parent.right;
+ onClicked: registerUserFormProxy.addUser(register_login.text, \
register_password.text, register_password2.text, register_firstname.text, \
register_lastname.text, register_email.text); + }
+ }
+ }
+}
diff --git a/player/desktop/registeruserform.cpp \
b/player/desktop/registeruserform.cpp new file mode 100755
index 0000000..99af526
--- /dev/null
+++ b/player/desktop/registeruserform.cpp
@@ -0,0 +1,32 @@
+#include "registeruserform.h"
+
+#include <player/lib/serviceprovider.h>
+#include <KDebug>
+
+
+RegisterUserForm::RegisterUserForm()
+{
+}
+
+RegisterUserForm::~RegisterUserForm()
+{
+}
+
+void RegisterUserForm::addUser(QString login, QString password, QString password2, \
QString firstname, QString lastname, QString email) +{
+
+ kDebug() << email;
+
+ //check if all mandatory fields are not empty
+ if( login.isEmpty() || password.isEmpty() || password2.isEmpty() || \
firstname.isEmpty() || lastname.isEmpty() || email.isEmpty() ) + {
+ return;
+ }
+
+ //check if passwords are the same
+ if(password != password2){
+ return;
+ }
+
+ GluonPlayer::ServiceProvider::instance()->registerAccount( login, password, \
email, firstname, lastname ); +}
diff --git a/player/desktop/loginform.h b/player/desktop/registeruserform.h
old mode 100644
new mode 100755
similarity index 66%
copy from player/desktop/loginform.h
copy to player/desktop/registeruserform.h
index 29f7ca0..d500751
--- a/player/desktop/loginform.h
+++ b/player/desktop/registeruserform.h
@@ -1,3 +1,6 @@
+#ifndef REGISTERUSERFORM_H
+#define REGISTERUSERFORM_H
+
/******************************************************************************
* This file is part of the Gluon Development Platform
* Copyright (C) 2010 Laszlo Papp <lpapp@kde.org>
@@ -17,37 +20,21 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef LOGINFORM_H
-#define LOGINFORM_H
-
-#include <attica/providermanager.h>
#include <attica/provider.h>
-class LoginForm : public QObject
+class RegisterUserForm : public QObject
{
Q_OBJECT
public:
- LoginForm();
- virtual ~LoginForm();
+ RegisterUserForm();
+ virtual ~RegisterUserForm();
protected slots:
- Q_INVOKABLE void doLogin(QString m_username, QString m_password);
- void doLogout();
- void loginDone();
- void logoutDone();
- void loginFailed();
- void initDone();
- void initFailed();
- void loadCredentials();
+ Q_INVOKABLE void addUser(QString login, QString password, QString password2, \
QString firstname, QString lastname, QString email);
private:
- void initialize();
-
- bool m_loggedIn;
-
- Attica::ProviderManager m_manager;
Attica::Provider m_provider;
};
-#endif // LOGINFORM_H
+#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic