Skip to content
Browse files

when no package is selected, the install button is disabled

  • Loading branch information...
1 parent b522895 commit c7772fcf0aab2ce28e326e59a1d6667ea5936a15 @saurabhsood91 saurabhsood91 committed Feb 16, 2013
Showing with 50 additions and 0 deletions.
  1. +17 −0 src/firstscreen.cpp
  2. +10 −0 src/firstscreen.h
  3. +6 −0 src/mainwindow.cpp
  4. +5 −0 src/mainwindow.h
  5. +6 −0 src/packagedetails.cpp
  6. +6 −0 src/packagedetails.h
View
17 src/firstscreen.cpp
@@ -63,13 +63,16 @@ FirstScreen::FirstScreen( PackageBackend *backend, QString *tmpFileName, const Q
mainLayout->addSpacing( -10 );
PackageDetails *packDetails = new PackageDetails( iter, j, m_packages.count() );
QObject::connect( packDetails, SIGNAL( sizeUpdated( QString ) ), this, SIGNAL( sizeUpdated( QString ) ) );
+ QObject::connect( packDetails, SIGNAL( checkboxChanged( bool ) ), this, SLOT( countCheckedPackages( bool ) ) );
mainLayout->addWidget( packDetails );
j++;
}
i++;
mainLayout->addSpacing( -8 );
}
+ m_packagesSelected = m_backend->packages().count();
+
if( m_untrustedSources > 0 ) {
m_warning = new QLabel( "<b>Be careful!</b> Some Sources are not currently known. Installing<br />software requires trusting these sources" );
m_warning->setStyleSheet( "border : 1px solid rgb(196,181,147); background-color: rgb(253, 227, 187); border-radius : 10px" );
@@ -94,3 +97,17 @@ void FirstScreen::showEvent( QShowEvent *s )
emit countChanged( m_repos.count(), m_packages.count() );
qDebug() << "number of untrusted sources is " << m_untrustedSources;
}
+
+void FirstScreen::countCheckedPackages( bool checked )
+{
+ if( checked == false ) {
+ m_packagesSelected--;
+ } else {
+ m_packagesSelected++;
+ }
+
+ if( m_packagesSelected == 0 )
+ emit packagesSelected( false );
+ else
+ emit packagesSelected( true );
+}
View
10 src/firstscreen.h
@@ -34,13 +34,20 @@ class FirstScreen : public QWidget
Default constructor taking the backend, and the filename as argument
*/
FirstScreen( PackageBackend *backend, QString *tmpFileName, const QString& filename, QObject *parent = 0 );
+
private slots:
/**
Show Event
*/
void showEvent( QShowEvent * s);
+
+ /**
+ * Count checked packages
+ */
+ void countCheckedPackages(bool checked);
+
private:
PackageBackend *m_backend;
@@ -53,10 +60,13 @@ private slots:
int m_untrustedSources;
+ int m_packagesSelected;
+
signals:
void showNextScreen( int );
void countChanged( int, int );
void sizeUpdated( QString size );
+ void packagesSelected( bool );
};
#endif
View
6 src/mainwindow.cpp
@@ -94,6 +94,7 @@ MainWindow::MainWindow( const QString& filename, QString tmpFileName, bool fakeR
QObject::connect( m_backend, SIGNAL( installationCompleted() ), m_header, SLOT( installationCompleted() ) );
QObject::connect( installer, SIGNAL( installationCompleted() ), m_header, SLOT( installationCompleted() ) );
QObject::connect( m_backend, SIGNAL( installationCompleted() ), installer, SLOT( showCompletionStatus() ) );
+ QObject::connect( m_firstScreen, SIGNAL( packagesSelected( bool ) ), this, SLOT( toggleInstallButton( bool ) ) );
show();
}
@@ -133,3 +134,8 @@ void MainWindow::updateSize( QString size )
if( m_screenStack->currentIndex() == 0 )
m_header->updateDetails( size );
}
+
+void MainWindow::toggleInstallButton(bool value)
+{
+ m_install->setEnabled( value );
+}
View
5 src/mainwindow.h
@@ -71,6 +71,11 @@ private slots:
*/
void updateSize(QString size );
+ /**
+ * Disable Cancel Button
+ */
+ void toggleInstallButton( bool value );
+
signals:
void countChanged( int repoCount, int packageCount );
};
View
6 src/packagedetails.cpp
@@ -70,6 +70,7 @@ PackageDetails::PackageDetails(OCI::Package *package,int count, int packagecount
m_packageName->setContentsMargins( 10, 10, 10, 10 );
m_packageName->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Expanding );
m_packageName->setStyleSheet( "background-color : white; border-left : 1px solid rgb(196,181,147); padding-left : 3px;" );
+ QObject::connect( m_packageName, SIGNAL( toggled( bool ) ), this, SIGNAL( checkboxChanged( bool ) ) );
packageLayout->addWidget( m_packageName );
}
packageLayout->addWidget( m_version );
@@ -106,3 +107,8 @@ void PackageDetails::dataChanged( QString version, QString size )
emit sizeUpdated( size );
}
+
+bool PackageDetails::packageChecked()
+{
+ return m_packageName->isChecked();
+}
View
6 src/packagedetails.h
@@ -19,6 +19,11 @@ class PackageDetails : public QWidget
* Constructor for Package Widget. Parameter is the index and Package Object
*/
PackageDetails(OCI::Package *package, int packagecount, int count, QObject *parent = 0 );
+
+ /**
+ * If More than one package, Return if Checkbox is checked
+ */
+ bool packageChecked();
private:
bool m_descriptionVisible;
@@ -46,6 +51,7 @@ private slots:
signals:
void sizeUpdated( QString size );
+ void checkboxChanged( bool checked );
};
#endif

0 comments on commit c7772fc

Please sign in to comment.
Something went wrong with that request. Please try again.