author | dwmw2 <dwmw2> | 2002-09-19 13:29:25 (UTC) |
---|---|---|
committer | dwmw2 <dwmw2> | 2002-09-19 13:29:25 (UTC) |
commit | 0f1ad29634d6bf8a0f64272d7ae8bff74707a9b8 (patch) (unidiff) | |
tree | bc37fc135ad81d720d4d1e806024173bc29bccca | |
parent | f339a98665a80dd6d5497629c3392cf63a456917 (diff) | |
download | opie-0f1ad29634d6bf8a0f64272d7ae8bff74707a9b8.zip opie-0f1ad29634d6bf8a0f64272d7ae8bff74707a9b8.tar.gz opie-0f1ad29634d6bf8a0f64272d7ae8bff74707a9b8.tar.bz2 |
Add '-p' option to opie-sh, to get user input and display '*'s
-rw-r--r-- | noncore/tools/opie-sh/inputdialog.cpp | 6 | ||||
-rw-r--r-- | noncore/tools/opie-sh/opie-sh.cpp | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/noncore/tools/opie-sh/inputdialog.cpp b/noncore/tools/opie-sh/inputdialog.cpp index 1c4e688..8046795 100644 --- a/noncore/tools/opie-sh/inputdialog.cpp +++ b/noncore/tools/opie-sh/inputdialog.cpp | |||
@@ -1,118 +1,124 @@ | |||
1 | /* | 1 | /* |
2 | Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) | 2 | Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) |
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 | #include "inputdialog.h" | 16 | #include "inputdialog.h" |
17 | 17 | ||
18 | InputDialog::InputDialog(int w, int h, int newtype, QString labelString, QString title, QString filename, bool edit, QWidget *parent, const char *name, bool modal, WFlags f):QDialog(parent, name, modal, f) | 18 | InputDialog::InputDialog(int w, int h, int newtype, QString labelString, QString title, QString filename, bool edit, QWidget *parent, const char *name, bool modal, WFlags f):QDialog(parent, name, modal, f) |
19 | { | 19 | { |
20 | type = newtype; | 20 | type = newtype; |
21 | QHBoxLayout *layout = new QHBoxLayout(this); | 21 | QHBoxLayout *layout = new QHBoxLayout(this); |
22 | layout->addStrut(32); | 22 | layout->addStrut(32); |
23 | QLabel *label = new QLabel(labelString, this, "label"); | 23 | QLabel *label = new QLabel(labelString, this, "label"); |
24 | setCaption(title); | 24 | setCaption(title); |
25 | int x, y; | 25 | int x, y; |
26 | 26 | ||
27 | layout->addSpacing(5); | 27 | layout->addSpacing(5); |
28 | layout->addWidget(label); | 28 | layout->addWidget(label); |
29 | layout->addSpacing(5); | 29 | layout->addSpacing(5); |
30 | 30 | ||
31 | switch(type) | 31 | switch(type) |
32 | { | 32 | { |
33 | case 0: | 33 | case 0: |
34 | lineEdit = new QLineEdit(this, "line edit"); | 34 | lineEdit = new QLineEdit(this, "line edit"); |
35 | layout->addWidget(lineEdit); | 35 | layout->addWidget(lineEdit); |
36 | break; | 36 | break; |
37 | case 1: | 37 | case 1: |
38 | comboBox = new QComboBox(edit, this, "combo box"); | 38 | comboBox = new QComboBox(edit, this, "combo box"); |
39 | layout->addWidget(comboBox); | 39 | layout->addWidget(comboBox); |
40 | if(!filename.isNull()) | 40 | if(!filename.isNull()) |
41 | { | 41 | { |
42 | QFile file(filename); | 42 | QFile file(filename); |
43 | file.open(IO_ReadOnly); | 43 | file.open(IO_ReadOnly); |
44 | QTextStream stream(&file); | 44 | QTextStream stream(&file); |
45 | QString string = stream.read(); | 45 | QString string = stream.read(); |
46 | 46 | ||
47 | comboBox->insertStringList(QStringList::split('\n', string)); | 47 | comboBox->insertStringList(QStringList::split('\n', string)); |
48 | } | 48 | } |
49 | else | 49 | else |
50 | { | 50 | { |
51 | QFile file; | 51 | QFile file; |
52 | file.open(IO_ReadOnly, 0); | 52 | file.open(IO_ReadOnly, 0); |
53 | QTextStream stream(&file); | 53 | QTextStream stream(&file); |
54 | QString string = stream.read(); | 54 | QString string = stream.read(); |
55 | 55 | ||
56 | comboBox->insertStringList(QStringList::split('\n', string)); | 56 | comboBox->insertStringList(QStringList::split('\n', string)); |
57 | } | 57 | } |
58 | break; | 58 | break; |
59 | case 2: | 59 | case 2: |
60 | listBox = new QListBox(this, "list box"); | 60 | listBox = new QListBox(this, "list box"); |
61 | listBox->setSelectionMode(QListBox::Multi); | 61 | listBox->setSelectionMode(QListBox::Multi); |
62 | layout->addWidget(listBox); | 62 | layout->addWidget(listBox); |
63 | if(!filename.isNull()) | 63 | if(!filename.isNull()) |
64 | { | 64 | { |
65 | QFile file(filename); | 65 | QFile file(filename); |
66 | file.open(IO_ReadOnly); | 66 | file.open(IO_ReadOnly); |
67 | QTextStream stream(&file); | 67 | QTextStream stream(&file); |
68 | QString string = stream.read(); | 68 | QString string = stream.read(); |
69 | 69 | ||
70 | listBox->insertStringList(QStringList::split('\n', string)); | 70 | listBox->insertStringList(QStringList::split('\n', string)); |
71 | } | 71 | } |
72 | else | 72 | else |
73 | { | 73 | { |
74 | QFile file; | 74 | QFile file; |
75 | file.open(IO_ReadOnly, 0); | 75 | file.open(IO_ReadOnly, 0); |
76 | QTextStream stream(&file); | 76 | QTextStream stream(&file); |
77 | QString string = stream.read(); | 77 | QString string = stream.read(); |
78 | 78 | ||
79 | listBox->insertStringList(QStringList::split('\n', string)); | 79 | listBox->insertStringList(QStringList::split('\n', string)); |
80 | } | 80 | } |
81 | break; | 81 | break; |
82 | case 3: | ||
83 | lineEdit = new QLineEdit(this, "line edit"); | ||
84 | lineEdit->setEchoMode(QLineEdit::Password); | ||
85 | layout->addWidget(lineEdit); | ||
86 | break; | ||
82 | } | 87 | } |
83 | layout->addSpacing(5); | 88 | layout->addSpacing(5); |
84 | 89 | ||
85 | x=(w/2)-(width()/2); | 90 | x=(w/2)-(width()/2); |
86 | y=(h/2)-(height()/2); | 91 | y=(h/2)-(height()/2); |
87 | 92 | ||
88 | move(x,y); | 93 | move(x,y); |
89 | } | 94 | } |
90 | 95 | ||
91 | QString InputDialog::getString() | 96 | QString InputDialog::getString() |
92 | { | 97 | { |
93 | switch (type) | 98 | switch (type) |
94 | { | 99 | { |
95 | case 0: | 100 | case 0: |
101 | case 3: | ||
96 | return ((QLineEdit *)child("line edit"))->text(); | 102 | return ((QLineEdit *)child("line edit"))->text(); |
97 | break; | 103 | break; |
98 | case 1: | 104 | case 1: |
99 | return ((QComboBox *)child("combo box"))->currentText(); | 105 | return ((QComboBox *)child("combo box"))->currentText(); |
100 | break; | 106 | break; |
101 | case 2: | 107 | case 2: |
102 | QString string; | 108 | QString string; |
103 | int i; | 109 | int i; |
104 | for(i = 0; i < listBox->count(); i++) | 110 | for(i = 0; i < listBox->count(); i++) |
105 | { | 111 | { |
106 | if(listBox->isSelected(i)) | 112 | if(listBox->isSelected(i)) |
107 | { | 113 | { |
108 | string+=listBox->text(i)+'\n'; | 114 | string+=listBox->text(i)+'\n'; |
109 | } | 115 | } |
110 | } | 116 | } |
111 | if(string[string.length()-1] == '\n') | 117 | if(string[string.length()-1] == '\n') |
112 | { | 118 | { |
113 | string.truncate(string.length()-1); | 119 | string.truncate(string.length()-1); |
114 | } | 120 | } |
115 | return string; | 121 | return string; |
116 | } | 122 | } |
117 | return QString::null; | 123 | return QString::null; |
118 | } | 124 | } |
diff --git a/noncore/tools/opie-sh/opie-sh.cpp b/noncore/tools/opie-sh/opie-sh.cpp index 96b4b93..a353d3f 100644 --- a/noncore/tools/opie-sh/opie-sh.cpp +++ b/noncore/tools/opie-sh/opie-sh.cpp | |||
@@ -1,278 +1,284 @@ | |||
1 | /* | 1 | /* |
2 | Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) | 2 | Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) |
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 <qstring.h> | 17 | #include <qstring.h> |
18 | #include <qstringlist.h> | 18 | #include <qstringlist.h> |
19 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | #include <qwidget.h> | 21 | #include <qwidget.h> |
22 | 22 | ||
23 | #include <stdio.h> | 23 | #include <stdio.h> |
24 | 24 | ||
25 | #include "mbox.h" | 25 | #include "mbox.h" |
26 | #include "fviewer.h" | 26 | #include "fviewer.h" |
27 | #include "inputdialog.h" | 27 | #include "inputdialog.h" |
28 | 28 | ||
29 | int myMessageBox(int wi, int h, QWidget *w, int argc, QStringList args) | 29 | int myMessageBox(int wi, int h, QWidget *w, int argc, QStringList args) |
30 | { | 30 | { |
31 | int i, type=0; | 31 | int i, type=0; |
32 | QString button0Text, button1Text, button2Text, string, title; | 32 | QString button0Text, button1Text, button2Text, string, title; |
33 | bool full=true; | 33 | bool full=true; |
34 | 34 | ||
35 | for(i=0; i<argc; i++) | 35 | for(i=0; i<argc; i++) |
36 | { | 36 | { |
37 | if(args[i] == "-t") | 37 | if(args[i] == "-t") |
38 | { | 38 | { |
39 | title = args[i+1]; | 39 | title = args[i+1]; |
40 | } | 40 | } |
41 | 41 | ||
42 | if(args[i] == "-M") | 42 | if(args[i] == "-M") |
43 | { | 43 | { |
44 | string = args[i+1]; | 44 | string = args[i+1]; |
45 | } | 45 | } |
46 | 46 | ||
47 | if(args[i] == "-0") | 47 | if(args[i] == "-0") |
48 | { | 48 | { |
49 | button0Text = args[i+1]; | 49 | button0Text = args[i+1]; |
50 | } | 50 | } |
51 | 51 | ||
52 | if(args[i] == "-1") | 52 | if(args[i] == "-1") |
53 | { | 53 | { |
54 | button1Text = args[i+1]; | 54 | button1Text = args[i+1]; |
55 | } | 55 | } |
56 | 56 | ||
57 | if(args[i] == "-2") | 57 | if(args[i] == "-2") |
58 | { | 58 | { |
59 | button2Text = args[i+1]; | 59 | button2Text = args[i+1]; |
60 | } | 60 | } |
61 | 61 | ||
62 | if(args[i] == "-I") | 62 | if(args[i] == "-I") |
63 | { | 63 | { |
64 | type=0; | 64 | type=0; |
65 | } | 65 | } |
66 | 66 | ||
67 | if(args[i] == "-w") | 67 | if(args[i] == "-w") |
68 | { | 68 | { |
69 | type = 1; | 69 | type = 1; |
70 | } | 70 | } |
71 | 71 | ||
72 | if(args[i] == "-e") | 72 | if(args[i] == "-e") |
73 | { | 73 | { |
74 | type = 2; | 74 | type = 2; |
75 | } | 75 | } |
76 | 76 | ||
77 | if(args[i] == "-g") | 77 | if(args[i] == "-g") |
78 | { | 78 | { |
79 | full = false; | 79 | full = false; |
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | MBox *mbox = new MBox(wi, h, (int)type, title, string, &button0Text, &button1Text, &button2Text, w, (QString)"messagebox"); | 83 | MBox *mbox = new MBox(wi, h, (int)type, title, string, &button0Text, &button1Text, &button2Text, w, (QString)"messagebox"); |
84 | if(full) | 84 | if(full) |
85 | { | 85 | { |
86 | w->setCaption(title); | 86 | w->setCaption(title); |
87 | w->showMaximized(); | 87 | w->showMaximized(); |
88 | } | 88 | } |
89 | //mbox->show(); | 89 | //mbox->show(); |
90 | switch(mbox->exec() ) | 90 | switch(mbox->exec() ) |
91 | { | 91 | { |
92 | case 0: | 92 | case 0: |
93 | return -1; | 93 | return -1; |
94 | case 1: | 94 | case 1: |
95 | return -1; | 95 | return -1; |
96 | case 2: | 96 | case 2: |
97 | return 0; | 97 | return 0; |
98 | case 3: | 98 | case 3: |
99 | return 1; | 99 | return 1; |
100 | case 4: | 100 | case 4: |
101 | return 2; | 101 | return 2; |
102 | default: return -1; | 102 | default: return -1; |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | void printusage() | 106 | void printusage() |
107 | { | 107 | { |
108 | printf("Usage instructions for Opie-sh\n"); | 108 | printf("Usage instructions for Opie-sh\n"); |
109 | printf("Usage: opie-sh [dialog type] [type specific options]\n"); | 109 | printf("Usage: opie-sh [dialog type] [type specific options]\n"); |
110 | printf("Types:\n"); | 110 | printf("Types:\n"); |
111 | printf(" -m Message Box\n"); | 111 | printf(" -m Message Box\n"); |
112 | printf(" -f [filename] View file [Default = stdin]\n"); | 112 | printf(" -f [filename] View file [Default = stdin]\n"); |
113 | printf(" -i Input dialog\n"); | 113 | printf(" -i Input dialog\n"); |
114 | printf(" -h --help These instructions\n"); | 114 | printf(" -h --help These instructions\n"); |
115 | printf(" -t [title] The window/dialog title\n"); | 115 | printf(" -t [title] The window/dialog title\n"); |
116 | printf("Message box options:\n"); | 116 | printf("Message box options:\n"); |
117 | printf(" -M [message] The message to display\n"); | 117 | printf(" -M [message] The message to display\n"); |
118 | printf(" -I Use information icon\n"); | 118 | printf(" -I Use information icon\n"); |
119 | printf(" -w Use the warning icon\n"); | 119 | printf(" -w Use the warning icon\n"); |
120 | printf(" -e Use the error icon\n"); | 120 | printf(" -e Use the error icon\n"); |
121 | printf(" -0 [text] First button text [Default = OK]\n"); | 121 | printf(" -0 [text] First button text [Default = OK]\n"); |
122 | printf(" -1 [text] Second button text\n"); | 122 | printf(" -1 [text] Second button text\n"); |
123 | printf(" -2 [text] Third button text\n"); | 123 | printf(" -2 [text] Third button text\n"); |
124 | printf(" -g Disable fullscreen\n"); | 124 | printf(" -g Disable fullscreen\n"); |
125 | printf("Input Dialog options:\n"); | 125 | printf("Input Dialog options:\n"); |
126 | printf(" -s A single line of input (output to console)\n"); | 126 | printf(" -s A single line of input (output to console)\n"); |
127 | printf(" -l List input (newline separated list read in from file)\n"); | 127 | printf(" -l List input (newline separated list read in from file)\n"); |
128 | printf(" -b A list box, enabling multiple selections (input same as -l)\n"); | 128 | printf(" -b A list box, enabling multiple selections (input same as -l)\n"); |
129 | printf(" -p Password input (display '*'s)\n"); | ||
129 | printf(" -L [label] The label for the input field\n"); | 130 | printf(" -L [label] The label for the input field\n"); |
130 | printf(" -F [filename] An input file (for when it makes sense) [Default = stdin]\n"); | 131 | printf(" -F [filename] An input file (for when it makes sense) [Default = stdin]\n"); |
131 | printf(" -E Makes list input editable\n"); | 132 | printf(" -E Makes list input editable\n"); |
132 | printf(" -g Disable fullscreen\n"); | 133 | printf(" -g Disable fullscreen\n"); |
133 | } | 134 | } |
134 | 135 | ||
135 | int fileviewer(QPEApplication *a, int argc, QStringList args) | 136 | int fileviewer(QPEApplication *a, int argc, QStringList args) |
136 | { | 137 | { |
137 | int i; | 138 | int i; |
138 | QString filename, title, icon; | 139 | QString filename, title, icon; |
139 | bool update=false; | 140 | bool update=false; |
140 | 141 | ||
141 | for(i=0; i < argc; i++) | 142 | for(i=0; i < argc; i++) |
142 | { | 143 | { |
143 | if(args[i] == "-f") | 144 | if(args[i] == "-f") |
144 | { | 145 | { |
145 | if(args[i+1][0] != '-') | 146 | if(args[i+1][0] != '-') |
146 | { | 147 | { |
147 | filename = args[i+1]; | 148 | filename = args[i+1]; |
148 | } | 149 | } |
149 | } | 150 | } |
150 | 151 | ||
151 | if(args[i] == "-I") | 152 | if(args[i] == "-I") |
152 | { | 153 | { |
153 | icon=args[i+1]; | 154 | icon=args[i+1]; |
154 | } | 155 | } |
155 | 156 | ||
156 | if(args[i] == "-t") | 157 | if(args[i] == "-t") |
157 | { | 158 | { |
158 | title = args[i+1]; | 159 | title = args[i+1]; |
159 | } | 160 | } |
160 | } | 161 | } |
161 | FViewer *fview = new FViewer(icon, filename, title, 0, (QString) "fileviewer"); | 162 | FViewer *fview = new FViewer(icon, filename, title, 0, (QString) "fileviewer"); |
162 | a->setMainWidget(fview); | 163 | a->setMainWidget(fview); |
163 | fview->showMaximized(); | 164 | fview->showMaximized(); |
164 | return a->exec(); | 165 | return a->exec(); |
165 | } | 166 | } |
166 | 167 | ||
167 | int input(int wi, int h, QWidget *w, int argc, QStringList args) | 168 | int input(int wi, int h, QWidget *w, int argc, QStringList args) |
168 | { | 169 | { |
169 | int i, type = 0; | 170 | int i, type = 0; |
170 | QString title, label, filename; | 171 | QString title, label, filename; |
171 | bool edit=false, full=true; | 172 | bool edit=false, full=true; |
172 | 173 | ||
173 | for(i=0; i < argc; i++) | 174 | for(i=0; i < argc; i++) |
174 | { | 175 | { |
175 | if(args[i] == "-s") | 176 | if(args[i] == "-s") |
176 | { | 177 | { |
177 | type = 0; | 178 | type = 0; |
178 | } | 179 | } |
179 | 180 | ||
180 | if(args[i] == "-l") | 181 | if(args[i] == "-l") |
181 | { | 182 | { |
182 | type = 1; | 183 | type = 1; |
183 | } | 184 | } |
184 | 185 | ||
185 | if(args[i] == "-b") | 186 | if(args[i] == "-b") |
186 | { | 187 | { |
187 | type = 2; | 188 | type = 2; |
188 | } | 189 | } |
189 | 190 | ||
191 | if(args[i] == "-p") | ||
192 | { | ||
193 | type = 3; | ||
194 | } | ||
195 | |||
190 | if(args[i] == "-t") | 196 | if(args[i] == "-t") |
191 | { | 197 | { |
192 | title = args[i+1]; | 198 | title = args[i+1]; |
193 | } | 199 | } |
194 | 200 | ||
195 | if(args[i] == "-L") | 201 | if(args[i] == "-L") |
196 | { | 202 | { |
197 | label = args[i+1]; | 203 | label = args[i+1]; |
198 | } | 204 | } |
199 | 205 | ||
200 | if(args[i] == "-F") | 206 | if(args[i] == "-F") |
201 | { | 207 | { |
202 | if(args[i+1][0] != '-') | 208 | if(args[i+1][0] != '-') |
203 | { | 209 | { |
204 | filename = args[i+1]; | 210 | filename = args[i+1]; |
205 | } | 211 | } |
206 | } | 212 | } |
207 | 213 | ||
208 | if(args[i] =="-E") | 214 | if(args[i] =="-E") |
209 | { | 215 | { |
210 | edit = true; | 216 | edit = true; |
211 | } | 217 | } |
212 | 218 | ||
213 | if(args[i] == "-g") | 219 | if(args[i] == "-g") |
214 | { | 220 | { |
215 | full = false; | 221 | full = false; |
216 | } | 222 | } |
217 | } | 223 | } |
218 | InputDialog *id = new InputDialog(wi, h, type, label, title, filename, edit, w); | 224 | InputDialog *id = new InputDialog(wi, h, type, label, title, filename, edit, w); |
219 | if(full) | 225 | if(full) |
220 | { | 226 | { |
221 | w->setCaption(title); | 227 | w->setCaption(title); |
222 | w->showMaximized(); | 228 | w->showMaximized(); |
223 | } | 229 | } |
224 | if( id->exec() == 1) | 230 | if( id->exec() == 1) |
225 | { | 231 | { |
226 | printf("%s\n", id->getString().latin1()); | 232 | printf("%s\n", id->getString().latin1()); |
227 | return 0; | 233 | return 0; |
228 | } | 234 | } |
229 | else | 235 | else |
230 | { | 236 | { |
231 | return -1; | 237 | return -1; |
232 | } | 238 | } |
233 | } | 239 | } |
234 | 240 | ||
235 | int main(int argc, char **argv) | 241 | int main(int argc, char **argv) |
236 | { | 242 | { |
237 | int i; | 243 | int i; |
238 | QStringList args; | 244 | QStringList args; |
239 | QPEApplication a(argc, argv); | 245 | QPEApplication a(argc, argv); |
240 | QWidget w; | 246 | QWidget w; |
241 | a.setMainWidget(&w); | 247 | a.setMainWidget(&w); |
242 | QWidget *d = a.desktop(); | 248 | QWidget *d = a.desktop(); |
243 | int width=d->width(); | 249 | int width=d->width(); |
244 | int height=d->height(); | 250 | int height=d->height(); |
245 | 251 | ||
246 | for(i=0; i < argc; i++) | 252 | for(i=0; i < argc; i++) |
247 | { | 253 | { |
248 | args += argv[i]; | 254 | args += argv[i]; |
249 | } | 255 | } |
250 | 256 | ||
251 | for(i=0; i < argc; i++) | 257 | for(i=0; i < argc; i++) |
252 | { | 258 | { |
253 | if(args[i] == "-m") | 259 | if(args[i] == "-m") |
254 | { | 260 | { |
255 | return myMessageBox(width, height, &w, argc, args); | 261 | return myMessageBox(width, height, &w, argc, args); |
256 | } | 262 | } |
257 | 263 | ||
258 | if(args[i] == "-f") | 264 | if(args[i] == "-f") |
259 | { | 265 | { |
260 | return fileviewer(&a, argc, args); | 266 | return fileviewer(&a, argc, args); |
261 | } | 267 | } |
262 | 268 | ||
263 | if(args[i] == "-i") | 269 | if(args[i] == "-i") |
264 | { | 270 | { |
265 | return input(width, height, &w, argc, args); | 271 | return input(width, height, &w, argc, args); |
266 | } | 272 | } |
267 | 273 | ||
268 | if(args[i] == "-h" || args[i] =="--help") | 274 | if(args[i] == "-h" || args[i] =="--help") |
269 | { | 275 | { |
270 | printusage(); | 276 | printusage(); |
271 | return -1; | 277 | return -1; |
272 | } | 278 | } |
273 | } | 279 | } |
274 | 280 | ||
275 | printusage(); | 281 | printusage(); |
276 | return -1; | 282 | return -1; |
277 | } | 283 | } |
278 | 284 | ||