author | paule <paule> | 2007-02-07 10:29:42 (UTC) |
---|---|---|
committer | paule <paule> | 2007-02-07 10:29:42 (UTC) |
commit | 83d7fd04cc8e1fcafb345f74bc861515e17c5414 (patch) (unidiff) | |
tree | cac8b8e8481a9ea8df48b7393439de7e686a4a09 | |
parent | 6629be2c0147283023abcf021227bf74ca18849f (diff) | |
download | opie-83d7fd04cc8e1fcafb345f74bc861515e17c5414.zip opie-83d7fd04cc8e1fcafb345f74bc861515e17c5414.tar.gz opie-83d7fd04cc8e1fcafb345f74bc861515e17c5414.tar.bz2 |
Rename Add button to Learn; remove Edit button; move list updating to its own public slot and don't call it automatically (should be called from MainView when lircd is properly set up); correctly show learn dialog modal and update list when it closes; delete learn dialog when done
-rw-r--r-- | noncore/tools/remote/learntab.cpp | 51 | ||||
-rw-r--r-- | noncore/tools/remote/learntab.h | 4 |
2 files changed, 34 insertions, 21 deletions
diff --git a/noncore/tools/remote/learntab.cpp b/noncore/tools/remote/learntab.cpp index 69d2e7f..82de631 100644 --- a/noncore/tools/remote/learntab.cpp +++ b/noncore/tools/remote/learntab.cpp | |||
@@ -1,66 +1,79 @@ | |||
1 | /* | 1 | /* |
2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. | 2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. |
3 | Copyright (C) 2002 Thomas Stephens | 3 | Copyright (C) 2002 Thomas Stephens |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public | 5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public |
6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later | 6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later |
7 | version. | 7 | version. |
8 | 8 | ||
9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | 9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11 | Public License for more details. | 11 | Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free | 13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free |
14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include "learntab.h" | 17 | #include "learntab.h" |
18 | 18 | ||
19 | /* OPIE */ | 19 | /* OPIE */ |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | 21 | ||
22 | LearnTab::LearnTab(QWidget *parent, const char *name):QWidget(parent,name) | 22 | LearnTab::LearnTab(QWidget *parent, const char *name):QWidget(parent,name) |
23 | { | 23 | { |
24 | LircHandler lh; | ||
25 | |||
26 | QVBoxLayout *layout = new QVBoxLayout(this); | 24 | QVBoxLayout *layout = new QVBoxLayout(this); |
27 | QHBoxLayout *bottomLayout = new QHBoxLayout(this); | 25 | QHBoxLayout *bottomLayout = new QHBoxLayout(this); |
28 | 26 | ||
29 | layout->insertSpacing(0,5); | 27 | layout->insertSpacing(0,5); |
30 | remotesBox = new QListBox(this, "remotesBox"); | 28 | remotesBox = new QListBox(this, "remotesBox"); |
31 | layout->insertWidget(0, remotesBox, 1); | 29 | layout->insertWidget(0, remotesBox, 1); |
32 | remotesBox->insertStringList(lh.getRemotes()); | ||
33 | 30 | ||
34 | layout->insertSpacing(-1,5); | 31 | layout->insertSpacing(-1,5); |
35 | layout->insertLayout(-1, bottomLayout); | 32 | layout->insertLayout(-1, bottomLayout); |
36 | layout->insertSpacing(-1,5); | 33 | layout->insertSpacing(-1,5); |
37 | 34 | ||
38 | QPushButton *add = new QPushButton("Add", this, "add"); | 35 | QPushButton *learn = new QPushButton(tr("Learn"), this, "learn"); |
39 | bottomLayout->insertSpacing(-1, 5); | ||
40 | bottomLayout->insertWidget(-1, add); | ||
41 | bottomLayout->insertSpacing(-1, 5); | 36 | bottomLayout->insertSpacing(-1, 5); |
42 | QPushButton *edit = new QPushButton("Edit", this, "edit"); | 37 | bottomLayout->insertWidget(-1, learn); |
43 | bottomLayout->insertWidget(-1, edit); | ||
44 | bottomLayout->insertSpacing(-1, 5); | 38 | bottomLayout->insertSpacing(-1, 5); |
45 | QPushButton *del = new QPushButton("Delete", this, "delete"); | 39 | QPushButton *del = new QPushButton(tr("Delete"), this, "delete"); |
46 | bottomLayout->insertWidget(-1, del); | 40 | bottomLayout->insertWidget(-1, del); |
47 | bottomLayout->insertSpacing(-1, 5); | 41 | bottomLayout->insertSpacing(-1, 5); |
48 | 42 | ||
49 | connect(add, SIGNAL(clicked()), this, SLOT(add()) ); | 43 | connect(learn, SIGNAL(clicked()), this, SLOT(learn()) ); |
50 | connect(edit, SIGNAL(clicked()), this, SLOT(edit()) ); | ||
51 | connect(del, SIGNAL(clicked()), this, SLOT(del()) ); | 44 | connect(del, SIGNAL(clicked()), this, SLOT(del()) ); |
52 | } | 45 | } |
53 | 46 | ||
54 | void LearnTab::add() | 47 | void LearnTab::learn() |
55 | { | 48 | { |
56 | printf("LearnTab::add: add pressed\n"); | 49 | printf("LearnTab::learn: learn pressed\n"); |
57 | RecordDialog *dialog = new RecordDialog(this); | 50 | RecordDialog *dialog = new RecordDialog(this); |
58 | QPEApplication::showDialog( dialog ); | 51 | dialog->showMaximized(); |
52 | dialog->exec(); | ||
53 | delete dialog; | ||
54 | updateRemotesList(); | ||
59 | } | 55 | } |
60 | 56 | ||
61 | void LearnTab::edit() | ||
62 | {} | ||
63 | |||
64 | void LearnTab::del() | 57 | void LearnTab::del() |
65 | {} | 58 | { |
59 | QString remotename = remotesBox->currentText(); | ||
60 | |||
61 | if(remotename != "") { | ||
62 | if (QMessageBox::warning(this, tr("Delete"), | ||
63 | tr("Are you sure you want\n to delete %1?").arg(remotename), | ||
64 | QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) { | ||
65 | LircHandler lh; | ||
66 | lh.removeRemote(remotename); | ||
67 | lh.reloadLircdConf(); | ||
68 | updateRemotesList(); | ||
69 | } | ||
70 | } | ||
71 | } | ||
66 | 72 | ||
73 | void LearnTab::updateRemotesList() | ||
74 | { | ||
75 | LircHandler lh; | ||
76 | remotesBox->clear(); | ||
77 | if(lh.checkLircdConfValid(true)) | ||
78 | remotesBox->insertStringList(lh.getRemotes()); | ||
79 | } | ||
diff --git a/noncore/tools/remote/learntab.h b/noncore/tools/remote/learntab.h index c9d8e41..ac9568a 100644 --- a/noncore/tools/remote/learntab.h +++ b/noncore/tools/remote/learntab.h | |||
@@ -1,48 +1,48 @@ | |||
1 | /* | 1 | /* |
2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. | 2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. |
3 | Copyright (C) 2002 Thomas Stephens | 3 | Copyright (C) 2002 Thomas Stephens |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public | 5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public |
6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later | 6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later |
7 | version. | 7 | version. |
8 | 8 | ||
9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | 9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11 | Public License for more details. | 11 | Public License for more details. |
12 | 12 | ||
13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free | 13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free |
14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <qwidget.h> | 17 | #include <qwidget.h> |
18 | #include <qlistbox.h> | 18 | #include <qlistbox.h> |
19 | #include <qstring.h> | 19 | #include <qstring.h> |
20 | #include <qstringlist.h> | 20 | #include <qstringlist.h> |
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qpushbutton.h> | 22 | #include <qpushbutton.h> |
23 | #include <qmessagebox.h> | 23 | #include <qmessagebox.h> |
24 | 24 | ||
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 "recorddialog.h" | 34 | #include "recorddialog.h" |
35 | #include "lirchandler.h" | 35 | #include "lirchandler.h" |
36 | 36 | ||
37 | class LearnTab : public QWidget | 37 | class LearnTab : public QWidget |
38 | { | 38 | { |
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | public: | 40 | public: |
41 | LearnTab(QWidget *parent=0, const char *name=0); | 41 | LearnTab(QWidget *parent=0, const char *name=0); |
42 | public slots: | 42 | public slots: |
43 | void add(); | 43 | void learn(); |
44 | void edit(); | ||
45 | void del(); | 44 | void del(); |
45 | void updateRemotesList(); | ||
46 | private: | 46 | private: |
47 | QListBox *remotesBox; | 47 | QListBox *remotesBox; |
48 | }; | 48 | }; |