Skip to content

Commit

Permalink
Fixed - Added overloaded AtenWindow::setSelectedMode() to take button…
Browse files Browse the repository at this point in the history
… checked argument, and permitting button status to be corrected when using QShortcuts to access modes.
  • Loading branch information
trisyoungs committed Aug 26, 2016
1 parent 8f0a82d commit 029ac1b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/gui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ class AtenWindow : public QMainWindow
void useSelectedMode();
// Sets the currently selected interact mode
void setSelectedMode(UserAction::Action ua);
// Sets the currently selected interact mode, and corrects source button checked status
void setSelectedMode(UserAction::Action ua, bool buttonChecked);
// Return the currently selected mode
UserAction::Action selectedMode() const;
// Return the currently active mode
Expand Down
11 changes: 11 additions & 0 deletions src/gui/mainwindow_interaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ void AtenWindow::setSelectedMode(UserAction::Action ua)
Messenger::exit("AtenWindow::setSelectedMode");
}

// Sets the currently selected interact mode, and corrects source button checked status
void AtenWindow::setSelectedMode(UserAction::Action ua, bool buttonChecked)
{
// If the button is checked, set the current mode to that suppled.
// Otherwise, set the button down status again (re-set the mode) if this mode is already selected.
// This is to overcome issues with QShortcuts connecting the 'click()' method of the TMenuButtons,
// which toggles the checked status instead of just keeping the button checked.
if (buttonChecked) setSelectedMode(ua);
else if (selectedMode_ == ua) setSelectedMode(ua);
}

// Set the active mode to the current user mode
void AtenWindow::useSelectedMode()
{
Expand Down
18 changes: 9 additions & 9 deletions src/gui/mainwindow_panel_build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ void AtenWindow::updateBuildPanel(Model* sourceModel)

void AtenWindow::on_BuildSelectAtomsButton_clicked(bool checked)
{
if (checked) setSelectedMode(UserAction::SelectAction);
setSelectedMode(UserAction::SelectAction, checked);
}

void AtenWindow::on_BuildSelectBoundButton_clicked(bool checked)
{
if (checked) setSelectedMode(UserAction::SelectBoundAction);
setSelectedMode(UserAction::SelectBoundAction, checked);
}

void AtenWindow::on_BuildSelectElementButton_clicked(bool checked)
{
if (checked) setSelectedMode(UserAction::SelectElementAction);
setSelectedMode(UserAction::SelectElementAction, checked);
}

/*
Expand All @@ -54,32 +54,32 @@ void AtenWindow::on_BuildSelectElementButton_clicked(bool checked)

void AtenWindow::on_BuildDrawDrawButton_clicked(bool checked)
{
if (checked) setSelectedMode(UserAction::DrawAtomsAction);
setSelectedMode(UserAction::DrawAtomsAction, checked);
}

void AtenWindow::on_BuildDrawFragmentButton_clicked(bool checked)
{
if (checked) setSelectedMode(UserAction::DrawFragmentsAction);
setSelectedMode(UserAction::DrawFragmentsAction, checked);
}

void AtenWindow::on_BuildDrawDeleteButton_clicked(bool checked)
{
if (checked) setSelectedMode(UserAction::DrawDeleteAction);
setSelectedMode(UserAction::DrawDeleteAction, checked);
}

void AtenWindow::on_BuildDrawTransmuteButton_clicked(bool checked)
{
if (checked) setSelectedMode(UserAction::DrawTransmuteAction);
setSelectedMode(UserAction::DrawTransmuteAction, checked);
}

void AtenWindow::on_BuildDrawAddHButton_clicked(bool checked)
{
if (checked) setSelectedMode(UserAction::DrawAddHydrogenAction);
setSelectedMode(UserAction::DrawAddHydrogenAction, checked);
}

void AtenWindow::on_BuildDrawGrowButton_clicked(bool checked)
{
if (checked) setSelectedMode(UserAction::DrawGrowAtomsAction);
setSelectedMode(UserAction::DrawGrowAtomsAction, checked);
}

/*
Expand Down
6 changes: 3 additions & 3 deletions src/gui/mainwindow_panel_calculate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ void AtenWindow::updateCalculatePanel(Model* sourceModel)

void AtenWindow::on_CalculateMeasureDistanceButton_clicked(bool checked)
{
if (checked) setSelectedMode(UserAction::MeasureDistanceAction);
setSelectedMode(UserAction::MeasureDistanceAction, checked);
}

void AtenWindow::on_CalculateMeasureAngleButton_clicked(bool checked)
{
if (checked) setSelectedMode(UserAction::MeasureAngleAction);
setSelectedMode(UserAction::MeasureAngleAction, checked);
}

void AtenWindow::on_CalculateMeasureTorsionButton_clicked(bool checked)
{
if (checked) setSelectedMode(UserAction::MeasureTorsionAction);
setSelectedMode(UserAction::MeasureTorsionAction, checked);
}

void AtenWindow::on_CalculateMeasureClearButton_clicked(bool checked)
Expand Down

0 comments on commit 029ac1b

Please sign in to comment.