From 9a1787acd9fcd5dc0cce80cc0d6d007fa47b8bbe Mon Sep 17 00:00:00 2001 From: manuel Date: Fri, 15 Apr 2011 00:40:13 +0200 Subject: add about dialog --- pacman-c++/client.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- pacman-c++/client.h | 1 + 2 files changed, 48 insertions(+), 3 deletions(-) (limited to 'pacman-c++') diff --git a/pacman-c++/client.cpp b/pacman-c++/client.cpp index fc0fdfc..7b84dae 100644 --- a/pacman-c++/client.cpp +++ b/pacman-c++/client.cpp @@ -1,6 +1,7 @@ #include "client.h" #include "clicklabel.h" #include "audio.h" +#include "util.h" #include "pacman.pb.h" Client::Client() @@ -36,7 +37,7 @@ void Client::createMenu() menuBar()->setCornerWidget(toggleSound); /* toggle sound: menu */ - QAction *toggleSoundAction = new QAction("Sound", this); + QAction *toggleSoundAction = new QAction("&Sound", this); toggleSoundAction->setToolTip("Toggle Sound"); toggleSoundAction->setCheckable(true); toggleSoundAction->setChecked(!muted); @@ -50,7 +51,7 @@ void Client::createMenu() /* toggle ambient sound: menu */ m_ambientMuted = muted || m_settings->value("ambientMuted", false).toBool(); - QAction *toggleAmbientAction = new QAction("Ambient Sound", this); + QAction *toggleAmbientAction = new QAction("&Ambient Sound", this); toggleAmbientAction->setToolTip("Toggle Ambient Sound"); toggleAmbientAction->setCheckable(true); toggleAmbientAction->setChecked(!m_ambientMuted); @@ -65,8 +66,13 @@ void Client::createMenu() /* exit entry */ fileMenu->addSeparator(); QAction *quitAction = new QAction("E&xit", this); - connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); + quitAction->setIcon(QIcon::fromTheme(QLatin1String("application-exit"))); fileMenu->addAction(quitAction); + connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); + + + QAction *aboutAction= menuBar()->addAction("Ab&out"); + connect(aboutAction, SIGNAL(triggered()), this, SLOT(showAbout())); } void Client::toggleSound() @@ -106,6 +112,44 @@ QPixmap Client::soundIcon(bool enabled) const return QPixmap::fromImage(img); } +void Client::showAbout() +{ + QDialog *about = new QDialog(this); + about->setWindowTitle("About Pacman"); + about->setWindowFlags(about->windowFlags() & ~Qt::WindowContextHelpButtonHint); + + QGridLayout *layout = new QGridLayout(about); + layout->setSizeConstraint(QLayout::SetFixedSize); + + QString actoricons; + for(int i = 0; Color::order[i] != Color::none; ++i) + actoricons += QString("").arg(i + 1); + + const QString text = QString( + "

Multiplayer Pacman %1

" + "Authors: H. Demel, B. Mallinger, M. Mausz, M. Racz
" + "
" + "Gameplay based on Pacman" + ", © Namco, 1980
" + "
" + "Developed using Qt %2 (%3 bit)
") + .arg(actoricons, QLatin1String(QT_VERSION_STR), QString::number(QSysInfo::WordSize)); + + QLabel *label = new QLabel(text); + label->setWordWrap(true); + label->setOpenExternalLinks(true); + label->setTextInteractionFlags(Qt::TextBrowserInteraction); + + QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); + QPushButton *closeButton = buttonBox->button(QDialogButtonBox::Close); + buttonBox->addButton(closeButton, QDialogButtonBox::ButtonRole(QDialogButtonBox::RejectRole | QDialogButtonBox::AcceptRole)); + connect(buttonBox , SIGNAL(rejected()), about, SLOT(reject())); + + layout->addWidget(label, 0, 1, 4, 4); + layout->addWidget(buttonBox, 4, 0, 1, 5); + about->show(); +} + bool Constants::server = false; int main(int argc, char ** argv) diff --git a/pacman-c++/client.h b/pacman-c++/client.h index 2583826..7030683 100644 --- a/pacman-c++/client.h +++ b/pacman-c++/client.h @@ -23,6 +23,7 @@ private slots: void mutedChanged(bool); /* enable ambient (emitted by action) */ void enableAmbientSound(bool); + void showAbout(); private: void createMenu(); -- cgit v1.2.3