-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 | |||
@@ -58,61 +58,67 @@ InputDialog::InputDialog(int w, int h, int newtype, QString labelString, QString | |||
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 | |||
@@ -105,48 +105,49 @@ int myMessageBox(int wi, int h, QWidget *w, int argc, QStringList args) | |||
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 | { |
@@ -166,48 +167,53 @@ int fileviewer(QPEApplication *a, int argc, QStringList args) | |||
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") |