From b05d5d32979047605c2e60ad75be28c1235faa08 Mon Sep 17 00:00:00 2001 From: drbob Date: Mon, 21 Jan 2008 09:26:12 +0000 Subject: [PATCH] Addition of new GamesDialog and PhotoDialog. The GamesDialog is semi-functional, but doesn't launch games yet, while the PhotoDialog is a place holder. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@302 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/RetroShare.pro | 6 + retroshare-gui/src/gui/ApplicationWindow.cpp | 12 + retroshare-gui/src/gui/GamesDialog.cpp | 548 +++++++++++++++++++ retroshare-gui/src/gui/GamesDialog.h | 80 +++ retroshare-gui/src/gui/GamesDialog.ui | 347 ++++++++++++ retroshare-gui/src/gui/MainWindow.cpp | 4 +- retroshare-gui/src/gui/PhotoDialog.cpp | 275 ++++++++++ retroshare-gui/src/gui/PhotoDialog.h | 70 +++ retroshare-gui/src/gui/PhotoDialog.ui | 79 +++ 9 files changed, 1420 insertions(+), 1 deletion(-) create mode 100644 retroshare-gui/src/gui/GamesDialog.cpp create mode 100644 retroshare-gui/src/gui/GamesDialog.h create mode 100644 retroshare-gui/src/gui/GamesDialog.ui create mode 100644 retroshare-gui/src/gui/PhotoDialog.cpp create mode 100644 retroshare-gui/src/gui/PhotoDialog.h create mode 100644 retroshare-gui/src/gui/PhotoDialog.ui diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index 356e195d5..bb1b4970d 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -58,6 +58,8 @@ HEADERS += rshare.h \ gui/MainWindow.h \ gui/ApplicationWindow.h \ gui/ExampleDialog.h \ + gui/GamesDialog.h \ + gui/PhotoDialog.h \ gui/MessengerWindow.h \ gui/PeersDialog.h \ gui/SearchDialog.h \ @@ -142,6 +144,8 @@ FORMS += gui/ChatDialog.ui \ gui/MainWindow.ui \ gui/ApplicationWindow.ui \ gui/ExampleDialog.ui \ + gui/GamesDialog.ui \ + gui/PhotoDialog.ui \ gui/MessengerWindow.ui \ gui/PeersDialog.ui \ gui/SearchDialog.ui \ @@ -201,6 +205,8 @@ SOURCES += main.cpp \ gui/MainWindow.cpp \ gui/ApplicationWindow.cpp \ gui/ExampleDialog.cpp \ + gui/GamesDialog.cpp \ + gui/PhotoDialog.cpp \ gui/MessengerWindow.cpp \ gui/PeersDialog.cpp \ gui/SearchDialog.cpp \ diff --git a/retroshare-gui/src/gui/ApplicationWindow.cpp b/retroshare-gui/src/gui/ApplicationWindow.cpp index 00dd1c2ce..c3a1da63d 100644 --- a/retroshare-gui/src/gui/ApplicationWindow.cpp +++ b/retroshare-gui/src/gui/ApplicationWindow.cpp @@ -30,6 +30,7 @@ #include #include "ApplicationWindow.h" + #include "Preferences/PreferencesWindow.h" #include "Settings/gsettingswin.h" #include "util/rsversion.h" @@ -39,6 +40,8 @@ #include "gui/connect/InviteDialog.h" #include "gui/connect/AddFriendDialog.h" +#include "GamesDialog.h" +#include "PhotoDialog.h" #define FONT QFont(tr("Arial"), 8) @@ -85,6 +88,15 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags) ui.stackPages->add(exampleDialog = new ExampleDialog(ui.stackPages), createPageAction(QIcon(IMAGE_MESSAGES), tr("Example Application"), grp)); + + GamesDialog *gamesDialog = NULL; + ui.stackPages->add(gamesDialog = new GamesDialog(ui.stackPages), + createPageAction(QIcon(IMAGE_MESSAGES), tr("Games Launcher"), grp)); + + PhotoDialog *photoDialog = NULL; + ui.stackPages->add(photoDialog = new PhotoDialog(ui.stackPages), + createPageAction(QIcon(IMAGE_MESSAGES), tr("Photo View"), grp)); + //ui.stackPages->add(groupsDialog = new GroupsDialog(ui.stackPages), // createPageAction(QIcon(), tr("Groups"), grp)); diff --git a/retroshare-gui/src/gui/GamesDialog.cpp b/retroshare-gui/src/gui/GamesDialog.cpp new file mode 100644 index 000000000..f9e754973 --- /dev/null +++ b/retroshare-gui/src/gui/GamesDialog.cpp @@ -0,0 +1,548 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006,2007 crypton + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#include +#include + +//#include "common/vmessagebox.h" +//#include "rshare.h" + +#include "GamesDialog.h" +#include "rsiface/rsiface.h" +#include "rsiface/rsgame.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +const uint32_t GAME_LIST_TYPE = 0; +const uint32_t GAME_LIST_SERVER = 1; +const uint32_t GAME_LIST_STATUS = 2; +const uint32_t GAME_LIST_NAME = 3; +const uint32_t GAME_LIST_ID = 4; + +const uint32_t GAME_PEER_PLAYER = 0; +const uint32_t GAME_PEER_INVITE = 1; +const uint32_t GAME_PEER_INTEREST = 2; +const uint32_t GAME_PEER_PLAY = 3; +const uint32_t GAME_PEER_ID = 4; + + +/* Images for context menu icons */ +#define IMAGE_REMOVEFRIEND ":/images/removefriend16.png" +#define IMAGE_EXPIORTFRIEND ":/images/exportpeers_16x16.png" +#define IMAGE_CHAT ":/images/chat.png" +/* Images for Status icons */ +#define IMAGE_ONLINE ":/images/donline.png" +#define IMAGE_OFFLINE ":/images/dhidden.png" + +/** Constructor */ +GamesDialog::GamesDialog(QWidget *parent) +: MainPage(parent) +{ + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); + + connect( ui.gameTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( gameListPopupMenu( QPoint ) ) ); + connect( ui.peertreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( gamePeersPopupMenu( QPoint ) ) ); + + connect( ui.createButton, SIGNAL( pressed( void ) ), this, SLOT( createGame( void ) ) ); + connect( ui.deleteButton, SIGNAL( pressed( void ) ), this, SLOT( deleteGame( void ) ) ); + connect( ui.inviteButton, SIGNAL( pressed( void ) ), this, SLOT( inviteGame( void ) ) ); + connect( ui.playButton, SIGNAL( pressed( void ) ), this, SLOT( playGame ( void ) ) ); + + connect( ui.gameTreeWidget, SIGNAL( itemSelectionChanged( void ) ), this, SLOT( updateGameDetails( void ) ) ); + + /* hide the Tree +/- */ + ui.peertreeWidget -> setRootIsDecorated( false ); + + /* Set header resize modes and initial section sizes */ +// QHeaderView * _header = ui.peertreeWidget->header () ; +// _header->setResizeMode (0, QHeaderView::Custom); +// _header->setResizeMode (1, QHeaderView::Interactive); +// _header->setResizeMode (2, QHeaderView::Interactive); +// _header->setResizeMode (3, QHeaderView::Interactive); +// _header->setResizeMode (4, QHeaderView::Interactive); +// _header->setResizeMode (5, QHeaderView::Interactive); +// _header->setResizeMode (6, QHeaderView::Interactive); +// _header->setResizeMode (7, QHeaderView::Interactive); +// _header->setResizeMode (8, QHeaderView::Interactive); +// _header->setResizeMode (9, QHeaderView::Interactive); +// _header->setResizeMode (10, QHeaderView::Interactive); +// _header->setResizeMode (11, QHeaderView::Interactive); +// +// _header->resizeSection ( 0, 25 ); +// _header->resizeSection ( 1, 100 ); +// _header->resizeSection ( 2, 100 ); +// _header->resizeSection ( 3, 100 ); +// _header->resizeSection ( 4, 100 ); +// _header->resizeSection ( 5, 200 ); +// _header->resizeSection ( 6, 100 ); +// _header->resizeSection ( 7, 100 ); +// _header->resizeSection ( 8, 100 ); +// _header->resizeSection ( 9, 100 ); +// _header->resizeSection ( 10, 100 ); + + + /* Hide platform specific features */ +#ifdef Q_WS_WIN + +#endif +} + + +void GamesDialog::updateGameList() +{ + /* get the list of games from the server */ + std::list gameList; + std::list::iterator it; + + rsGameLauncher->getGameList(gameList); + + /* get a link to the table */ + QTreeWidget *gameWidget = ui.gameTreeWidget; + QTreeWidgetItem *oldSelect = getCurrentGame(); + QTreeWidgetItem *newSelect = NULL; + std::string oldId; + if (oldSelect) + { + oldId = (oldSelect->text(GAME_LIST_ID)).toStdString(); + } + + + QList items; + for(it = gameList.begin(); it != gameList.end(); it++) + { + /* make a widget per game */ + QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0); + item -> setText(GAME_LIST_TYPE, QString::fromStdString(it->gameType)); + item -> setText(GAME_LIST_SERVER, QString::fromStdString(it->serverName)); + item -> setText(GAME_LIST_NAME, QString::fromStdString(it->gameName)); + item -> setText(GAME_LIST_STATUS, QString::fromStdString(it->status)); + item -> setText(GAME_LIST_ID, QString::fromStdString(it->gameId)); + + if ((oldSelect) && (oldId == it->gameId)) + { + newSelect = item; + } + + /* add to the list */ + items.append(item); + } + + gameWidget->clear(); + gameWidget->setColumnCount(5); + + /* add the items in! */ + gameWidget->insertTopLevelItems(0, items); + if (newSelect) + { + gameWidget->setCurrentItem(newSelect); + } + gameWidget->update(); /* update display */ + + updateGameDetails(); +} + +QTreeWidgetItem *GamesDialog::getCurrentGame() +{ + return ui.gameTreeWidget->currentItem(); +} + +QTreeWidgetItem *GamesDialog::getCurrentPeer() +{ + return ui.peertreeWidget->currentItem(); +} + +void GamesDialog::updateGameDetails() +{ + /* get the list of games from the server */ + RsGameDetail detail; + + /* get a link to the table */ + QTreeWidget *detailWidget = ui.peertreeWidget; + QTreeWidgetItem *gameSelect = getCurrentGame(); + if (!gameSelect) + { + /* clear and finished */ + detailWidget->clear(); + //detailWidget->update(); + mCurrentGame = ""; + mCurrentGameStatus = ""; + return; + } + + std::string gameId = (gameSelect->text(GAME_LIST_ID)).toStdString(); + + rsGameLauncher->getGameDetail(gameId, detail); + + QTreeWidgetItem *oldSelect = getCurrentPeer(); + QTreeWidgetItem *newSelect = NULL; + std::string oldId; + if (mCurrentGame != gameId) + oldSelect = NULL; /* if we've changed game -> clear select */ + + if (oldSelect) + { + oldId = (oldSelect->text(GAME_PEER_ID)).toStdString(); + } + + QList items; + /* layout depends on the game status */ + std::map::iterator it; + for(it = detail.gamers.begin(); it != detail.gamers.end(); it++) + { + bool showPeer = false; + if (detail.status == "Invite") + { + showPeer = true; + } + else if (detail.status == "Confirm") + { + if ((it->second).invite == true) + showPeer = true; + } + else if (detail.status == "Playing") + { + if ((it->second).play == true) + showPeer = true; + } + + /* display */ + if (showPeer) + { + QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0); + item -> setText(GAME_PEER_PLAYER, QString::fromStdString(it->second.name)); + if (it->second.invite) + item -> setText(GAME_PEER_INVITE, "Yes"); + else + item -> setText(GAME_PEER_INVITE, "No"); + + if (it->second.interested) + item -> setText(GAME_PEER_INTEREST, "Yes"); + else + item -> setText(GAME_PEER_INTEREST, "No"); + + if (it->second.play) + item -> setText(GAME_PEER_PLAY, "Yes"); + else + item -> setText(GAME_PEER_PLAY, "No"); + + /* add a checkItem here */ + //item -> setText(GAME_PEER_PLAY, "Maybe"); + item -> setText(GAME_PEER_ID, QString::fromStdString(it->first)); + + if ((oldSelect) && (oldId == it->first)) + { + newSelect = item; + } + + /* add to the list */ + items.append(item); + } + } + if (detail.status == "Invite") + { + /* add all the online peers not listed above */ + rsiface->lockData(); /* Lock Interface */ + + std::map::const_iterator fit; + const std::map &friends = + rsiface->getFriendMap(); + for(fit = friends.begin(); fit != friends.end(); fit++) + { + if (detail.gamers.end() != detail.gamers.find(fit->first)) + { + /* already present */ + continue; + } + + if (1) + { + /* not online */ + + } + + /* make a widget per friend */ + QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0); + item -> setText(GAME_PEER_PLAYER, QString::fromStdString(fit->second.name)); + item -> setText(GAME_PEER_INVITE, "No"); + item -> setText(GAME_PEER_INTEREST, "?"); + item -> setText(GAME_PEER_PLAY, "?"); + item -> setText(GAME_PEER_ID, QString::fromStdString(fit->first)); + + if ((oldSelect) && (oldId == fit->first)) + { + newSelect = item; + } + + /* add to the list */ + items.append(item); + } + + rsiface->unlockData(); /* UnLock Interface */ + + } + + detailWidget->clear(); + detailWidget->setColumnCount(5); + + /* add the items in! */ + detailWidget->insertTopLevelItems(0, items); + if (newSelect) + { + detailWidget->setCurrentItem(newSelect); + } + detailWidget->update(); /* update display */ + + /* store the game Id */ + mCurrentGame = gameId; + mCurrentGameStatus = detail.status; +} + + + +void GamesDialog::gameListPopupMenu( QPoint point ) +{ + + QMenu contextMnu( this ); + QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier ); + + QAction *deleteAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Cancel Game" ), this ); + connect( deleteAct , SIGNAL( triggered() ), this, SLOT( deleteGame() ) ); + + contextMnu.clear(); + contextMnu.addSeparator(); + contextMnu.addAction(deleteAct); + contextMnu.addSeparator(); + contextMnu.exec( mevent->globalPos() ); +} + + +void GamesDialog::gamePeersPopupMenu( QPoint point ) +{ + + QMenu contextMnu( this ); + QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier ); + + if (mCurrentGame == "") + { + return; + } + + if (mCurrentGameStatus == "Invite") + { + /* invite */ + /* uninvite */ + + QAction *inviteAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Add to Invite List" ), this ); + connect( inviteAct , SIGNAL( triggered() ), this, SLOT( invitePeer() ) ); + QAction *uninviteAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Remove from Invite List" ), this ); + connect( uninviteAct , SIGNAL( triggered() ), this, SLOT( uninvitePeer() ) ); + + contextMnu.clear(); + contextMnu.addAction(inviteAct); + contextMnu.addAction(uninviteAct); + contextMnu.exec( mevent->globalPos() ); + } + else if (mCurrentGameStatus == "Confirm") + { + /* invite */ + /* uninvite */ + + QAction *inviteAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Add to Play List" ), this ); + connect( inviteAct , SIGNAL( triggered() ), this, SLOT( confirmPeer() ) ); + QAction *uninviteAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Remove from Play List" ), this ); + connect( uninviteAct , SIGNAL( triggered() ), this, SLOT( unconfirmPeer() ) ); + QAction *interestedAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Interested in Game" ), this ); + connect( interestedAct , SIGNAL( triggered() ), this, SLOT( interested() ) ); + QAction *uninterestedAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Not Interested" ), this ); + connect( uninterestedAct , SIGNAL( triggered() ), this, SLOT( uninterested() ) ); + + contextMnu.clear(); + contextMnu.addAction(inviteAct); + contextMnu.addAction(uninviteAct); + contextMnu.addSeparator(); + contextMnu.addAction(interestedAct); + contextMnu.addAction(uninterestedAct); + contextMnu.exec( mevent->globalPos() ); + } + else + { + /* no menu for playing */ + } + + return; +} + + + +void GamesDialog::createGame() +{ + /* extract the Game Type and number of players from GUI */ + std::string gameName = ui.gameNameEdit->text().toStdString(); + uint32_t gameType = ui.gameComboBox->currentIndex(); + bool addAll = ui.checkInviteAll->isChecked(); + std::list playerList; + + std::string gameId = rsGameLauncher->createGame(gameType, gameName); + + if (addAll) + { + /* add all the online peers not listed above */ + rsiface->lockData(); /* Lock Interface */ + + std::map::const_iterator fit; + const std::map &friends = + rsiface->getFriendMap(); + for(fit = friends.begin(); fit != friends.end(); fit++) + { + rsGameLauncher -> invitePeer(gameId, fit->first); + } + + rsiface->unlockData(); /* UnLock Interface */ + } + + /* call to the GameControl */ + std::cerr << "GamesDialog::createGame() Game: " << gameType << " name: " << gameName; + std::cerr << std::endl; + + updateGameList(); +} + +void GamesDialog::deleteGame() +{ + QTreeWidgetItem *gameSelect = getCurrentGame(); + if (!gameSelect) + return; + + std::string gameId = (gameSelect->text(GAME_LIST_ID)).toStdString(); + rsGameLauncher->deleteGame(gameId); + + updateGameList(); +} + + +void GamesDialog::inviteGame() +{ + QTreeWidgetItem *gameSelect = getCurrentGame(); + if (!gameSelect) + return; + + std::string gameId = (gameSelect->text(GAME_LIST_ID)).toStdString(); + rsGameLauncher->inviteGame(gameId); + + updateGameList(); +} + + +void GamesDialog::playGame() +{ + QTreeWidgetItem *gameSelect = getCurrentGame(); + if (!gameSelect) + return; + + std::string gameId = (gameSelect->text(GAME_LIST_ID)).toStdString(); + rsGameLauncher->playGame(gameId); + + updateGameList(); +} + +void GamesDialog::invitePeer() +{ + QTreeWidgetItem *peerSelect = getCurrentPeer(); + if (!peerSelect) + return; + + std::string peerId = (peerSelect->text(GAME_PEER_ID)).toStdString(); + rsGameLauncher->invitePeer(mCurrentGame, peerId); + updateGameDetails(); +} + + +void GamesDialog::uninvitePeer() +{ + QTreeWidgetItem *peerSelect = getCurrentPeer(); + if (!peerSelect) + return; + + std::string peerId = (peerSelect->text(GAME_PEER_ID)).toStdString(); + rsGameLauncher->uninvitePeer(mCurrentGame, peerId); + updateGameDetails(); +} + + +void GamesDialog::confirmPeer() +{ + QTreeWidgetItem *peerSelect = getCurrentPeer(); + if (!peerSelect) + return; + + std::string peerId = (peerSelect->text(GAME_PEER_ID)).toStdString(); + rsGameLauncher->confirmPeer(mCurrentGame, peerId); + updateGameDetails(); +} + + +void GamesDialog::unconfirmPeer() +{ + QTreeWidgetItem *peerSelect = getCurrentPeer(); + if (!peerSelect) + return; + + std::string peerId = (peerSelect->text(GAME_PEER_ID)).toStdString(); + rsGameLauncher->unconfirmPeer(mCurrentGame, peerId); + updateGameDetails(); +} + + +void GamesDialog::interested() +{ + QTreeWidgetItem *gameSelect = getCurrentGame(); + if (!gameSelect) + return; + + std::string gameId = (gameSelect->text(GAME_LIST_ID)).toStdString(); + rsGameLauncher->interestedPeer(gameId); + updateGameDetails(); +} + + +void GamesDialog::uninterested() +{ + QTreeWidgetItem *gameSelect = getCurrentGame(); + if (!gameSelect) + return; + + std::string gameId = (gameSelect->text(GAME_LIST_ID)).toStdString(); + rsGameLauncher->uninterestedPeer(gameId); + updateGameDetails(); +} + + diff --git a/retroshare-gui/src/gui/GamesDialog.h b/retroshare-gui/src/gui/GamesDialog.h new file mode 100644 index 000000000..a232f98ed --- /dev/null +++ b/retroshare-gui/src/gui/GamesDialog.h @@ -0,0 +1,80 @@ +/**************************************************************** + * RetroShareGui is distributed under the following license: + * + * Copyright (C) 2007-2008 Robert Fernie + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#ifndef _GAMESDIALOG_H +#define _GAMESDIALOG_H + +#include "mainpage.h" +#include "ui_GamesDialog.h" + +class GamesDialog : public MainPage +{ + Q_OBJECT + +public: + /** Default Constructor */ + GamesDialog(QWidget *parent = 0); + /** Default Destructor */ + + void insertExample(); + +private slots: + /** Create the context popup menu and it's submenus */ + void gameListPopupMenu( QPoint point ); + void gamePeersPopupMenu( QPoint point ); + + void createGame(); + void deleteGame(); + void inviteGame(); + void playGame(); + + void invitePeer(); + void uninvitePeer(); + void confirmPeer(); + void unconfirmPeer(); + + void interested(); + void uninterested(); + + void updateGameList(); + void updateGameDetails(); + /*** + * + */ + +private: + + + /***** UTILS *******/ +QTreeWidgetItem *getCurrentGame(); +QTreeWidgetItem *getCurrentPeer(); + + /* Data */ +std::string mCurrentGame; +std::string mCurrentGameStatus; +private: + + /** Qt Designer generated object */ + Ui::GamesDialog ui; +}; + +#endif + diff --git a/retroshare-gui/src/gui/GamesDialog.ui b/retroshare-gui/src/gui/GamesDialog.ui new file mode 100644 index 000000000..b0aa3d873 --- /dev/null +++ b/retroshare-gui/src/gui/GamesDialog.ui @@ -0,0 +1,347 @@ + + GamesDialog + + + + 0 + 0 + 578 + 519 + + + + Form + + + + + + + + + + + + + 14 + + + + Game: + + + + + + + + QtChess + + + + + Backgammon + + + + + QGo + + + + + Snakes + + + + + BigTwo + + + + + Poker + + + + + Checkers + + + + + + + + + + + + + 14 + + + + Title / Comment + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 14 + + + + Create New Game + + + :/images/kbackgammon.png + + + + + + + + 14 + + + + Invite All Friends + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Vertical + + + + Qt::CustomContextMenu + + + + Game Type + + + + + Server + + + + + Status + + + + + Comment + + + + + GameID + + + + + QtChess + + + DrBob + + + Invites + + + 2 + + + + + + + + + Qt::CustomContextMenu + + + + Player + + + + + Invite + + + + + Interested + + + + + Accept + + + + + Pauly + + + Yes + + + Yes + + + Yes + + + + + New Item + + + + + + + + + Np + + + + + + + + + + + + 14 + + + + Delete + + + :/images/reset.png + + + + + + + + 14 + + + + Invite + + + :/images/dadd.png + + + + + + + + 14 + + + + Move Player + + + :/images/up.png + + + + + + + + 14 + + + + Move Player + + + :/images/down_24x24.png + + + + + + + + 14 + + + + Play Game + + + :/images/startall.png + + + + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index a02b96f62..b32771545 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -73,7 +73,9 @@ #define UI_PREF_PROMPT_ON_QUIT "UIOptions/ConfirmOnQuit" /* uncomment this for release version */ -#define RS_RELEASE_VERSION 1 +/***** + * #define RS_RELEASE_VERSION 1 + ****/ /* TEST (1) * friends/neighbours: okay for 16 hours! */ /* TEST (2) * all but transfer/sharedfiles: crashed in under 8 hours! */ diff --git a/retroshare-gui/src/gui/PhotoDialog.cpp b/retroshare-gui/src/gui/PhotoDialog.cpp new file mode 100644 index 000000000..e26cb9eb1 --- /dev/null +++ b/retroshare-gui/src/gui/PhotoDialog.cpp @@ -0,0 +1,275 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2008 Robert Fernie + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#include +#include +#include "common/vmessagebox.h" + +#include "rshare.h" +#include "PhotoDialog.h" +#include "rsiface/rsiface.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + + +/* Images for context menu icons */ +#define IMAGE_REMOVEFRIEND ":/images/removefriend16.png" +#define IMAGE_EXPIORTFRIEND ":/images/exportpeers_16x16.png" +#define IMAGE_CHAT ":/images/chat.png" +/* Images for Status icons */ +#define IMAGE_ONLINE ":/images/donline.png" +#define IMAGE_OFFLINE ":/images/dhidden.png" + +/** Constructor */ +PhotoDialog::PhotoDialog(QWidget *parent) +: MainPage(parent) +{ + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); + + connect( ui.photoTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( photoTreeWidgetCostumPopupMenu( QPoint ) ) ); + + /* hide the Tree +/- */ + ui.photoTreeWidget -> setRootIsDecorated( false ); + + /* Set header resize modes and initial section sizes */ +// QHeaderView * _header = ui.peertreeWidget->header () ; +// _header->setResizeMode (0, QHeaderView::Custom); +// _header->setResizeMode (1, QHeaderView::Interactive); +// _header->setResizeMode (2, QHeaderView::Interactive); +// _header->setResizeMode (3, QHeaderView::Interactive); +// _header->setResizeMode (4, QHeaderView::Interactive); +// _header->setResizeMode (5, QHeaderView::Interactive); +// _header->setResizeMode (6, QHeaderView::Interactive); +// _header->setResizeMode (7, QHeaderView::Interactive); +// _header->setResizeMode (8, QHeaderView::Interactive); +// _header->setResizeMode (9, QHeaderView::Interactive); +// _header->setResizeMode (10, QHeaderView::Interactive); +// _header->setResizeMode (11, QHeaderView::Interactive); +// +// _header->resizeSection ( 0, 25 ); +// _header->resizeSection ( 1, 100 ); +// _header->resizeSection ( 2, 100 ); +// _header->resizeSection ( 3, 100 ); +// _header->resizeSection ( 4, 100 ); +// _header->resizeSection ( 5, 200 ); +// _header->resizeSection ( 6, 100 ); +// _header->resizeSection ( 7, 100 ); +// _header->resizeSection ( 8, 100 ); +// _header->resizeSection ( 9, 100 ); +// _header->resizeSection ( 10, 100 ); + + + /* Hide platform specific features */ +#ifdef Q_WS_WIN + +#endif +} + +void PhotoDialog::peertreeWidgetCostumPopupMenu( QPoint point ) +{ + + QMenu contextMnu( this ); + QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier ); + + voteupAct = new QAction(QIcon(IMAGE_EXPIORTFRIEND), tr( "Vote Up" ), this ); + connect( voteupAct , SIGNAL( triggered() ), this, SLOT( voteup() ) ); + + votedownAct = new QAction(QIcon(IMAGE_REMOVEFRIEND), tr( "Vote Down" ), this ); + connect( votedownAct , SIGNAL( triggered() ), this, SLOT( votedown() ) ); + + contextMnu.clear(); + contextMnu.addAction(voteupAct); + contextMnu.addSeparator(); + contextMnu.addAction(votedownAct); + contextMnu.exec( mevent->globalPos() ); +} + + + +/* get the list of peers from the RsIface. */ +void PhotoDialog::insertExample() +{ + rsiface->lockData(); /* Lock Interface */ + + std::map::const_iterator it; + const std::map &friends = + rsiface->getFriendMap(); + + /* get a link to the table */ + QTreeWidget *peerWidget = ui.photoTreeWidget; + + /* remove old items ??? */ + peerWidget->clear(); + peerWidget->setColumnCount(12); + + QList items; + for(it = friends.begin(); it != friends.end(); it++) + { + /* make a widget per friend */ + QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0); + + /* add all the labels */ + /* First 5 (1-5) Key Items */ + /* () Status Icon */ + item -> setText(0, ""); + + /* (0) Status */ + item -> setText(1, QString::fromStdString( + it->second.statusString)); + + /* (1) Person */ + item -> setText(2, QString::fromStdString(it->second.name)); + + /* (2) Auto Connect */ + item -> setText(3, QString::fromStdString( + it->second.connectString)); + + /* (3) Trust Level */ + item -> setText(4, QString::fromStdString(it->second.trustString)); + /* (4) Peer Address */ + item -> setText(5, QString::fromStdString(it->second.peerAddress)); + + /* less important ones */ + /* () Last Contact */ + item -> setText(6, QString::fromStdString(it->second.lastConnect)); + + /* () Org */ + item -> setText(7, QString::fromStdString(it->second.org)); + /* () Location */ + item -> setText(8, QString::fromStdString(it->second.loc)); + /* () Country */ + item -> setText(9, QString::fromStdString(it->second.country)); + + + /* Hidden ones: */ + /* () RsCertId */ + { + std::ostringstream out; + out << it -> second.id; + item -> setText(10, QString::fromStdString(out.str())); + } + + /* () AuthCode */ + item -> setText(11, QString::fromStdString(it->second.authCode)); + + /* change background */ + int i; + if (it->second.statusString == "Online") + { + /* bright green */ + for(i = 1; i < 12; i++) + { + item -> setBackground(i,QBrush(Qt::green)); + item -> setIcon(0,(QIcon(IMAGE_ONLINE))); + } + } + else + { + if (it->second.lastConnect != "Never") + { + for(i = 1; i < 12; i++) + { + item -> setBackground(i,QBrush(Qt::lightGray)); + item -> setIcon(0,(QIcon(IMAGE_OFFLINE))); + } + } + else + { + for(i = 1; i < 12; i++) + { + item -> setBackground(i,QBrush(Qt::gray)); + item -> setIcon(0,(QIcon(IMAGE_OFFLINE))); + } + } + } + + + + /* add to the list */ + items.append(item); + } + + /* add the items in! */ + peerWidget->insertTopLevelItems(0, items); + + rsiface->unlockData(); /* UnLock Interface */ + + peerWidget->update(); /* update display */ +} + +QTreeWidgetItem *PhotoDialog::getCurrentLine() +{ + /* get the current, and extract the Id */ + + /* get a link to the table */ + QTreeWidget *peerWidget = ui.photoTreeWidget; + QTreeWidgetItem *item = peerWidget -> currentItem(); + if (!item) + { + std::cerr << "Invalid Current Item" << std::endl; + return NULL; + } + + /* Display the columns of this item. */ + std::ostringstream out; + out << "CurrentPeerItem: " << std::endl; + + for(int i = 1; i < 6; i++) + { + QString txt = item -> text(i); + out << "\t" << i << ":" << txt.toStdString() << std::endl; + } + std::cerr << out.str(); + return item; +} + +void PhotoDialog::voteup() +{ + QTreeWidgetItem *c = getCurrentLine(); + std::cerr << "PhotoDialog::voteup()" << std::endl; +} + +void PhotoDialog::votedown() +{ + QTreeWidgetItem *c = getCurrentLine(); + std::cerr << "PhotoDialog::votedown()" << std::endl; + + /* need to get the input address / port */ + /* + std::string addr; + unsigned short port; + rsServer->FriendSetAddress(getPeerRsCertId(c), addr, port); + */ +} + + + diff --git a/retroshare-gui/src/gui/PhotoDialog.h b/retroshare-gui/src/gui/PhotoDialog.h new file mode 100644 index 000000000..185573eef --- /dev/null +++ b/retroshare-gui/src/gui/PhotoDialog.h @@ -0,0 +1,70 @@ +/**************************************************************** + * RShare is distributed under the following license: + * + * Copyright (C) 2008 Robert Fernie + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#ifndef _PHOTODIALOG_H +#define _PHOTODIALOG_H + +#include + +#include "mainpage.h" +#include "ui_PhotoDialog.h" + + +class PhotoDialog : public MainPage +{ + Q_OBJECT + +public: + /** Default Constructor */ + PhotoDialog(QWidget *parent = 0); + /** Default Destructor */ + + void insertExample(); + +private slots: + /** Create the context popup menu and it's submenus */ + void peertreeWidgetCostumPopupMenu( QPoint point ); + + void voteup(); + void votedown(); + +private: + + /* Worker Functions */ + /* (1) Update Display */ + + /* (2) Utility Fns */ + QTreeWidgetItem *getCurrentLine(); + + /** Define the popup menus for the Context menu */ + QMenu* contextMnu; + /** Defines the actions for the context menu */ + QAction* voteupAct; + QAction* votedownAct; + + QTreeWidget *exampletreeWidget; + + /** Qt Designer generated object */ + Ui::PhotoDialog ui; +}; + +#endif + diff --git a/retroshare-gui/src/gui/PhotoDialog.ui b/retroshare-gui/src/gui/PhotoDialog.ui new file mode 100644 index 000000000..92d6d73eb --- /dev/null +++ b/retroshare-gui/src/gui/PhotoDialog.ui @@ -0,0 +1,79 @@ + + PhotoDialog + + + + 0 + 0 + 598 + 510 + + + + Form + + + + + + Qt::CustomContextMenu + + + + Friend / Set + + + + + Thumb Image + + + + + Image Name + + + + + Date + + + + + Location + + + + + Comment + + + + + QtChess + + + DrBob + + + 2 + + + Invites + + + + + + + + + + + + + + + + +