diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2 (patch) | |
tree | d3bb9f5d25a2dc09ca81adecf39621d871534297 /blinken/src/button.cpp | |
download | tdeedu-ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2.tar.gz tdeedu-ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2.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/kdeedu@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'blinken/src/button.cpp')
-rw-r--r-- | blinken/src/button.cpp | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/blinken/src/button.cpp b/blinken/src/button.cpp new file mode 100644 index 00000000..b359e953 --- /dev/null +++ b/blinken/src/button.cpp @@ -0,0 +1,119 @@ +/*************************************************************************** + * Copyright (C) 2005 by Albert Astals Cid <tsdgeos@terra.es> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#include <kaction.h> +#include <kapplication.h> +#include <kconfig.h> +#include <kstandarddirs.h> +#include <kdebug.h> + +#include "button.h" + +button::button(blinkenGame::color c) : m_selected(false), m_color(c) +{ + KConfig *kc = kapp->config(); + kc->setGroup("General"); + QString cs = getColorString(); + QString pixmap = QString("images/%1h.png").arg(cs); + + switch (c) + { + case blinkenGame::blue: + m_key = kc->readNumEntry(cs, Qt::Key_3); + break; + + case blinkenGame::yellow: + m_key = kc->readNumEntry(cs, Qt::Key_1); + break; + + case blinkenGame::red: + m_key = kc->readNumEntry(cs, Qt::Key_2); + break; + + case blinkenGame::green: + m_key = kc->readNumEntry(cs, Qt::Key_4); + break; + + default: + // never happens + break; + } + + m_highlighted = new QPixmap(locate("appdata", pixmap)); +} + +button::~button() +{ + delete m_highlighted; +} + +void button::setShortcut(int key) +{ + m_key = key; + m_selected = false; + + KConfig *kc = kapp->config(); + kc->setGroup("General"); + kc->writeEntry(getColorString(), key); + kc->sync(); +} + +QString button::shortcut() const +{ + return KShortcut(m_key).toString(); +} + +int button::key() const +{ + return m_key; +} + +void button::setSelected(bool b) +{ + m_selected = b; +} + +bool button::selected() const +{ + return m_selected; +} + +QPixmap *button::pixmap() const +{ + return m_highlighted; +} + +QString button::getColorString() const +{ + switch (m_color) + { + case blinkenGame::blue: + return "blue"; + break; + + case blinkenGame::yellow: + return "yellow"; + break; + + case blinkenGame::red: + return "red"; + break; + + case blinkenGame::green: + return "green"; + break; + + default: + // never happens + break; + } + + // never happens + return QString::null; +} |