author | drw <drw> | 2003-03-19 02:48:27 (UTC) |
---|---|---|
committer | drw <drw> | 2003-03-19 02:48:27 (UTC) |
commit | f35989ef21fb5a27ebe6f6924ee2cc601318c1b8 (patch) (side-by-side diff) | |
tree | f169286f925c01758d1456027eb43743bb0cd162 | |
parent | 06ddd131a6f33d341290617e71a14006fc9957a1 (diff) | |
download | opie-f35989ef21fb5a27ebe6f6924ee2cc601318c1b8.zip opie-f35989ef21fb5a27ebe6f6924ee2cc601318c1b8.tar.gz opie-f35989ef21fb5a27ebe6f6924ee2cc601318c1b8.tar.bz2 |
Fix for bug #741
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 3 | ||||
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.h | 6 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 29 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.h | 3 |
4 files changed, 33 insertions, 8 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index 1f0bb5f..2bb8b4d 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp @@ -162,95 +162,96 @@ void InstallDlgImpl :: init( bool displayextrainfo ) 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 ); + btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); layout->addWidget( btnOptions, 3, 1 ); connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); } void InstallDlgImpl :: optionsSelected() { InstallOptionsDlgImpl opt( flags, this, "Option", true ); opt.exec(); // set options selected from dialog flags = opt.getFlags(); #ifdef QWS Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); cfg.writeEntry( "installFlags", flags ); #endif } void InstallDlgImpl :: installSelected() { if ( btnInstall->text() == tr( "Abort" ) ) { if ( pIpkg ) { displayText( tr( "\n**** User Clicked ABORT ***" ) ); pIpkg->abort(); displayText( tr( "**** Process Aborted ****" ) ); } btnInstall->setText( tr( "Close" ) ); btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); return; } else if ( btnInstall->text() == tr( "Close" ) ) { emit reloadData( this ); return; } // Disable buttons btnOptions->setEnabled( false ); // btnInstall->setEnabled( false ); 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(); } else { output->setText( "" ); Destination *d = dataMgr->getDestination( destination->currentText() ); QString dest = d->getDestinationName(); QString destDir = d->getDestinationPath(); int instFlags = flags; if ( d->linkToRoot() ) instFlags |= MAKE_LINKS; #ifdef QWS // Save settings Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); cfg.writeEntry( "dest", dest ); #endif pIpkg = new Ipkg; diff --git a/noncore/settings/aqpkg/installdlgimpl.h b/noncore/settings/aqpkg/installdlgimpl.h index d7509bb..c30963e 100644 --- a/noncore/settings/aqpkg/installdlgimpl.h +++ b/noncore/settings/aqpkg/installdlgimpl.h @@ -34,51 +34,51 @@ class Ipkg; class InstallData { public: QString option; // I - install, D - delete, R- reinstall U - upgrade QString packageName; Destination *destination; bool recreateLinks; }; class InstallDlgImpl : public QWidget { Q_OBJECT public: InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title = 0 ); InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 ); ~InstallDlgImpl(); bool upgradeServer( QString &server ); protected: private: DataManager *dataMgr; - QList<InstallData> installList; - QList<InstallData> removeList; - QList<InstallData> updateList; + QList<InstallData> installList; + QList<InstallData> removeList; + QList<InstallData> updateList; int flags; Ipkg *pIpkg; bool upgradePackages; QComboBox *destination; QPushButton *btnInstall; QPushButton *btnOptions; QMultiLineEdit *output; QLabel *txtAvailableSpace; void init( bool ); bool runIpkg( QString &option, const QString& package, const QString& dest, int flags ); 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 dfe6d9c..7fa311d 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp @@ -319,48 +319,65 @@ void MainWindow :: setDocument( const QString &doc ) // Now set the check box of the selected package for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 ; item = (QCheckListItem *)item->nextSibling() ) { if ( item->text().startsWith( package ) ) { item->setOn( true ); break; } } } */ void MainWindow :: displaySettings() { SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); if ( dlg->showDlg() ) { stack->raiseWidget( progressWindow ); updateData(); stack->raiseWidget( networkPkgWindow ); } delete dlg; } + +void MainWindow :: closeEvent( QCloseEvent *e ) +{ + // If install dialog is visible, return to main view, otherwise close app + QWidget *widget = stack->visibleWidget(); + + if ( widget != networkPkgWindow && widget != progressWindow ) + { + if ( widget ) delete widget; + stack->raiseWidget( networkPkgWindow ); + e->ignore(); + } + else + { + e->accept(); + } +} void MainWindow :: displayFindBar() { findBar->show(); findEdit->setFocus(); } void MainWindow :: displayJumpBar() { jumpBar->show(); } void MainWindow :: repeatFind() { searchForPackage( findEdit->text() ); } void MainWindow :: findPackage( const QString &text ) { actionFindNext->setEnabled( !text.isEmpty() ); searchForPackage( text ); } void MainWindow :: hideFindBar() @@ -758,78 +775,80 @@ void MainWindow :: searchForPackage( const QString &text ) break; } } } } void MainWindow :: updateServer() { QString serverName = serversList->currentText(); // Update the current server // Display dialog // Disable buttons to stop silly people clicking lots on them :) // First, write out ipkg_conf file so that ipkg can use it mgr->writeOutIpkgConf(); Ipkg *ipkg = new Ipkg; ipkg->setOption( "update" ); InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), tr( "Update lists" ) ); connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); - dlg->showMaximized(); + stack->addWidget( dlg, 3 ); + stack->raiseWidget( dlg ); // delete progDlg; } void MainWindow :: upgradePackages() { // We're gonna do an upgrade of all packages // First warn user that this isn't recommended // TODO - ODevice???? QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 0, this ); warn.adjustSize(); if ( warn.exec() == QMessageBox::Yes ) { // First, write out ipkg_conf file so that ipkg can use it mgr->writeOutIpkgConf(); // Now run upgrade Ipkg *ipkg = new Ipkg; ipkg->setOption( "upgrade" ); InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), tr ( "Upgrade" ) ); connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); - dlg->showMaximized(); + stack->addWidget( dlg, 3 ); + stack->raiseWidget( dlg ); } } void MainWindow :: downloadPackage() { bool doUpdate = true; if ( downloadEnabled ) { // See if any packages are selected bool found = false; if ( serversList->currentText() != LOCAL_SERVER ) { for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 && !found; item = (QCheckListItem *)item->nextSibling() ) { if ( item->isOn() ) found = true; } } // If user selected some packages then download the and store the locally // otherwise, display dialog asking user what package to download from an http server // and whether to install it @@ -928,87 +947,89 @@ void MainWindow :: downloadSelectedPackages() void MainWindow :: downloadRemotePackage() { // Display dialog bool ok; QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); if ( !ok || package.isEmpty() ) return; // DownloadRemoteDlgImpl dlg( this, "Install", true ); // if ( dlg.exec() == QDialog::Rejected ) // return; // grab details from dialog // QString package = dlg.getPackageLocation(); InstallData *item = new InstallData(); item->option = "I"; item->packageName = package; QList<InstallData> workingPackages; workingPackages.setAutoDelete( TRUE ); workingPackages.append( item ); InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); - dlg->showMaximized(); + stack->addWidget( dlg, 3 ); + stack->raiseWidget( dlg ); } void MainWindow :: applyChanges() { stickyOption = ""; // First, write out ipkg_conf file so that ipkg can use it mgr->writeOutIpkgConf(); // Now for each selected item // deal with it QList<InstallData> workingPackages; workingPackages.setAutoDelete( TRUE ); for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); item != 0 ; item = (QCheckListItem *)item->nextSibling() ) { if ( item->isOn() ) { workingPackages.append( dealWithItem( item ) ); } } if ( workingPackages.count() == 0 ) { // Nothing to do QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); return; } // do the stuff InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); - dlg->showMaximized(); + stack->addWidget( dlg, 3 ); + stack->raiseWidget( dlg ); } // decide what to do - either remove, upgrade or install // Current rules: // If not installed - install // If installed and different version available - upgrade // If installed and version up to date - remove InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) { QString name = item->text(); // Get package Server *s = mgr->getServer( serversList->currentText() ); Package *p = s->getPackage( name ); // If the package has a filename then it is a local file if ( p->isPackageStoredLocally() ) name = p->getFilename(); QString option; QString dest = "root"; if ( !p->isInstalled() ) { InstallData *newitem = new InstallData();; diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h index d75e5d2..b2de871 100644 --- a/noncore/settings/aqpkg/mainwin.h +++ b/noncore/settings/aqpkg/mainwin.h @@ -22,48 +22,51 @@ #include <qpixmap.h> class DataManager; class InstallData; class InstallDlgImpl; class QAction; class QCheckListItem; class QComboBox; class QLabel; class QLineEdit; class QListView; class QPEToolBar; class QProgressBar; class QWidgetStack; class MainWindow :public QMainWindow { Q_OBJECT public: MainWindow(); ~MainWindow(); +protected: + void closeEvent( QCloseEvent* e ); + private: DataManager *mgr; QWidgetStack *stack; QPEToolBar *findBar; QPEToolBar *jumpBar; QLineEdit *findEdit; QAction *actionFindNext; QAction *actionFilter; QAction *actionUpgrade; QAction *actionDownload; QAction *actionUninstalled; QAction *actionInstalled; QAction *actionUpdated; QPixmap iconDownload; QPixmap iconRemove; int mnuShowUninstalledPkgsId; int mnuShowInstalledPkgsId; int mnuShowUpgradedPkgsId; int mnuFilterByCategory; int mnuSetFilterCategory; |