author | drw <drw> | 2004-11-18 15:49:02 (UTC) |
---|---|---|
committer | drw <drw> | 2004-11-18 15:49:02 (UTC) |
commit | 7ac32658ba09d8456cc75e5cf80707caa616848b (patch) (side-by-side diff) | |
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 @@ -21,24 +21,25 @@ _;:, .> :=|. This file is free software; you can : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "installdlg.h" #include <opie2/ofiledialog.h> +#include <opie2/oprocess.h> #include <qpe/fileselector.h> #include <qpe/resource.h> #include <qpe/storage.h> #include <qapplication.h> #include <qcombobox.h> #include <qfileinfo.h> #include <qgroupbox.h> #include <qlabel.h> #include <qlayout.h> #include <qmap.h> @@ -48,24 +49,25 @@ _;:, .> :=|. This file is free software; you can #include <sys/vfs.h> #include "opackagemanager.h" InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, bool showDestInfo, OPackage::Command command1, const QStringList &packages1, OPackage::Command command2, const QStringList &packages2, OPackage::Command command3, const QStringList &packages3 ) : QWidget( 0x0 ) , m_packman( pm ) , m_numCommands( 0 ) , m_currCommand( 0 ) + , m_destItem( 0x0 ) { // Save command/package list information if ( command1 != OPackage::NotDefined ) { m_command[ m_numCommands ] = command1; m_packages[ m_numCommands ] = packages1; ++m_numCommands; } if ( command2 != OPackage::NotDefined ) { m_command[ m_numCommands ] = command2; m_packages[ m_numCommands ] = packages2; @@ -154,44 +156,41 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) ); } m_output->append( lineStr ); } } m_output->append( tr( "Press the start button to begin.\n" ) ); m_output->setCursorPosition( m_output->numLines(), 0 ); } -InstallDlg::~InstallDlg() -{ -} - void InstallDlg::slotDisplayAvailSpace( const QString &destination ) { // If available space is not displayed, exit if ( !m_availSpace ) return; QString space = tr( "Unknown" ); // Get destination - OConfItem *dest = m_packman->findConfItem( OConfItem::Destination, destination ); + if ( !destination.isNull() ) + m_destItem = m_packman->findConfItem( OConfItem::Destination, destination ); - if ( dest ) + if ( m_destItem ) { // Calculate available space struct statfs fs; - if ( !statfs( dest->value(), &fs ) ) + if ( !statfs( m_destItem->value(), &fs ) ) { long mult = fs.f_bsize / 1024; long div = 1024 / fs.f_bsize; if ( !mult ) mult = 1; if ( !div ) div = 1; long avail = fs.f_bavail * mult / div; space = tr( "%1 Kb" ).arg( avail ); } } @@ -211,45 +210,82 @@ void InstallDlg::slotBtnStart() m_btnStart->setText( tr( "Close" ) ); m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); return; } else if ( btnText == tr( "Close" ) ) { // TODO - force reload of package data emit closeInstallDlg(); return; } // Start was clicked, start executing + QString dest; + if ( m_destination ) + { + dest = m_destination->currentText(); + m_destination->setEnabled( false ); + } + m_btnOptions->setEnabled( false ); if ( m_numCommands > 1 ) { m_btnStart->setText( tr( "Abort" ) ); m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); } else { m_btnStart->setEnabled( false ); } - QString dest; - if ( m_destination ) - dest = m_destination->currentText(); - for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) { // Execute next command m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, this, SLOT(slotOutput(char*)), true ); } + slotProcessDone(0l); + + // Get destination +/* + if ( dest == "root" ) + { + slotProcessDone(0l); + return; + } + + m_destItem = m_packman->findConfItem( OConfItem::Destination, dest ); + if ( m_destItem ) + { + QString path = m_destItem->value(); + Opie::Core::OProcess *process = new Opie::Core::OProcess( this, "ipkg-link process" ); + connect( process, SIGNAL(processExited(Opie::Core::OProcess*)), + this, SLOT(slotProcessDone(Opie::Core::OProcess*)) ); + + *process << "ipkg-link" << "mount" << path; + if ( !process->start( Opie::Core::OProcess::NotifyOnExit, + Opie::Core::OProcess::NoCommunication ) ) + slotProcessDone( 0l ); + m_output->append( tr( "Starting ipkg-link to link installed applications." ) ); + m_output->setCursorPosition( m_output->numLines(), 0 ); + } +*/ +} + +void InstallDlg::slotProcessDone( Opie::Core::OProcess *proc ) +{ + delete proc; + + m_output->append( tr( "The package linking is done." ) ); + m_output->setCursorPosition( m_output->numLines(), 0 ); // All commands executed, allow user to close dialog m_btnStart->setEnabled( true ); m_btnStart->setText( tr( "Close" ) ); m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); m_btnOptions->setEnabled( true ); m_btnOptions->setText( tr( "Save output" ) ); m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); } void InstallDlg::slotBtnOptions() @@ -285,13 +321,16 @@ void InstallDlg::slotBtnOptions() } void InstallDlg::slotOutput( char *msg ) { // Allow processing of other events qApp->processEvents(); QString lineStr = msg; if ( lineStr[lineStr.length()-1] == '\n' ) lineStr.truncate( lineStr.length() - 1 ); m_output->append( lineStr ); m_output->setCursorPosition( m_output->numLines(), 0 ); + + // Update available space + slotDisplayAvailSpace( QString::null ); } |