author | drw <drw> | 2004-11-18 15:49:02 (UTC) |
---|---|---|
committer | drw <drw> | 2004-11-18 15:49:02 (UTC) |
commit | 7ac32658ba09d8456cc75e5cf80707caa616848b (patch) (unidiff) | |
tree | 56bae9b9c75eae7a9096013830fe98d28a4de0ed /noncore/settings/packagemanager/installdlg.cpp | |
parent | 718a7a8ba68e10faa1a22fcc6bdc26e1723b2a40 (diff) | |
download | opie-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/settings/packagemanager/installdlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/packagemanager/installdlg.cpp | 61 |
1 files changed, 50 insertions, 11 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 | |||
@@ -30,6 +30,7 @@ _;:, .> :=|. This file is free software; you can | |||
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> |
@@ -57,6 +58,7 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap | |||
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 ) |
@@ -163,10 +165,6 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap | |||
163 | 165 | ||
164 | } | 166 | } |
165 | 167 | ||
166 | InstallDlg::~InstallDlg() | ||
167 | { | ||
168 | } | ||
169 | |||
170 | void InstallDlg::slotDisplayAvailSpace( const QString &destination ) | 168 | void InstallDlg::slotDisplayAvailSpace( const QString &destination ) |
171 | { | 169 | { |
172 | // If available space is not displayed, exit | 170 | // If available space is not displayed, exit |
@@ -176,13 +174,14 @@ void InstallDlg::slotDisplayAvailSpace( const QString &destination ) | |||
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; |
@@ -220,6 +219,13 @@ void InstallDlg::slotBtnStart() | |||
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 | { |
@@ -231,16 +237,46 @@ void InstallDlg::slotBtnStart() | |||
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 | |||
274 | void 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 ); |
@@ -294,4 +330,7 @@ void InstallDlg::slotOutput( char *msg ) | |||
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 | } |