-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 69 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.h | 21 |
2 files changed, 84 insertions, 6 deletions
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 0102292..0efa1e0 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp @@ -958,5 +958,9 @@ void MainWindow :: applyChanges() if ( item->isOn() ) { - workingPackages.append( dealWithItem( item ) ); + InstallData *instdata = dealWithItem( item ); + if ( instdata ) + workingPackages.append( instdata ); + else + return; } } @@ -1068,12 +1072,17 @@ InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) QString msgtext; msgtext = caption.arg( ( const char * )name ); - switch( QMessageBox::information( this, text, - msgtext, tr( "Remove" ), secondButton ) ) +// switch( QMessageBox::information( this, text, +// msgtext, tr( "Remove" ), secondButton ) ) + QuestionDlg dlg( text, msgtext, secondButton ); + switch( dlg.exec() ) { - case 0: // Try again or Enter - // option 0 = Remove + case 0: // Cancel + delete newitem; + return 0x0; + break; + case 1: // Remove newitem->option = "D"; break; - case 1: // Quit or Escape + case 2: // Reinstall or Upgrade newitem->option = secondOption; break; @@ -1165,2 +1174,50 @@ void MainWindow :: slotDisplayPackage( QListViewItem *item ) p->showMaximized(); } + +QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) + : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) +{ + setCaption( caption ); + resize( 175, 100 ); + + QGridLayout *layout = new QGridLayout( this ); + + QLabel *l = new QLabel( text, this ); + l->setAlignment( AlignCenter | WordBreak ); + layout->addMultiCellWidget( l, 0, 0, 0, 1 ); + + btn1 = new QPushButton( tr( "Remove" ), this ); + connect( btn1, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); + layout->addWidget( btn1, 1, 0 ); + + btn2 = new QPushButton( secondbtn, this ); + connect( btn2, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); + layout->addWidget( btn2, 1, 1 ); + + executing = FALSE; +} + +int QuestionDlg::exec() +{ + show(); + + if ( !executing ) + { + executing = TRUE; + qApp->enter_loop(); + } + + return buttonpressed; +} + +void QuestionDlg::slotButtonPressed() +{ + if ( sender() == btn1 ) + buttonpressed = 1; + else if ( sender() == btn2 ) + buttonpressed = 2; + else + buttonpressed = 0; + + qApp->exit_loop(); +} diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h index 9f48321..615ff8b 100644 --- a/noncore/settings/aqpkg/mainwin.h +++ b/noncore/settings/aqpkg/mainwin.h @@ -47,4 +47,5 @@ class QListViewItem; class QToolBar; class QProgressBar; +class QPushButton; class QWidgetStack; @@ -152,3 +153,23 @@ private slots: void slotDisplayPackage( QListViewItem * ); }; + +class QuestionDlg : public QWidget +{ + Q_OBJECT +public: + QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ); + + int exec(); + +private: + QPushButton *btn1; + QPushButton *btn2; + + bool executing; + int buttonpressed; + +private slots: + void slotButtonPressed(); +}; + #endif |