summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaroline Chao <caroline.chao@digia.com>2014-09-16 14:47:22 +0200
committerCaroline Chao <caroline.chao@digia.com>2014-09-18 10:20:51 +0200
commita95abd9c5b298048b92015ed0dc88b64412749f8 (patch)
tree670f441b0097655279ca89688fca1c177902aeda
parent575dbefbbc29de662290f19ebd4fb4b06456315b (diff)
Add Switch Conference page
When no conference is selected, the Switch Conference page is the first page displayed to the user. The selected conference is saved. Change-Id: I1a29ea4412e0e2a778f747643bcfcad6c6be6ccd Reviewed-by: Niels Weber <niels.weber@digia.com>
-rw-r--r--qml/components/ConferenceHeader.qml2
-rw-r--r--qml/components/ConferenceSwitcher.qml113
-rw-r--r--qml/main.qml50
-rw-r--r--resource.qrc1
-rw-r--r--src/applicationclient.cpp14
-rw-r--r--src/applicationclient.h1
-rw-r--r--src/fileio.cpp4
-rw-r--r--src/fileio.h2
-rw-r--r--src/theme.cpp2
-rw-r--r--talk-schedule.pro1
10 files changed, 180 insertions, 10 deletions
diff --git a/qml/components/ConferenceHeader.qml b/qml/components/ConferenceHeader.qml
index cb94432..a982bd5 100644
--- a/qml/components/ConferenceHeader.qml
+++ b/qml/components/ConferenceHeader.qml
@@ -98,7 +98,7 @@ Item {
id: locationButton
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
- opacity: (!!stack.currentItem && stack.currentItem.objectName !== "event" && Theme.currentConference !== "") ? 1 : 0
+ opacity: (!!stack.currentItem && stack.currentItem.objectName !== "event" && applicationClient.currentConferenceId !== "") ? 1 : 0
Behavior on opacity { PropertyAnimation{} }
Image {
diff --git a/qml/components/ConferenceSwitcher.qml b/qml/components/ConferenceSwitcher.qml
new file mode 100644
index 0000000..22e0cfd
--- /dev/null
+++ b/qml/components/ConferenceSwitcher.qml
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import TalkSchedule 1.0
+import QtQuick.Layouts 1.1
+import QtQuick.Controls 1.1
+import QtQuick.Controls.Styles 1.2
+
+Rectangle {
+ id: conferencesList
+ objectName: "switchConf"
+ signal initialConferenceSelected
+
+ SubTitle {
+ id: subTitle
+ titleText: Theme.text.select_conference
+ }
+
+ ListView {
+ interactive: false
+ anchors.top: subTitle.bottom
+ anchors.topMargin: Theme.margins.twenty
+ height: parent.height - subTitle.height
+ width: parent.width
+ spacing: Theme.margins.ten
+ model: SortFilterModel {
+ id: sortModel
+ sortRole: "title"
+ model: applicationClient.conferencesModel
+ }
+
+ Connections {
+ target: applicationClient.conferencesModel
+ onDataReady: sortModel.model = applicationClient.conferencesModel
+ }
+
+ delegate: Item {
+ width: parent.width
+ height: Theme.sizes.buttonHeight
+ Button {
+ text: title
+ anchors.centerIn: parent
+ onClicked: {
+ applicationClient.currentConferenceId = id
+ var item = Qt.resolvedUrl("HomeScreen.qml")
+ var loadedHS = stack.find(function(item){ return item.objectName === "homeScreen" })
+ if (loadedHS !== null)
+ stack.pop(loadedHS)
+ else
+ initialConferenceSelected()
+ }
+ width: window.width / 3.5
+ height: Theme.sizes.buttonHeight
+ style: ButtonStyle {
+ background: Rectangle {
+ border.width: 2
+ property var backgroundColor: applicationClient.currentConferenceId === id ? Theme.colors.qtgreen : Theme.colors.white
+ property var borderColor: applicationClient.currentConferenceId === id ? Qt.lighter(Theme.colors.qtgreen, 1.3) : Theme.colors.qtgreen
+ color: control.pressed ? Qt.darker(backgroundColor, 1.1) : backgroundColor
+ border.color: control.pressed ? Qt.darker(borderColor, 1.3) : borderColor
+ }
+ label: Text {
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ text: control.text
+ color: applicationClient.currentConferenceId === id ? Theme.colors.white : Theme.colors.qtgreen
+ font.pointSize: Theme.fonts.six_pt
+ font.capitalization: Font.AllUppercase
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/qml/main.qml b/qml/main.qml
index 6eb3cb9..3c18d2d 100644
--- a/qml/main.qml
+++ b/qml/main.qml
@@ -88,12 +88,14 @@ ApplicationWindow {
append({name: Theme.text.schedule, id: "schedule" })
append({name: Theme.text.talks, id: "talks" })
append({name: Theme.text.favorites, id: "favorites" })
+ append({name: Theme.text.switchConf, id: "switchConf" })
menuRectangle.height = Theme.sizes.buttonHeight * menuModel.count
}
}
Repeater {
id: listMenu
anchors.fill: parent
+ anchors.margins: Theme.margins.ten
model: menuModel
function firstOrLast(index)
{
@@ -137,7 +139,7 @@ ApplicationWindow {
id: separator
visible: index < menuModel.count - 1
anchors.bottom: parent.bottom
- height: Theme.applyRatio(1)
+ height: 1
width: parent.width
color: Theme.colors.gray_menu
}
@@ -183,6 +185,15 @@ ApplicationWindow {
})
}
break
+ case "switchConf":
+ var item = Qt.resolvedUrl("components/ConferenceSwitcher.qml")
+ var loadedSC = stack.find(function(item){ return item.objectName === "switchConf" })
+ if (loadedSC !== null)
+ stack.pop(loadedSC)
+ else {
+ stack.push(item)
+ }
+ break
default:
break
}
@@ -194,6 +205,7 @@ ApplicationWindow {
ConferenceHeader {
id: header
+ visible: !initConferenceSwitcher.visible
anchors.top: parent.top
height: Theme.sizes.conferenceHeaderHeight
width: parent.width
@@ -204,6 +216,7 @@ ApplicationWindow {
StackView {
id: stack
+ visible: !initConferenceSwitcher.visible
focus: true
width: parent.width
anchors.top: header.bottom
@@ -224,8 +237,10 @@ ApplicationWindow {
Item {
id: splashscreen
anchors.fill: parent
+ visible: !initConferenceSwitcher.visible
Image {
id: splashlogo
+ visible: splashscreen.visible
anchors.centerIn: parent
source: Theme.images.logo
sourceSize.width: Theme.sizes.logoWidth * 2
@@ -240,7 +255,38 @@ ApplicationWindow {
stack.push(Qt.resolvedUrl("components/HomeScreen.qml"))
}
}
- Component.onCompleted: animation.running = true
}
+ onVisibleChanged: if (visible) animation.running = true
+ }
+
+ Rectangle {
+ id: initConferenceSwitcher
+ anchors.fill: parent
+ opacity: 0.01
+ visible: ModelsSingleton.conferenceId === ""
+ Image {
+ id: logo
+ visible: parent.visible
+ opacity: parent.opacity
+ anchors.top: parent.top
+ anchors.topMargin: Theme.margins.thirty
+ anchors.horizontalCenter: parent.horizontalCenter
+ sourceSize.height: Theme.sizes.logoHeight
+ sourceSize.width: Theme.sizes.logoWidth
+ source: Theme.images.logo
+ fillMode: Image.PreserveAspectFit
+ }
+ ConferenceSwitcher {
+ anchors.top: logo.bottom
+ anchors.topMargin: Theme.margins.thirty
+ anchors.bottom: parent.bottom
+ opacity: parent.opacity
+ width: parent.width
+ }
+ }
+
+ Connections {
+ target: applicationClient
+ onConferencesModelChanged: if (initConferenceSwitcher.visible) initConferenceSwitcher.opacity = 1
}
}
diff --git a/resource.qrc b/resource.qrc
index 324c947..74fdc63 100644
--- a/resource.qrc
+++ b/resource.qrc
@@ -32,5 +32,6 @@
<file alias="images/Btn_VenueMap.svg">qml/components/images/Btn_VenueMap.svg</file>
<file alias="images/Location.svg">qml/components/images/Location.svg</file>
<file alias="images/Twitter.svg">qml/components/images/Twitter.svg</file>
+ <file>qml/components/ConferenceSwitcher.qml</file>
</qresource>
</RCC>
diff --git a/src/applicationclient.cpp b/src/applicationclient.cpp
index 3a2444d..95ccd0f 100644
--- a/src/applicationclient.cpp
+++ b/src/applicationclient.cpp
@@ -56,6 +56,8 @@
ApplicationClient::ApplicationClient()
{
+ m_settings = new FileIO(this, "settings.txt");
+
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(authenticate()));
@@ -150,23 +152,27 @@ void ApplicationClient::authenticationSuccess(EnginioReply *reply)
void ApplicationClient::setCurrentConferenceId(const QString &newConfId)
{
if (m_currentConferenceId != newConfId) {
- m_currentConferenceId = newConfId;
- emit currentConferenceIdChanged();
+ int indexCurrentConf = m_conferenceModel->indexOf("id", newConfId).toInt();
+ if (indexCurrentConf != -1) {
+ m_currentConferenceId = newConfId;
+ m_settings->write(m_currentConferenceId);
+ setCurrentConferenceIndex(indexCurrentConf);
+ emit currentConferenceIdChanged();
+ }
}
}
void ApplicationClient::queryConferenceReply(EnginioReply *reply)
{
m_conferenceModel->onFinished(reply);
+ setCurrentConferenceId(m_settings->read());
emit conferencesModelChanged();
- setCurrentConferenceIndex(0);
}
void ApplicationClient::setCurrentConferenceIndex(const int index)
{
if (index > m_conferenceModel->rowCount() - 1)
return;
- setCurrentConferenceId(m_conferenceModel->data(index, "id").toString());
m_details->insert(QLatin1String("location"),m_conferenceModel->data(index, "location"));
m_details->insert(QLatin1String("title"), m_conferenceModel->data(index, "title"));
m_details->insert(QLatin1String("TwitterTag"), m_conferenceModel->data(index, "TwitterTag"));
diff --git a/src/applicationclient.h b/src/applicationclient.h
index a11bed3..a23ae14 100644
--- a/src/applicationclient.h
+++ b/src/applicationclient.h
@@ -94,6 +94,7 @@ private:
EnginioClient *m_client;
Model *m_conferenceModel;
FileIO *m_userData;
+ FileIO *m_settings;
QString currentUsername;
QString currentPassword;
EnginioOAuth2Authentication *authenticator;
diff --git a/src/fileio.cpp b/src/fileio.cpp
index 2f18557..4cd7473 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -45,7 +45,7 @@
#include <QUuid>
#include <QDebug>
-FileIO::FileIO(QObject *parent) :
+FileIO::FileIO(QObject *parent, QString filename) :
QObject(parent)
{
QString path = QStandardPaths::standardLocations(QStandardPaths::DataLocation).value(0);
@@ -54,7 +54,7 @@ FileIO::FileIO(QObject *parent) :
dir.mkpath(path);
if (!path.isEmpty() && !path.endsWith("/"))
path += "/";
- mSource = QString("%1userId.txt").arg(path);
+ mSource = QString("%1%2").arg(path).arg(filename);
}
QString FileIO::read()
diff --git a/src/fileio.h b/src/fileio.h
index 1af916b..03432d0 100644
--- a/src/fileio.h
+++ b/src/fileio.h
@@ -48,7 +48,7 @@ class FileIO : public QObject
public:
Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged)
- explicit FileIO(QObject *parent = 0);
+ explicit FileIO(QObject *parent = 0, QString filename = "userId.txt");
Q_INVOKABLE QString read();
Q_INVOKABLE bool write(const QString &data);
diff --git a/src/theme.cpp b/src/theme.cpp
index 2732032..133ff12 100644
--- a/src/theme.cpp
+++ b/src/theme.cpp
@@ -84,6 +84,8 @@ Theme::Theme(QObject *parent)
m_text->insert(QLatin1String("room"), tr("Room %1"));
m_text->insert(QLatin1String("room_space"), tr(" - Room %1"));
m_text->insert(QLatin1String("twitterLink"), tr("https://twitter.com/"));
+ m_text->insert(QLatin1String("select_conference"), "Select a conference");
+ m_text->insert(QLatin1String("switchConf"), "Switch conference");
m_colors = new QQmlPropertyMap(this);
m_colors->insert(QLatin1String("white"), QVariant("#ffffff"));
diff --git a/talk-schedule.pro b/talk-schedule.pro
index 02e0b22..512216b 100644
--- a/talk-schedule.pro
+++ b/talk-schedule.pro
@@ -23,6 +23,7 @@ OTHER_FILES += \
qml/components/TrackSwitcher.qml \
qml/components/Track.qml \
qml/components/ConferenceHeader.qml \
+ qml/components/ConferenceSwitcher.qml \
qml/components/TrackHeader.qml \
qml/components/DaySwitcher.qml \
qml/components/SubTitle.qml \