summaryrefslogtreecommitdiffstats
path: root/libksirtet/base/main.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitc90c389a8a8d9d8661e9772ec4144c5cf2039f23 (patch)
tree6d8391395bce9eaea4ad78958617edb20c6a7573 /libksirtet/base/main.cpp
downloadtdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.tar.gz
tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'libksirtet/base/main.cpp')
-rw-r--r--libksirtet/base/main.cpp131
1 files changed, 131 insertions, 0 deletions
diff --git a/libksirtet/base/main.cpp b/libksirtet/base/main.cpp
new file mode 100644
index 00000000..4b5a4160
--- /dev/null
+++ b/libksirtet/base/main.cpp
@@ -0,0 +1,131 @@
+#include "main.h"
+#include "main.moc"
+
+#include <kaction.h>
+#include <kstdaction.h>
+#include <kmenubar.h>
+#include <kstdgameaction.h>
+#include <kcmenumngr.h>
+#include <kkeydialog.h>
+#include <klocale.h>
+#include <knotifyclient.h>
+#include <knotifydialog.h>
+#include <kexthighscore.h>
+#include <kconfigdialog.h>
+
+#include "inter.h"
+#include "factory.h"
+#include "settings.h"
+#include "baseprefs.h"
+
+BaseMainWindow::BaseMainWindow()
+ : KZoomMainWindow(4, 100, 1, "main_window")
+{
+ KNotifyClient::startDaemon();
+
+ // File & Popup
+ KStdGameAction::gameNew(this, SLOT(start()), actionCollection());
+ _pause = KStdGameAction::pause(this, SLOT(pause()), actionCollection());
+ _pause->setEnabled(false);
+ KStdGameAction::highscores(this, SLOT(showHighscores()),
+ actionCollection());
+ KStdGameAction::quit(qApp, SLOT(quit()), actionCollection());
+
+ // Settings
+ KStdAction::preferences(this, SLOT(configureSettings()),
+ actionCollection());
+ KStdAction::keyBindings(this, SLOT(configureKeys()), actionCollection());
+ KStdAction::configureNotifications(this, SLOT(configureNotifications()),
+ actionCollection());
+ KStdGameAction::configureHighscores(this, SLOT(configureHighscores()),
+ actionCollection());
+
+ _inter = bfactory->createInterface(this);
+}
+
+void BaseMainWindow::buildGUI(QWidget *widget)
+{
+ createGUI();
+ setCentralWidget(widget);
+ init("popup");
+}
+
+BaseMainWindow::~BaseMainWindow()
+{
+ delete _inter;
+}
+
+void BaseMainWindow::showHighscores()
+{
+ _inter->showHighscores(this);
+}
+
+void BaseMainWindow::start()
+{
+ _inter->_start();
+}
+
+void BaseMainWindow::pause()
+{
+ _inter->_pause();
+}
+
+void BaseMainWindow::configureHighscores()
+{
+ KExtHighscore::configure(this);
+}
+
+void BaseMainWindow::configureSettings()
+{
+ if ( !_inter->_isPaused() ) _inter->_pause();
+ if ( KConfigDialog::showDialog("settings") ) return;
+
+ KConfigDialog *dialog = new KConfigDialog(this, "settings", BasePrefs::self() );
+ QWidget *w = bfactory->createGameConfig();
+ if (w) dialog->addPage(w, i18n("Game"), "package_system");
+ w = bfactory->createAppearanceConfig();
+ if (w) dialog->addPage(w, i18n("Appearance"), "style");
+ w = bfactory->createColorConfig();
+ if (w) dialog->addPage(w, i18n("Colors"), "colorize");
+// dialog->addPage(new BackgroundConfigWidget, i18n("Background"), "background");
+ addConfig(dialog);
+ connect(dialog, SIGNAL(settingsChanged()), SIGNAL(settingsChanged()));
+ dialog->show();
+}
+
+void BaseMainWindow::configureKeys()
+{
+ KKeyDialog d(true, this);
+ addKeys(d);
+ d.insert(actionCollection());
+ d.configure(false);
+ actionCollection()->writeShortcutSettings();
+ saveKeys();
+}
+
+void BaseMainWindow::configureNotifications()
+{
+ KNotifyDialog::configure(this);
+}
+
+void BaseMainWindow::writeZoomSetting(uint zoom)
+{
+ BasePrefs::setBlockSize(zoom);
+ BasePrefs::writeConfig();
+}
+
+uint BaseMainWindow::readZoomSetting() const
+{
+ return BasePrefs::blockSize();
+}
+
+void BaseMainWindow::writeMenubarVisibleSetting(bool visible)
+{
+ BasePrefs::setMenubarVisible(visible);
+ BasePrefs::writeConfig();
+}
+
+bool BaseMainWindow::menubarVisibleSetting() const
+{
+ return BasePrefs::menubarVisible();
+}