author | drw <drw> | 2004-11-16 17:38:05 (UTC) |
---|---|---|
committer | drw <drw> | 2004-11-16 17:38:05 (UTC) |
commit | 3ba09273d96a32263bb22bfbc32fcc6290bde6e8 (patch) (unidiff) | |
tree | 5191d954dd0769bbf47445daeec024888e523773 | |
parent | 36f98a2f0438edf82e4f326660786207ee46d87d (diff) | |
download | opie-3ba09273d96a32263bb22bfbc32fcc6290bde6e8.zip opie-3ba09273d96a32263bb22bfbc32fcc6290bde6e8.tar.gz opie-3ba09273d96a32263bb22bfbc32fcc6290bde6e8.tar.bz2 |
Minor UI tweak - in filter dialog, when option is enabled, set focus to widget that corresponds to that option (less tapping)
-rw-r--r-- | noncore/settings/packagemanager/filterdlg.cpp | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/noncore/settings/packagemanager/filterdlg.cpp b/noncore/settings/packagemanager/filterdlg.cpp index 70875bd..0e1ea52 100644 --- a/noncore/settings/packagemanager/filterdlg.cpp +++ b/noncore/settings/packagemanager/filterdlg.cpp | |||
@@ -1,189 +1,194 @@ | |||
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) 2003 Dan Williams <drw@handhelds.org> | 4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | .=l. |
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 "filterdlg.h" | 30 | #include "filterdlg.h" |
31 | 31 | ||
32 | #include <qwhatsthis.h> | 32 | #include <qwhatsthis.h> |
33 | 33 | ||
34 | FilterDlg::FilterDlg( QWidget *parent, OPackageManager *pm, const QString &name, | 34 | FilterDlg::FilterDlg( QWidget *parent, OPackageManager *pm, const QString &name, |
35 | const QString &server, const QString &destination, | 35 | const QString &server, const QString &destination, |
36 | OPackageManager::Status status, const QString &category ) | 36 | OPackageManager::Status status, const QString &category ) |
37 | : QDialog( parent, QString::null, true, WStyle_ContextHelp ) | 37 | : QDialog( parent, QString::null, true, WStyle_ContextHelp ) |
38 | { | 38 | { |
39 | setCaption( tr( "Filter packages" ) ); | 39 | setCaption( tr( "Filter packages" ) ); |
40 | 40 | ||
41 | QVBoxLayout *layout = new QVBoxLayout( this ); | 41 | QVBoxLayout *layout = new QVBoxLayout( this ); |
42 | QScrollView *sv = new QScrollView( this ); | 42 | QScrollView *sv = new QScrollView( this ); |
43 | layout->addWidget( sv, 0, 0 ); | 43 | layout->addWidget( sv, 0, 0 ); |
44 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 44 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
45 | sv->setFrameStyle( QFrame::NoFrame ); | 45 | sv->setFrameStyle( QFrame::NoFrame ); |
46 | QWidget *container = new QWidget( sv->viewport() ); | 46 | QWidget *container = new QWidget( sv->viewport() ); |
47 | sv->addChild( container ); | 47 | sv->addChild( container ); |
48 | layout = new QVBoxLayout( container, 4, 4 ); | 48 | layout = new QVBoxLayout( container, 4, 4 ); |
49 | 49 | ||
50 | // Category | 50 | // Category |
51 | m_categoryCB = new QCheckBox( tr( "Category:" ), container ); | 51 | m_categoryCB = new QCheckBox( tr( "Category:" ), container ); |
52 | QWhatsThis::add( m_categoryCB, tr( "Tap here to filter package list by application category." ) ); | 52 | QWhatsThis::add( m_categoryCB, tr( "Tap here to filter package list by application category." ) ); |
53 | connect( m_categoryCB, SIGNAL(toggled(bool)), this, SLOT(slotCategorySelected(bool)) ); | 53 | connect( m_categoryCB, SIGNAL(toggled(bool)), this, SLOT(slotCategorySelected(bool)) ); |
54 | m_category = new QComboBox( container ); | 54 | m_category = new QComboBox( container ); |
55 | QWhatsThis::add( m_category, tr( "Select the application category to filter by here." ) ); | 55 | QWhatsThis::add( m_category, tr( "Select the application category to filter by here." ) ); |
56 | m_category->insertStringList( pm->categories() ); | 56 | m_category->insertStringList( pm->categories() ); |
57 | initItem( m_category, m_categoryCB, category ); | 57 | initItem( m_category, m_categoryCB, category ); |
58 | layout->addWidget( m_categoryCB ); | 58 | layout->addWidget( m_categoryCB ); |
59 | layout->addWidget( m_category ); | 59 | layout->addWidget( m_category ); |
60 | 60 | ||
61 | // Package name | 61 | // Package name |
62 | m_nameCB = new QCheckBox( tr( "Names containing:" ), container ); | 62 | m_nameCB = new QCheckBox( tr( "Names containing:" ), container ); |
63 | QWhatsThis::add( m_nameCB, tr( "Tap here to filter package list by package name." ) ); | 63 | QWhatsThis::add( m_nameCB, tr( "Tap here to filter package list by package name." ) ); |
64 | connect( m_nameCB, SIGNAL(toggled(bool)), this, SLOT(slotNameSelected(bool)) ); | 64 | connect( m_nameCB, SIGNAL(toggled(bool)), this, SLOT(slotNameSelected(bool)) ); |
65 | m_name = new QLineEdit( name, container ); | 65 | m_name = new QLineEdit( name, container ); |
66 | QWhatsThis::add( m_name, tr( "Enter the package name to filter by here." ) ); | 66 | QWhatsThis::add( m_name, tr( "Enter the package name to filter by here." ) ); |
67 | if ( !name.isNull() ) | 67 | if ( !name.isNull() ) |
68 | m_nameCB->setChecked( true ); | 68 | m_nameCB->setChecked( true ); |
69 | m_name->setEnabled( !name.isNull() ); | 69 | m_name->setEnabled( !name.isNull() ); |
70 | layout->addWidget( m_nameCB ); | 70 | layout->addWidget( m_nameCB ); |
71 | layout->addWidget( m_name ); | 71 | layout->addWidget( m_name ); |
72 | 72 | ||
73 | // Status | 73 | // Status |
74 | m_statusCB = new QCheckBox( tr( "With the status:" ), container ); | 74 | m_statusCB = new QCheckBox( tr( "With the status:" ), container ); |
75 | QWhatsThis::add( m_statusCB, tr( "Tap here to filter package list by the package status." ) ); | 75 | QWhatsThis::add( m_statusCB, tr( "Tap here to filter package list by the package status." ) ); |
76 | connect( m_statusCB, SIGNAL(toggled(bool)), this, SLOT(slotStatusSelected(bool)) ); | 76 | connect( m_statusCB, SIGNAL(toggled(bool)), this, SLOT(slotStatusSelected(bool)) ); |
77 | m_status = new QComboBox( container ); | 77 | m_status = new QComboBox( container ); |
78 | QWhatsThis::add( m_status, tr( "Select the package status to filter by here." ) ); | 78 | QWhatsThis::add( m_status, tr( "Select the package status to filter by here." ) ); |
79 | connect( m_status, SIGNAL(activated(const QString&)), this, SLOT(slotStatusChanged(const QString&)) ); | 79 | connect( m_status, SIGNAL(activated(const QString&)), this, SLOT(slotStatusChanged(const QString&)) ); |
80 | QString currStatus; | 80 | QString currStatus; |
81 | switch ( status ) | 81 | switch ( status ) |
82 | { | 82 | { |
83 | case OPackageManager::All : currStatus = tr( "All" ); | 83 | case OPackageManager::All : currStatus = tr( "All" ); |
84 | break; | 84 | break; |
85 | case OPackageManager::Installed : currStatus = tr( "Installed" ); | 85 | case OPackageManager::Installed : currStatus = tr( "Installed" ); |
86 | break; | 86 | break; |
87 | case OPackageManager::NotInstalled : currStatus = tr( "Not installed" ); | 87 | case OPackageManager::NotInstalled : currStatus = tr( "Not installed" ); |
88 | break; | 88 | break; |
89 | case OPackageManager::Updated : currStatus = tr( "Updated" ); | 89 | case OPackageManager::Updated : currStatus = tr( "Updated" ); |
90 | break; | 90 | break; |
91 | default : currStatus = QString::null; | 91 | default : currStatus = QString::null; |
92 | }; | 92 | }; |
93 | m_status->insertItem( tr( "All" ) ); | 93 | m_status->insertItem( tr( "All" ) ); |
94 | m_status->insertItem( tr( "Installed" ) ); | 94 | m_status->insertItem( tr( "Installed" ) ); |
95 | m_status->insertItem( tr( "Not installed" ) ); | 95 | m_status->insertItem( tr( "Not installed" ) ); |
96 | m_status->insertItem( tr( "Updated" ) ); | 96 | m_status->insertItem( tr( "Updated" ) ); |
97 | initItem( m_status, m_statusCB, currStatus ); | 97 | initItem( m_status, m_statusCB, currStatus ); |
98 | layout->addWidget( m_statusCB ); | 98 | layout->addWidget( m_statusCB ); |
99 | layout->addWidget( m_status ); | 99 | layout->addWidget( m_status ); |
100 | 100 | ||
101 | // Server | 101 | // Server |
102 | m_serverCB = new QCheckBox( tr( "Available from the following server:" ), container ); | 102 | m_serverCB = new QCheckBox( tr( "Available from the following server:" ), container ); |
103 | QWhatsThis::add( m_serverCB, tr( "Tap here to filter package list by source server." ) ); | 103 | QWhatsThis::add( m_serverCB, tr( "Tap here to filter package list by source server." ) ); |
104 | connect( m_serverCB, SIGNAL(toggled(bool)), this, SLOT(slotServerSelected(bool)) ); | 104 | connect( m_serverCB, SIGNAL(toggled(bool)), this, SLOT(slotServerSelected(bool)) ); |
105 | m_server = new QComboBox( container ); | 105 | m_server = new QComboBox( container ); |
106 | QWhatsThis::add( m_server, tr( "Select the source server to filter by here." ) ); | 106 | QWhatsThis::add( m_server, tr( "Select the source server to filter by here." ) ); |
107 | m_server->insertStringList( *(pm->servers()) ); | 107 | m_server->insertStringList( *(pm->servers()) ); |
108 | initItem( m_server, m_serverCB, server ); | 108 | initItem( m_server, m_serverCB, server ); |
109 | layout->addWidget( m_serverCB ); | 109 | layout->addWidget( m_serverCB ); |
110 | layout->addWidget( m_server ); | 110 | layout->addWidget( m_server ); |
111 | 111 | ||
112 | // Destination | 112 | // Destination |
113 | m_destCB = new QCheckBox( tr( "Installed on device at:" ), container ); | 113 | m_destCB = new QCheckBox( tr( "Installed on device at:" ), container ); |
114 | QWhatsThis::add( m_destCB, tr( "Tap here to filter package list by destination where the package is installed to on this device." ) ); | 114 | QWhatsThis::add( m_destCB, tr( "Tap here to filter package list by destination where the package is installed to on this device." ) ); |
115 | connect( m_destCB, SIGNAL(toggled(bool)), this, SLOT(slotDestSelected(bool)) ); | 115 | connect( m_destCB, SIGNAL(toggled(bool)), this, SLOT(slotDestSelected(bool)) ); |
116 | m_destination = new QComboBox( container ); | 116 | m_destination = new QComboBox( container ); |
117 | QWhatsThis::add( m_destination, tr( "Select the destination location to filter by here." ) ); | 117 | QWhatsThis::add( m_destination, tr( "Select the destination location to filter by here." ) ); |
118 | m_destination->insertStringList( *(pm->destinations()) ); | 118 | m_destination->insertStringList( *(pm->destinations()) ); |
119 | initItem( m_destination, m_destCB, destination ); | 119 | initItem( m_destination, m_destCB, destination ); |
120 | layout->addWidget( m_destCB ); | 120 | layout->addWidget( m_destCB ); |
121 | layout->addWidget( m_destination ); | 121 | layout->addWidget( m_destination ); |
122 | } | 122 | } |
123 | 123 | ||
124 | void FilterDlg::initItem( QComboBox *comboBox, QCheckBox *checkBox, const QString &selection ) | 124 | void FilterDlg::initItem( QComboBox *comboBox, QCheckBox *checkBox, const QString &selection ) |
125 | { | 125 | { |
126 | if ( !selection.isNull() ) | 126 | if ( !selection.isNull() ) |
127 | { | 127 | { |
128 | checkBox->setChecked( true ); | 128 | checkBox->setChecked( true ); |
129 | 129 | ||
130 | for ( int i = 0; i < comboBox->count(); i++ ) | 130 | for ( int i = 0; i < comboBox->count(); i++ ) |
131 | { | 131 | { |
132 | if ( comboBox->text( i ) == selection ) | 132 | if ( comboBox->text( i ) == selection ) |
133 | { | 133 | { |
134 | comboBox->setCurrentItem( i ); | 134 | comboBox->setCurrentItem( i ); |
135 | return; | 135 | return; |
136 | } | 136 | } |
137 | } | 137 | } |
138 | } | 138 | } |
139 | comboBox->setEnabled( !selection.isNull() ); | 139 | comboBox->setEnabled( !selection.isNull() ); |
140 | } | 140 | } |
141 | 141 | ||
142 | void FilterDlg::slotNameSelected( bool selected ) | 142 | void FilterDlg::slotNameSelected( bool selected ) |
143 | { | 143 | { |
144 | m_name->setEnabled( selected ); | 144 | m_name->setEnabled( selected ); |
145 | m_name->setFocus(); | ||
145 | } | 146 | } |
146 | 147 | ||
147 | void FilterDlg::slotServerSelected( bool selected ) | 148 | void FilterDlg::slotServerSelected( bool selected ) |
148 | { | 149 | { |
149 | m_server->setEnabled( selected ); | 150 | m_server->setEnabled( selected ); |
151 | m_server->setFocus(); | ||
150 | } | 152 | } |
151 | 153 | ||
152 | void FilterDlg::slotDestSelected( bool selected ) | 154 | void FilterDlg::slotDestSelected( bool selected ) |
153 | { | 155 | { |
154 | m_destination->setEnabled( selected ); | 156 | m_destination->setEnabled( selected ); |
157 | m_destination->setFocus(); | ||
155 | } | 158 | } |
156 | 159 | ||
157 | void FilterDlg::slotStatusSelected( bool selected ) | 160 | void FilterDlg::slotStatusSelected( bool selected ) |
158 | { | 161 | { |
159 | m_status->setEnabled( selected ); | 162 | m_status->setEnabled( selected ); |
163 | m_status->setFocus(); | ||
160 | 164 | ||
161 | if ( !selected && !m_destCB->isEnabled() ) | 165 | if ( !selected && !m_destCB->isEnabled() ) |
162 | { | 166 | { |
163 | // If status check box has been deselected and destination option was previously deselected | 167 | // If status check box has been deselected and destination option was previously deselected |
164 | // (because status == "Not installed"), re-enable destination option | 168 | // (because status == "Not installed"), re-enable destination option |
165 | m_destCB->setEnabled( true ); | 169 | m_destCB->setEnabled( true ); |
166 | m_destination->setEnabled( true ); | 170 | m_destination->setEnabled( true ); |
167 | } | 171 | } |
168 | else if ( selected && m_destCB->isEnabled() && m_status->currentText() == tr( "Not installed" ) ) | 172 | else if ( selected && m_destCB->isEnabled() && m_status->currentText() == tr( "Not installed" ) ) |
169 | { | 173 | { |
170 | // If status check box has been selected and status == "Not installed", disable destination option | 174 | // If status check box has been selected and status == "Not installed", disable destination option |
171 | m_destCB->setEnabled( false ); | 175 | m_destCB->setEnabled( false ); |
172 | m_destCB->setChecked( false ); | 176 | m_destCB->setChecked( false ); |
173 | m_destination->setEnabled( false ); | 177 | m_destination->setEnabled( false ); |
174 | } | 178 | } |
175 | } | 179 | } |
176 | 180 | ||
177 | void FilterDlg::slotStatusChanged( const QString &category ) | 181 | void FilterDlg::slotStatusChanged( const QString &category ) |
178 | { | 182 | { |
179 | bool notInstalled = ( category == tr( "Not installed" ) ); | 183 | bool notInstalled = ( category == tr( "Not installed" ) ); |
180 | m_destCB->setEnabled( !notInstalled ); | 184 | m_destCB->setEnabled( !notInstalled ); |
181 | m_destination->setEnabled( !notInstalled ); | 185 | m_destination->setEnabled( !notInstalled ); |
182 | if ( notInstalled ) | 186 | if ( notInstalled ) |
183 | m_destCB->setChecked( false ); | 187 | m_destCB->setChecked( false ); |
184 | } | 188 | } |
185 | 189 | ||
186 | void FilterDlg::slotCategorySelected( bool selected ) | 190 | void FilterDlg::slotCategorySelected( bool selected ) |
187 | { | 191 | { |
188 | m_category->setEnabled( selected ); | 192 | m_category->setEnabled( selected ); |
193 | m_category->setFocus(); | ||
189 | } | 194 | } |