Skip to content
This repository has been archived by the owner on Jun 11, 2020. It is now read-only.

Sounds #112

Open
wants to merge 2 commits into
base: master
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
10 changes: 7 additions & 3 deletions projectfiles/QtCreator/TOX-Qt-GUI.pro
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ defineTest(minQtVersion) {
error("Cannot build with Qt version $${QT_VERSION}, this project requires at least Qt 5.2.0")
}

QT += core gui widgets
QT += core gui widgets multimedia

TARGET = TOX-Qt-GUI
TEMPLATE = app
Expand Down Expand Up @@ -92,7 +92,9 @@ SOURCES += \
../../src/frienditemdelegate.cpp \
../../src/editablelabelwidget.cpp \
../../src/esclineedit.cpp \
../../src/copyableelidelabel.cpp
../../src/copyableelidelabel.cpp \
../../src/soundmanager.cpp \
../../src/Settings/soundsettingspage.cpp

HEADERS += \
../../src/mainwindow.hpp \
Expand Down Expand Up @@ -135,7 +137,9 @@ HEADERS += \
../../src/frienditemdelegate.hpp \
../../src/editablelabelwidget.hpp \
../../src/esclineedit.hpp \
../../src/copyableelidelabel.hpp
../../src/copyableelidelabel.hpp \
../../src/soundmanager.hpp \
../../src/Settings/soundsettingspage.hpp

### ToxCore section. Please keep it alphabetical ###

Expand Down
Binary file added resources/icons/sound.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions resources/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
<file>icons/arrow_redo.png</file>
<file>icons/arrow_undo.png</file>
<file>DejaVuSans.ttf</file>
<file>icons/sound.png</file>
</qresource>
</RCC>
20 changes: 20 additions & 0 deletions sounds/theme
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[header]
name = Default
author = Adam Reid
decription = default sound pack fot tox
license = Creative Commons Attribution 3.0 Unported

[sounds]
error = Error.wav
friendLogsIn = Contact Logs In.wav
friendLogsOut = Contact Logs Out.wav
friendRequestAccepted = Contact Request Accepted.wav
incommingCall = Incoming Call.wav
incommingVideoCall = Incoming Video Call.wav
logIn = Log In.wav
logOut = Log Out.wav
newMessage = New Message.wav
outgoingCall = Outgoing Call.wav
outgoingVideoCall = Outgoing Video Call.wav
filetransferComplete = Transfer Complete.wav
filetransferPending = Transfer Pending.wav
159 changes: 159 additions & 0 deletions src/Settings/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,122 @@ void Settings::load()
emojiFontPointSize = s.value("emojiFontPointSize", QApplication::font().pointSize()).toInt();
s.endGroup();

s.beginGroup("Sound");
soundEnabled = s.value("enabled", true).toBool();
soundPackDirName = s.value("soundPackDirName", "tox").toString();
playOnError = s.value("playOnError", true).toBool();
playOnLogInOut = s.value("playOnLogInOut", true).toBool();
playOnFriendLogsInOut = s.value("playOnFriendLogsInOut", true).toBool();
playOnFriendRequestAccepted = s.value("playOnFriendRequestAccepted", true).toBool();
playOnIncommingCall = s.value("playOnIncommingCall", true).toBool();
playOnOutgoingCall = s.value("playOnOutgoingCall", true).toBool();
playOnNewMessage = s.value("playOnNewMessage", true).toBool();
playOnFiletransferComplete = s.value("playOnFiletransferComplete", true).toBool();
playOnFiletransferPending = s.value("playOnFiletransferPending", true).toBool();
s.endGroup();

loaded = true;
}
bool Settings::isPlayOnFiletransferPending() const
{
return playOnFiletransferPending;
}

void Settings::setPlayOnFiletransferPending(bool value)
{
playOnFiletransferPending = value;
}

bool Settings::isPlayOn(const Sound &sound)
{
switch (sound) {
case Sound::Error: return playOnError;
case Sound::FriendLogsIn:
case Sound::FriendLogsOut: return playOnFriendLogsInOut;
case Sound::FriendRequestAccepted:return playOnFriendRequestAccepted;
case Sound::IncommingCall:
case Sound::IncommingVideoCall: return playOnIncommingCall;
case Sound::LogIn:
case Sound::LogOut: return playOnLogInOut;
case Sound::NewMessage: return playOnNewMessage;
case Sound::OutgoingCall:
case Sound::OutgoingVideoCall: return playOnOutgoingCall;
case Sound::FiletransferComplete: return playOnFiletransferComplete;
case Sound::FiletransferPending: return playOnFiletransferPending;
}
return false;
}

bool Settings::isPlayOnFiletransferComplete() const
{
return playOnFiletransferComplete;
}

void Settings::setPlayOnFiletransferComplete(bool value)
{
playOnFiletransferComplete = value;
}

bool Settings::isPlayOnNewMessage() const
{
return playOnNewMessage;
}

void Settings::setPlayOnNewMessage(bool value)
{
playOnNewMessage = value;
}

bool Settings::isPlayOnOutgoingCall() const
{
return playOnOutgoingCall;
}

void Settings::setPlayOnOutgoingCall(bool value)
{
playOnOutgoingCall = value;
}

bool Settings::isPlayOnIncommingCall() const
{
return playOnIncommingCall;
}

void Settings::setPlayOnIncommingCall(bool value)
{
playOnIncommingCall = value;
}

bool Settings::isPlayOnFriendRequestAccepted() const
{
return playOnFriendRequestAccepted;
}

void Settings::setPlayOnFriendRequestAccepted(bool value)
{
playOnFriendRequestAccepted = value;
}

bool Settings::isPlayOnFriendLogsInOut() const
{
return playOnFriendLogsInOut;
}

void Settings::setPlayOnFriendLogsInOut(bool value)
{
playOnFriendLogsInOut = value;
}

bool Settings::isPlayOnLogInOut() const
{
return playOnLogInOut;
}

void Settings::setPlayOnLogInOut(bool value)
{
playOnLogInOut = value;
}


void Settings::save()
{
Expand Down Expand Up @@ -150,6 +264,20 @@ void Settings::save()
s.setValue("emojiFontFamily", emojiFontFamily);
s.setValue("emojiFontPointSize", emojiFontPointSize);
s.endGroup();

s.beginGroup("Sound");
s.setValue("enabled", soundEnabled);
s.setValue("soundPackDirName", soundPackDirName);
s.setValue("playOnError", playOnError);
s.setValue("playOnLogInOut", playOnLogInOut);
s.setValue("playOnFriendLogsInOut", playOnFriendLogsInOut);
s.setValue("playOnFriendRequestAccepted", playOnFriendRequestAccepted);
s.setValue("playOnIncommingCall", playOnIncommingCall);
s.setValue("playOnOutgoingCall", playOnOutgoingCall);
s.setValue("playOnNewMessage", playOnNewMessage);
s.setValue("playOnFiletransferComplete", playOnFiletransferComplete);
s.setValue("playOnFiletransferPending", playOnFiletransferPending);
s.endGroup();
}

void Settings::executeSettingsDialog(QWidget* parent)
Expand Down Expand Up @@ -265,6 +393,37 @@ void Settings::setEmojiFontPointSize(int value)
emit emojiFontChanged();
}

bool Settings::isSoundEnabled() const
{
return soundEnabled;
}

void Settings::setSoundEnabled(bool value)
{
soundEnabled = value;
}

QString Settings::getsoundPackDirName() const
{
return soundPackDirName;
}

void Settings::setsoundPackDirName(const QString &value)
{
soundPackDirName = value;
emit soundPackChanged(value);
}

bool Settings::isPlayOnError() const
{
return playOnError;
}

void Settings::setPlayOnError(bool value)
{
playOnError = value;
}

QString Settings::getEmojiFontFamily() const
{
return emojiFontFamily;
Expand Down
50 changes: 50 additions & 0 deletions src/Settings/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <QHash>
#include <QMainWindow>
#include <QSplitter>
#include "soundmanager.hpp"

class Settings : public QObject
{
Expand Down Expand Up @@ -90,6 +91,41 @@ class Settings : public QObject
int getEmojiFontPointSize() const;
void setEmojiFontPointSize(int value);

bool isSoundEnabled() const;
void setSoundEnabled(bool value);

QString getsoundPackDirName() const;
void setsoundPackDirName(const QString &value);

bool isPlayOnError() const;
void setPlayOnError(bool value);

bool isPlayOnLogInOut() const;
void setPlayOnLogInOut(bool value);

bool isPlayOnFriendLogsInOut() const;
void setPlayOnFriendLogsInOut(bool value);

bool isPlayOnFriendRequestAccepted() const;
void setPlayOnFriendRequestAccepted(bool value);

bool isPlayOnIncommingCall() const;
void setPlayOnIncommingCall(bool value);

bool isPlayOnOutgoingCall() const;
void setPlayOnOutgoingCall(bool value);

bool isPlayOnNewMessage() const;
void setPlayOnNewMessage(bool value);

bool isPlayOnFiletransferComplete() const;
void setPlayOnFiletransferComplete(bool value);

bool isPlayOnFiletransferPending() const;
void setPlayOnFiletransferPending(bool value);

bool isPlayOn(const Sound &sound);

private:
Settings();
Settings(Settings &settings) = delete;
Expand Down Expand Up @@ -121,12 +157,26 @@ class Settings : public QObject
QString emojiFontFamily;
int emojiFontPointSize;

// Sound
bool soundEnabled;
QString soundPackDirName;
bool playOnError;
bool playOnLogInOut;
bool playOnFriendLogsInOut;
bool playOnFriendRequestAccepted;
bool playOnIncommingCall;
bool playOnOutgoingCall;
bool playOnNewMessage;
bool playOnFiletransferComplete;
bool playOnFiletransferPending;

signals:
//void dataChanged();
void dhtServerListChanged();
void logStorageOptsChanged();
void smileyPackChanged();
void emojiFontChanged();
void soundPackChanged(const QString &pack);
};

#endif // SETTINGS_HPP
2 changes: 2 additions & 0 deletions src/Settings/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "loggingsettingspage.hpp"
#include "settingsdialog.hpp"
#include "guisettingspage.hpp"
#include "soundsettingspage.hpp"

SettingsDialog::SettingsDialog(QWidget* parent) :
BasicSettingsDialog(parent)
Expand All @@ -28,6 +29,7 @@ SettingsDialog::SettingsDialog(QWidget* parent) :
//NOTE: make use of when logging will be implemented
//addPage(":/icons/database.png", "Logging", new LoggingSettingsPage(this));
addPage(":/icons/application_side_list.png", tr("GUI"), new GuiSettingsPage(this));
addPage(":/icons/sound.png", tr("Sound"), new SoundSettingsPage(this));

listWidget->setCurrentRow(0);
listWidget->setMinimumWidth(130);
Expand Down
Loading