summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/lua.cc2
-rw-r--r--client/macrowindow.cc3
-rw-r--r--client/widgets/button.cc4
-rw-r--r--client/widgets/checkbox.cc6
-rw-r--r--client/widgets/combobox.cc25
-rw-r--r--client/widgets/combobox.h7
-rw-r--r--client/widgets/groupbox.cc31
-rw-r--r--client/widgets/label.cc4
-rw-r--r--client/widgets/lineedit.cc4
-rw-r--r--client/widgets/listbox.cc4
-rw-r--r--client/widgets/multilist.cc37
-rw-r--r--client/widgets/multilist.h3
-rw-r--r--client/widgets/radiobutton.cc4
-rw-r--r--client/widgets/radiobuttons.cc11
-rw-r--r--client/widgets/textedit.cc4
-rw-r--r--client/widgets/widget.cc4
-rw-r--r--client/widgets/window.cc6
17 files changed, 133 insertions, 26 deletions
diff --git a/client/lua.cc b/client/lua.cc
index 65d0188..9494ee2 100644
--- a/client/lua.cc
+++ b/client/lua.cc
@@ -209,7 +209,7 @@ bool LUA::run(QString program, QString name, QString value)
if(macrowindow->luaprograms.contains(program) == false) return false;
- printf("%s\n", macrowindow->luaprograms.value(program).toStdString().c_str());
+ // printf("%s\n", macrowindow->luaprograms.value(program).toStdString().c_str());
lua_pushstring(L, value.toStdString().c_str());
lua_setglobal(L, "value");
diff --git a/client/macrowindow.cc b/client/macrowindow.cc
index abd615c..ddaf905 100644
--- a/client/macrowindow.cc
+++ b/client/macrowindow.cc
@@ -211,5 +211,8 @@ Widget *MacroWindow::getWidget(QString name)
if(name == w->getName()) return w;
i++;
}
+
+ printf("WARNING: Widget %s not found\n", name.toStdString().c_str());
+
return NULL;
}
diff --git a/client/widgets/button.cc b/client/widgets/button.cc
index f40b0ec..0f9df2f 100644
--- a/client/widgets/button.cc
+++ b/client/widgets/button.cc
@@ -42,6 +42,10 @@ Button::Button(QDomNode &node, MacroWindow *macrowindow)
setMinimumHeight(elem.attribute("height").toInt());
}
+ if(elem.hasAttribute("help")) {
+ setToolTip(elem.attribute("help"));
+ }
+
if(elem.hasAttribute("field")) {
field = elem.attribute("field");
}
diff --git a/client/widgets/checkbox.cc b/client/widgets/checkbox.cc
index 95f5a53..1f089bb 100644
--- a/client/widgets/checkbox.cc
+++ b/client/widgets/checkbox.cc
@@ -41,8 +41,10 @@ CheckBox::CheckBox(QDomNode &node, MacroWindow *macrowindow)
if(elem.hasAttribute("caption")) {
setText(elem.attribute("caption"));
- } else {
- setText("");
+ }
+
+ if(elem.hasAttribute("help")) {
+ setToolTip(elem.attribute("help"));
}
connect(this, SIGNAL(stateChanged(int)), this, SLOT(state_change()));
diff --git a/client/widgets/combobox.cc b/client/widgets/combobox.cc
index d6d6483..39a957b 100644
--- a/client/widgets/combobox.cc
+++ b/client/widgets/combobox.cc
@@ -30,12 +30,6 @@
#include <QRegExpValidator>
#include <QRegExp>
-typedef enum {
- SELECT,
- EDIT,
- SEARCH
-} types_t;
-
ComboBox::ComboBox(QDomNode &node, MacroWindow *macrowindow)
: QComboBox(), Widget(node, macrowindow)
{
@@ -51,6 +45,13 @@ ComboBox::ComboBox(QDomNode &node, MacroWindow *macrowindow)
setMinimumHeight(elem.attribute("height").toInt());
}
+ if(elem.hasAttribute("help")) {
+ setWhatsThis(elem.attribute("help"));
+ }
+ if(elem.hasAttribute("help")) {
+ // setToolTip(elem.attribute("help"));
+ }
+
QDomNodeList children = node.childNodes();
QStringList itemlist;
@@ -73,7 +74,7 @@ ComboBox::ComboBox(QDomNode &node, MacroWindow *macrowindow)
}
*/
- types_t combotype = SELECT;
+ combotype = SELECT;
if(elem.hasAttribute("type")) {
if(elem.attribute("type") == "select") combotype = SELECT;
if(elem.attribute("type") == "edit") combotype = EDIT;
@@ -83,7 +84,7 @@ ComboBox::ComboBox(QDomNode &node, MacroWindow *macrowindow)
switch(combotype) {
case SELECT:
setEditable(false);
- //connect(this, SIGNAL(currentIndexChanged(QString)), this, SLOT(changed()));
+ connect(this, SIGNAL(currentIndexChanged(QString)), this, SLOT(changed()));
break;
case EDIT:
@@ -136,14 +137,20 @@ void ComboBox::setValue(QString value)
bool ComboBox::isValid()
{
+ if(combotype == SELECT) return true;
return rx.exactMatch(currentText());
}
void ComboBox::changed()
{
+ if(combotype == SELECT) {
+ luaValidator();
+ return;
+ }
+
QPalette palette;
- if(isValid()) {
+ if(isValid() && luaValidator()) {
// valid string
palette.setBrush(QPalette::Base, QBrush(QColor(255, 255, 255)));
} else {
diff --git a/client/widgets/combobox.h b/client/widgets/combobox.h
index 0a5724f..f072bea 100644
--- a/client/widgets/combobox.h
+++ b/client/widgets/combobox.h
@@ -32,6 +32,12 @@
#include <QComboBox>
#include <QRegExp>
+typedef enum {
+ SELECT,
+ EDIT,
+ SEARCH
+} types_t;
+
class ComboBox : public QComboBox, public Widget
{
Q_OBJECT
@@ -52,6 +58,7 @@ public slots:
private:
QRegExp rx;
QString combo_value;
+ types_t combotype;
};
#endif/*__PRACRO_COMBOBOX_H__*/
diff --git a/client/widgets/groupbox.cc b/client/widgets/groupbox.cc
index 9dc36ec..4d40dca 100644
--- a/client/widgets/groupbox.cc
+++ b/client/widgets/groupbox.cc
@@ -28,6 +28,8 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
+#include <string.h>
+
GroupBox::GroupBox(QDomNode &node, MacroWindow *macrowindow)
: QGroupBox(), Widget(node, macrowindow)
{
@@ -35,8 +37,33 @@ GroupBox::GroupBox(QDomNode &node, MacroWindow *macrowindow)
if(elem.hasAttribute("caption")) {
setTitle(elem.attribute("caption"));
- } else {
- setTitle(elem.attribute(""));
+ }
+
+ if(elem.hasAttribute("help")) {
+ setWhatsThis(elem.attribute("help"));
+ }
+ if(elem.hasAttribute("help")) {
+ QString helptext = elem.attribute("help");
+
+ int idx = 0;
+ while(idx < helptext.length() - 1) {
+ if(helptext[idx] == '\\' && helptext[idx+1] == 'n') {
+ helptext[idx] = '\n';
+ helptext[idx+1] = '\n';
+ }
+ idx++;
+ }
+
+ idx = 60;
+ while(idx < helptext.length()) {
+ while(idx < helptext.length() && helptext[idx] != ' ') {
+ idx++;
+ }
+ helptext[idx] = '\n';
+
+ idx += 60;
+ }
+ setToolTip(helptext);
}
if(elem.hasAttribute("layout")) {
diff --git a/client/widgets/label.cc b/client/widgets/label.cc
index 47a709e..1d58665 100644
--- a/client/widgets/label.cc
+++ b/client/widgets/label.cc
@@ -40,6 +40,10 @@ Label::Label(QDomNode &node, MacroWindow *macrowindow)
setMinimumHeight(elem.attribute("height").toInt());
}
+ if(elem.hasAttribute("help")) {
+ setToolTip(elem.attribute("help"));
+ }
+
if(elem.hasAttribute("caption")) {
setText(elem.attribute("caption"));
} else {
diff --git a/client/widgets/lineedit.cc b/client/widgets/lineedit.cc
index 6decbab..89ac276 100644
--- a/client/widgets/lineedit.cc
+++ b/client/widgets/lineedit.cc
@@ -40,6 +40,10 @@ LineEdit::LineEdit(QDomNode &node, MacroWindow *macrowindow)
setMinimumHeight(elem.attribute("height").toInt());
}
+ if(elem.hasAttribute("help")) {
+ setWhatsThis(elem.attribute("help"));
+ }
+
if(elem.hasAttribute("readonly")) {
if(elem.attribute("readonly") == "true" || elem.attribute("readonly") == "1") {
setReadOnly(true);
diff --git a/client/widgets/listbox.cc b/client/widgets/listbox.cc
index a47812a..5215c18 100644
--- a/client/widgets/listbox.cc
+++ b/client/widgets/listbox.cc
@@ -80,6 +80,10 @@ ListBox::ListBox(QDomNode &node, MacroWindow *macrowindow)
setMinimumHeight(elem.attribute("height").toInt());
}
+ if(elem.hasAttribute("help")) {
+ setToolTip(elem.attribute("help"));
+ }
+
QDomNodeList children = node.childNodes();
for (int i=0; i < children.count(); i++) {
diff --git a/client/widgets/multilist.cc b/client/widgets/multilist.cc
index b2ba2a2..5f795b3 100644
--- a/client/widgets/multilist.cc
+++ b/client/widgets/multilist.cc
@@ -58,6 +58,10 @@ MultiList::MultiList(QDomNode &node, MacroWindow *macrowindow)
inputbox->setLayout(layout);
}
+ if(elem.hasAttribute("help")) {
+ setToolTip(elem.attribute("help"));
+ }
+
inputbox->layout()->setContentsMargins(0,0,0,0);
QDomNodeList children = node.childNodes();
@@ -73,16 +77,16 @@ MultiList::MultiList(QDomNode &node, MacroWindow *macrowindow)
// layout->addWidget(add, 0, 1, Qt::AlignTop);
layout->addWidget(add, 1, 0, 1, 1, Qt::AlignTop);
- list = new QListWidget(this);
- // layout->addWidget(list, 1, 0, Qt::AlignTop);
- layout->addWidget(list, 2, 0, 1, 2, Qt::AlignTop);
-
QPushButton *rem = new QPushButton(this);
connect(rem, SIGNAL(clicked()), this, SLOT(remove()));
rem->setText("Fjern");
// layout->addWidget(rem, 1, 1, Qt::AlignTop);
layout->addWidget(rem, 1, 1, 1, 1, Qt::AlignTop);
+ list = new QListWidget(this);
+ // layout->addWidget(list, 1, 0, Qt::AlignTop);
+ layout->addWidget(list, 2, 0, 1, 2, Qt::AlignTop);
+
/* // This is done later
if(elem.hasAttribute("value")) {
setValue(elem.attribute("value"));
@@ -101,6 +105,21 @@ MultiList::MultiList(QDomNode &node, MacroWindow *macrowindow)
}
}
+ /*
+ QVector< Widget* >::iterator i = widgets.begin();
+ while (i != widgets.end()) {
+ for (int j = 0; j < children.count(); j++) {
+ QDomNode child = children.at(j);
+ QDomElement elem = child.toElement();
+ if(elem.attribute("name") == (*i)->getName()) {
+ printf("Set\n");
+ (*i)->setValue(elem.attribute("value"));
+ }
+ }
+ i++;
+ }
+ */
+
if(elem.hasAttribute("width")) {
setMinimumWidth(elem.attribute("width").toInt());
}
@@ -157,3 +176,13 @@ void MultiList::add()
}
list->addItem(format_parser(format, widgets));
}
+
+void MultiList::enable()
+{
+ setEnabled(true);
+}
+
+void MultiList::disable()
+{
+ setEnabled(false);
+}
diff --git a/client/widgets/multilist.h b/client/widgets/multilist.h
index cee6ccb..276c1b1 100644
--- a/client/widgets/multilist.h
+++ b/client/widgets/multilist.h
@@ -48,6 +48,9 @@ public slots:
void remove();
void add();
+ void enable();
+ void disable();
+
private:
QListWidget *list;
QVector< Widget* > widgets;
diff --git a/client/widgets/radiobutton.cc b/client/widgets/radiobutton.cc
index b757828..9e04e07 100644
--- a/client/widgets/radiobutton.cc
+++ b/client/widgets/radiobutton.cc
@@ -40,6 +40,10 @@ RadioButton::RadioButton(QDomNode &node)
resize(width(), elem.attribute("height").toInt());
}
+ if(elem.hasAttribute("help")) {
+ setToolTip(elem.attribute("help"));
+ }
+
if(elem.hasAttribute("caption")) {
setText(elem.attribute("caption"));
} else {
diff --git a/client/widgets/radiobuttons.cc b/client/widgets/radiobuttons.cc
index 0c3892c..f0c9e8c 100644
--- a/client/widgets/radiobuttons.cc
+++ b/client/widgets/radiobuttons.cc
@@ -55,6 +55,10 @@ RadioButtons::RadioButtons(QDomNode &node, MacroWindow *macrowindow)
setMinimumHeight(elem.attribute("height").toInt());
}
+ if(elem.hasAttribute("help")) {
+ setToolTip(elem.attribute("help"));
+ }
+
QDomNodeList children = node.childNodes();
for (int i=0; i<children.count();i++) {
@@ -66,12 +70,7 @@ RadioButtons::RadioButtons(QDomNode &node, MacroWindow *macrowindow)
layout()->addWidget(radiobutton);
radiobutton_list.push_back(radiobutton);
}
-
- /* // This is done later
- if(elem.hasAttribute("value")) {
- setValue(elem.attribute("value"));
- }
- */
+
layout()->setContentsMargins(0,0,0,0);
}
diff --git a/client/widgets/textedit.cc b/client/widgets/textedit.cc
index dbc9e25..0cd2d4f 100644
--- a/client/widgets/textedit.cc
+++ b/client/widgets/textedit.cc
@@ -44,6 +44,10 @@ TextEdit::TextEdit(QDomNode &node, MacroWindow *macrowindow)
setMinimumHeight(elem.attribute("height").toInt());
}
+ if(elem.hasAttribute("help")) {
+ setToolTip(elem.attribute("help"));
+ }
+
connect(this, SIGNAL(textChanged()), this, SLOT(changed()));
/* // This is done later
diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc
index efba31c..de49968 100644
--- a/client/widgets/widget.cc
+++ b/client/widgets/widget.cc
@@ -39,8 +39,8 @@ Widget::Widget(QDomNode &node, MacroWindow *macrowindow)
elem.tagName().toStdString().c_str());
}
- if(elem.hasAttribute("lua")) {
- luaprogram = elem.attribute("lua");
+ if(elem.hasAttribute("script")) {
+ luaprogram = elem.attribute("script");
hasluaprogram = true;
} else {
hasluaprogram = false;
diff --git a/client/widgets/window.cc b/client/widgets/window.cc
index bda3667..c385d04 100644
--- a/client/widgets/window.cc
+++ b/client/widgets/window.cc
@@ -31,6 +31,8 @@
Window::Window(QDomNode &node, MacroWindow *macrowindow)
: QWidget(NULL), Widget(node, macrowindow)
{
+ setWindowFlags(Qt::WindowContextHelpButtonHint | Qt::WindowSystemMenuHint);
+
QDomElement elem = node.toElement();
if(elem.hasAttribute("width")) {
@@ -43,6 +45,10 @@ Window::Window(QDomNode &node, MacroWindow *macrowindow)
resize(width(), elem.attribute("height").toInt());
}
+ if(elem.hasAttribute("help")) {
+ setToolTip(elem.attribute("help"));
+ }
+
if(elem.hasAttribute("fixed")) {
if(elem.attribute("fixed") == "true") {
setFixedSize(width(), height());