summaryrefslogtreecommitdiff
authordrw <drw>2003-05-16 23:17:49 (UTC)
committer drw <drw>2003-05-16 23:17:49 (UTC)
commiteac84192decbd60ecb680b82c92b55e70b5fd015 (patch) (side-by-side diff)
tree3e47155aff48679a971bccb82b58c6b89fe4c358
parentdb67960cfab97f9897e0fdc1cb9c8e8794f4a2ba (diff)
downloadopie-eac84192decbd60ecb680b82c92b55e70b5fd015.zip
opie-eac84192decbd60ecb680b82c92b55e70b5fd015.tar.gz
opie-eac84192decbd60ecb680b82c92b55e70b5fd015.tar.bz2
Fix for bug #914 (correct dialog cancel behaviour)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp69
-rw-r--r--noncore/settings/aqpkg/mainwin.h21
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
@@ -948,25 +948,29 @@ void MainWindow :: applyChanges()
// 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 ) );
+ InstallData *instdata = dealWithItem( item );
+ if ( instdata )
+ workingPackages.append( instdata );
+ else
+ return;
}
}
if ( workingPackages.count() == 0 )
{
// Nothing to do
QMessageBox::information( this, tr( "Nothing to do" ),
tr( "No packages selected" ), tr( "OK" ) );
return;
}
@@ -1058,32 +1062,37 @@ InstallData *MainWindow :: dealWithItem( QCheckListItem *item )
caption = tr( "Do you wish to remove or upgrade\n%1?" );
text = tr( "Remove or Upgrade" );
secondButton = tr( "Upgrade" );
secondOption = tr( "U" );
}
// Sticky option not implemented yet, but will eventually allow
// the user to say something like 'remove all'
if ( stickyOption == "" )
{
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;
}
}
else
{
// newitem->option = stickyOption;
}
}
// Check if we are reinstalling the same version
@@ -1155,12 +1164,60 @@ void MainWindow :: letterPushed( QString t )
item = (QCheckListItem *)item->nextSibling();
if ( !item )
item = (QCheckListItem *)packagesList->firstChild();
} while ( item != start);
}
void MainWindow :: slotDisplayPackage( QListViewItem *item )
{
QString itemstr( ((QCheckListItem*)item)->text() );
PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) );
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
@@ -37,24 +37,25 @@ class DataManager;
class InstallData;
class InstallDlgImpl;
class QAction;
class QCheckListItem;
class QComboBox;
class QLabel;
class QLineEdit;
class QListView;
class QListViewItem;
class QToolBar;
class QProgressBar;
+class QPushButton;
class QWidgetStack;
class MainWindow :public QMainWindow
{
Q_OBJECT
public:
MainWindow();
~MainWindow();
protected:
void closeEvent( QCloseEvent* e );
@@ -142,13 +143,33 @@ private slots:
void init();
void setProgressSteps( int );
void setProgressMessage( const QString & );
void updateProgress( int );
void serverSelected( int index );
void updateServer();
void upgradePackages();
void downloadPackage();
void applyChanges();
void letterPushed( QString t );
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