summaryrefslogtreecommitdiff
path: root/noncore/settings/packagemanager/installdlg.cpp
Unidiff
Diffstat (limited to 'noncore/settings/packagemanager/installdlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/installdlg.cpp26
1 files changed, 9 insertions, 17 deletions
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp
index 205d7ed..15d88ad 100644
--- a/noncore/settings/packagemanager/installdlg.cpp
+++ b/noncore/settings/packagemanager/installdlg.cpp
@@ -10,51 +10,51 @@
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17 : ..    .:,     . . . without even the implied warranty of 17 : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22:     =  ...= . :.=- 22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include "installdlg.h" 31#include "installdlg.h"
32 32
33#include <opie2/ofiledialog.h> 33#include <opie2/ofiledialog.h>
34#include <opie2/oresource.h>
34 35
35#include <qpe/fileselector.h> 36#include <qpe/fileselector.h>
36#include <qpe/resource.h>
37#include <qpe/storage.h> 37#include <qpe/storage.h>
38 38
39#include <qapplication.h> 39#include <qapplication.h>
40#include <qcombobox.h> 40#include <qcombobox.h>
41#include <qfileinfo.h> 41#include <qfileinfo.h>
42#include <qgroupbox.h> 42#include <qgroupbox.h>
43#include <qlabel.h> 43#include <qlabel.h>
44#include <qlayout.h> 44#include <qlayout.h>
45#include <qmap.h> 45#include <qmap.h>
46#include <qmultilineedit.h> 46#include <qmultilineedit.h>
47#include <qpushbutton.h> 47#include <qpushbutton.h>
48 48
49#include <sys/vfs.h> 49#include <sys/vfs.h>
50 50
51#include "opackagemanager.h" 51#include "opackagemanager.h"
52 52
53InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, 53InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption,
54 OPackage::Command command1, const QStringList &packages1, 54 OPackage::Command command1, const QStringList &packages1,
55 OPackage::Command command2, const QStringList &packages2, 55 OPackage::Command command2, const QStringList &packages2,
56 OPackage::Command command3, const QStringList &packages3 ) 56 OPackage::Command command3, const QStringList &packages3 )
57 : QWidget( 0l ) 57 : QWidget( 0l )
58 , m_packman( pm ) 58 , m_packman( pm )
59 , m_installFound( false ) 59 , m_installFound( false )
60 , m_numCommands( 0 ) 60 , m_numCommands( 0 )
@@ -109,57 +109,56 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap
109 label = new QLabel( tr( "Space Avail" ), this ); 109 label = new QLabel( tr( "Space Avail" ), this );
110 layout->addWidget( label, 1, 0 ); 110 layout->addWidget( label, 1, 0 );
111 m_availSpace = new QLabel( this ); 111 m_availSpace = new QLabel( this );
112 layout->addWidget( m_availSpace, 1, 1 ); 112 layout->addWidget( m_availSpace, 1, 1 );
113 113
114 // TODO - select correct destination 114 // TODO - select correct destination
115 slotDisplayAvailSpace( m_destination->currentText() ); 115 slotDisplayAvailSpace( m_destination->currentText() );
116 } 116 }
117 else 117 else
118 { 118 {
119 m_destination = 0l; 119 m_destination = 0l;
120 m_availSpace = 0l; 120 m_availSpace = 0l;
121 } 121 }
122 122
123 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); 123 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this );
124 groupBox->layout()->setSpacing( 0 ); 124 groupBox->layout()->setSpacing( 0 );
125 groupBox->layout()->setMargin( 4 ); 125 groupBox->layout()->setMargin( 4 );
126 126
127 QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); 127 QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() );
128 m_output = new QMultiLineEdit( groupBox ); 128 m_output = new QMultiLineEdit( groupBox );
129 m_output->setReadOnly( true ); 129 m_output->setReadOnly( true );
130 groupBoxLayout->addWidget( m_output ); 130 groupBoxLayout->addWidget( m_output );
131 layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); 131 layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 );
132 132
133 QPixmap pic; 133 m_btnStart = new QPushButton( Opie::Core::OResource::loadPixmap( "packagemanager/apply",
134 pic.convertFromImage( Resource::loadImage( "packagemanager/apply" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); 134 Opie::Core::OResource::SmallIcon ), tr( "Start" ), this );
135 m_btnStart = new QPushButton( pic, tr( "Start" ), this );
136 m_btnStart->setMinimumHeight( AppLnk::smallIconSize() ); 135 m_btnStart->setMinimumHeight( AppLnk::smallIconSize() );
137 layout->addWidget( m_btnStart, 3, 0 ); 136 layout->addWidget( m_btnStart, 3, 0 );
138 connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) ); 137 connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) );
139 138
140 pic.convertFromImage( Resource::loadImage( "SettingsIcon" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); 139 m_btnOptions = new QPushButton( Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ),
141 m_btnOptions = new QPushButton( pic, tr( "Options" ), this ); 140 tr( "Options" ), this );
142 m_btnOptions->setMinimumHeight( AppLnk::smallIconSize() ); 141 m_btnOptions->setMinimumHeight( AppLnk::smallIconSize() );
143 layout->addWidget( m_btnOptions, 3, 1 ); 142 layout->addWidget( m_btnOptions, 3, 1 );
144 connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) ); 143 connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) );
145 144
146 // Display packages being acted upon in output widget 145 // Display packages being acted upon in output widget
147 for( int i = 0; i < m_numCommands; i++ ) 146 for( int i = 0; i < m_numCommands; i++ )
148 { 147 {
149 if ( !m_packages[ i ].isEmpty() ) 148 if ( !m_packages[ i ].isEmpty() )
150 { 149 {
151 QString lineStr = tr( "Packages to " ); 150 QString lineStr = tr( "Packages to " );
152 151
153 switch( m_command[ i ] ) 152 switch( m_command[ i ] )
154 { 153 {
155 case OPackage::Install : lineStr.append( tr( "install" ) ); 154 case OPackage::Install : lineStr.append( tr( "install" ) );
156 break; 155 break;
157 case OPackage::Remove : lineStr.append( tr( "remove" ) ); 156 case OPackage::Remove : lineStr.append( tr( "remove" ) );
158 break; 157 break;
159 case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) ); 158 case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) );
160 break; 159 break;
161 case OPackage::Download : lineStr.append( tr( "download" ) ); 160 case OPackage::Download : lineStr.append( tr( "download" ) );
162 break; 161 break;
163 default : 162 default :
164 break; 163 break;
165 }; 164 };
@@ -202,99 +201,92 @@ void InstallDlg::slotDisplayAvailSpace( const QString &destination )
202 long div = 1024 / fs.f_bsize; 201 long div = 1024 / fs.f_bsize;
203 202
204 if ( !mult ) mult = 1; 203 if ( !mult ) mult = 1;
205 if ( !div ) div = 1; 204 if ( !div ) div = 1;
206 long avail = fs.f_bavail * mult / div; 205 long avail = fs.f_bavail * mult / div;
207 206
208 space = tr( "%1 Kb" ).arg( avail ); 207 space = tr( "%1 Kb" ).arg( avail );
209 } 208 }
210 } 209 }
211 210
212 // Display available space 211 // Display available space
213 m_availSpace->setText( space ); 212 m_availSpace->setText( space );
214} 213}
215 214
216void InstallDlg::slotBtnStart() 215void InstallDlg::slotBtnStart()
217{ 216{
218 QString btnText = m_btnStart->text(); 217 QString btnText = m_btnStart->text();
219 if ( btnText == tr( "Abort" ) ) 218 if ( btnText == tr( "Abort" ) )
220 { 219 {
221 // Prevent unexecuted commands from executing 220 // Prevent unexecuted commands from executing
222 m_currCommand = 999; 221 m_currCommand = 999;
223 222
224 // Allow user to close dialog 223 // Allow user to close dialog
225 m_btnStart->setText( tr( "Close" ) ); 224 m_btnStart->setText( tr( "Close" ) );
226 QPixmap pic; 225 m_btnStart->setIconSet( Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ) );
227 pic.convertFromImage( Resource::loadImage( "close" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
228 m_btnStart->setIconSet( pic );
229 return; 226 return;
230 } 227 }
231 else if ( btnText == tr( "Close" ) ) 228 else if ( btnText == tr( "Close" ) )
232 { 229 {
233 // TODO - force reload of package data 230 // TODO - force reload of package data
234 emit closeInstallDlg(); 231 emit closeInstallDlg();
235 return; 232 return;
236 } 233 }
237 234
238 // Start was clicked, start executing 235 // Start was clicked, start executing
239 QString dest; 236 QString dest;
240 if ( m_installFound ) 237 if ( m_installFound )
241 { 238 {
242 dest = m_destination->currentText(); 239 dest = m_destination->currentText();
243 m_destination->setEnabled( false ); 240 m_destination->setEnabled( false );
244 } 241 }
245 242
246 m_btnOptions->setEnabled( false ); 243 m_btnOptions->setEnabled( false );
247 if ( m_numCommands > 1 ) 244 if ( m_numCommands > 1 )
248 { 245 {
249 m_btnStart->setText( tr( "Abort" ) ); 246 m_btnStart->setText( tr( "Abort" ) );
250 QPixmap pic; 247 m_btnStart->setIconSet( Opie::Core::OResource::loadPixmap( "reset", Opie::Core::OResource::SmallIcon ) );
251 pic.convertFromImage( Resource::loadImage( "reset" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
252 m_btnStart->setIconSet( pic );
253 } 248 }
254 else 249 else
255 { 250 {
256 m_btnStart->setEnabled( false ); 251 m_btnStart->setEnabled( false );
257 } 252 }
258 253
259 for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) 254 for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ )
260 { 255 {
261 // Execute next command 256 // Execute next command
262 m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, 257 m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest,
263 this, SLOT(slotOutput(const QString &)), true ); 258 this, SLOT(slotOutput(const QString &)), true );
264 } 259 }
265 260
266 // All commands executed, allow user to close dialog 261 // All commands executed, allow user to close dialog
267 m_btnStart->setEnabled( true ); 262 m_btnStart->setEnabled( true );
268 m_btnStart->setText( tr( "Close" ) ); 263 m_btnStart->setText( tr( "Close" ) );
269 QPixmap pic; 264 m_btnStart->setIconSet( Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ) );
270 pic.convertFromImage( Resource::loadImage( "close" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) );
271 m_btnStart->setIconSet( pic );
272 265
273 m_btnOptions->setEnabled( true ); 266 m_btnOptions->setEnabled( true );
274 m_btnOptions->setText( tr( "Save output" ) ); 267 m_btnOptions->setText( tr( "Save output" ) );
275 pic.convertFromImage( Resource::loadImage( "save" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); 268 m_btnOptions->setIconSet( Opie::Core::OResource::loadPixmap( "save", Opie::Core::OResource::SmallIcon ) );
276 m_btnOptions->setIconSet( pic );
277} 269}
278 270
279void InstallDlg::slotBtnOptions() 271void InstallDlg::slotBtnOptions()
280{ 272{
281 QString btnText = m_btnOptions->text(); 273 QString btnText = m_btnOptions->text();
282 if ( btnText == tr( "Options" ) ) 274 if ( btnText == tr( "Options" ) )
283 { 275 {
284 // Display configuration dialog (only options tab is enabled) 276 // Display configuration dialog (only options tab is enabled)
285 m_packman->configureDlg( true ); 277 m_packman->configureDlg( true );
286 return; 278 return;
287 } 279 }
288 280
289 // Save output was clicked 281 // Save output was clicked
290 QMap<QString, QStringList> map; 282 QMap<QString, QStringList> map;
291 map.insert( tr( "All" ), QStringList() ); 283 map.insert( tr( "All" ), QStringList() );
292 QStringList text; 284 QStringList text;
293 text << "text/*"; 285 text << "text/*";
294 map.insert(tr( "Text" ), text ); 286 map.insert(tr( "Text" ), text );
295 text << "*"; 287 text << "*";
296 map.insert( tr( "All" ), text ); 288 map.insert( tr( "All" ), text );
297 289
298 QString filename = Opie::Ui::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); 290 QString filename = Opie::Ui::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map );
299 if( !filename.isEmpty() ) 291 if( !filename.isEmpty() )
300 { 292 {