summaryrefslogtreecommitdiff
path: root/noncore/settings/packagemanager/entrydlg.cpp
Unidiff
Diffstat (limited to 'noncore/settings/packagemanager/entrydlg.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/packagemanager/entrydlg.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/noncore/settings/packagemanager/entrydlg.cpp b/noncore/settings/packagemanager/entrydlg.cpp
new file mode 100644
index 0000000..8deaa37
--- a/dev/null
+++ b/noncore/settings/packagemanager/entrydlg.cpp
@@ -0,0 +1,82 @@
1/*
2                This file is part of the OPIE Project
3
4 =. Copyright (c) 2004 Dan Williams <drw@handhelds.org>
5             .=l.
6           .>+-=
7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29
30#include "entrydlg.h"
31
32#include <qlabel.h>
33#include <qlayout.h>
34#include <qlineedit.h>
35#include <qpushbutton.h>
36
37EntryDlg::EntryDlg( const QString &label, QWidget* parent, const char* name, bool modal )
38 : QDialog( parent, name, modal )
39{
40 QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 );
41
42 QLabel *l = new QLabel( label, this );
43 l->setAlignment( AlignLeft | AlignTop | WordBreak );
44 vbox->addWidget( l );
45
46 m_entry = new QLineEdit( this );
47 vbox->addWidget( m_entry );
48
49 connect( m_entry, SIGNAL(returnPressed()), this, SLOT(tryAccept()) );
50}
51
52void EntryDlg::setText( const QString &text )
53{
54 m_entry->setText( text );
55 m_entry->selectAll();
56}
57
58QString EntryDlg::getText()
59{
60 return m_entry->text();
61}
62
63QString EntryDlg::getText( const QString &caption, const QString &label, const QString &text, bool *ok,
64 QWidget *parent, const char *name )
65{
66 EntryDlg *dlg = new EntryDlg( label, parent, name, true );
67 dlg->setCaption( caption );
68 dlg->setText( text );
69
70 QString result;
71 *ok = ( dlg->exec() == QDialog::Accepted );
72 if ( *ok )
73 result = dlg->getText();
74
75 delete dlg;
76 return result;
77}
78void EntryDlg::tryAccept()
79{
80 if ( !m_entry->text().isEmpty() )
81 accept();
82}