Skip to content

Commit

Permalink
- Play a bell sound when the Terminal tab is asking for the user
Browse files Browse the repository at this point in the history
password.
  • Loading branch information
aarnt committed Sep 9, 2024
1 parent d984e11 commit 4fe3873
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
0.17 (dev)
BugFix: Code for EndeavourOS news was incomplete (thanks to LegitGreenBoi).
BugFix: Help msg for newer packages was wrong because they're not installed.
Play a bell sound when the Terminal tab is asking for the user password.
Improvement: Show a "Collecting transaction data..." msg before presenting the transaction
dialog, as it can be quite slow on some systems (thanks to Valdir).
Updated translations.
Expand Down
2 changes: 1 addition & 1 deletion octopi.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
#-------------------------------------------------

QT += core gui network xml widgets
QT += core gui network xml widgets multimedia
DEFINES += OCTOPI_EXTENSIONS ALPM_BACKEND

# Disable automatic string conversions
Expand Down
1 change: 1 addition & 0 deletions resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,6 @@
<file>resources/translations/octopi_zh-Hans.qm</file>
<file>resources/translations/octopi_zh_CN.qm</file>
<file>resources/translations/octopi_ko.qm</file>
<file>resources/sounds/bell.wav</file>
</qresource>
</RCC>
Binary file added resources/sounds/bell.wav
Binary file not shown.
18 changes: 18 additions & 0 deletions src/termwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <QMessageBox>
#include <QAbstractButton>
#include <QRegularExpression>
#include <QSoundEffect>
//#include <QDebug>

/*
Expand Down Expand Up @@ -142,6 +143,10 @@ void TermWidget::parseOutput(QString str)
{
emit onKeyQuit();
}
else if (str.contains(QLatin1String("password for ") + QLatin1String(qgetenv("USER")) + QLatin1String(":")))
{
playBellSound();
}
}

/*
Expand Down Expand Up @@ -214,6 +219,19 @@ void TermWidget::onZoomOut()
if (m_zoomFactor != 0) SettingsManager::setConsoleFontSize(m_zoomFactor);
}

/*
* Plays a bell sound which is encoded in the resource file
*/
void TermWidget::playBellSound()
{
QSoundEffect *se = new QSoundEffect(this);
se->setSource(QUrl::fromLocalFile(QLatin1String(":/resources/sounds/bell.wav")));
se->setLoopCount(3);
se->setMuted(false);
se->setVolume(1.0f);
se->play();
}

/*
* Paste code extracted from project "lxqt/qterminal"
*/
Expand Down
1 change: 1 addition & 0 deletions src/termwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ private slots:

public:
explicit TermWidget(QWidget *parent);
void playBellSound();
void execute(QString command);
void enter();

Expand Down

0 comments on commit 4fe3873

Please sign in to comment.