Diffstat (limited to 'noncore/settings/aqpkg/inputdlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/inputdlg.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/settings/aqpkg/inputdlg.cpp b/noncore/settings/aqpkg/inputdlg.cpp index 06e934c..30f0527 100644 --- a/noncore/settings/aqpkg/inputdlg.cpp +++ b/noncore/settings/aqpkg/inputdlg.cpp | |||
@@ -1,134 +1,134 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qlabel.h> | 31 | #include <qlabel.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qspinbox.h> | 34 | #include <qspinbox.h> |
35 | #include <qcombobox.h> | 35 | #include <qcombobox.h> |
36 | #include <qwidgetstack.h> | 36 | #include <qwidgetstack.h> |
37 | #include <qvalidator.h> | 37 | #include <qvalidator.h> |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | 39 | ||
40 | #include "inputdlg.h" | 40 | #include "inputdlg.h" |
41 | #include "global.h" | 41 | #include "global.h" |
42 | 42 | ||
43 | 43 | ||
44 | InputDialog :: InputDialog( const QString &label, QWidget* parent, const char* name, | 44 | InputDialog :: InputDialog( const QString &label, QWidget* parent, const char* name, |
45 | bool modal ) | 45 | bool modal ) |
46 | : QDialog( parent, name, modal ) | 46 | : QDialog( parent, name, modal ) |
47 | { | 47 | { |
48 | lineEdit = 0; | 48 | lineEdit = 0; |
49 | 49 | ||
50 | QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 ); | 50 | QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 ); |
51 | 51 | ||
52 | QLabel* l = new QLabel( label, this ); | 52 | QLabel* l = new QLabel( label, this ); |
53 | vbox->addWidget( l ); | 53 | vbox->addWidget( l ); |
54 | 54 | ||
55 | lineEdit = new QLineEdit( this ); | 55 | lineEdit = new QLineEdit( this ); |
56 | vbox->addWidget( lineEdit ); | 56 | vbox->addWidget( lineEdit ); |
57 | 57 | ||
58 | QHBoxLayout *hbox = new QHBoxLayout( 6 ); | 58 | QHBoxLayout *hbox = new QHBoxLayout( 6 ); |
59 | vbox->addLayout( hbox, AlignRight ); | 59 | vbox->addLayout( hbox, AlignRight ); |
60 | 60 | ||
61 | ok = new QPushButton( tr( "&OK" ), this ); | 61 | ok = new QPushButton( tr( "&OK" ), this ); |
62 | ok->setDefault( TRUE ); | 62 | ok->setDefault( TRUE ); |
63 | QPushButton *cancel = new QPushButton( tr( "&Cancel" ), this ); | 63 | QPushButton *cancel = new QPushButton( tr( "&Cancel" ), this ); |
64 | 64 | ||
65 | QSize bs( ok->sizeHint() ); | 65 | QSize bs( ok->sizeHint() ); |
66 | if ( cancel->sizeHint().width() > bs.width() ) | 66 | if ( cancel->sizeHint().width() > bs.width() ) |
67 | bs.setWidth( cancel->sizeHint().width() ); | 67 | bs.setWidth( cancel->sizeHint().width() ); |
68 | 68 | ||
69 | ok->setFixedSize( bs ); | 69 | ok->setFixedSize( bs ); |
70 | cancel->setFixedSize( bs ); | 70 | cancel->setFixedSize( bs ); |
71 | 71 | ||
72 | hbox->addWidget( new QWidget( this ) ); | 72 | hbox->addWidget( new QWidget( this ) ); |
73 | hbox->addWidget( ok ); | 73 | hbox->addWidget( ok ); |
74 | hbox->addWidget( cancel ); | 74 | hbox->addWidget( cancel ); |
75 | 75 | ||
76 | connect( lineEdit, SIGNAL( returnPressed() ), | 76 | connect( lineEdit, SIGNAL( returnPressed() ), |
77 | this, SLOT( tryAccept() ) ); | 77 | this, SLOT( tryAccept() ) ); |
78 | connect( lineEdit, SIGNAL( textChanged( const QString & ) ), | 78 | connect( lineEdit, SIGNAL( textChanged(const QString&) ), |
79 | this, SLOT( textChanged( const QString & ) ) ); | 79 | this, SLOT( textChanged(const QString&) ) ); |
80 | 80 | ||
81 | connect( ok, SIGNAL( clicked() ), this, SLOT( accept() ) ); | 81 | connect( ok, SIGNAL( clicked() ), this, SLOT( accept() ) ); |
82 | connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); | 82 | connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); |
83 | 83 | ||
84 | resize( QMAX( sizeHint().width(), 240 ), sizeHint().height() ); | 84 | resize( QMAX( sizeHint().width(), 240 ), sizeHint().height() ); |
85 | } | 85 | } |
86 | 86 | ||
87 | /*! | 87 | /*! |
88 | Destructor. | 88 | Destructor. |
89 | */ | 89 | */ |
90 | 90 | ||
91 | InputDialog::~InputDialog() | 91 | InputDialog::~InputDialog() |
92 | { | 92 | { |
93 | } | 93 | } |
94 | 94 | ||
95 | void InputDialog :: setText( const QString &text ) | 95 | void InputDialog :: setText( const QString &text ) |
96 | { | 96 | { |
97 | lineEdit->setText( text ); | 97 | lineEdit->setText( text ); |
98 | lineEdit->selectAll(); | 98 | lineEdit->selectAll(); |
99 | } | 99 | } |
100 | 100 | ||
101 | QString InputDialog :: getText() | 101 | QString InputDialog :: getText() |
102 | { | 102 | { |
103 | return lineEdit->text(); | 103 | return lineEdit->text(); |
104 | } | 104 | } |
105 | 105 | ||
106 | QString InputDialog::getText( const QString &caption, const QString &label, | 106 | QString InputDialog::getText( const QString &caption, const QString &label, |
107 | const QString &text, bool *ok, QWidget *parent, | 107 | const QString &text, bool *ok, QWidget *parent, |
108 | const char *name ) | 108 | const char *name ) |
109 | { | 109 | { |
110 | InputDialog *dlg = new InputDialog( label, parent, name, true ); | 110 | InputDialog *dlg = new InputDialog( label, parent, name, true ); |
111 | dlg->setCaption( caption ); | 111 | dlg->setCaption( caption ); |
112 | dlg->setText( text ); | 112 | dlg->setText( text ); |
113 | 113 | ||
114 | QString result; | 114 | QString result; |
115 | *ok = dlg->exec() == QDialog::Accepted; | 115 | *ok = dlg->exec() == QDialog::Accepted; |
116 | if ( *ok ) | 116 | if ( *ok ) |
117 | result = dlg->getText(); | 117 | result = dlg->getText(); |
118 | 118 | ||
119 | delete dlg; | 119 | delete dlg; |
120 | return result; | 120 | return result; |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | 124 | ||
125 | void InputDialog :: textChanged( const QString &s ) | 125 | void InputDialog :: textChanged( const QString &s ) |
126 | { | 126 | { |
127 | ok->setEnabled( !s.isEmpty() ); | 127 | ok->setEnabled( !s.isEmpty() ); |
128 | } | 128 | } |
129 | 129 | ||
130 | void InputDialog :: tryAccept() | 130 | void InputDialog :: tryAccept() |
131 | { | 131 | { |
132 | if ( !lineEdit->text().isEmpty() ) | 132 | if ( !lineEdit->text().isEmpty() ) |
133 | accept(); | 133 | accept(); |
134 | } | 134 | } |