summaryrefslogtreecommitdiff
path: root/client/widgets/button.cc
diff options
context:
space:
mode:
authordeva <deva>2010-08-12 10:57:04 +0000
committerdeva <deva>2010-08-12 10:57:04 +0000
commitd9338083192084613e5530b02710b796252d342b (patch)
treee0ec2b36e0de62328e5fd5d3b597f6ee71d1b18f /client/widgets/button.cc
parentdbab8458dcce186e7eb7a114a83f759d7db5445a (diff)
New scripting system part2.
Diffstat (limited to 'client/widgets/button.cc')
-rw-r--r--client/widgets/button.cc128
1 files changed, 28 insertions, 100 deletions
diff --git a/client/widgets/button.cc b/client/widgets/button.cc
index 963242c..3234296 100644
--- a/client/widgets/button.cc
+++ b/client/widgets/button.cc
@@ -25,70 +25,53 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include "button.h"
+
#include <stdio.h>
+#include <QPushButton>
#include "common.h"
+#include "macrowindow.h"
+
Button::Button(QDomNode &node, MacroWindow *macrowindow)
- : QPushButton(), Widget(node, macrowindow)
+ : Widget(node, macrowindow)
{
- resetToDisabled = false;
- setCommonAttributes(this, node);
+ button = new QPushButton();
+ widget = button;
- QDomElement elem = node.toElement();
+ setCommonAttributes(button, node);
- if(elem.hasAttribute("field")) {
- field = elem.attribute("field");
- }
+ QDomElement elem = node.toElement();
- if(elem.hasAttribute("caption")) {
- setText(elem.attribute("caption"));
- } else {
- setText("");
- }
+ button->setText(elem.attribute("caption", ""));
if(elem.hasAttribute("action")) {
if(elem.attribute("action") == "commit") {
- connect(this, SIGNAL(clicked()), this, SLOT(commit()));
- setIcon(QPixmap(":icons/add.png"));
- setEnabled(false);
-
- //
- // Hack to re-disable the commit button when the macro is reset.
- //
- resetToDisabled = true;
- widget_name = "commit_button_" + QString::number((int)this);
- QVector< Widget* > ws;
- ws.push_back(this);
- macrowindow->addAuxWidgets(ws);
-
- } else if(elem.attribute("action") == "reset") {
- connect(this, SIGNAL(clicked()), this, SLOT(_reset()));
- setIcon(QPixmap(":icons/del.png"));
+ connect(button, SIGNAL(clicked()), this, SLOT(commit()));
+ button->setIcon(QPixmap(":icons/add.png"));
+ button->setEnabled(false);
} else if(elem.attribute("action") == "cancel") {
- connect(this, SIGNAL(clicked()), this, SLOT(cancel()));
- setIcon(QPixmap(":icons/del.png"));
- } else if(elem.attribute("action") == "continue") {
- connect(this, SIGNAL(clicked()), this, SLOT(cont()));
- setIcon(QPixmap(":icons/add.png"));
- } else if(elem.attribute("action") == "continue_nocommit") {
- connect(this, SIGNAL(clicked()), this, SLOT(cont_nocommit()));
- }
- } else {
- setEnabled(false);
+ connect(button, SIGNAL(clicked()), this, SLOT(cancel()));
+ button->setIcon(QPixmap(":icons/del.png"));
+ }
}
+
+ connect(this, SIGNAL(act_commit()), macrowindow, SLOT(commit()));
+ connect(this, SIGNAL(act_cancel()), macrowindow, SLOT(cancel()));
+ connect(macrowindow, SIGNAL(macroHasChanged()), this, SLOT(do_enable()));
+
}
-void Button::commit()
+Button::~Button()
{
- emit act_commit();
- printf("Emit: commit\n");
+ printf("Delete (Button) %p\n", this); fflush(stdout);
+ // delete button;
}
-void Button::_reset()
+void Button::commit()
{
- emit act_reset();
- printf("Emit: reset\n");
+ emit act_commit();
+ printf("Emit: commit\n");
}
void Button::cancel()
@@ -97,62 +80,7 @@ void Button::cancel()
printf("Emit: cancel\n");
}
-void Button::cont()
-{
- emit act_continue(field);
- printf("Emit: continue\n");
-}
-
-void Button::cont_nocommit()
-{
- emit act_continue_nocommit(field);
- printf("Emit: continue_nocommit\n");
-}
-
void Button::do_enable()
{
- setEnabled(true);
-}
-
-void Button::connectFrom(const char *signal,
- const QObject *receiver, const char *method)
-{
- connect(this, signal, receiver, method);
-}
-
-void Button::connectTo(const QObject *sender, const char *signal,
- const char *method)
-{
- connect(sender, signal, this, method);
-}
-
-void Button::setVisibility(bool visible)
-{
- setVisible(visible);
-}
-
-bool Button::setKeyboardFocus()
-{
- setFocus();
- return true;
-}
-
-void Button::reset()
-{
- if(resetToDisabled) setEnabled(false);
-}
-
-void Button::enable()
-{
- setEnabled(true);
-}
-
-void Button::disable()
-{
- setEnabled(false);
-}
-
-bool Button::isDisabled()
-{
- return isEnabled() == false;
+ button->setEnabled(true);
}