Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new configuration option: "Require confirmation on quit" #230

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Source/OptionsView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ OptionsView::OptionsView(SonobusAudioProcessor& proc, std::function<AudioDeviceM
mOptionsDisableShortcutButton = std::make_unique<ToggleButton>(TRANS("Disable keyboard shortcuts"));
mOptionsDisableShortcutButton->addListener(this);

mOptionsConfirmOnQuit = std::make_unique<ToggleButton>(TRANS("Require confirmation on quit"));
mOptionsConfirmOnQuit->addListener(this);

#if JUCE_IOS
if (JUCEApplicationBase::isStandaloneApp()) {
mOptionsAllowBluetoothInput = std::make_unique<ToggleButton>(TRANS("Allow Bluetooth Input"));
Expand Down Expand Up @@ -397,6 +400,7 @@ OptionsView::OptionsView(SonobusAudioProcessor& proc, std::function<AudioDeviceM
}
mOptionsComponent->addAndMakeVisible(mOptionsSliderSnapToMouseButton.get());
mOptionsComponent->addAndMakeVisible(mOptionsDisableShortcutButton.get());
mOptionsComponent->addAndMakeVisible(mOptionsConfirmOnQuit.get());



Expand Down Expand Up @@ -640,6 +644,7 @@ void OptionsView::updateState(bool ignorecheck)

mOptionsSliderSnapToMouseButton->setToggleState(processor.getSlidersSnapToMousePosition(), dontSendNotification);
mOptionsDisableShortcutButton->setToggleState(processor.getDisableKeyboardShortcuts(), dontSendNotification);
mOptionsConfirmOnQuit->setToggleState(processor.getConfirmOnQuit(), dontSendNotification);

uint32 recmask = processor.getDefaultRecordingOptions();

Expand Down Expand Up @@ -795,6 +800,11 @@ void OptionsView::updateLayout()
optionsDisableShortcutsBox.items.add(FlexItem(10, 12).withFlex(0));
optionsDisableShortcutsBox.items.add(FlexItem(180, minpassheight, *mOptionsDisableShortcutButton).withMargin(0).withFlex(1));

optionsDisableShortcutsBox.items.clear();
optionsDisableShortcutsBox.flexDirection = FlexBox::Direction::row;
optionsDisableShortcutsBox.items.add(FlexItem(10, 12).withFlex(0));
optionsDisableShortcutsBox.items.add(FlexItem(180, minpassheight, *mOptionsConfirmOnQuit).withMargin(0).withFlex(1));


optionsAllowBluetoothBox.items.clear();
optionsAllowBluetoothBox.flexDirection = FlexBox::Direction::row;
Expand Down Expand Up @@ -1168,6 +1178,13 @@ void OptionsView::buttonClicked (Button* buttonThatWasClicked)
updateKeybindings();
}
}
else if (buttonThatWasClicked == mOptionsConfirmOnQuit.get()) {
bool newval = mOptionsConfirmOnQuit->getToggleState();
processor.setConfirmOnQuit(newval);
if (updateConfirmOnQuit) {
updateConfirmOnQuit();
}
}
else if (buttonThatWasClicked == mOptionsSavePluginDefaultButton.get()) {
processor.saveCurrentAsDefaultPluginSettings();
}
Expand Down Expand Up @@ -1388,4 +1405,3 @@ void OptionsView::paint(Graphics & g)
g.drawRoundedRectangle(bounds.toFloat(), 6.0f, 0.5f);
*/
}

2 changes: 2 additions & 0 deletions Source/OptionsView.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public MultiTimer
std::function<Value*()> getAllowBluetoothInputValue; // = []() { return 0; };
std::function<void()> updateSliderSnap; // = []() { return 0; };
std::function<void()> updateKeybindings; // = []() { return 0; };
std::function<void()> updateConfirmOnQuit; // = []() { return 0; };
std::function<bool(const String &)> setupLocalisation; // = []() { return 0; };
std::function<void()> saveSettingsIfNeeded; // = []() { return 0; };

Expand Down Expand Up @@ -136,6 +137,7 @@ public MultiTimer
std::unique_ptr<ToggleButton> mOptionsSliderSnapToMouseButton;
std::unique_ptr<ToggleButton> mOptionsAllowBluetoothInput;
std::unique_ptr<ToggleButton> mOptionsDisableShortcutButton;
std::unique_ptr<ToggleButton> mOptionsConfirmOnQuit;
std::unique_ptr<TextButton> mOptionsSavePluginDefaultButton;
std::unique_ptr<TextButton> mOptionsResetPluginDefaultButton;

Expand Down
5 changes: 2 additions & 3 deletions Source/SonobusPluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1433,8 +1433,8 @@ static void doActuallyQuit (int result, SonobusAudioProcessorEditor* editor)

bool SonobusAudioProcessorEditor::requestedQuit()
{
// allow quit if we are not connected
if (currConnected && currGroup.isNotEmpty()) {
// allow quit if we are not connected and option "Confirm on quit" is unchecked
if (currConnected && currGroup.isNotEmpty() && processor.getConfirmOnQuit()) {
// pop up confirmation
AlertWindow::showOkCancelBox (AlertWindow::WarningIcon,
TRANS("Quit Confirmation"),
Expand Down Expand Up @@ -6040,4 +6040,3 @@ void SonobusAudioProcessorEditor::SonobusMenuBarModel::menuItemSelected (int men
}
#endif
}

3 changes: 3 additions & 0 deletions Source/SonobusPluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ static String defRecordDirURLKey("DefaultRecordDirURL");
static String lastBrowseDirKey("LastBrowseDir");
static String sliderSnapKey("SliderSnapToMouse");
static String disableShortcutsKey("DisableKeyShortcuts");
static String confirmOnQuitKey("ConfirmOnQuit");
static String peerDisplayModeKey("PeerDisplayMode");
static String lastChatWidthKey("lastChatWidth");
static String lastChatShownKey("lastChatShown");
Expand Down Expand Up @@ -8530,6 +8531,7 @@ void SonobusAudioProcessor::getStateInformationWithOptions(MemoryBlock& destData
extraTree.setProperty(lastBrowseDirKey, mLastBrowseDir, nullptr);
extraTree.setProperty(sliderSnapKey, mSliderSnapToMouse, nullptr);
extraTree.setProperty(disableShortcutsKey, mDisableKeyboardShortcuts, nullptr);
extraTree.setProperty(confirmOnQuitKey, mConfirmOnQuit, nullptr);
extraTree.setProperty(peerDisplayModeKey, var((int)mPeerDisplayMode), nullptr);
extraTree.setProperty(lastChatWidthKey, var((int)mLastChatWidth), nullptr);
extraTree.setProperty(lastChatShownKey, mLastChatShown, nullptr);
Expand Down Expand Up @@ -8698,6 +8700,7 @@ void SonobusAudioProcessor::setStateInformationWithOptions (const void* data, in
#endif
setSlidersSnapToMousePosition(extraTree.getProperty(sliderSnapKey, mSliderSnapToMouse));
setDisableKeyboardShortcuts(extraTree.getProperty(disableShortcutsKey, mDisableKeyboardShortcuts));
setConfirmOnQuit(extraTree.getProperty(confirmOnQuitKey, mConfirmOnQuit));
setPeerDisplayMode((PeerDisplayMode)(int)extraTree.getProperty(peerDisplayModeKey, (int)mPeerDisplayMode));
setLastChatWidth((int)extraTree.getProperty(lastChatWidthKey, (int)mLastChatWidth));
setLastChatShown(extraTree.getProperty(lastChatShownKey, mLastChatShown));
Expand Down
4 changes: 4 additions & 0 deletions Source/SonobusPluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,9 @@ class SonobusAudioProcessor : public AudioProcessor, public AudioProcessorValue
bool getDisableKeyboardShortcuts() const { return mDisableKeyboardShortcuts; }
void setDisableKeyboardShortcuts(bool flag) { mDisableKeyboardShortcuts = flag; }

bool getConfirmOnQuit() const { return mConfirmOnQuit; }
void setConfirmOnQuit(bool flag) { mConfirmOnQuit = flag; }


struct VideoLinkInfo
{
Expand Down Expand Up @@ -1254,6 +1257,7 @@ class SonobusAudioProcessor : public AudioProcessor, public AudioProcessorValue
// misc
bool mSliderSnapToMouse = true;
bool mDisableKeyboardShortcuts = false;
bool mConfirmOnQuit = true;
VideoLinkInfo mVideoLinkInfo;

File mSupportDir;
Expand Down