summaryrefslogtreecommitdiffstats
path: root/pacman-c++/client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pacman-c++/client.cpp')
-rw-r--r--pacman-c++/client.cpp50
1 files changed, 47 insertions, 3 deletions
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 @@
1#include "client.h" 1#include "client.h"
2#include "clicklabel.h" 2#include "clicklabel.h"
3#include "audio.h" 3#include "audio.h"
4#include "util.h"
4#include "pacman.pb.h" 5#include "pacman.pb.h"
5 6
6Client::Client() 7Client::Client()
@@ -36,7 +37,7 @@ void Client::createMenu()
36 menuBar()->setCornerWidget(toggleSound); 37 menuBar()->setCornerWidget(toggleSound);
37 38
38 /* toggle sound: menu */ 39 /* toggle sound: menu */
39 QAction *toggleSoundAction = new QAction("Sound", this); 40 QAction *toggleSoundAction = new QAction("&Sound", this);
40 toggleSoundAction->setToolTip("Toggle Sound"); 41 toggleSoundAction->setToolTip("Toggle Sound");
41 toggleSoundAction->setCheckable(true); 42 toggleSoundAction->setCheckable(true);
42 toggleSoundAction->setChecked(!muted); 43 toggleSoundAction->setChecked(!muted);
@@ -50,7 +51,7 @@ void Client::createMenu()
50 51
51 /* toggle ambient sound: menu */ 52 /* toggle ambient sound: menu */
52 m_ambientMuted = muted || m_settings->value("ambientMuted", false).toBool(); 53 m_ambientMuted = muted || m_settings->value("ambientMuted", false).toBool();
53 QAction *toggleAmbientAction = new QAction("Ambient Sound", this); 54 QAction *toggleAmbientAction = new QAction("&Ambient Sound", this);
54 toggleAmbientAction->setToolTip("Toggle Ambient Sound"); 55 toggleAmbientAction->setToolTip("Toggle Ambient Sound");
55 toggleAmbientAction->setCheckable(true); 56 toggleAmbientAction->setCheckable(true);
56 toggleAmbientAction->setChecked(!m_ambientMuted); 57 toggleAmbientAction->setChecked(!m_ambientMuted);
@@ -65,8 +66,13 @@ void Client::createMenu()
65 /* exit entry */ 66 /* exit entry */
66 fileMenu->addSeparator(); 67 fileMenu->addSeparator();
67 QAction *quitAction = new QAction("E&xit", this); 68 QAction *quitAction = new QAction("E&xit", this);
68 connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); 69 quitAction->setIcon(QIcon::fromTheme(QLatin1String("application-exit")));
69 fileMenu->addAction(quitAction); 70 fileMenu->addAction(quitAction);
71 connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
72
73
74 QAction *aboutAction= menuBar()->addAction("Ab&out");
75 connect(aboutAction, SIGNAL(triggered()), this, SLOT(showAbout()));
70} 76}
71 77
72void Client::toggleSound() 78void Client::toggleSound()
@@ -106,6 +112,44 @@ QPixmap Client::soundIcon(bool enabled) const
106 return QPixmap::fromImage(img); 112 return QPixmap::fromImage(img);
107} 113}
108 114
115void Client::showAbout()
116{
117 QDialog *about = new QDialog(this);
118 about->setWindowTitle("About Pacman");
119 about->setWindowFlags(about->windowFlags() & ~Qt::WindowContextHelpButtonHint);
120
121 QGridLayout *layout = new QGridLayout(about);
122 layout->setSizeConstraint(QLayout::SetFixedSize);
123
124 QString actoricons;
125 for(int i = 0; Color::order[i] != Color::none; ++i)
126 actoricons += QString("<img src=\":/actor%1icon\"/>").arg(i + 1);
127
128 const QString text = QString(
129 "<h3>Multiplayer Pacman %1</h3>"
130 "Authors: H. Demel, B. Mallinger, M. Mausz, M. Racz<br/>"
131 "<br/>"
132 "Gameplay based on <a href=\"http://en.wikipedia.org/wiki/Pac-Man\">Pacman</a>"
133 ", &copy; <a href=\"http://www.namco.co.jp/\">Namco</a>, 1980<br/>"
134 "<br/>"
135 "Developed using Qt %2 (%3 bit)<br/>")
136 .arg(actoricons, QLatin1String(QT_VERSION_STR), QString::number(QSysInfo::WordSize));
137
138 QLabel *label = new QLabel(text);
139 label->setWordWrap(true);
140 label->setOpenExternalLinks(true);
141 label->setTextInteractionFlags(Qt::TextBrowserInteraction);
142
143 QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
144 QPushButton *closeButton = buttonBox->button(QDialogButtonBox::Close);
145 buttonBox->addButton(closeButton, QDialogButtonBox::ButtonRole(QDialogButtonBox::RejectRole | QDialogButtonBox::AcceptRole));
146 connect(buttonBox , SIGNAL(rejected()), about, SLOT(reject()));
147
148 layout->addWidget(label, 0, 1, 4, 4);
149 layout->addWidget(buttonBox, 4, 0, 1, 5);
150 about->show();
151}
152
109bool Constants::server = false; 153bool Constants::server = false;
110 154
111int main(int argc, char ** argv) 155int main(int argc, char ** argv)