summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/client.pro5
-rw-r--r--client/editor/editor.cc36
-rw-r--r--client/editor/editor.pro41
-rw-r--r--client/lua.cc66
-rw-r--r--client/lua.h2
-rw-r--r--client/macrowindow.cc30
-rw-r--r--client/macrowindow.h2
-rw-r--r--client/widgets/checkbox.cc25
-rw-r--r--client/widgets/checkbox.h4
-rw-r--r--client/widgets/combobox.cc10
-rw-r--r--client/widgets/combobox.h7
-rw-r--r--client/widgets/frame.cc3
-rw-r--r--client/widgets/groupbox.cc7
-rw-r--r--client/widgets/lineedit.cc10
-rw-r--r--client/widgets/lineedit.h2
-rw-r--r--client/widgets/widget.cc8
-rw-r--r--client/widgets/widget.h2
-rw-r--r--client/widgets/window.cc2
18 files changed, 253 insertions, 9 deletions
diff --git a/client/client.pro b/client/client.pro
index cc69d96..7523dac 100644
--- a/client/client.pro
+++ b/client/client.pro
@@ -1,11 +1,10 @@
-######################################################################
-# Automatically generated by qmake (2.01a) Wed Aug 29 14:24:47 2007
-######################################################################
+# -*- Makefile -*-
TEMPLATE = app
TARGET = pracro
DEPENDPATH += . widgets
INCLUDEPATH += . widgets
+SUBDIRS += editor
QT += core gui network xml
# For debugging
diff --git a/client/editor/editor.cc b/client/editor/editor.cc
new file mode 100644
index 0000000..de0bac1
--- /dev/null
+++ b/client/editor/editor.cc
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * editor.cc
+ *
+ * Tue Jul 1 09:05:41 CEST 2008
+ * Copyright 2008 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro 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.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+
+
+ return app.exec();
+}
diff --git a/client/editor/editor.pro b/client/editor/editor.pro
new file mode 100644
index 0000000..513c977
--- /dev/null
+++ b/client/editor/editor.pro
@@ -0,0 +1,41 @@
+# -*- Makefile -*-
+
+TEMPLATE = app
+TARGET = editor
+DEPENDPATH += . ..
+INCLUDEPATH += . ..
+QT += core gui xml
+
+# For debugging
+QMAKE_CXXFLAGS += -g -Wall -Werror
+
+win32 {
+ LIBPATH += lua/lib
+ INCLUDEPATH += lua/include
+ LIBS += -llua51
+ DEFINES += HOST_WIN32
+}
+
+unix {
+ LIBS += -llua
+}
+
+HEADERS += \
+ widgets.h \
+ widgets/widget.h \
+ widgets/label.h \
+ widgets/lineedit.h \
+ widgets/multilist.h \
+ widgets/textedit.h \
+ widgets/button.h \
+ widgets/combobox.h \
+ widgets/listbox.h \
+ widgets/frame.h \
+ widgets/groupbox.h \
+ widgets/radiobutton.h \
+ widgets/radiobuttons.h \
+ widgets/checkbox.h \
+ widgets/window.h
+
+SOURCES += \
+ editor.cc
diff --git a/client/lua.cc b/client/lua.cc
index 1be850c..22249a4 100644
--- a/client/lua.cc
+++ b/client/lua.cc
@@ -30,6 +30,60 @@
#define GLOBAL_POINTER "_pracroGlobalLUAObjectPointerThisShouldBeANameThatIsNotAccidentallyOverwritten"
+static int _enable(lua_State *L)
+{
+ int n = lua_gettop(L); // number of arguments
+ if(n != 1) {
+ char errstr[512];
+ sprintf(errstr, "Number of args expected 0, got %d", n);
+ lua_pushstring(L, errstr);
+ lua_error(L);
+ return 1;
+ }
+
+ QString name = lua_tostring(L, lua_gettop(L));
+
+ lua_getglobal(L, GLOBAL_POINTER);
+ LUA *lua = (LUA*)lua_touserdata(L, lua_gettop(L));
+
+ if(!lua) {
+ lua_pushstring(L, "No LUA pointer!");
+ lua_error(L);
+ return 1;
+ }
+
+ lua->enable(name);
+
+ return 0;
+}
+
+static int _disable(lua_State *L)
+{
+ int n = lua_gettop(L); // number of arguments
+ if(n != 1) {
+ char errstr[512];
+ sprintf(errstr, "Number of args expected 0, got %d", n);
+ lua_pushstring(L, errstr);
+ lua_error(L);
+ return 1;
+ }
+
+ QString name = lua_tostring(L, lua_gettop(L));
+
+ lua_getglobal(L, GLOBAL_POINTER);
+ LUA *lua = (LUA*)lua_touserdata(L, lua_gettop(L));
+
+ if(!lua) {
+ lua_pushstring(L, "No LUA pointer!");
+ lua_error(L);
+ return 1;
+ }
+
+ lua->disable(name);
+
+ return 0;
+}
+
static int _getValue(lua_State *L)
{
int n = lua_gettop(L); // number of arguments
@@ -105,6 +159,8 @@ LUA::LUA(MacroWindow *macrowindow)
lua_register(L, "getValue", _getValue);
lua_register(L, "setValue", _setValue);
+ lua_register(L, "enable", _enable);
+ lua_register(L, "disable", _disable);
}
LUA::~LUA()
@@ -122,6 +178,16 @@ void LUA::setValue(QString name, QString value)
macrowindow->setValue(name, value);
}
+void LUA::enable(QString name)
+{
+ return macrowindow->enable(name);
+}
+
+void LUA::disable(QString name)
+{
+ return macrowindow->disable(name);
+}
+
bool LUA::run(QString program, QString name, QString value)
{
if(L == NULL) {
diff --git a/client/lua.h b/client/lua.h
index 1499279..a3867ca 100644
--- a/client/lua.h
+++ b/client/lua.h
@@ -43,6 +43,8 @@ public:
QString getValue(QString name);
void setValue(QString name, QString value);
+ void enable(QString name);
+ void disable(QString name);
void error(QString message);
diff --git a/client/macrowindow.cc b/client/macrowindow.cc
index 6f52916..ad85c6f 100644
--- a/client/macrowindow.cc
+++ b/client/macrowindow.cc
@@ -243,3 +243,33 @@ void MacroWindow::setValue(QString name, QString value)
i++;
}
}
+
+void MacroWindow::enable(QString name)
+{
+ // Iterate the different entries, and append their results to the commit string
+ QVector< Widget* >::iterator i=widgets.begin();
+ while (i != widgets.end()) {
+ Widget* w = *i;
+ if(name == w->getName()) {
+ w->enable();
+ return;
+ }
+ i++;
+ }
+ printf("widget not found!\n");
+}
+
+void MacroWindow::disable(QString name)
+{
+ // Iterate the different entries, and append their results to the commit string
+ QVector< Widget* >::iterator i=widgets.begin();
+ while (i != widgets.end()) {
+ Widget* w = *i;
+ if(name == w->getName()) {
+ w->disable();
+ return;
+ }
+ i++;
+ }
+ printf("widget not found!\n");
+}
diff --git a/client/macrowindow.h b/client/macrowindow.h
index 82853d8..050e59d 100644
--- a/client/macrowindow.h
+++ b/client/macrowindow.h
@@ -52,6 +52,8 @@ public:
QString getValue(QString name);
void setValue(QString name, QString value);
+ void enable(QString name);
+ void disable(QString name);
public slots:
void commit();
diff --git a/client/widgets/checkbox.cc b/client/widgets/checkbox.cc
index 0585abf..8474e58 100644
--- a/client/widgets/checkbox.cc
+++ b/client/widgets/checkbox.cc
@@ -42,13 +42,15 @@ CheckBox::CheckBox(QDomNode &node, MacroWindow *macrowindow)
if(elem.hasAttribute("caption")) {
setText(elem.attribute("caption"));
} else {
- setText(elem.attribute(""));
+ setText("");
}
+ connect(this, SIGNAL(stateChanged(int)), this, SLOT(state_change()));
+
if(elem.hasAttribute("value")) {
setValue(elem.attribute("value"));
} else {
- setChecked(false);
+ setValue("false");
}
}
@@ -60,11 +62,26 @@ QString CheckBox::getValue()
void CheckBox::setValue(QString value)
{
- if(value == "true") setChecked(true);
- else setChecked(false);
+ bool old = isChecked();
+
+ if(value == "true") {
+ setChecked(true);
+ } else {
+ setChecked(false);
+ }
+
+ // If set operation did not change the value we must invocate the code manually.
+ if(old == isChecked()) state_change();
}
bool CheckBox::isValid()
{
return true;
}
+
+void CheckBox::state_change()
+{
+ printf("state_change\n");
+
+ luaValidator();
+}
diff --git a/client/widgets/checkbox.h b/client/widgets/checkbox.h
index 9db7bf2..65a0356 100644
--- a/client/widgets/checkbox.h
+++ b/client/widgets/checkbox.h
@@ -33,15 +33,17 @@
class CheckBox : public QCheckBox, public Widget
{
+Q_OBJECT
public:
CheckBox(QDomNode &node, MacroWindow *macrowindow);
bool isValid();
-public slots:
QString getValue();
void setValue(QString value);
+public slots:
+ void state_change();
};
#endif/*__PRACRO_CHECKBOX_H__*/
diff --git a/client/widgets/combobox.cc b/client/widgets/combobox.cc
index a60f1ed..3856bed 100644
--- a/client/widgets/combobox.cc
+++ b/client/widgets/combobox.cc
@@ -154,3 +154,13 @@ void ComboBox::changed()
setPalette(palette);
}
+
+void ComboBox::enable()
+{
+ setEnabled(true);
+}
+
+void ComboBox::disable()
+{
+ setEnabled(false);
+}
diff --git a/client/widgets/combobox.h b/client/widgets/combobox.h
index 9ad2323..0a5724f 100644
--- a/client/widgets/combobox.h
+++ b/client/widgets/combobox.h
@@ -38,10 +38,15 @@ Q_OBJECT
public:
ComboBox(QDomNode &node, MacroWindow *macrowindow);
-public slots:
bool isValid();
+
QString getValue();
void setValue(QString value);
+
+ void enable();
+ void disable();
+
+public slots:
void changed();
private:
diff --git a/client/widgets/frame.cc b/client/widgets/frame.cc
index ecf0701..44571f5 100644
--- a/client/widgets/frame.cc
+++ b/client/widgets/frame.cc
@@ -42,5 +42,8 @@ Frame::Frame(QDomNode &node, MacroWindow *macrowindow)
setLayout(layout);
}
}
+ setLineWidth(0);
+ setMidLineWidth(0);
+ setContentsMargins(0,0,0,0);
}
diff --git a/client/widgets/groupbox.cc b/client/widgets/groupbox.cc
index 2edb344..9dc36ec 100644
--- a/client/widgets/groupbox.cc
+++ b/client/widgets/groupbox.cc
@@ -47,5 +47,12 @@ GroupBox::GroupBox(QDomNode &node, MacroWindow *macrowindow)
QVBoxLayout *layout = new QVBoxLayout();
setLayout(layout);
}
+ } else {
+ QHBoxLayout *layout = new QHBoxLayout();
+ setLayout(layout);
}
+
+ // setLineWidth(0);
+ // setMidLineWidth(0);
+ setContentsMargins(0,10,0,0);
}
diff --git a/client/widgets/lineedit.cc b/client/widgets/lineedit.cc
index 7f270e9..8694889 100644
--- a/client/widgets/lineedit.cc
+++ b/client/widgets/lineedit.cc
@@ -80,3 +80,13 @@ void LineEdit::setValue(QString value)
{
setText(value);
}
+
+void LineEdit::enable()
+{
+ setEnabled(true);
+}
+
+void LineEdit::disable()
+{
+ setEnabled(false);
+}
diff --git a/client/widgets/lineedit.h b/client/widgets/lineedit.h
index 3deb3d1..3f0bb17 100644
--- a/client/widgets/lineedit.h
+++ b/client/widgets/lineedit.h
@@ -40,6 +40,8 @@ public:
QString getValue();
void setValue(QString value);
+ void enable();
+ void disable();
public slots:
void changed();
diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc
index dafe4b7..efba31c 100644
--- a/client/widgets/widget.cc
+++ b/client/widgets/widget.cc
@@ -84,3 +84,11 @@ bool Widget::luaValidator()
return macrowindow->lua->run(luaprogram, getName(), getValue());
}
+
+void Widget::disable()
+{
+}
+
+void Widget::enable()
+{
+}
diff --git a/client/widgets/widget.h b/client/widgets/widget.h
index cba6be9..9b6a996 100644
--- a/client/widgets/widget.h
+++ b/client/widgets/widget.h
@@ -41,6 +41,8 @@ public:
virtual QString getValue();
virtual void setValue(QString value);
virtual bool isValid();
+ virtual void disable();
+ virtual void enable();
QString getName();
protected:
diff --git a/client/widgets/window.cc b/client/widgets/window.cc
index b2b4298..c4d8d14 100644
--- a/client/widgets/window.cc
+++ b/client/widgets/window.cc
@@ -64,6 +64,8 @@ Window::Window(QDomNode &node, MacroWindow *macrowindow)
setLayout(layout);
}
}
+
+ setContentsMargins(0,0,0,0);
}
QString Window::getValue()