Skip to content

Commit

Permalink
Progress FollowMyVote#19: Begin contest creation form
Browse files Browse the repository at this point in the history
NOTE: We now dep Qt 5.6 (currently in beta)
  • Loading branch information
nathanielhourt committed Feb 8, 2016
1 parent f47c323 commit e035a2d
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 3 deletions.
3 changes: 2 additions & 1 deletion VotingApp/qml/ContestDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ Column {
Layout.fillHeight: true
Layout.preferredHeight: {
var maxHeight = 0
for (var i = 0; i < contestantRepeater.count; ++i)
for (var i = 0; i < contestantRepeater.count; ++i) {
if (contestantRepeater.itemAt(i) !== null)
maxHeight = Math.max(maxHeight, contestantRepeater.itemAt(i).contentHeight)
}
return maxHeight + window.dp(16)
}
color: isSelected? Theme.tintColor : Theme.tintLightColor
Expand Down
62 changes: 62 additions & 0 deletions VotingApp/qml/CreateContestPage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import QtQuick 2.5
import QtQuick.Layouts 1.1
import QtQuick.Controls 1.4 as Controls
import QtQuick.Controls.Styles 1.4 as ControlStyles
import Qt.labs.controls 1.0

import VPlayApps 1.0

import FollowMyVote.StakeWeightedVoting 1.0

Page {
id: createContestPage
backgroundColor: "white"

property var contestCreator
property VotingSystem votingSystem

SwipeView {
id: swiper
anchors.fill: parent

Item {
ColumnLayout {
anchors.fill: parent
anchors.margins: window.dp(16)

AppTextField {
Layout.fillWidth: true
placeholderText: qsTr("Contest Name")
maximumLength: contestCreator.contestLimits[ContestLimits.NameLength]
}
AppTextEdit {
Layout.fillWidth: true
placeholderText: qsTr("Description")
wrapMode: TextEdit.Wrap
}
Row {
spacing: window.dp(8)

AppText {
id: weightCoinLabel
text: qsTr("Coin to Poll:")
}
Controls.ComboBox {
width: window.dp(120)
model: ["a", "b", "c"]
style: ControlStyles.ComboBoxStyle {
font: weightCoinLabel.font
}
}
}
}
}
}

PageControl {
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
pages: swiper.count
currentPage: swiper.currentIndex
}
}
9 changes: 8 additions & 1 deletion VotingApp/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,14 @@ App {
return votingSystem.backend.getContestsByCreator(votingSystem.currentAccount)
}
listView.headerPositioning: ListView.PullBackHeader
listView.header: CreateContestPlaceholder {}
listView.header: CreateContestPlaceholder {
onClicked: {
console.log("Begin contest creation")
myContestsPage.navigationStack.push(Qt.resolvedUrl("CreateContestPage.qml"),
{"contestCreator": _votingSystem.backend.contestCreator,
"votingSystem": _votingSystem})
}
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion VotingApp/wrappers/ContestCreator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <kj/debug.h>

#include <QDebug>

namespace swv {

void ContestCreatorWrapper::taskFailed(kj::Exception&& exception)
Expand Down Expand Up @@ -40,7 +42,7 @@ void ContestCreatorWrapper::refreshLimits()
{
m_contestLimits.clear();
for (auto limitKeyValue : r.getLimits().getEntries())
m_priceSchedule[QString::number(static_cast<uint16_t>(limitKeyValue.getKey().getLimit()))] =
m_contestLimits[QString::number(static_cast<uint16_t>(limitKeyValue.getKey().getLimit()))] =
QVariant::fromValue(limitKeyValue.getValue().getValue());
emit contestLimitsChanged(m_contestLimits);
}));
Expand Down

0 comments on commit e035a2d

Please sign in to comment.