summaryrefslogtreecommitdiffstats
path: root/pica-client
diff options
context:
space:
mode:
Diffstat (limited to 'pica-client')
-rw-r--r--pica-client/globals.h1
-rw-r--r--pica-client/main.cpp4
-rw-r--r--pica-client/msguirouter.cpp2
-rw-r--r--pica-client/pica-client.pro6
-rw-r--r--pica-client/picaactioncenter.cpp10
-rw-r--r--pica-client/picaactioncenter.h3
-rw-r--r--pica-client/picapica-snd-newmessage.wavbin0 -> 17400 bytes
-rw-r--r--pica-client/picasystray.cpp1
-rw-r--r--pica-client/sound.cpp37
-rw-r--r--pica-client/sound.h17
10 files changed, 79 insertions, 2 deletions
diff --git a/pica-client/globals.h b/pica-client/globals.h
index 48c3ec8..660e764 100644
--- a/pica-client/globals.h
+++ b/pica-client/globals.h
@@ -28,4 +28,5 @@ extern class QIcon picapica_ico_fly;
extern class PicaActionCenter *action_center;
extern class PicaSysTray *systray;
extern class FileTransferController *ftctrl;
+extern class QString snd_newmessage;
#endif // GLOBALS_H
diff --git a/pica-client/main.cpp b/pica-client/main.cpp
index 0139bb0..4c73499 100644
--- a/pica-client/main.cpp
+++ b/pica-client/main.cpp
@@ -35,9 +35,13 @@ class FileTransferController *ftctrl;
#ifndef WIN32
QString config_defaultCA(PICA_INSTALLPREFIX"/share/pica-client/CA.pem");
QString config_defaultDHParam(PICA_INSTALLPREFIX"/share/pica-client/"PICA_CLIENT_DHPARAMFILE);
+
+QString snd_newmessage(PICA_INSTALLPREFIX"/share/pica-client/picapica-snd-newmessage.wav");
#else
QString config_defaultCA("share\\CA.pem");
QString config_defaultDHParam("share\\"PICA_CLIENT_DHPARAMFILE);
+
+QString snd_newmessage("share\\picapica-snd-newmessage.wav");
#endif
static bool create_database()
diff --git a/pica-client/msguirouter.cpp b/pica-client/msguirouter.cpp
index 2b6b845..93b6c66 100644
--- a/pica-client/msguirouter.cpp
+++ b/pica-client/msguirouter.cpp
@@ -4,6 +4,7 @@
#include "mainwindow.h"
#include "picasystray.h"
#include "globals.h"
+#include "sound.h"
/*
этот класс должен обеспечивать связь между приёмом-отправкой сообщений и их отображением в пользовательском интерфейсе.
@@ -68,6 +69,7 @@ void MsgUIRouter::create_chatwindow(QByteArray peer_id)
void MsgUIRouter::msg_from_peer(QByteArray from, QString msg)
{
+ Sound::play(snd_newmessage);
if ( ! chatwindows.contains(from))
{
diff --git a/pica-client/pica-client.pro b/pica-client/pica-client.pro
index df3b729..70c1222 100644
--- a/pica-client/pica-client.pro
+++ b/pica-client/pica-client.pro
@@ -36,7 +36,8 @@ SOURCES += main.cpp\
dhparam.cpp \
dialogs/showpicaiddialog.cpp \
dialogs/filetransferdialog.cpp \
- filetransfercontroller.cpp
+ filetransfercontroller.cpp \
+ sound.cpp
HEADERS += mainwindow.h \
chatwindow.h \
@@ -66,7 +67,8 @@ HEADERS += mainwindow.h \
dhparam.h \
dialogs/showpicaiddialog.h \
dialogs/filetransferdialog.h \
- filetransfercontroller.h
+ filetransfercontroller.h \
+ sound.h
DEFINES = PICA_MULTITHREADED
diff --git a/pica-client/picaactioncenter.cpp b/pica-client/picaactioncenter.cpp
index b88960c..5cd7b40 100644
--- a/pica-client/picaactioncenter.cpp
+++ b/pica-client/picaactioncenter.cpp
@@ -6,6 +6,7 @@
#include "../PICA_proto.h"
#include "accounts.h"
#include "dialogs/showpicaiddialog.h"
+#include "sound.h"
#include <QMessageBox>
@@ -22,6 +23,10 @@ PicaActionCenter::PicaActionCenter(QObject *parent) :
showmyidAct = new QAction(tr("Show My Pica Pica ID"), this);
connect(showmyidAct, SIGNAL(triggered()), this, SLOT(showmyid()));
+
+ muteSoundsAct = new QAction(tr("&Mute Sounds"), this);
+ muteSoundsAct->setCheckable(true);
+ connect(muteSoundsAct, SIGNAL(triggered(bool)), this, SLOT(muteSounds(bool)));
}
void PicaActionCenter::about()
@@ -55,3 +60,8 @@ void PicaActionCenter::showmyid()
ShowPicaIdDialog d(Accounts::GetCurrentAccount().name, Accounts::GetCurrentAccount().id, tr("My Current Account"));
d.exec();
}
+
+void PicaActionCenter::muteSounds(bool yes)
+{
+ Sound::mute(yes);
+}
diff --git a/pica-client/picaactioncenter.h b/pica-client/picaactioncenter.h
index 3fb0780..6361d01 100644
--- a/pica-client/picaactioncenter.h
+++ b/pica-client/picaactioncenter.h
@@ -13,11 +13,13 @@ public:
QAction *AboutAct() {return aboutAct;};
QAction *ExitAct() {return exitAct;};
QAction *ShowMyIDAct() {return showmyidAct;};
+ QAction *MuteSoundsAct() {return muteSoundsAct;};
private:
QAction *aboutAct;
QAction *exitAct;
QAction *showmyidAct;
+ QAction *muteSoundsAct;
signals:
@@ -26,6 +28,7 @@ private slots:
void about();
void exit();
void showmyid();
+ void muteSounds(bool yes);
};
#endif // PICAACTIONCENTER_H
diff --git a/pica-client/picapica-snd-newmessage.wav b/pica-client/picapica-snd-newmessage.wav
new file mode 100644
index 0000000..9611b6a
--- /dev/null
+++ b/pica-client/picapica-snd-newmessage.wav
Binary files differ
diff --git a/pica-client/picasystray.cpp b/pica-client/picasystray.cpp
index 62a7adb..1f9d1da 100644
--- a/pica-client/picasystray.cpp
+++ b/pica-client/picasystray.cpp
@@ -15,6 +15,7 @@ PicaSysTray::PicaSysTray(QObject *parent) :
systrayMenu_ = new QMenu();
systrayMenu_->addAction(action_center->AboutAct());
+ systrayMenu_->addAction(action_center->MuteSoundsAct());
systrayMenu_->addSeparator();
systrayMenu_->addAction(action_center->ExitAct());
diff --git a/pica-client/sound.cpp b/pica-client/sound.cpp
new file mode 100644
index 0000000..0caff3e
--- /dev/null
+++ b/pica-client/sound.cpp
@@ -0,0 +1,37 @@
+#include "sound.h"
+
+#ifndef WIN32
+
+#include <QProcess>
+
+#else
+
+//link with winmm.lib
+#include <Mmsystem.h>
+#include <windows.h>
+
+#endif
+
+
+bool Sound::is_muted = false;
+
+Sound::Sound()
+{
+}
+
+void Sound::mute(bool yes)
+{
+ is_muted = yes;
+}
+
+void Sound::play(const QString sndfile)
+{
+ if (is_muted)
+ return;
+
+#ifndef WIN32
+ QProcess::execute("aplay -q " + sndfile);
+#else
+ sndPlaySound(sndfile.toAscii().constData(), SND_ASYNC | SND_NODEFAULT);
+#endif
+}
diff --git a/pica-client/sound.h b/pica-client/sound.h
new file mode 100644
index 0000000..3b1357a
--- /dev/null
+++ b/pica-client/sound.h
@@ -0,0 +1,17 @@
+#ifndef SOUND_H
+#define SOUND_H
+#include <QString>
+
+class Sound
+{
+public:
+ Sound();
+
+ static void play(const QString sndfile);
+ static void mute(bool yes);
+
+private:
+ static bool is_muted;
+};
+
+#endif // SOUND_H