diff options
| author | manuel <manuel@mausz.at> | 2011-04-15 00:40:13 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2011-04-15 00:40:13 +0200 |
| commit | 9a1787acd9fcd5dc0cce80cc0d6d007fa47b8bbe (patch) | |
| tree | ee3f92b43fa55f950272eb65a9af53e8e14a5471 /pacman-c++ | |
| parent | 9ab0c3e066b2c0b48daed461e80c7bb22bc6803f (diff) | |
| download | foop-9a1787acd9fcd5dc0cce80cc0d6d007fa47b8bbe.tar.gz foop-9a1787acd9fcd5dc0cce80cc0d6d007fa47b8bbe.tar.bz2 foop-9a1787acd9fcd5dc0cce80cc0d6d007fa47b8bbe.zip | |
add about dialog
Diffstat (limited to 'pacman-c++')
| -rw-r--r-- | pacman-c++/client.cpp | 50 | ||||
| -rw-r--r-- | pacman-c++/client.h | 1 |
2 files changed, 48 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 | ||
| 6 | Client::Client() | 7 | Client::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 | ||
| 72 | void Client::toggleSound() | 78 | void 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 | ||
| 115 | void 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 | ", © <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 | |||
| 109 | bool Constants::server = false; | 153 | bool Constants::server = false; |
| 110 | 154 | ||
| 111 | int main(int argc, char ** argv) | 155 | 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: | |||
| 23 | void mutedChanged(bool); | 23 | void mutedChanged(bool); |
| 24 | /* enable ambient (emitted by action) */ | 24 | /* enable ambient (emitted by action) */ |
| 25 | void enableAmbientSound(bool); | 25 | void enableAmbientSound(bool); |
| 26 | void showAbout(); | ||
| 26 | 27 | ||
| 27 | private: | 28 | private: |
| 28 | void createMenu(); | 29 | void createMenu(); |
