mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-10-31 22:47:05 +01:00
Playing different sounds on different actions
still bloody beta
This commit is contained in:
parent
10560644de
commit
6634d1fd71
@ -103,6 +103,10 @@ install(DIRECTORY images/ DESTINATION share/doorlockd/images
|
|||||||
FILES_MATCHING PATTERN "images/*.png"
|
FILES_MATCHING PATTERN "images/*.png"
|
||||||
PERMISSIONS WORLD_READ OWNER_READ GROUP_READ)
|
PERMISSIONS WORLD_READ OWNER_READ GROUP_READ)
|
||||||
|
|
||||||
|
install(DIRECTORY sounds/ DESTINATION share/doorlockd/sounds
|
||||||
|
FILES_MATCHING PATTERN "sounds/*.wav"
|
||||||
|
PERMISSIONS WORLD_READ OWNER_READ GROUP_READ)
|
||||||
|
|
||||||
install(FILES scripts/doorlockd.service DESTINATION /etc/systemd/system/)
|
install(FILES scripts/doorlockd.service DESTINATION /etc/systemd/system/)
|
||||||
|
|
||||||
install(DIRECTORY scripts/ DESTINATION etc/doorlockd/
|
install(DIRECTORY scripts/ DESTINATION etc/doorlockd/
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
|
#define PLAY(file) \
|
||||||
|
system("play -q " file " &")
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::MainWindow)
|
ui(new Ui::MainWindow)
|
||||||
@ -22,7 +25,33 @@ void MainWindow::setClientmessage(const Clientmessage &msg)
|
|||||||
ui->qrwidget->setQRData(msg.token());
|
ui->qrwidget->setQRData(msg.token());
|
||||||
ui->tokenLabel->setText(QString::fromStdString(msg.token()));
|
ui->tokenLabel->setText(QString::fromStdString(msg.token()));
|
||||||
|
|
||||||
|
const auto &doormsg = msg.doormessage();
|
||||||
|
|
||||||
_LED(msg.isOpen());
|
_LED(msg.isOpen());
|
||||||
|
|
||||||
|
if (_oldMessage.isOpen() && !msg.isOpen()) {
|
||||||
|
// regular close
|
||||||
|
PLAY(SOUND_LOCK);
|
||||||
|
} else if (!_oldMessage.isOpen() && msg.isOpen()) {
|
||||||
|
// regular open
|
||||||
|
PLAY(SOUND_UNLOCK);
|
||||||
|
} else {
|
||||||
|
// no change
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doormsg.isEmergencyUnlock) {
|
||||||
|
PLAY(SOUND_EMERGENCY_UNLOCK);
|
||||||
|
} else if (doormsg.isLockButton) {
|
||||||
|
PLAY(SOUND_LOCK_BUTTON);
|
||||||
|
} else if (doormsg.isUnlockButton) {
|
||||||
|
if (msg.isOpen()) {
|
||||||
|
PLAY(SOUND_ZONK);
|
||||||
|
} else {
|
||||||
|
PLAY(SOUND_UNLOCK_BUTTON);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_oldMessage = msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::_LED(const bool on)
|
void MainWindow::_LED(const bool on)
|
||||||
|
@ -25,6 +25,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
|
||||||
|
Clientmessage _oldMessage = { };
|
||||||
|
|
||||||
void _LED(const bool on);
|
void _LED(const bool on);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,6 +29,14 @@
|
|||||||
#define SHARED_LOCATION "@CMAKE_INSTALL_PREFIX@/share/doorlockd/"
|
#define SHARED_LOCATION "@CMAKE_INSTALL_PREFIX@/share/doorlockd/"
|
||||||
#define IMAGE_LOCATION SHARED_LOCATION "images/"
|
#define IMAGE_LOCATION SHARED_LOCATION "images/"
|
||||||
|
|
||||||
|
#define SOUNDS_LOCATION SHARED_LOCATION "sounds/"
|
||||||
|
#define SOUND_LOCK SOUNDS_LOCATION "lock.wav"
|
||||||
|
#define SOUND_UNLOCK SOUNDS_LOCATION "unlock.wav"
|
||||||
|
#define SOUND_EMERGENCY_UNLOCK SOUNDS_LOCATION "emergency_unlock.wav"
|
||||||
|
#define SOUND_ZONK SOUNDS_LOCATION "zonk.wav"
|
||||||
|
#define SOUND_LOCK_BUTTON SOUNDS_LOCATION "lock_button.wav"
|
||||||
|
#define SOUND_UNLOCK_BUTTON SOUNDS_LOCATION "unlock_button.wav"
|
||||||
|
|
||||||
#define PRE_LOCK_SCRIPT "@CMAKE_INSTALL_PREFIX@/etc/doorlockd/pre_lock &"
|
#define PRE_LOCK_SCRIPT "@CMAKE_INSTALL_PREFIX@/etc/doorlockd/pre_lock &"
|
||||||
#define POST_LOCK_SCRIPT "@CMAKE_INSTALL_PREFIX@/etc/doorlockd/post_lock &"
|
#define POST_LOCK_SCRIPT "@CMAKE_INSTALL_PREFIX@/etc/doorlockd/post_lock &"
|
||||||
#define PRE_UNLOCK_SCRIPT "@CMAKE_INSTALL_PREFIX@/etc/doorlockd/pre_unlock &"
|
#define PRE_UNLOCK_SCRIPT "@CMAKE_INSTALL_PREFIX@/etc/doorlockd/pre_unlock &"
|
||||||
|
Loading…
Reference in New Issue
Block a user