Commit f5683db7 authored by Denis Kuplyakov's avatar Denis Kuplyakov

Added popup functionality.

Popup was implemented. Plasma IconItem has been used to load icon for
popup as it done in original KGamePopupItem. Now colors are hardcoded,
but it will be better to load them from KDE theme.
parent 847e7af5
......@@ -234,12 +234,17 @@ void KReversiView::slotGameOver()
void KReversiView::slotComputerCantMove()
{
// TODO: 3000 ms message "Computer can not move. It is your turn again.";
QMetaObject::invokeMethod(m_qml_root, "showPopup",
Q_ARG(QVariant,
i18n("Computer can not move. It is your turn again.")));
}
void KReversiView::slotPlayerCantMove()
{
// TODO: 3000 ms message "You can not perform any move. Computer takes next turn now.";
QMetaObject::invokeMethod(m_qml_root, "showPopup",
Q_ARG(QVariant,
i18n("You can not perform any move. Computer takes next turn now.")));
}
void KReversiView::slotOnDelay()
......
......@@ -20,6 +20,7 @@
#ifndef KREVERSI_VIEW_H
#define KREVERSI_VIEW_H
#include <klocalizedstring.h>
#include <KgDeclarativeView>
#include "kreversigame.h"
......
......@@ -85,6 +85,7 @@ Item {
rows: Globals.ROW_COUNT
columns: Globals.COLUMN_COUNT
Repeater {
id: cells
model: Globals.ROW_COUNT * Globals.COLUMN_COUNT
......@@ -95,6 +96,7 @@ Item {
onClicked: container.cellClicked(index / Globals.COLUMN_COUNT,
index % Globals.COLUMN_COUNT)
}
}
}
}
/*
Copyright 2013 Denis Kuplyakov <dener.kup@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.0
import org.kde.games.core 0.1 as KgCore
import org.kde.plasma.core 0.1 as PlasmaCore
Item {
Rectangle {
id: container
height: row.height + 30
width: row.width + 30
anchors.bottom: undefined
anchors.top: parent.bottom
anchors.left: parent.left
anchors.leftMargin: 5
anchors.bottomMargin: 5
color: "#111111"
opacity: 0.9
border.color: "#111111"
border.width: 1
function show(message) {
text.text = message
timer.start();
state = "Showing"
}
Timer {
id: timer
repeat: false
interval: 3000
onTriggered: state = ""
}
Row {
id: row
x: 15
y: 15
spacing: 10
PlasmaCore.IconItem {
id: icon
anchors.verticalCenter: parent.verticalCenter
width: theme.iconSizes.dialog
height: width
source: "dialog-information"
}
Text {
id: text
anchors.verticalCenter: parent.verticalCenter
color: "white"
wrapMode: Text.WordWrap
}
}
states: [
State {
name: "Showing"
AnchorChanges {
target: container
anchors.bottom: container.parent.bottom
anchors.top: undefined
}
}
]
transitions: [
Transition {
AnchorAnimation {
duration: 300
}
}
]
}
......@@ -53,7 +53,9 @@ Item {
board.setAnimationTime(value)
}
function showPopup(text) {}
function showPopup(text) {
popup.show(text);
}
KgCore.KgItem {
id: table_background
......@@ -64,8 +66,8 @@ Item {
}
Board {
z: 1
id: board
z: 1
width: Math.min(parent.width, parent.height)
height: Math.min(parent.width, parent.height)
anchors.horizontalCenter: parent.horizontalCenter
......@@ -73,4 +75,9 @@ Item {
onCellClicked: container.cellClicked(row, column)
}
Popup {
id: popup
z: 2
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment