-rw-r--r-- | noncore/tools/opie-sh/fviewer.cpp | 56 | ||||
-rw-r--r-- | noncore/tools/opie-sh/fviewer.h | 35 | ||||
-rw-r--r-- | noncore/tools/opie-sh/inputdialog.cpp | 117 | ||||
-rw-r--r-- | noncore/tools/opie-sh/inputdialog.h | 38 | ||||
-rw-r--r-- | noncore/tools/opie-sh/mbox.cpp | 90 | ||||
-rw-r--r-- | noncore/tools/opie-sh/mbox.h | 38 | ||||
-rw-r--r-- | noncore/tools/opie-sh/opie-sh.control | 10 | ||||
-rw-r--r-- | noncore/tools/opie-sh/opie-sh.cpp | 269 | ||||
-rw-r--r-- | noncore/tools/opie-sh/opie-sh.pro | 10 | ||||
-rw-r--r-- | pics/opie-sh/error.png | bin | 0 -> 675 bytes | |||
-rwxr-xr-x | pics/opie-sh/info.png | bin | 0 -> 1053 bytes | |||
-rw-r--r-- | pics/opie-sh/warning.png | bin | 0 -> 609 bytes |
12 files changed, 663 insertions, 0 deletions
diff --git a/noncore/tools/opie-sh/fviewer.cpp b/noncore/tools/opie-sh/fviewer.cpp new file mode 100644 index 0000000..1a0acc6 --- a/dev/null +++ b/noncore/tools/opie-sh/fviewer.cpp | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) | ||
3 | Copyright (C) 2002 Thomas Stephens | ||
4 | |||
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 | ||
7 | version. | ||
8 | |||
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 | ||
11 | Public License for more details. | ||
12 | |||
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 | ||
15 | */ | ||
16 | #include "fviewer.h" | ||
17 | |||
18 | FViewer::FViewer(QString filename, QString title, QWidget *parent=0, const char*name=0):QWidget(parent, name) | ||
19 | { | ||
20 | QVBoxLayout *layout = new QVBoxLayout(this); | ||
21 | |||
22 | textView = new QTextBrowser(this, "textview"); | ||
23 | layout->addWidget(textView); | ||
24 | |||
25 | QString string; | ||
26 | |||
27 | if(title.isNull()) | ||
28 | { | ||
29 | setCaption(filename); | ||
30 | } | ||
31 | else | ||
32 | { | ||
33 | setCaption(title); | ||
34 | } | ||
35 | |||
36 | file = new QFile(); | ||
37 | |||
38 | if(!filename.isNull()) | ||
39 | { | ||
40 | file->setName(filename); | ||
41 | file->open(IO_ReadOnly); | ||
42 | } | ||
43 | else | ||
44 | { | ||
45 | file->open(IO_ReadOnly, 0); | ||
46 | } | ||
47 | |||
48 | stream = new QTextStream(file); | ||
49 | |||
50 | string = stream->read(); | ||
51 | textView->setText(string); | ||
52 | textView->mimeSourceFactory()->setFilePath(QDir::currentDirPath()); | ||
53 | file->close(); | ||
54 | |||
55 | } | ||
56 | |||
diff --git a/noncore/tools/opie-sh/fviewer.h b/noncore/tools/opie-sh/fviewer.h new file mode 100644 index 0000000..488b6ed --- a/dev/null +++ b/noncore/tools/opie-sh/fviewer.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) | ||
3 | Copyright (C) 2002 Thomas Stephens | ||
4 | |||
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 | ||
7 | version. | ||
8 | |||
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 | ||
11 | Public License for more details. | ||
12 | |||
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 | ||
15 | */ | ||
16 | |||
17 | #include <qwidget.h> | ||
18 | #include <qfile.h> | ||
19 | #include <qtextstream.h> | ||
20 | #include <qtextbrowser.h> | ||
21 | #include <qlayout.h> | ||
22 | #include <qtimer.h> | ||
23 | #include <qdir.h> | ||
24 | |||
25 | class FViewer :public QWidget | ||
26 | { | ||
27 | Q_OBJECT | ||
28 | public: | ||
29 | FViewer(QString filename, QString title, QWidget *parent=0, const char*name=0); | ||
30 | private: | ||
31 | QFile *file; | ||
32 | QTextBrowser *textView; | ||
33 | QTextStream *stream; | ||
34 | QTimer *timer; | ||
35 | }; | ||
diff --git a/noncore/tools/opie-sh/inputdialog.cpp b/noncore/tools/opie-sh/inputdialog.cpp new file mode 100644 index 0000000..0780def --- a/dev/null +++ b/noncore/tools/opie-sh/inputdialog.cpp | |||
@@ -0,0 +1,117 @@ | |||
1 | /* | ||
2 | Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) | ||
3 | Copyright (C) 2002 Thomas Stephens | ||
4 | |||
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 | ||
7 | version. | ||
8 | |||
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 | ||
11 | Public License for more details. | ||
12 | |||
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 | ||
15 | */ | ||
16 | #include "inputdialog.h" | ||
17 | |||
18 | InputDialog::InputDialog(int w, int h, int newtype, QString labelString, QString title, QString filename, bool edit, QWidget *parent=0, const char *name=0, bool modal=true, WFlags f=0):QDialog(parent, name, modal, f) | ||
19 | { | ||
20 | type = newtype; | ||
21 | QHBoxLayout *layout = new QHBoxLayout(this); | ||
22 | layout->addStrut(32); | ||
23 | QLabel *label = new QLabel(labelString, this, "label"); | ||
24 | setCaption(title); | ||
25 | int x, y; | ||
26 | |||
27 | layout->addSpacing(5); | ||
28 | layout->addWidget(label); | ||
29 | layout->addSpacing(5); | ||
30 | |||
31 | switch(type) | ||
32 | { | ||
33 | case 0: | ||
34 | lineEdit = new QLineEdit(this, "line edit"); | ||
35 | layout->addWidget(lineEdit); | ||
36 | break; | ||
37 | case 1: | ||
38 | comboBox = new QComboBox(edit, this, "combo box"); | ||
39 | layout->addWidget(comboBox); | ||
40 | if(!filename.isNull()) | ||
41 | { | ||
42 | QFile file(filename); | ||
43 | file.open(IO_ReadOnly); | ||
44 | QTextStream stream(&file); | ||
45 | QString string = stream.read(); | ||
46 | |||
47 | comboBox->insertStringList(QStringList::split('\n', string)); | ||
48 | } | ||
49 | else | ||
50 | { | ||
51 | QFile file; | ||
52 | file.open(IO_ReadOnly, 0); | ||
53 | QTextStream stream(&file); | ||
54 | QString string = stream.read(); | ||
55 | |||
56 | comboBox->insertStringList(QStringList::split('\n', string)); | ||
57 | } | ||
58 | break; | ||
59 | case 2: | ||
60 | listBox = new QListBox(this, "list box"); | ||
61 | listBox->setSelectionMode(QListBox::Multi); | ||
62 | layout->addWidget(listBox); | ||
63 | if(!filename.isNull()) | ||
64 | { | ||
65 | QFile file(filename); | ||
66 | file.open(IO_ReadOnly); | ||
67 | QTextStream stream(&file); | ||
68 | QString string = stream.read(); | ||
69 | |||
70 | listBox->insertStringList(QStringList::split('\n', string)); | ||
71 | } | ||
72 | else | ||
73 | { | ||
74 | QFile file; | ||
75 | file.open(IO_ReadOnly, 0); | ||
76 | QTextStream stream(&file); | ||
77 | QString string = stream.read(); | ||
78 | |||
79 | listBox->insertStringList(QStringList::split('\n', string)); | ||
80 | } | ||
81 | break; | ||
82 | } | ||
83 | layout->addSpacing(5); | ||
84 | |||
85 | x=(w/2)-(width()/2); | ||
86 | y=(h/2)-(height()/2); | ||
87 | |||
88 | move(x,y); | ||
89 | } | ||
90 | |||
91 | QString InputDialog::getString() | ||
92 | { | ||
93 | switch (type) | ||
94 | { | ||
95 | case 0: | ||
96 | return ((QLineEdit *)child("line edit"))->text(); | ||
97 | break; | ||
98 | case 1: | ||
99 | return ((QComboBox *)child("combo box"))->currentText(); | ||
100 | break; | ||
101 | case 2: | ||
102 | QString string; | ||
103 | int i; | ||
104 | for(i = 0; i < listBox->count(); i++) | ||
105 | { | ||
106 | if(listBox->isSelected(i)) | ||
107 | { | ||
108 | string+=listBox->text(i)+'\n'; | ||
109 | } | ||
110 | } | ||
111 | if(string[string.length()-1] == '\n') | ||
112 | { | ||
113 | string.truncate(string.length()-1); | ||
114 | } | ||
115 | return string; | ||
116 | } | ||
117 | } | ||
diff --git a/noncore/tools/opie-sh/inputdialog.h b/noncore/tools/opie-sh/inputdialog.h new file mode 100644 index 0000000..9624db7 --- a/dev/null +++ b/noncore/tools/opie-sh/inputdialog.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) | ||
3 | Copyright (C) 2002 Thomas Stephens | ||
4 | |||
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 | ||
7 | version. | ||
8 | |||
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 | ||
11 | Public License for more details. | ||
12 | |||
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 | ||
15 | */ | ||
16 | |||
17 | #include <qdialog.h> | ||
18 | #include <qstring.h> | ||
19 | #include <qlineedit.h> | ||
20 | #include <qlayout.h> | ||
21 | #include <qlabel.h> | ||
22 | #include <qcombobox.h> | ||
23 | #include <qfile.h> | ||
24 | #include <qtextstream.h> | ||
25 | #include <qlistbox.h> | ||
26 | |||
27 | class InputDialog : public QDialog | ||
28 | { | ||
29 | Q_OBJECT | ||
30 | public: | ||
31 | InputDialog(int w, int h, int newtype, QString labelString, QString title, QString filename, bool edit, QWidget *parent=0, const char *name=0, bool modal=true, WFlags f=0); | ||
32 | QString getString(); | ||
33 | private: | ||
34 | int type; | ||
35 | QLineEdit *lineEdit; | ||
36 | QComboBox *comboBox; | ||
37 | QListBox *listBox; | ||
38 | }; | ||
diff --git a/noncore/tools/opie-sh/mbox.cpp b/noncore/tools/opie-sh/mbox.cpp new file mode 100644 index 0000000..cb3ea1b --- a/dev/null +++ b/noncore/tools/opie-sh/mbox.cpp | |||
@@ -0,0 +1,90 @@ | |||
1 | /* | ||
2 | Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) | ||
3 | Copyright (C) 2002 Thomas Stephens | ||
4 | |||
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 | ||
7 | version. | ||
8 | |||
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 | ||
11 | Public License for more details. | ||
12 | |||
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 | ||
15 | */ | ||
16 | |||
17 | #include "mbox.h" | ||
18 | |||
19 | MBox::MBox(int w, int h, int type, QString title, QString message, QString *btext0 = 0, QString *btext1= 0, QString *btext2 = 0, QWidget *parent=0, const char*name=0, bool modal=true, WFlags f=0):QDialog(parent, name, modal, f) | ||
20 | { | ||
21 | QVBoxLayout *layout = new QVBoxLayout(this); | ||
22 | |||
23 | QHBoxLayout *hlayout1 = new QHBoxLayout(this); | ||
24 | QHBoxLayout *hlayout2 = new QHBoxLayout(this); | ||
25 | |||
26 | int x, y; | ||
27 | |||
28 | layout->addLayout(hlayout1); | ||
29 | layout->addLayout(hlayout2); | ||
30 | |||
31 | setCaption(title); | ||
32 | |||
33 | QLabel *image = new QLabel(this, "image"); | ||
34 | QLabel *text = new QLabel(message, this, "text"); | ||
35 | |||
36 | switch (type) | ||
37 | { | ||
38 | case 0: | ||
39 | image->setPixmap(Resource::loadPixmap("opie-sh/info")); | ||
40 | break; | ||
41 | case 1: | ||
42 | image->setPixmap(Resource::loadPixmap("opie-sh/warning")); | ||
43 | break; | ||
44 | case 2: | ||
45 | image->setPixmap(Resource::loadPixmap("opie-sh/error")); | ||
46 | break; | ||
47 | } | ||
48 | |||
49 | hlayout1->addWidget(image); | ||
50 | hlayout1->addSpacing(5); | ||
51 | hlayout1->addWidget(text); | ||
52 | |||
53 | if(!btext0->isNull()) | ||
54 | { | ||
55 | QPushButton *button0 = new QPushButton((const QString)*btext0, this, "button0"); | ||
56 | hlayout2->addSpacing(5); | ||
57 | hlayout2->addWidget(button0); | ||
58 | hlayout2->addSpacing(5); | ||
59 | connect(button0, SIGNAL(clicked()), this, SLOT(b0pressed()) ); | ||
60 | } | ||
61 | else | ||
62 | { | ||
63 | QPushButton *button0 = new QPushButton("Ok", this, "button0"); | ||
64 | hlayout2->addSpacing(5); | ||
65 | hlayout2->addWidget(button0); | ||
66 | hlayout2->addSpacing(5); | ||
67 | connect(button0, SIGNAL(clicked()), this, SLOT(b0pressed()) ); | ||
68 | } | ||
69 | |||
70 | if(!btext1->isNull()) | ||
71 | { | ||
72 | QPushButton *button1 = new QPushButton((const QString)*btext1, this, "button1"); | ||
73 | hlayout2->addWidget(button1); | ||
74 | hlayout2->addSpacing(5); | ||
75 | connect(button1, SIGNAL(clicked()), this, SLOT(b1pressed()) ); | ||
76 | } | ||
77 | |||
78 | if(!btext2->isNull()) | ||
79 | { | ||
80 | QPushButton *button2 = new QPushButton((const QString)*btext2, this, "button2"); | ||
81 | hlayout2->addWidget(button2); | ||
82 | hlayout2->addSpacing(5); | ||
83 | connect(button2, SIGNAL(clicked()), this, SLOT(b2pressed()) ); | ||
84 | } | ||
85 | |||
86 | x=(w/2)-(width()/2); | ||
87 | y=(h/2)-(height()/2); | ||
88 | |||
89 | move(x, y); | ||
90 | } | ||
diff --git a/noncore/tools/opie-sh/mbox.h b/noncore/tools/opie-sh/mbox.h new file mode 100644 index 0000000..66c982a --- a/dev/null +++ b/noncore/tools/opie-sh/mbox.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) | ||
3 | Copyright (C) 2002 Thomas Stephens | ||
4 | |||
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 | ||
7 | version. | ||
8 | |||
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 | ||
11 | Public License for more details. | ||
12 | |||
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 | ||
15 | */ | ||
16 | |||
17 | #include <qpe/resource.h> | ||
18 | #include <qdialog.h> | ||
19 | #include <qstring.h> | ||
20 | #include <qiconset.h> | ||
21 | #include <qpixmap.h> | ||
22 | #include <qlabel.h> | ||
23 | #include <qlayout.h> | ||
24 | #include <qpushbutton.h> | ||
25 | #include <qwidget.h> | ||
26 | |||
27 | #include <unistd.h> | ||
28 | |||
29 | class MBox : public QDialog | ||
30 | { | ||
31 | Q_OBJECT | ||
32 | public: | ||
33 | MBox(int w, int h, int type, QString title, QString message, QString *btext0 = 0, QString *btext1= 0, QString *btext2 = 0, QWidget *parent=0, const char*name=0, bool modal=true, WFlags f=0); | ||
34 | public slots: | ||
35 | void b0pressed(){done(2);}; | ||
36 | void b1pressed(){done(3);}; | ||
37 | void b2pressed(){done(4);}; | ||
38 | }; | ||
diff --git a/noncore/tools/opie-sh/opie-sh.control b/noncore/tools/opie-sh/opie-sh.control new file mode 100644 index 0000000..e9b13a5 --- a/dev/null +++ b/noncore/tools/opie-sh/opie-sh.control | |||
@@ -0,0 +1,10 @@ | |||
1 | Files: bin/opie-sh pics/opie-sh/*.png | ||
2 | Priority: optional | ||
3 | Section: opie/applications | ||
4 | Maintainer: Thomas Stephens <spiralman@softhome.net> | ||
5 | Architecture: arm | ||
6 | Version: 0.4-$SUB_VERSION | ||
7 | Depends: opie-base ($QPE_VERSION) | ||
8 | License: GPL | ||
9 | Description: a QDialog shell frontend | ||
10 | A program to let you use various dialogs from the console (or a shell script) | ||
diff --git a/noncore/tools/opie-sh/opie-sh.cpp b/noncore/tools/opie-sh/opie-sh.cpp new file mode 100644 index 0000000..a1b8035 --- a/dev/null +++ b/noncore/tools/opie-sh/opie-sh.cpp | |||
@@ -0,0 +1,269 @@ | |||
1 | /* | ||
2 | Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) | ||
3 | Copyright (C) 2002 Thomas Stephens | ||
4 | |||
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 | ||
7 | version. | ||
8 | |||
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 | ||
11 | Public License for more details. | ||
12 | |||
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 | ||
15 | */ | ||
16 | |||
17 | #include <qstring.h> | ||
18 | #include <qstringlist.h> | ||
19 | #include <qpe/qpeapplication.h> | ||
20 | #include <qmessagebox.h> | ||
21 | #include <qwidget.h> | ||
22 | |||
23 | #include <stdio.h> | ||
24 | |||
25 | #include "mbox.h" | ||
26 | #include "fviewer.h" | ||
27 | #include "inputdialog.h" | ||
28 | |||
29 | int myMessageBox(int wi, int h, QWidget *w, int argc, QStringList args) | ||
30 | { | ||
31 | int i, type=0; | ||
32 | QString button0Text, button1Text, button2Text, string, title; | ||
33 | bool full=true; | ||
34 | |||
35 | for(i=0; i<argc; i++) | ||
36 | { | ||
37 | if(args[i] == "-t") | ||
38 | { | ||
39 | title = args[i+1]; | ||
40 | } | ||
41 | |||
42 | if(args[i] == "-M") | ||
43 | { | ||
44 | string = args[i+1]; | ||
45 | } | ||
46 | |||
47 | if(args[i] == "-0") | ||
48 | { | ||
49 | button0Text = args[i+1]; | ||
50 | } | ||
51 | |||
52 | if(args[i] == "-1") | ||
53 | { | ||
54 | button1Text = args[i+1]; | ||
55 | } | ||
56 | |||
57 | if(args[i] == "-2") | ||
58 | { | ||
59 | button2Text = args[i+1]; | ||
60 | } | ||
61 | |||
62 | if(args[i] == "-I") | ||
63 | { | ||
64 | type=0; | ||
65 | } | ||
66 | |||
67 | if(args[i] == "-w") | ||
68 | { | ||
69 | type = 1; | ||
70 | } | ||
71 | |||
72 | if(args[i] == "-e") | ||
73 | { | ||
74 | type = 2; | ||
75 | } | ||
76 | |||
77 | if(args[i] == "-g") | ||
78 | { | ||
79 | full = false; | ||
80 | } | ||
81 | } | ||
82 | |||
83 | MBox *mbox = new MBox(wi, h, (int)type, title, string, &button0Text, &button1Text, &button2Text, w, (QString)"messagebox"); | ||
84 | if(full) | ||
85 | { | ||
86 | w->setCaption(title); | ||
87 | w->showMaximized(); | ||
88 | } | ||
89 | //mbox->show(); | ||
90 | switch(mbox->exec() ) | ||
91 | { | ||
92 | case 0: | ||
93 | return -1; | ||
94 | case 1: | ||
95 | return -1; | ||
96 | case 2: | ||
97 | return 0; | ||
98 | case 3: | ||
99 | return 1; | ||
100 | case 4: | ||
101 | return 2; | ||
102 | } | ||
103 | } | ||
104 | |||
105 | void printusage() | ||
106 | { | ||
107 | printf("Usage instructions for Opie-sh\n"); | ||
108 | printf("Usage: opie-sh [dialog type] [type specific options]\n"); | ||
109 | printf("Types:\n"); | ||
110 | printf(" -m Message Box\n"); | ||
111 | printf(" -f [filename] View file [Default = stdin]\n"); | ||
112 | printf(" -i Input dialog\n"); | ||
113 | printf(" -h --help These instructions\n"); | ||
114 | printf(" -t [title] The window/dialog title\n"); | ||
115 | printf("Message box options:\n"); | ||
116 | printf(" -M [message] The message to display\n"); | ||
117 | printf(" -I Use information icon\n"); | ||
118 | printf(" -w Use the warning icon\n"); | ||
119 | printf(" -e Use the error icon\n"); | ||
120 | printf(" -0 [text] First button text [Default = OK]\n"); | ||
121 | printf(" -1 [text] Second button text\n"); | ||
122 | printf(" -2 [text] Third button text\n"); | ||
123 | printf(" -g Disable fullscreen\n"); | ||
124 | printf("Input Dialog options:\n"); | ||
125 | printf(" -s A single line of input (output to console)\n"); | ||
126 | printf(" -l List input (newline separated list read in from file)\n"); | ||
127 | printf(" -b A list box, enabling multiple selections (input same as -l)\n"); | ||
128 | printf(" -L [label] The label for the input field\n"); | ||
129 | printf(" -F [filename] An input file (for when it makes sense) [Default = stdin]\n"); | ||
130 | printf(" -E Makes list input editable\n"); | ||
131 | printf(" -g Disable fullscreen\n"); | ||
132 | } | ||
133 | |||
134 | int fileviewer(QPEApplication *a, int argc, QStringList args) | ||
135 | { | ||
136 | int i; | ||
137 | QString filename, title; | ||
138 | bool update=false; | ||
139 | |||
140 | for(i=0; i < argc; i++) | ||
141 | { | ||
142 | if(args[i] == "-f") | ||
143 | { | ||
144 | if(args[i+1][0] != '-') | ||
145 | { | ||
146 | filename = args[i+1]; | ||
147 | } | ||
148 | } | ||
149 | |||
150 | if(args[i] == "-t") | ||
151 | { | ||
152 | title = args[i+1]; | ||
153 | } | ||
154 | } | ||
155 | FViewer *fview = new FViewer(filename, title, 0, (QString) "fileviewer"); | ||
156 | a->setMainWidget(fview); | ||
157 | fview->showMaximized(); | ||
158 | return a->exec(); | ||
159 | } | ||
160 | |||
161 | int input(int wi, int h, QWidget *w, int argc, QStringList args) | ||
162 | { | ||
163 | int i, type = 0; | ||
164 | QString title, label, filename; | ||
165 | bool edit=false, full=true; | ||
166 | |||
167 | for(i=0; i < argc; i++) | ||
168 | { | ||
169 | if(args[i] == "-s") | ||
170 | { | ||
171 | type = 0; | ||
172 | } | ||
173 | |||
174 | if(args[i] == "-l") | ||
175 | { | ||
176 | type = 1; | ||
177 | } | ||
178 | |||
179 | if(args[i] == "-b") | ||
180 | { | ||
181 | type = 2; | ||
182 | } | ||
183 | |||
184 | if(args[i] == "-t") | ||
185 | { | ||
186 | title = args[i+1]; | ||
187 | } | ||
188 | |||
189 | if(args[i] == "-L") | ||
190 | { | ||
191 | label = args[i+1]; | ||
192 | } | ||
193 | |||
194 | if(args[i] == "-F") | ||
195 | { | ||
196 | filename = args[i+1]; | ||
197 | } | ||
198 | |||
199 | if(args[i] =="-E") | ||
200 | { | ||
201 | edit = true; | ||
202 | } | ||
203 | |||
204 | if(args[i] == "-g") | ||
205 | { | ||
206 | full = false; | ||
207 | } | ||
208 | } | ||
209 | InputDialog *id = new InputDialog(wi, h, type, label, title, filename, edit, w); | ||
210 | if(full) | ||
211 | { | ||
212 | w->setCaption(title); | ||
213 | w->showMaximized(); | ||
214 | } | ||
215 | if( id->exec() == 1) | ||
216 | { | ||
217 | printf("%s\n", id->getString().latin1()); | ||
218 | return 0; | ||
219 | } | ||
220 | else | ||
221 | { | ||
222 | return -1; | ||
223 | } | ||
224 | } | ||
225 | |||
226 | int main(int argc, char **argv) | ||
227 | { | ||
228 | int i; | ||
229 | QStringList args; | ||
230 | QPEApplication a(argc, argv); | ||
231 | QWidget w; | ||
232 | a.setMainWidget(&w); | ||
233 | QWidget *d = a.desktop(); | ||
234 | int width=d->width(); | ||
235 | int height=d->height(); | ||
236 | |||
237 | for(i=0; i < argc; i++) | ||
238 | { | ||
239 | args += argv[i]; | ||
240 | } | ||
241 | |||
242 | for(i=0; i < argc; i++) | ||
243 | { | ||
244 | if(args[i] == "-m") | ||
245 | { | ||
246 | return myMessageBox(width, height, &w, argc, args); | ||
247 | } | ||
248 | |||
249 | if(args[i] == "-f") | ||
250 | { | ||
251 | return fileviewer(&a, argc, args); | ||
252 | } | ||
253 | |||
254 | if(args[i] == "-i") | ||
255 | { | ||
256 | return input(width, height, &w, argc, args); | ||
257 | } | ||
258 | |||
259 | if(args[i] == "-h" || args[i] =="--help") | ||
260 | { | ||
261 | printusage(); | ||
262 | return -1; | ||
263 | } | ||
264 | } | ||
265 | |||
266 | printusage(); | ||
267 | return -1; | ||
268 | } | ||
269 | |||
diff --git a/noncore/tools/opie-sh/opie-sh.pro b/noncore/tools/opie-sh/opie-sh.pro new file mode 100644 index 0000000..5c0d36c --- a/dev/null +++ b/noncore/tools/opie-sh/opie-sh.pro | |||
@@ -0,0 +1,10 @@ | |||
1 | TEMPLATE =app | ||
2 | CONFIG +=qt warn_on release | ||
3 | DESTDIR =$(OPIEDIR)/bin | ||
4 | HEADERS =mbox.h fviewer.h inputdialog.h | ||
5 | SOURCES =opie-sh.cpp mbox.cpp fviewer.cpp inputdialog.cpp | ||
6 | INCLUDEPATH +=$(OPIEDIR)/include | ||
7 | DEPENDPATH +=$(OPIEDIR)/include | ||
8 | LIBS +=-lqpe | ||
9 | TRANSLATIONS= | ||
10 | TARGET = opie-sh | ||
diff --git a/pics/opie-sh/error.png b/pics/opie-sh/error.png new file mode 100644 index 0000000..53487ef --- a/dev/null +++ b/pics/opie-sh/error.png | |||
Binary files differ | |||
diff --git a/pics/opie-sh/info.png b/pics/opie-sh/info.png new file mode 100755 index 0000000..1c65c47 --- a/dev/null +++ b/pics/opie-sh/info.png | |||
Binary files differ | |||
diff --git a/pics/opie-sh/warning.png b/pics/opie-sh/warning.png new file mode 100644 index 0000000..137eaf5 --- a/dev/null +++ b/pics/opie-sh/warning.png | |||
Binary files differ | |||