From 766f09a89eef17808e77836f76371aab8ebc4c1c Mon Sep 17 00:00:00 2001 From: drw Date: Sat, 01 Feb 2003 02:07:22 +0000 Subject: Many updates to install dialog --- (limited to 'noncore') diff --git a/noncore/settings/aqpkg/.cvsignore b/noncore/settings/aqpkg/.cvsignore index ef0e27f..751040e 100644 --- a/noncore/settings/aqpkg/.cvsignore +++ b/noncore/settings/aqpkg/.cvsignore @@ -1,10 +1,8 @@ Makefile* -install.cpp -install.h instoptions.cpp instoptions.h moc* settings.cpp settings.h categoryfilter.cpp -categoryfilter.h \ No newline at end of file +categoryfilter.h diff --git a/noncore/settings/aqpkg/aqpkg.pro b/noncore/settings/aqpkg/aqpkg.pro index d8eee6a..d3f898b 100644 --- a/noncore/settings/aqpkg/aqpkg.pro +++ b/noncore/settings/aqpkg/aqpkg.pro @@ -33,7 +33,6 @@ SOURCES = mainwin.cpp \ version.cpp \ categoryfilterimpl.cpp INTERFACES = settings.ui \ - install.ui \ instoptions.ui \ categoryfilter.ui TARGET = aqpkg diff --git a/noncore/settings/aqpkg/install.ui b/noncore/settings/aqpkg/install.ui deleted file mode 100644 index 53622dd..0000000 --- a/noncore/settings/aqpkg/install.ui +++ b/dev/null @@ -1,147 +0,0 @@ - -InstallDlg - - QDialog - - name - InstallDlg - - - geometry - - 0 - 0 - 196 - 278 - - - - caption - Install - - - - margin - 11 - - - spacing - 6 - - - QComboBox - - name - destination - - - - QPushButton - - name - btnInstall - - - text - Start - - - - QPushButton - - name - btnOptions - - - text - Options - - - - QGroupBox - - name - GroupBox2 - - - title - Output - - - - margin - 11 - - - spacing - 6 - - - QMultiLineEdit - - name - output - - - - - - QLabel - - name - TextLabel1 - - - text - Destination - - - - QLabel - - name - TextLabel3 - - - text - Space Avail - - - - QLabel - - name - txtAvailableSpace - - - text - - - - - - - - btnOptions - clicked() - InstallDlg - optionsSelected() - - - btnInstall - clicked() - InstallDlg - installSelected() - - - destination - highlighted(const QString&) - InstallDlg - displayAvailableSpace( const QString& ) - - displayAvailableSpace( const QString& ) - installSelected() - displayText( const QString & ) - optionsSelected() - - diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index 75ce1a1..65aaa32 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp @@ -15,30 +15,38 @@ * * ***************************************************************************/ +#include + #ifdef QWS #include #include +#include #include #endif -#include -#include -#include #include -#include +#include +#include +#include +#include #include - +#include +#include #include "datamgr.h" -#include "instoptionsimpl.h" #include "destination.h" +#include "instoptionsimpl.h" #include "installdlgimpl.h" +#include "ipkg.h" #include "utils.h" #include "global.h" -InstallDlgImpl::InstallDlgImpl( vector &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) - : InstallDlg( parent, name, modal, fl ) +InstallDlgImpl::InstallDlgImpl( vector &packageList, DataManager *dataManager, const char *title = 0 ) + : QWidget( 0, 0, 0 ) { + setCaption( title ); + init( TRUE ); + pIpkg = 0; upgradePackages = false; dataMgr = dataManager; @@ -58,9 +66,9 @@ InstallDlgImpl::InstallDlgImpl( vector &packageList, DataManager *d // Output text is read only output->setReadOnly( true ); - QFont f( "helvetica" ); - f.setPointSize( 10 ); - output->setFont( f ); +// QFont f( "helvetica" ); +// f.setPointSize( 10 ); +// output->setFont( f ); // setup destination data @@ -77,40 +85,44 @@ InstallDlgImpl::InstallDlgImpl( vector &packageList, DataManager *d vector::iterator it; // setup package data - QString remove = "Remove\n"; - QString install = "\nInstall\n"; - QString upgrade = "\nUpgrade\n"; + QString remove = tr( "Remove\n" ); + QString install = tr( "Install\n" ); + QString upgrade = tr( "Upgrade\n" ); for ( it = packageList.begin() ; it != packageList.end() ; ++it ) { InstallData item = *it; if ( item.option == "I" ) { installList.push_back( item ); - install += " " + item.packageName + "\n"; + install.append( QString( " %1\n" ).arg( item.packageName ) ); } else if ( item.option == "D" ) { removeList.push_back( item ); - remove += " " + item.packageName + "\n"; + remove.append( QString( " %1\n" ).arg( item.packageName ) ); } else if ( item.option == "U" || item.option == "R" ) { updateList.push_back( item ); - QString type = " (Upgrade)"; + QString type; if ( item.option == "R" ) - type = " (ReInstall)"; - upgrade += " " + item.packageName + type + "\n"; - } + type = tr( "(ReInstall)" ); + else + type = tr( "(Upgrade)" ); + upgrade.append( QString( " %1 %2\n" ).arg( item.packageName ).arg( type ) ); + } } - output->setText( remove + install + upgrade ); + output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); displayAvailableSpace( destination->currentText() ); } -InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget *parent, const char *name, bool modal, WFlags fl ) - : InstallDlg( parent, name, modal, fl ) +InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 ) + : QWidget( 0, 0, 0 ) { + setCaption( title ); + init( FALSE ); pIpkg = ipkg; output->setText( initialText ); } @@ -118,14 +130,52 @@ InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget *parent InstallDlgImpl::~InstallDlgImpl() { + if ( pIpkg ) + delete pIpkg; } -bool InstallDlgImpl :: showDlg() +void InstallDlgImpl :: init( bool displayextrainfo ) { - showMaximized(); - bool ret = exec(); + QGridLayout *layout = new QGridLayout( this ); + layout->setSpacing( 4 ); + layout->setMargin( 4 ); - return ret; + if ( displayextrainfo ) + { + QLabel *label = new QLabel( tr( "Destination" ), this ); + layout->addWidget( label, 0, 0 ); + destination = new QComboBox( FALSE, this ); + layout->addWidget( destination, 0, 1 ); + connect( destination, SIGNAL( highlighted( const QString & ) ), + this, SLOT( displayAvailableSpace( const QString & ) ) ); + + QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); + layout->addWidget( label2, 1, 0 ); + txtAvailableSpace = new QLabel( "", this ); + layout->addWidget( txtAvailableSpace, 1, 1 ); + } + else + { + destination = 0x0; + txtAvailableSpace = 0x0; + } + + QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); + GroupBox2->layout()->setSpacing( 0 ); + GroupBox2->layout()->setMargin( 4 ); + + QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); + output = new QMultiLineEdit( GroupBox2 ); + GroupBox2Layout->addWidget( output ); + layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); + + btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); + layout->addWidget( btnInstall, 3, 0 ); + connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); + + btnOptions = new QPushButton( Resource::loadPixmap( "aqpkg/config" ), tr( "Options" ), this ); + layout->addWidget( btnOptions, 3, 1 ); + connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); } void InstallDlgImpl :: optionsSelected() @@ -145,21 +195,22 @@ void InstallDlgImpl :: optionsSelected() void InstallDlgImpl :: installSelected() { - if ( btnInstall->text() == "Abort" ) + if ( btnInstall->text() == tr( "Abort" ) ) { if ( pIpkg ) { - displayText( "\n**** User Clicked ABORT ***" ); + displayText( tr( "\n**** User Clicked ABORT ***" ) ); pIpkg->abort(); - displayText( "**** Process Aborted ****" ); + displayText( tr( "**** Process Aborted ****" ) ); } btnInstall->setText( tr( "Close" ) ); + btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); return; } else if ( btnInstall->text() == tr( "Close" ) ) { - done( 1 ); + emit reloadData( this ); return; } @@ -167,12 +218,11 @@ void InstallDlgImpl :: installSelected() btnOptions->setEnabled( false ); // btnInstall->setEnabled( false ); - btnInstall->setText( "Abort" ); - + btnInstall->setText( tr( "Abort" ) ); + btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); if ( pIpkg ) { output->setText( "" ); - connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); pIpkg->runIpkg(); } @@ -242,21 +292,24 @@ void InstallDlgImpl :: installSelected() } delete pIpkg; + pIpkg = 0; } btnOptions->setEnabled( true ); // btnInstall->setEnabled( true ); btnInstall->setText( tr( "Close" ) ); + btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); - if ( destination->currentText() != 0 && destination->currentText() != "" ) + if ( destination && destination->currentText() != 0 && destination->currentText() != "" ) displayAvailableSpace( destination->currentText() ); } void InstallDlgImpl :: displayText(const QString &text ) { - QString t = output->text() + "\n" + text; - output->setText( t ); + //output->setText( QString( "%1\n%2" ).arg( output->text() ).arg( text ) ); + QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); + output->setText( newtext ); output->setCursorPosition( output->numLines(), 0 ); } @@ -284,8 +337,9 @@ void InstallDlgImpl :: displayAvailableSpace( const QString &text ) space.sprintf( "%ld Kb", avail ); } else - space = "Unknown"; + space = tr( "Unknown" ); - txtAvailableSpace->setText( space ); + if ( txtAvailableSpace ) + txtAvailableSpace->setText( space ); } diff --git a/noncore/settings/aqpkg/installdlgimpl.h b/noncore/settings/aqpkg/installdlgimpl.h index 2f80f08..4c9f087 100644 --- a/noncore/settings/aqpkg/installdlgimpl.h +++ b/noncore/settings/aqpkg/installdlgimpl.h @@ -20,10 +20,17 @@ #include using namespace std; +#include #include -#include "ipkg.h" -#include "install.h" +class QComboBox; +class QLabel; +class QMultiLineEdit; +class QPushButton; + +class DataManager; +class Destination; +class Ipkg; class InstallData { @@ -34,17 +41,16 @@ public: bool recreateLinks; }; -class InstallDlgImpl : public InstallDlg +class InstallDlgImpl : public QWidget { + Q_OBJECT public: - InstallDlgImpl( vector &packageList, DataManager *dataManager, QWidget * parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 ); - InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget * parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 ); + InstallDlgImpl( vector &packageList, DataManager *dataManager, const char *title = 0 ); + InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 ); ~InstallDlgImpl(); - bool showDlg(); bool upgradeServer( QString &server ); - protected: private: @@ -55,11 +61,23 @@ private: int flags; Ipkg *pIpkg; bool upgradePackages; + + QComboBox *destination; + QPushButton *btnInstall; + QPushButton *btnOptions; + QMultiLineEdit *output; + QLabel *txtAvailableSpace; - bool runIpkg( QString &option, const QString& package, const QString& dest, int flags ); + void init( bool ); + + bool runIpkg( QString &option, const QString& package, const QString& dest, int flags ); - void optionsSelected(); - void installSelected(); +signals: + void reloadData( InstallDlgImpl * ); + +public slots: + void optionsSelected(); + void installSelected(); void displayText(const QString &text ); void displayAvailableSpace( const QString &text); }; diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index a25f5a7..947aace 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp @@ -45,6 +45,7 @@ #include "global.h" #include "helpwindow.h" #include "inputdlg.h" +#include "ipkg.h" #include "installdlgimpl.h" #include "letterpushbutton.h" #include "mainwin.h" @@ -88,9 +89,6 @@ MainWindow :: MainWindow() jumpBar->setStretchableWidget( w ); QGridLayout *layout = new QGridLayout( w ); - //QVBoxLayout *vbox = new QVBoxLayout( w, 0, -1 ); - //QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1 ); - //QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1 ); char text[2]; text[1] = '\0'; @@ -100,12 +98,6 @@ MainWindow :: MainWindow() LetterPushButton *b = new LetterPushButton( text, w ); connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); layout->addWidget( b, i / 13, i % 13); -/* - if ( i < 13 ) - hbox3->addWidget( b ); - else - hbox4->addWidget( b ); -*/ } QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); @@ -798,13 +790,13 @@ void MainWindow :: updateServer() // First, write out ipkg_conf file so that ipkg can use it mgr->writeOutIpkgConf(); - Ipkg ipkg; - ipkg.setOption( "update" ); - - InstallDlgImpl dlg( &ipkg, tr( "Refreshing server package lists" ), this, tr( "Upgrade" ), true ); - dlg.showDlg(); + Ipkg *ipkg = new Ipkg; + ipkg->setOption( "update" ); - reloadData(); + InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), + tr( "Update lists" ) ); + connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); + dlg->showMaximized(); // delete progDlg; } @@ -827,16 +819,17 @@ void MainWindow :: upgradePackages() mgr->writeOutIpkgConf(); // Now run upgrade - Ipkg ipkg; - ipkg.setOption( "upgrade" ); - - InstallDlgImpl dlg( &ipkg, tr( "Upgrading installed packages" ), this, tr( "Upgrade" ), true ); - dlg.showDlg(); + Ipkg *ipkg = new Ipkg; + ipkg->setOption( "upgrade" ); - reloadData(); + InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), + tr ( "Upgrade" ) ); + connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); + dlg->showMaximized(); } } - void MainWindow :: downloadPackage() + +void MainWindow :: downloadPackage() { bool doUpdate = true; if ( downloadEnabled ) @@ -898,7 +891,7 @@ void MainWindow :: upgradePackages() if ( doUpdate ) { - reloadData(); + reloadData( 0x0 ); } } @@ -970,17 +963,9 @@ void MainWindow :: downloadRemotePackage() vector workingPackages; workingPackages.push_back( item ); - InstallDlgImpl dlg2( workingPackages, mgr, this, "Install", true ); - dlg2.showDlg(); - - reloadData(); - -#ifdef QWS - // Finally let the main system update itself - QCopEnvelope e("QPE/System", "linkChanged(QString)"); - QString lf = QString::null; - e << lf; -#endif + InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); + connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); + dlg->showMaximized(); } @@ -1016,17 +1001,9 @@ void MainWindow :: applyChanges() } // do the stuff - InstallDlgImpl dlg( workingPackages, mgr, this, "Install", true ); - dlg.showDlg(); - - reloadData(); - -#ifdef QWS - // Finally let the main system update itself - QCopEnvelope e("QPE/System", "linkChanged(QString)"); - QString lf = QString::null; - e << lf; -#endif + InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); + connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); + dlg->showMaximized(); } // decide what to do - either remove, upgrade or install @@ -1150,11 +1127,28 @@ InstallData MainWindow :: dealWithItem( QCheckListItem *item ) } } -void MainWindow :: reloadData() +void MainWindow :: reloadData( InstallDlgImpl *dlg ) { stack->raiseWidget( progressWindow ); + + if ( dlg ) + { + dlg->close(); + delete dlg; + } + mgr->reloadServerData(); serverSelected( -1, FALSE ); + +#ifdef QWS + m_status->setText( tr( "Updating Launcher..." ) ); + + // Finally let the main system update itself + QCopEnvelope e("QPE/System", "linkChanged(QString)"); + QString lf = QString::null; + e << lf; +#endif + stack->raiseWidget( networkPkgWindow ); } diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h index b49c819..d0777fb 100644 --- a/noncore/settings/aqpkg/mainwin.h +++ b/noncore/settings/aqpkg/mainwin.h @@ -23,6 +23,7 @@ class DataManager; class InstallData; +class InstallDlgImpl; class QAction; class QCheckListItem; @@ -92,7 +93,6 @@ private: void downloadSelectedPackages(); void downloadRemotePackage(); InstallData dealWithItem( QCheckListItem *item ); - void reloadData(); // Progress widget QWidget *progressWindow; @@ -121,6 +121,7 @@ public slots: void raiseProgressWidget(); void enableUpgrade( bool ); void enableDownload( bool ); + void reloadData( InstallDlgImpl * ); private slots: void init(); -- cgit v0.9.0.2