summaryrefslogtreecommitdiff
authorpaule <paule>2007-01-28 06:41:22 (UTC)
committer paule <paule>2007-01-28 06:41:22 (UTC)
commitb17ca0982b26c0f18ccd3113906206f8fb49df2a (patch) (unidiff)
treec6e98cc4bdab06ed9b1c198badc185abbfe58088
parentec2309cb69365847762db542c41951629cd06cbe (diff)
downloadopie-b17ca0982b26c0f18ccd3113906206f8fb49df2a.zip
opie-b17ca0982b26c0f18ccd3113906206f8fb49df2a.tar.gz
opie-b17ca0982b26c0f18ccd3113906206f8fb49df2a.tar.bz2
Load in current button action on opening
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/remote/buttondialog.cpp45
-rw-r--r--noncore/tools/remote/buttondialog.h6
2 files changed, 34 insertions, 17 deletions
diff --git a/noncore/tools/remote/buttondialog.cpp b/noncore/tools/remote/buttondialog.cpp
index 56738d1..7d03f27 100644
--- a/noncore/tools/remote/buttondialog.cpp
+++ b/noncore/tools/remote/buttondialog.cpp
@@ -1,95 +1,114 @@
1/* 1/*
2Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. 2Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie.
3Copyright (C) 2002 Thomas Stephens 3Copyright (C) 2002 Thomas Stephens
4 4
5This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public 5This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later 6License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
7version. 7version.
8 8
9This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 9This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 10implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11Public License for more details. 11Public License for more details.
12 12
13You should have received a copy of the GNU General Public License along with this program; if not, write to the Free 13You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
14Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 14Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15*/ 15*/
16 16
17#include "buttondialog.h" 17#include "buttondialog.h"
18 18
19ButtonDialog::ButtonDialog(QString buttonName, QWidget *parent, const char*name, bool modal, WFlags f):QDialog(parent, name, modal, f) 19ButtonDialog::ButtonDialog(QString buttonName, QString action, QWidget *parent, const char*name, bool modal, WFlags f)
20: QDialog(parent, name, modal, f)
20{ 21{
21 setCaption(tr(buttonName)); 22 setCaption(tr(buttonName));
22 23
23 QVBoxLayout *layout = new QVBoxLayout(this); 24 QVBoxLayout *layout = new QVBoxLayout(this);
24 25
25 QHBoxLayout *hlayout1 = new QHBoxLayout(this); 26 QHBoxLayout *hlayout1 = new QHBoxLayout(this);
26 QHBoxLayout *hlayout2 = new QHBoxLayout(this); 27 QHBoxLayout *hlayout2 = new QHBoxLayout(this);
27 QHBoxLayout *hlayout3 = new QHBoxLayout(this); 28 QHBoxLayout *hlayout3 = new QHBoxLayout(this);
28 29
29 layout->addSpacing(5); 30 layout->addSpacing(5);
30 layout->addLayout(hlayout1); 31 layout->addLayout(hlayout1);
31 layout->addSpacing(5); 32 layout->addSpacing(5);
32 layout->addLayout(hlayout2); 33 layout->addLayout(hlayout2);
33 layout->addSpacing(5); 34 layout->addSpacing(5);
34 layout->addLayout(hlayout3); 35 layout->addLayout(hlayout3);
35 layout->addSpacing(5); 36 layout->addSpacing(5);
36 37
37 lh = new LircHandler(); 38 lh = new LircHandler();
38 39
39 remote = new QComboBox(false, this, "remote"); 40 remote = new QComboBox(false, this, "remote");
40 QLabel *remoteLabel = new QLabel(remote, "Remote: ", this, "remoteLabel"); 41 QLabel *remoteLabel = new QLabel(remote, "Remote: ", this, "remoteLabel");
41 hlayout1->addSpacing(5); 42 hlayout1->addSpacing(5);
42 hlayout1->addWidget(remoteLabel); 43 hlayout1->addWidget(remoteLabel);
43 hlayout1->addSpacing(5); 44 hlayout1->addSpacing(5);
44 hlayout1->addWidget(remote); 45 hlayout1->addWidget(remote);
45 hlayout1->addSpacing(5); 46 hlayout1->addSpacing(5);
46 remote->insertItem("Remote ");
47 remote->insertStringList(lh->getRemotes()); 47 remote->insertStringList(lh->getRemotes());
48 connect(remote, SIGNAL(activated(const QString&)), this, SLOT(remoteSelected(const QString&)) ); 48 connect(remote, SIGNAL(activated(const QString&)), this, SLOT(remoteSelected(const QString&)) );
49 49
50 button = new QComboBox(false, this, "button"); 50 button = new QComboBox(false, this, "button");
51 QLabel *buttonLabel = new QLabel(remote, "Button: ", this, "buttonLabel"); 51 QLabel *buttonLabel = new QLabel(remote, "Button: ", this, "buttonLabel");
52 hlayout2->addSpacing(5); 52 hlayout2->addSpacing(5);
53 hlayout2->addWidget(buttonLabel); 53 hlayout2->addWidget(buttonLabel);
54 hlayout2->addSpacing(5); 54 hlayout2->addSpacing(5);
55 hlayout2->addWidget(button); 55 hlayout2->addWidget(button);
56 hlayout2->addSpacing(5); 56 hlayout2->addSpacing(5);
57 button->insertItem("Button ");
58 connect(button, SIGNAL(activated(const QString&)), this, SLOT(buttonSelected(const QString&)) );
59 57
60 label = new QLineEdit(this, "label"); 58 label = new QLineEdit(this, "label");
61 label->setText(buttonName); 59 label->setText(buttonName);
62 QLabel *labelLabel = new QLabel(label, "Label: ", this, "labelLabel"); 60 QLabel *labelLabel = new QLabel(label, "Label: ", this, "labelLabel");
63 hlayout3->addSpacing(5); 61 hlayout3->addSpacing(5);
64 hlayout3->addWidget(labelLabel); 62 hlayout3->addWidget(labelLabel);
65 hlayout3->addSpacing(5); 63 hlayout3->addSpacing(5);
66 hlayout3->addWidget(label); 64 hlayout3->addWidget(label);
67 hlayout3->addSpacing(5); 65 hlayout3->addSpacing(5);
66
67 QStringList actionArgs = QStringList::split(' ', action);
68 if(actionArgs.count() > 1) {
69 // Remote
70 for(int i=0;i<remote->count();i++) {
71 if(remote->text(i) == actionArgs[1]) {
72 remote->setCurrentItem(i);
73 break;
74 }
75 }
76 }
77 // Populate the list of buttons
78 remoteSelected(remote->currentText());
79
80 if(actionArgs.count() > 2) {
81 // Button
82 for(int i=0;i<button->count();i++) {
83 if(button->text(i) == actionArgs[2]) {
84 button->setCurrentItem(i);
85 break;
86 }
87 }
88 }
89 else {
90 button->setCurrentItem(-1);
91 }
68} 92}
69 93
70ButtonDialog::~ButtonDialog() 94ButtonDialog::~ButtonDialog()
71{ 95{
72 delete lh; 96 delete lh;
73} 97}
74 98
75void ButtonDialog::remoteSelected(const QString &string) 99void ButtonDialog::remoteSelected(const QString &string)
76{ 100{
101 button->clear();
77 button->insertStringList(lh->getButtons(string.latin1()) ); 102 button->insertStringList(lh->getButtons(string.latin1()) );
78 list="SEND_ONCE";
79 list+=string;
80}
81
82void ButtonDialog::buttonSelected(const QString &string)
83{
84 list+=string;
85} 103}
86 104
87QStringList ButtonDialog::getList() 105QString ButtonDialog::getAction()
88{ 106{
89 return list; 107 QString action("SEND_ONCE " + remote->currentText() + " " + button->currentText());
108 return action;
90} 109}
91 110
92QString ButtonDialog::getLabel() 111QString ButtonDialog::getLabel()
93{ 112{
94 return label->text(); 113 return label->text();
95} 114}
diff --git a/noncore/tools/remote/buttondialog.h b/noncore/tools/remote/buttondialog.h
index cc697b5..f66903f 100644
--- a/noncore/tools/remote/buttondialog.h
+++ b/noncore/tools/remote/buttondialog.h
@@ -1,53 +1,51 @@
1/* 1/*
2Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. 2Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie.
3Copyright (C) 2002 Thomas Stephens 3Copyright (C) 2002 Thomas Stephens
4 4
5This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public 5This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later 6License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
7version. 7version.
8 8
9This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 9This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 10implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11Public License for more details. 11Public License for more details.
12 12
13You should have received a copy of the GNU General Public License along with this program; if not, write to the Free 13You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
14Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 14Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15*/ 15*/
16 16
17#include <qdialog.h> 17#include <qdialog.h>
18#include <qstring.h> 18#include <qstring.h>
19#include <qstringlist.h> 19#include <qstringlist.h>
20#include <qcombobox.h> 20#include <qcombobox.h>
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qlabel.h> 22#include <qlabel.h>
23#include <qlineedit.h> 23#include <qlineedit.h>
24#include <qmessagebox.h> 24#include <qmessagebox.h>
25#include <stdio.h> 25#include <stdio.h>
26#include <stdlib.h> 26#include <stdlib.h>
27#include <string.h> 27#include <string.h>
28#include <sys/socket.h> 28#include <sys/socket.h>
29#include <sys/types.h> 29#include <sys/types.h>
30#include <sys/un.h> 30#include <sys/un.h>
31#include <unistd.h> 31#include <unistd.h>
32#include <errno.h> 32#include <errno.h>
33 33
34#include "lirchandler.h" 34#include "lirchandler.h"
35 35
36class ButtonDialog : public QDialog 36class ButtonDialog : public QDialog
37{ 37{
38 Q_OBJECT 38 Q_OBJECT
39public: 39public:
40 ButtonDialog(QString buttonName, QWidget *parent=0, const char*name=0, bool modal=FALSE, WFlags f=0); 40 ButtonDialog(QString buttonName, QString action, QWidget *parent=0, const char*name=0, bool modal=FALSE, WFlags f=0);
41 ~ButtonDialog(); 41 ~ButtonDialog();
42 QStringList getList(); 42 QString getAction();
43 QString getLabel(); 43 QString getLabel();
44public slots: 44public slots:
45 void remoteSelected(const QString &string); 45 void remoteSelected(const QString &string);
46 void buttonSelected(const QString &string);
47private: 46private:
48 QComboBox *remote; 47 QComboBox *remote;
49 QComboBox *button; 48 QComboBox *button;
50 QStringList list;
51 QLineEdit *label; 49 QLineEdit *label;
52 LircHandler *lh; 50 LircHandler *lh;
53}; 51};