Skip to content

Commit

Permalink
fix disabling buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
NEDJIMAbelgacem authored and nyalldawson committed Jan 12, 2022
1 parent 33f070f commit 6fc734c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/app/3d/qgs3dviewsmanagerdialog.cpp
Expand Up @@ -44,9 +44,11 @@ Qgs3DViewsManagerDialog::Qgs3DViewsManagerDialog( QWidget *parent, Qt::WindowFla
mShowButton->setEnabled( false );
mHideButton->setEnabled( false );

connect( m3DViewsListView->selectionModel(), &QItemSelectionModel::currentChanged, this, &Qgs3DViewsManagerDialog::showHideButtonStateChanged );
connect( m3DViewsListView->selectionModel(), &QItemSelectionModel::currentChanged, this, &Qgs3DViewsManagerDialog::currentChanged );

connect( QgsProject::instance()->views3DManager(), &Qgs3DViewsManager::viewsListChanged, this, &Qgs3DViewsManagerDialog::onViewsListChanged );
m3DViewsListView->selectionModel()->setCurrentIndex( m3DViewsListView->model()->index( 0, 0 ), QItemSelectionModel::Select );
currentChanged( m3DViewsListView->selectionModel()->currentIndex(), m3DViewsListView->selectionModel()->currentIndex() );
}

void Qgs3DViewsManagerDialog::onViewsListChanged()
Expand All @@ -73,7 +75,7 @@ void Qgs3DViewsManagerDialog::showClicked()
widget->show();
QgsProject::instance()->setDirty();
}

currentChanged( m3DViewsListView->selectionModel()->currentIndex(), m3DViewsListView->selectionModel()->currentIndex() );
}

void Qgs3DViewsManagerDialog::hideClicked()
Expand All @@ -90,6 +92,7 @@ void Qgs3DViewsManagerDialog::hideClicked()
}

QgsProject::instance()->setDirty();
currentChanged( m3DViewsListView->selectionModel()->currentIndex(), m3DViewsListView->selectionModel()->currentIndex() );
}

void Qgs3DViewsManagerDialog::duplicateClicked()
Expand Down Expand Up @@ -148,9 +151,13 @@ void Qgs3DViewsManagerDialog::renameClicked()
QgsProject::instance()->setDirty();
}

void Qgs3DViewsManagerDialog::showHideButtonStateChanged( const QModelIndex &current, const QModelIndex &previous )
void Qgs3DViewsManagerDialog::currentChanged( const QModelIndex &current, const QModelIndex &previous )
{
Q_UNUSED( previous );

mRenameButton->setEnabled( current.isValid() );
mRemoveButton->setEnabled( current.isValid() );
mDuplicateButton->setEnabled( current.isValid() );
if ( !current.isValid() )
{
mShowButton->setEnabled( false );
Expand Down
2 changes: 1 addition & 1 deletion src/app/3d/qgs3dviewsmanagerdialog.h
Expand Up @@ -40,7 +40,7 @@ class Qgs3DViewsManagerDialog : public QDialog, private Ui::Qgs3DViewsManagerDia
void removeClicked();
void renameClicked();

void showHideButtonStateChanged( const QModelIndex &current, const QModelIndex &previous );
void currentChanged( const QModelIndex &current, const QModelIndex &previous );

void onViewsListChanged();
private:
Expand Down

0 comments on commit 6fc734c

Please sign in to comment.