Skip to content

Commit

Permalink
Alerts: Added Beep when a new alert is emitted
Browse files Browse the repository at this point in the history
  • Loading branch information
foldynl committed May 15, 2022
1 parent 872e313 commit 75c4199
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
31 changes: 28 additions & 3 deletions ui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ MainWindow::MainWindow(QWidget* parent) :
menuAlert->addAction(ui->actionClearAlerts);
menuAlert->addSeparator();
menuAlert->addAction(ui->actionAlert);

menuAlert->addAction(ui->actionBeepSettingAlert);
ui->actionBeepSettingAlert->setChecked(settings.value("alertbeep", false).toBool());
alertButton->setMenu(menuAlert);


alertTextButton = new QPushButton(" ", ui->statusBar);
alertTextButton->setFlat(true);
alertTextButton->setFocusPolicy(Qt::NoFocus);
Expand Down Expand Up @@ -279,6 +279,20 @@ void MainWindow::clearAlertButtons()
alertTextButton->disconnect();
}

void MainWindow::beepSettingAlerts()
{
FCT_IDENTIFICATION;

QSettings settings;

settings.setValue("alertbeep", ui->actionBeepSettingAlert->isChecked());

if ( ui->actionBeepSettingAlert->isChecked() )
{
QApplication::beep();
}
}

void MainWindow::setDarkMode()
{
FCT_IDENTIFICATION;
Expand Down Expand Up @@ -314,7 +328,18 @@ void MainWindow::setLightMode()
void MainWindow::refreshAlertButton()
{
FCT_IDENTIFICATION;
alertButton->setText(QString::number(alertWidget->alertCount()));
static int prevCount = 0;

if ( prevCount != alertWidget->alertCount() )
{
alertButton->setText(QString::number(alertWidget->alertCount()));
if ( alertWidget->alertCount() != 0
&& ui->actionBeepSettingAlert->isChecked() )
{
QApplication::beep();
}
prevCount = alertWidget->alertCount();
}
}

void MainWindow::rotConnect() {
Expand Down
1 change: 1 addition & 0 deletions ui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ private slots:
void darkModeToggle(int);
void processSpotAlert(SpotAlert alert);
void clearAlertButtons();
void beepSettingAlerts();

private:
Ui::MainWindow* ui;
Expand Down
25 changes: 25 additions & 0 deletions ui/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,14 @@
<string>Clear Alerts</string>
</property>
</action>
<action name="actionBeepSettingAlert">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Beep</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
Expand Down Expand Up @@ -963,6 +971,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>actionBeepSettingAlert</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>beepSettingAlerts()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>456</x>
<y>298</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<signal>settingsChanged()</signal>
Expand All @@ -984,5 +1008,6 @@
<slot>alertRuleSetting()</slot>
<slot>showAlerts()</slot>
<slot>clearAlerts()</slot>
<slot>beepSettingAlerts()</slot>
</slots>
</ui>

0 comments on commit 75c4199

Please sign in to comment.