summaryrefslogtreecommitdiff
path: root/noncore
authordrw <drw>2004-11-18 15:49:02 (UTC)
committer drw <drw>2004-11-18 15:49:02 (UTC)
commit7ac32658ba09d8456cc75e5cf80707caa616848b (patch) (unidiff)
tree56bae9b9c75eae7a9096013830fe98d28a4de0ed /noncore
parent718a7a8ba68e10faa1a22fcc6bdc26e1723b2a40 (diff)
downloadopie-7ac32658ba09d8456cc75e5cf80707caa616848b.zip
opie-7ac32658ba09d8456cc75e5cf80707caa616848b.tar.gz
opie-7ac32658ba09d8456cc75e5cf80707caa616848b.tar.bz2
UI tweaks for Installation dialog - 1. Show destination selection only when installing apps, 2. Update available disk space after each package is processed, 3. Disable destination selection once start button has been clicked
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/installdlg.cpp61
-rw-r--r--noncore/settings/packagemanager/installdlg.h14
-rw-r--r--noncore/settings/packagemanager/mainwindow.cpp2
3 files changed, 63 insertions, 14 deletions
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp
index 945dfed..781f8f5 100644
--- a/noncore/settings/packagemanager/installdlg.cpp
+++ b/noncore/settings/packagemanager/installdlg.cpp
@@ -27,12 +27,13 @@ _;:, .> :=|. This file is free software; you can
27 27
28*/ 28*/
29 29
30#include "installdlg.h" 30#include "installdlg.h"
31 31
32#include <opie2/ofiledialog.h> 32#include <opie2/ofiledialog.h>
33#include <opie2/oprocess.h>
33 34
34#include <qpe/fileselector.h> 35#include <qpe/fileselector.h>
35#include <qpe/resource.h> 36#include <qpe/resource.h>
36#include <qpe/storage.h> 37#include <qpe/storage.h>
37 38
38#include <qapplication.h> 39#include <qapplication.h>
@@ -54,12 +55,13 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap
54 OPackage::Command command2, const QStringList &packages2, 55 OPackage::Command command2, const QStringList &packages2,
55 OPackage::Command command3, const QStringList &packages3 ) 56 OPackage::Command command3, const QStringList &packages3 )
56 : QWidget( 0x0 ) 57 : QWidget( 0x0 )
57 , m_packman( pm ) 58 , m_packman( pm )
58 , m_numCommands( 0 ) 59 , m_numCommands( 0 )
59 , m_currCommand( 0 ) 60 , m_currCommand( 0 )
61 , m_destItem( 0x0 )
60{ 62{
61 // Save command/package list information 63 // Save command/package list information
62 if ( command1 != OPackage::NotDefined ) 64 if ( command1 != OPackage::NotDefined )
63 { 65 {
64 m_command[ m_numCommands ] = command1; 66 m_command[ m_numCommands ] = command1;
65 m_packages[ m_numCommands ] = packages1; 67 m_packages[ m_numCommands ] = packages1;
@@ -160,32 +162,29 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap
160 162
161 m_output->append( tr( "Press the start button to begin.\n" ) ); 163 m_output->append( tr( "Press the start button to begin.\n" ) );
162 m_output->setCursorPosition( m_output->numLines(), 0 ); 164 m_output->setCursorPosition( m_output->numLines(), 0 );
163 165
164} 166}
165 167
166InstallDlg::~InstallDlg()
167{
168}
169
170void InstallDlg::slotDisplayAvailSpace( const QString &destination ) 168void InstallDlg::slotDisplayAvailSpace( const QString &destination )
171{ 169{
172 // If available space is not displayed, exit 170 // If available space is not displayed, exit
173 if ( !m_availSpace ) 171 if ( !m_availSpace )
174 return; 172 return;
175 173
176 QString space = tr( "Unknown" ); 174 QString space = tr( "Unknown" );
177 175
178 // Get destination 176 // Get destination
179 OConfItem *dest = m_packman->findConfItem( OConfItem::Destination, destination ); 177 if ( !destination.isNull() )
178 m_destItem = m_packman->findConfItem( OConfItem::Destination, destination );
180 179
181 if ( dest ) 180 if ( m_destItem )
182 { 181 {
183 // Calculate available space 182 // Calculate available space
184 struct statfs fs; 183 struct statfs fs;
185 if ( !statfs( dest->value(), &fs ) ) 184 if ( !statfs( m_destItem->value(), &fs ) )
186 { 185 {
187 long mult = fs.f_bsize / 1024; 186 long mult = fs.f_bsize / 1024;
188 long div = 1024 / fs.f_bsize; 187 long div = 1024 / fs.f_bsize;
189 188
190 if ( !mult ) mult = 1; 189 if ( !mult ) mult = 1;
191 if ( !div ) div = 1; 190 if ( !div ) div = 1;
@@ -217,33 +216,70 @@ void InstallDlg::slotBtnStart()
217 // TODO - force reload of package data 216 // TODO - force reload of package data
218 emit closeInstallDlg(); 217 emit closeInstallDlg();
219 return; 218 return;
220 } 219 }
221 220
222 // Start was clicked, start executing 221 // Start was clicked, start executing
222 QString dest;
223 if ( m_destination )
224 {
225 dest = m_destination->currentText();
226 m_destination->setEnabled( false );
227 }
228
223 m_btnOptions->setEnabled( false ); 229 m_btnOptions->setEnabled( false );
224 if ( m_numCommands > 1 ) 230 if ( m_numCommands > 1 )
225 { 231 {
226 m_btnStart->setText( tr( "Abort" ) ); 232 m_btnStart->setText( tr( "Abort" ) );
227 m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); 233 m_btnStart->setIconSet( Resource::loadPixmap( "close" ) );
228 } 234 }
229 else 235 else
230 { 236 {
231 m_btnStart->setEnabled( false ); 237 m_btnStart->setEnabled( false );
232 } 238 }
233 239
234 QString dest;
235 if ( m_destination )
236 dest = m_destination->currentText();
237
238 for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) 240 for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ )
239 { 241 {
240 // Execute next command 242 // Execute next command
241 m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, 243 m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest,
242 this, SLOT(slotOutput(char*)), true ); 244 this, SLOT(slotOutput(char*)), true );
243 } 245 }
246 slotProcessDone(0l);
247
248 // Get destination
249/*
250 if ( dest == "root" )
251 {
252 slotProcessDone(0l);
253 return;
254 }
255
256 m_destItem = m_packman->findConfItem( OConfItem::Destination, dest );
257 if ( m_destItem )
258 {
259 QString path = m_destItem->value();
260 Opie::Core::OProcess *process = new Opie::Core::OProcess( this, "ipkg-link process" );
261 connect( process, SIGNAL(processExited(Opie::Core::OProcess*)),
262 this, SLOT(slotProcessDone(Opie::Core::OProcess*)) );
263
264 *process << "ipkg-link" << "mount" << path;
265 if ( !process->start( Opie::Core::OProcess::NotifyOnExit,
266 Opie::Core::OProcess::NoCommunication ) )
267 slotProcessDone( 0l );
268 m_output->append( tr( "Starting ipkg-link to link installed applications." ) );
269 m_output->setCursorPosition( m_output->numLines(), 0 );
270 }
271*/
272}
273
274void InstallDlg::slotProcessDone( Opie::Core::OProcess *proc )
275{
276 delete proc;
277
278 m_output->append( tr( "The package linking is done." ) );
279 m_output->setCursorPosition( m_output->numLines(), 0 );
244 280
245 // All commands executed, allow user to close dialog 281 // All commands executed, allow user to close dialog
246 m_btnStart->setEnabled( true ); 282 m_btnStart->setEnabled( true );
247 m_btnStart->setText( tr( "Close" ) ); 283 m_btnStart->setText( tr( "Close" ) );
248 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); 284 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) );
249 285
@@ -291,7 +327,10 @@ void InstallDlg::slotOutput( char *msg )
291 327
292 QString lineStr = msg; 328 QString lineStr = msg;
293 if ( lineStr[lineStr.length()-1] == '\n' ) 329 if ( lineStr[lineStr.length()-1] == '\n' )
294 lineStr.truncate( lineStr.length() - 1 ); 330 lineStr.truncate( lineStr.length() - 1 );
295 m_output->append( lineStr ); 331 m_output->append( lineStr );
296 m_output->setCursorPosition( m_output->numLines(), 0 ); 332 m_output->setCursorPosition( m_output->numLines(), 0 );
333
334 // Update available space
335 slotDisplayAvailSpace( QString::null );
297} 336}
diff --git a/noncore/settings/packagemanager/installdlg.h b/noncore/settings/packagemanager/installdlg.h
index cddc911..f45c17c 100644
--- a/noncore/settings/packagemanager/installdlg.h
+++ b/noncore/settings/packagemanager/installdlg.h
@@ -36,14 +36,23 @@ _;:, .> :=|. This file is free software; you can
36 36
37class QComboBox; 37class QComboBox;
38class QLabel; 38class QLabel;
39class QMultiLineEdit; 39class QMultiLineEdit;
40class QPushButton; 40class QPushButton;
41 41
42class OConfItem;
42class OPackageManager; 43class OPackageManager;
43 44
45namespace Opie
46{
47 namespace Core
48 {
49 class OProcess;
50 }
51}
52
44class InstallDlg : public QWidget 53class InstallDlg : public QWidget
45{ 54{
46 Q_OBJECT 55 Q_OBJECT
47 56
48public: 57public:
49 InstallDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &caption = QString::null, 58 InstallDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &caption = QString::null,
@@ -51,13 +60,12 @@ public:
51 OPackage::Command command1 = OPackage::NotDefined, 60 OPackage::Command command1 = OPackage::NotDefined,
52 const QStringList &packages1 = QStringList(), 61 const QStringList &packages1 = QStringList(),
53 OPackage::Command command2 = OPackage::NotDefined, 62 OPackage::Command command2 = OPackage::NotDefined,
54 const QStringList &packages2 = QStringList(), 63 const QStringList &packages2 = QStringList(),
55 OPackage::Command command3 = OPackage::NotDefined, 64 OPackage::Command command3 = OPackage::NotDefined,
56 const QStringList &packages3 = QStringList() ); 65 const QStringList &packages3 = QStringList() );
57 ~InstallDlg();
58 66
59private: 67private:
60 OPackageManager *m_packman; // Pointer to application instance of package manager 68 OPackageManager *m_packman; // Pointer to application instance of package manager
61 69
62 // UI controls 70 // UI controls
63 QComboBox *m_destination; // Destination selection list 71 QComboBox *m_destination; // Destination selection list
@@ -68,19 +76,21 @@ private:
68 76
69 // Commands and packages to execute 77 // Commands and packages to execute
70 int m_numCommands; // Number of commands to be executed 78 int m_numCommands; // Number of commands to be executed
71 int m_currCommand; // Number of currently executing command 79 int m_currCommand; // Number of currently executing command
72 OPackage::Command m_command[3]; // List of commands to be executed 80 OPackage::Command m_command[3]; // List of commands to be executed
73 QStringList m_packages[3]; // Lists of package names associated to commands (m_command[]) 81 QStringList m_packages[3]; // Lists of package names associated to commands (m_command[])
82 OConfItem *m_destItem; // Pointer to destination for package installation
74 83
75private slots: 84private slots:
76 // UI control slots 85 // UI control slots
77 void slotDisplayAvailSpace( const QString &destination ); 86 void slotDisplayAvailSpace( const QString &destination );
78 void slotBtnStart(); 87 void slotBtnStart();
79 void slotBtnOptions(); 88 void slotBtnOptions();
80 89 void slotProcessDone( Opie::Core::OProcess *proc );
90
81 // Execution slots 91 // Execution slots
82 void slotOutput( char *msg ); 92 void slotOutput( char *msg );
83 93
84signals: 94signals:
85 void closeInstallDlg(); 95 void closeInstallDlg();
86}; 96};
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp
index 5e15874..459a75b 100644
--- a/noncore/settings/packagemanager/mainwindow.cpp
+++ b/noncore/settings/packagemanager/mainwindow.cpp
@@ -528,13 +528,13 @@ void MainWindow::slotApply()
528 installCmd = OPackage::Install; 528 installCmd = OPackage::Install;
529 OPackage::Command upgradeCmd = OPackage::NotDefined; 529 OPackage::Command upgradeCmd = OPackage::NotDefined;
530 if ( !upgradeList.isEmpty() ) 530 if ( !upgradeList.isEmpty() )
531 upgradeCmd = OPackage::Upgrade; 531 upgradeCmd = OPackage::Upgrade;
532 532
533 // Create package manager output widget 533 // Create package manager output widget
534 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true, 534 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), !installList.isEmpty(),
535 removeCmd, removeList, 535 removeCmd, removeList,
536 installCmd, installList, 536 installCmd, installList,
537 upgradeCmd, upgradeList ); 537 upgradeCmd, upgradeList );
538 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); 538 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
539 539
540 // Display widget 540 // Display widget