From 7f0f6c6212f2fcfc0b865af95c452dcc1cc75c6d Mon Sep 17 00:00:00 2001 From: brukie Date: Thu, 25 Jun 2009 13:25:20 +0200 Subject: [PATCH] changed some hotkeys --- cockatrice/src/gameselector.cpp | 2 +- cockatrice/src/window_main.cpp | 38 ++++++++++++++++----------------- cockatrice/src/window_main.h | 4 +--- 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/cockatrice/src/gameselector.cpp b/cockatrice/src/gameselector.cpp index 52ae2592..424c6b51 100644 --- a/cockatrice/src/gameselector.cpp +++ b/cockatrice/src/gameselector.cpp @@ -9,7 +9,7 @@ GameSelector::GameSelector(Client *_client, QWidget *parent) gameListModel = new GamesModel(this); gameListView->setModel(gameListModel); - createButton = new QPushButton(tr("&Create")); + createButton = new QPushButton(tr("C&reate")); joinButton = new QPushButton(tr("&Join")); QHBoxLayout *buttonLayout = new QHBoxLayout; buttonLayout->addStretch(); diff --git a/cockatrice/src/window_main.cpp b/cockatrice/src/window_main.cpp index 0265f1c1..29166c7d 100644 --- a/cockatrice/src/window_main.cpp +++ b/cockatrice/src/window_main.cpp @@ -60,6 +60,7 @@ void MainWindow::statusChanged(ProtocolStatus _status) break; case StatusDisconnected: if (game) { + zoneLayout->clear(); delete game; game = 0; } @@ -72,6 +73,14 @@ void MainWindow::statusChanged(ProtocolStatus _status) aDisconnect->setEnabled(true); break; case StatusIdle: { + if (game) { + zoneLayout->clear(); + delete game; + game = 0; + } + aRestartGame->setEnabled(false); + aLeaveGame->setEnabled(false); + GameSelector *gameSelector = new GameSelector(client); viewLayout->insertWidget(0, gameSelector); } @@ -104,12 +113,7 @@ void MainWindow::actRestartGame() void MainWindow::actLeaveGame() { - zoneLayout->clear(); client->leaveGame(); - delete game; - game = 0; - aRestartGame->setEnabled(false); - aLeaveGame->setEnabled(false); } void MainWindow::actDeckEditor() @@ -140,15 +144,11 @@ void MainWindow::updateSceneSize() view->fitInView(scene->sceneRect(), Qt::KeepAspectRatio); } -void MainWindow::textChanged(const QString &text) -{ - sayButton->setEnabled(!text.isEmpty()); -} - -// Knöpfe - -void MainWindow::buttonSay() +void MainWindow::actSay() { + if (sayEdit->text().isEmpty()) + return; + client->say(sayEdit->text()); sayEdit->clear(); } @@ -190,7 +190,7 @@ void MainWindow::createActions() aDeckEditor = new QAction(tr("&Deck editor"), this); connect(aDeckEditor, SIGNAL(triggered()), this, SLOT(actDeckEditor())); aFullScreen = new QAction(tr("&Full screen"), this); - aFullScreen->setShortcut(tr("Ctrl+F4")); + aFullScreen->setShortcut(tr("Ctrl+F")); aFullScreen->setCheckable(true); connect(aFullScreen, SIGNAL(toggled(bool)), this, SLOT(actFullScreen(bool))); aExit = new QAction(tr("&Exit"), this); @@ -244,13 +244,13 @@ MainWindow::MainWindow(QWidget *parent) cardInfo = new CardInfoWidget(db); messageLog = new MessageLogWidget; + QLabel *sayLabel = new QLabel(tr("&Say:")); sayEdit = new QLineEdit; - sayButton = new QPushButton(tr("&Say")); - sayButton->setEnabled(false); + sayLabel->setBuddy(sayEdit); QHBoxLayout *hLayout = new QHBoxLayout; + hLayout->addWidget(sayLabel); hLayout->addWidget(sayEdit); - hLayout->addWidget(sayButton); QVBoxLayout *verticalLayout = new QVBoxLayout; verticalLayout->addWidget(cardInfo); @@ -268,9 +268,7 @@ MainWindow::MainWindow(QWidget *parent) centralWidget->setLayout(mainLayout); setCentralWidget(centralWidget); - connect(sayEdit, SIGNAL(returnPressed()), sayButton, SLOT(click())); - connect(sayEdit, SIGNAL(textChanged(const QString &)), this, SLOT(textChanged(const QString &))); - connect(sayButton, SIGNAL(clicked()), this, SLOT(buttonSay())); + connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(actSay())); client = new Client(this); connect(client, SIGNAL(serverTimeout()), this, SLOT(serverTimeout())); diff --git a/cockatrice/src/window_main.h b/cockatrice/src/window_main.h index b3291593..b4d090b0 100644 --- a/cockatrice/src/window_main.h +++ b/cockatrice/src/window_main.h @@ -48,8 +48,7 @@ private slots: void playerIdReceived(int id, QString name); void serverTimeout(); - void textChanged(const QString &text); - void buttonSay(); + void actSay(); void actConnect(); void actDisconnect(); @@ -74,7 +73,6 @@ private: CardInfoWidget *cardInfo; MessageLogWidget *messageLog; QLineEdit *sayEdit; - QPushButton *sayButton; Client *client; QGraphicsScene *scene;