summaryrefslogtreecommitdiff
authordwmw2 <dwmw2>2002-09-19 13:29:25 (UTC)
committer dwmw2 <dwmw2>2002-09-19 13:29:25 (UTC)
commit0f1ad29634d6bf8a0f64272d7ae8bff74707a9b8 (patch) (unidiff)
treebc37fc135ad81d720d4d1e806024173bc29bccca
parentf339a98665a80dd6d5497629c3392cf63a456917 (diff)
downloadopie-0f1ad29634d6bf8a0f64272d7ae8bff74707a9b8.zip
opie-0f1ad29634d6bf8a0f64272d7ae8bff74707a9b8.tar.gz
opie-0f1ad29634d6bf8a0f64272d7ae8bff74707a9b8.tar.bz2
Add '-p' option to opie-sh, to get user input and display '*'s
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/opie-sh/inputdialog.cpp6
-rw-r--r--noncore/tools/opie-sh/opie-sh.cpp6
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
@@ -66,46 +66,52 @@ InputDialog::InputDialog(int w, int h, int newtype, QString labelString, QString
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
91QString InputDialog::getString() 96QString 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')
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
@@ -113,32 +113,33 @@ void printusage()
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
135int fileviewer(QPEApplication *a, int argc, QStringList args) 136int 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 {
@@ -174,32 +175,37 @@ int input(int wi, int h, QWidget *w, int argc, QStringList args)
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 }