Added Sound Notifications changes by callix, for Friend Connects and Chat Messages, need to be set a *.wav file on Sound Settings.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2849 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2010-05-05 11:47:29 +00:00
parent 8b9b8e9f6b
commit c720a32610
11 changed files with 273 additions and 350 deletions

View File

@ -69,6 +69,8 @@
#include <QHashIterator>
#include <QDesktopServices>
#include <QSound>
/* Images for context menu icons */
#define IMAGE_REMOVEFRIEND ":/images/removefriend16.png"
#define IMAGE_EXPIORTFRIEND ":/images/exportpeers_16x16.png"
@ -964,6 +966,7 @@ void PeersDialog::insertChat()
{
PopupChatDialog *pcd = getPrivateChat(it->rsid, it->name, chatflags);
pcd->addChatMsg(&(*it));
playsound();
QApplication::alert(pcd);
continue;
}
@ -1832,3 +1835,19 @@ void PeersDialog::setCurrentFileName(const QString &fileName)
setWindowModified(false);
}
////play sound when recv a message
void PeersDialog::playsound(){
_settings = new RshareSettings();
_settings->beginGroup("Sound");
_settings->beginGroup("SoundFilePath");
QString OnlineSound= _settings->value("NewChatMessage","").toString();
_settings->endGroup();
_settings->beginGroup("Enable");
bool flag= _settings->value("NewChatMessage",false).toBool();
_settings->endGroup();
_settings->endGroup();
if(!OnlineSound.isEmpty()&&flag)
if(QSound::isAvailable())
QSound::play(OnlineSound);
}

View File

@ -154,6 +154,9 @@ private:
class QWidget *widget;
class QWidgetAction *widgetAction;
class QSpacerItem *spacerItem;
///play the sound when recv a message
void playsound();
QString fileName;

View File

@ -283,6 +283,7 @@ void NotifyQt::UpdateGUI()
OnlineToaster * onlineToaster = new OnlineToaster();
onlineToaster->setMessage(QString::fromStdString(realmsg));
onlineToaster->show();
onlineToaster->play();
}
break;
}

View File

@ -35,7 +35,7 @@ SoundPage::SoundPage(QWidget * parent, Qt::WFlags flags)
_settings = new RshareSettings();
connect(ui.cmd_openFile, SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile()));
connect(ui.cmd_openFile_2,SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile2()));
//connect(ui.cmd_openFile_2,SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile2()));
connect(ui.cmd_openFile_3,SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile3()));
connect(ui.cmd_openFile_4,SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile4()));
connect(ui.cmd_openFile_5,SIGNAL(clicked(bool) ),this,SLOT(on_cmd_openFile5()));
@ -54,7 +54,7 @@ SoundPage::save(QString &errmsg)
_settings->beginGroup("Sound");
_settings->beginGroup("Enable");
_settings->setValue("User_go_Online",ui.checkBoxSound->isChecked());
_settings->setValue("User_go_Offline",ui.checkBoxSound_2->isChecked());
//_settings->setValue("User_go_Offline",ui.checkBoxSound_2->isChecked());
_settings->setValue("FileSend_Finished",ui.checkBoxSound_3->isChecked());
_settings->setValue("FileRecive_Incoming",ui.checkBoxSound_4->isChecked());
_settings->setValue("FileRecive_Finished",ui.checkBoxSound_5->isChecked());
@ -62,7 +62,7 @@ SoundPage::save(QString &errmsg)
_settings->endGroup();
_settings->beginGroup("SoundFilePath");
_settings->setValue("User_go_Online",ui.txt_SoundFile->text());
_settings->setValue("User_go_Offline",ui.txt_SoundFile2->text());
//_settings->setValue("User_go_Offline",ui.txt_SoundFile2->text());
_settings->setValue("FileSend_Finished",ui.txt_SoundFile3->text());
_settings->setValue("FileRecive_Incoming",ui.txt_SoundFile4->text());
_settings->setValue("FileRecive_Finished",ui.txt_SoundFile5->text());
@ -82,14 +82,14 @@ SoundPage::load()
_settings->beginGroup("Sound");
_settings->beginGroup("SoundFilePath");
ui.txt_SoundFile->setText(_settings->value("User_go_Online","").toString());
ui.txt_SoundFile2->setText(_settings->value("User_go_Offline","").toString());
//ui.txt_SoundFile2->setText(_settings->value("User_go_Offline","").toString());
ui.txt_SoundFile3->setText(_settings->value("FileSend_Finished","").toString());
ui.txt_SoundFile4->setText(_settings->value("FileRecive_Incoming","").toString());
ui.txt_SoundFile5->setText(_settings->value("FileRecive_Finished","").toString());
ui.txt_SoundFile6->setText(_settings->value("NewChatMessage","").toString());
if(!ui.txt_SoundFile->text().isEmpty())ui.checkBoxSound->setEnabled(true);
if(!ui.txt_SoundFile2->text().isEmpty())ui.checkBoxSound_2->setEnabled(true);
//if(!ui.txt_SoundFile2->text().isEmpty())ui.checkBoxSound_2->setEnabled(true);
if(!ui.txt_SoundFile3->text().isEmpty())ui.checkBoxSound_3->setEnabled(true);
if(!ui.txt_SoundFile4->text().isEmpty())ui.checkBoxSound_4->setEnabled(true);
if(!ui.txt_SoundFile5->text().isEmpty())ui.checkBoxSound_5->setEnabled(true);
@ -99,7 +99,7 @@ SoundPage::load()
_settings->beginGroup("Enable");
ui.checkBoxSound->setChecked(_settings->value("User_go_Online",false).toBool());
ui.checkBoxSound_2->setChecked(_settings->value("User_go_Offline",false).toBool());
//ui.checkBoxSound_2->setChecked(_settings->value("User_go_Offline",false).toBool());
ui.checkBoxSound_3->setChecked(_settings->value("FileSend_Finished",false).toBool());
ui.checkBoxSound_4->setChecked(_settings->value("FileRecive_Incoming",false).toBool());
ui.checkBoxSound_5->setChecked(_settings->value("FileRecive_Finished",false).toBool());
@ -120,7 +120,7 @@ void SoundPage::on_cmd_openFile()
ui.checkBoxSound->setEnabled(true);
}
void SoundPage::on_cmd_openFile2()
/*void SoundPage::on_cmd_openFile2()
{
ui.txt_SoundFile2->setText(QFileDialog::getOpenFileName(this,"Open File", ".", "wav (*.wav)"));
if(ui.txt_SoundFile2->text().isEmpty()){
@ -130,7 +130,7 @@ void SoundPage::on_cmd_openFile2()
else
ui.checkBoxSound_2->setEnabled(true);
}
}*/
void SoundPage::on_cmd_openFile3()
{
ui.txt_SoundFile3->setText(QFileDialog::getOpenFileName(this,"Open File", ".", "wav (*.wav)"));

View File

@ -47,7 +47,7 @@ public:
private slots:
void on_cmd_openFile();
void on_cmd_openFile2();
//void on_cmd_openFile2();
void on_cmd_openFile3();
void on_cmd_openFile4();
void on_cmd_openFile5();

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>468</width>
<height>407</height>
<width>463</width>
<height>370</height>
</rect>
</property>
<property name="palette">
@ -499,316 +499,185 @@
<property name="title">
<string>Sound Events</string>
</property>
<widget class="QGroupBox" name="groupBox_12">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>421</width>
<height>81</height>
</rect>
</property>
<property name="title">
<string>User</string>
</property>
<widget class="QCheckBox" name="checkBoxSound">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>80</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>go Online</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxSound_2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>80</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>go Offline</string>
</property>
</widget>
<widget class="QLineEdit" name="txt_SoundFile">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>90</x>
<y>20</y>
<width>281</width>
<height>24</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="txt_SoundFile2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>90</x>
<y>50</y>
<width>281</width>
<height>24</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="cmd_openFile">
<property name="geometry">
<rect>
<x>380</x>
<y>20</y>
<width>31</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
<widget class="QPushButton" name="cmd_openFile_2">
<property name="geometry">
<rect>
<x>380</x>
<y>50</y>
<width>31</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_13">
<property name="geometry">
<rect>
<x>10</x>
<y>100</y>
<width>421</width>
<height>61</height>
</rect>
</property>
<property name="title">
<string>FileSend</string>
</property>
<widget class="QLineEdit" name="txt_SoundFile3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>90</x>
<y>20</y>
<width>281</width>
<height>24</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="cmd_openFile_3">
<property name="geometry">
<rect>
<x>380</x>
<y>20</y>
<width>31</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxSound_3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>80</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Finished</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_14">
<property name="geometry">
<rect>
<x>10</x>
<y>160</y>
<width>421</width>
<height>91</height>
</rect>
</property>
<property name="title">
<string>FileRecive</string>
</property>
<widget class="QCheckBox" name="checkBoxSound_4">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>80</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Incoming</string>
</property>
</widget>
<widget class="QLineEdit" name="txt_SoundFile4">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>90</x>
<y>20</y>
<width>281</width>
<height>24</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="cmd_openFile_4">
<property name="geometry">
<rect>
<x>380</x>
<y>20</y>
<width>31</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
<widget class="QPushButton" name="cmd_openFile_5">
<property name="geometry">
<rect>
<x>380</x>
<y>50</y>
<width>31</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxSound_5">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>80</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Finished</string>
</property>
</widget>
<widget class="QLineEdit" name="txt_SoundFile5">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>90</x>
<y>50</y>
<width>281</width>
<height>24</height>
</rect>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_15">
<property name="geometry">
<rect>
<x>10</x>
<y>260</y>
<width>421</width>
<height>111</height>
</rect>
</property>
<property name="title">
<string>Chatmessage</string>
</property>
<widget class="QPushButton" name="cmd_openFile_6">
<property name="geometry">
<rect>
<x>380</x>
<y>20</y>
<width>31</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBoxSound_6">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>80</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>New</string>
</property>
</widget>
<widget class="QLineEdit" name="txt_SoundFile6">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>90</x>
<y>20</y>
<width>281</width>
<height>24</height>
</rect>
</property>
</widget>
</widget>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_12">
<property name="title">
<string>User</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QCheckBox" name="checkBoxSound">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>go Online</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="txt_SoundFile">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="cmd_openFile">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_15">
<property name="title">
<string>Chatmessage</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QCheckBox" name="checkBoxSound_6">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>New Msg</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="txt_SoundFile6">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="cmd_openFile_6">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="groupBox_13">
<property name="title">
<string>FileSend</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QCheckBox" name="checkBoxSound_3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Finished</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="txt_SoundFile3">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="cmd_openFile_3">
<property name="text">
<string>Brose</string>
</property>
</widget>
</item>
</layout>
<zorder>txt_SoundFile3</zorder>
<zorder>cmd_openFile_3</zorder>
<zorder>checkBoxSound_3</zorder>
<zorder>groupBox_15</zorder>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="groupBox_14">
<property name="title">
<string>FileRecive</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QCheckBox" name="checkBoxSound_4">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Incoming</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="txt_SoundFile4">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="cmd_openFile_4">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBoxSound_5">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Finished</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="txt_SoundFile5">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="cmd_openFile_5">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>29</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc"/>
</resources>
<resources/>
<connections/>
</ui>

View File

@ -107,10 +107,10 @@ RSettingsWin::initStackedWidget()
stackedWidget->addWidget(new CryptoPage());
stackedWidget->addWidget(new ChatPage());
stackedWidget->addWidget(new AppearancePage());
#ifndef RS_RELEASE_VERSION
stackedWidget->addWidget(new FileAssociationsPage() );
// #ifndef RS_RELEASE_VERSION
// stackedWidget->addWidget(new FileAssociationsPage() );
stackedWidget->addWidget(new SoundPage() );
#endif
// #endif
loadSettings(); /* load saved settings */
@ -156,16 +156,16 @@ RSettingsWin::setNewPage(int page)
text = tr("Appearance");
pageicon->setPixmap(QPixmap(":/images/looknfeel.png"));
break;
#ifndef RS_RELEASE_VERSION
/*// #ifndef RS_RELEASE_VERSION
case Fileassociations:
text = tr("File Associations");
pageicon->setPixmap(QPixmap(":/images/filetype-association.png"));
break;
break;*/
case Sound:
text = tr("Sound");
pageicon->setPixmap(QPixmap(":/images/sound.png"));
break;
#endif
// #endif
default:
text = tr("UnknownPage");// impossible case
}

View File

@ -32,7 +32,7 @@ class RSettingsWin: public QDialog, private Ui::Settings
public:
enum PageType { General = 0, Server, Transfer,
Directories, Notify, Security, Chat, Appearance, Fileassociations, Sound };
Directories, Notify, Security, Chat, Appearance, Sound,Fileassociations };
static void showYourself(QWidget *parent);
static void postModDirectories(bool update_local);

View File

@ -149,6 +149,15 @@
<normaloff>:/images/looknfeel.png</normaloff>:/images/looknfeel.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Sound</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/sound.png</normaloff>:/images/sound.png</iconset>
</property>
</item>
</widget>
</item>
<item row="0" column="1">

View File

@ -65,3 +65,21 @@ void OnlineToaster::chatButtonSlot() {
chatButtonClicked();
close();
}
void OnlineToaster::play(){
_settings = new RshareSettings();
_settings->beginGroup("Sound");
_settings->beginGroup("SoundFilePath");
QString OnlineSound= _settings->value("User_go_Online","").toString();
_settings->endGroup();
_settings->beginGroup("Enable");
bool flag= _settings->value("User_go_Online",false).toBool();
_settings->endGroup();
_settings->endGroup();
if(!OnlineSound.isEmpty()&&flag)
if(QSound::isAvailable())
QSound::play(OnlineSound);
// delete _settings;
}

View File

@ -16,57 +16,61 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef ONLINETOASTER_H
#define ONLINETOASTER_H
#ifndef ONLINETOASTER_H
#define ONLINETOASTER_H
#include "IQtToaster.h"
#include <gui/settings/rsharesettings.h>
#include <QtCore/QObject>
#include <QSound>
class QtToaster;
class QWidget;
class QString;
class QPixmap;
namespace Ui { class OnlineToaster; }
namespace Ui { class OnlineToaster; }
/**
* Shows a toaster when friend is Online .
*
*
*/
class OnlineToaster : public QObject, public IQtToaster {
Q_OBJECT
public:
OnlineToaster();
*/
class OnlineToaster : public QObject, public IQtToaster {
Q_OBJECT
public:
OnlineToaster();
~OnlineToaster();
void setMessage(const QString & message);
void setPixmap(const QPixmap & pixmap);
void show();
Q_SIGNALS:
void chatButtonClicked();
void show();
void play();
Q_SIGNALS:
void chatButtonClicked();
private Q_SLOTS:
void chatButtonSlot();
void close();
private:
Ui::OnlineToaster * _ui;
private:
RshareSettings* _settings;
QWidget * _onlineToasterWidget;
Ui::OnlineToaster * _ui;
QtToaster * _toaster;
};
#endif //MESSAGETOASTER_H
QWidget * _onlineToasterWidget;
QtToaster * _toaster;
};
#endif //MESSAGETOASTER_H