mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-26 16:09:35 -05:00
Some more optimizations of SoundManager
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8392 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
acfa384f7f
commit
24a07702f2
@ -70,8 +70,9 @@ SoundManager::SoundManager() : QObject()
|
||||
|
||||
void SoundManager::soundEvents(SoundEvents &events)
|
||||
{
|
||||
QDir baseDir = QDir(qApp->applicationDirPath());
|
||||
baseDir.cd("sounds");
|
||||
QDir baseDir = QDir(qApp->applicationDirPath() + "/sounds");
|
||||
|
||||
events.mDefaultPath = baseDir.absolutePath();
|
||||
|
||||
/* add standard events */
|
||||
events.addEvent(tr("Friend"), tr("Go Online"), SOUND_USER_ONLINE, QFileInfo(baseDir, "online1.wav").absoluteFilePath());
|
||||
@ -132,13 +133,13 @@ void SoundManager::initDefault()
|
||||
}
|
||||
}
|
||||
|
||||
void SoundManager::setMute(bool mute)
|
||||
void SoundManager::setMute(bool m)
|
||||
{
|
||||
Settings->beginGroup(GROUP_MAIN);
|
||||
Settings->setValue("mute", mute);
|
||||
Settings->setValue("mute", m);
|
||||
Settings->endGroup();
|
||||
|
||||
emit SoundManager::mute(mute);
|
||||
emit mute(m);
|
||||
}
|
||||
|
||||
bool SoundManager::isMute()
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
void addEvent(const QString &groupName, const QString &eventName, const QString &event, const QString &defaultFilename);
|
||||
|
||||
public:
|
||||
QString mDefaultPath;
|
||||
QMap<QString, SoundEventInfo> mEventInfos;
|
||||
};
|
||||
|
||||
@ -58,7 +59,7 @@ class SoundManager : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
void setMute(bool mute);
|
||||
void setMute(bool m);
|
||||
|
||||
signals:
|
||||
void mute(bool isMute);
|
||||
@ -66,23 +67,23 @@ signals:
|
||||
public:
|
||||
static void create();
|
||||
|
||||
void initDefault();
|
||||
QString defaultFilename(const QString &event, bool check);
|
||||
static void initDefault();
|
||||
static QString defaultFilename(const QString &event, bool check);
|
||||
static QString convertFilename(const QString &filename);
|
||||
static QString realFilename(const QString &filename);
|
||||
|
||||
void soundEvents(SoundEvents &events);
|
||||
static void soundEvents(SoundEvents &events);
|
||||
|
||||
bool isMute();
|
||||
static bool isMute();
|
||||
|
||||
void play(const QString &event);
|
||||
void playFile(const QString &filename);
|
||||
static void play(const QString &event);
|
||||
static void playFile(const QString &filename);
|
||||
|
||||
bool eventEnabled(const QString &event);
|
||||
void setEventEnabled(const QString &event, bool enabled);
|
||||
static bool eventEnabled(const QString &event);
|
||||
static void setEventEnabled(const QString &event, bool enabled);
|
||||
|
||||
QString eventFilename(const QString &event);
|
||||
void setEventFilename(const QString &event, const QString &filename);
|
||||
static QString eventFilename(const QString &event);
|
||||
static void setEventFilename(const QString &event, const QString &filename);
|
||||
|
||||
private:
|
||||
SoundManager();
|
||||
|
@ -170,7 +170,7 @@ void ChatDialog::init(ChatId id, const QString &title)
|
||||
|
||||
if(msg.incoming && (msg.chat_id.isPeerId() || msg.chat_id.isGxsId()))
|
||||
// play sound when recv a message
|
||||
soundManager->play(SOUND_NEW_CHAT_MESSAGE);
|
||||
SoundManager::play(SOUND_NEW_CHAT_MESSAGE);
|
||||
|
||||
ChatDialog *cd = getChat(msg.chat_id, Settings->getChatFlags());
|
||||
if(cd)
|
||||
|
@ -790,7 +790,7 @@ void NotifyQt::UpdateGUI()
|
||||
switch(type)
|
||||
{
|
||||
case RS_POPUP_ENCRYPTED_MSG:
|
||||
soundManager->play(SOUND_MESSAGE_ARRIVED);
|
||||
SoundManager::play(SOUND_MESSAGE_ARRIVED);
|
||||
|
||||
if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster)
|
||||
{
|
||||
@ -798,7 +798,7 @@ void NotifyQt::UpdateGUI()
|
||||
}
|
||||
break;
|
||||
case RS_POPUP_MSG:
|
||||
soundManager->play(SOUND_MESSAGE_ARRIVED);
|
||||
SoundManager::play(SOUND_MESSAGE_ARRIVED);
|
||||
|
||||
if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster)
|
||||
{
|
||||
@ -806,7 +806,7 @@ void NotifyQt::UpdateGUI()
|
||||
}
|
||||
break;
|
||||
case RS_POPUP_CONNECT:
|
||||
soundManager->play(SOUND_USER_ONLINE);
|
||||
SoundManager::play(SOUND_USER_ONLINE);
|
||||
|
||||
if ((popupflags & RS_POPUP_CONNECT) && !_disableAllToaster)
|
||||
{
|
||||
@ -814,7 +814,7 @@ void NotifyQt::UpdateGUI()
|
||||
}
|
||||
break;
|
||||
case RS_POPUP_DOWNLOAD:
|
||||
soundManager->play(SOUND_DOWNLOAD_COMPLETE);
|
||||
SoundManager::play(SOUND_DOWNLOAD_COMPLETE);
|
||||
|
||||
if ((popupflags & RS_POPUP_DOWNLOAD) && !_disableAllToaster)
|
||||
{
|
||||
|
@ -95,9 +95,9 @@ QTreeWidgetItem *SoundPage::addItem(QTreeWidgetItem *groupItem, const QString &n
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(TYPE_ITEM);
|
||||
item->setData(COLUMN_DATA, ROLE_EVENT, event);
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||
item->setCheckState(COLUMN_NAME, soundManager->eventEnabled(event) ? Qt::Checked : Qt::Unchecked);
|
||||
item->setCheckState(COLUMN_NAME, SoundManager::eventEnabled(event) ? Qt::Checked : Qt::Unchecked);
|
||||
item->setText(COLUMN_NAME, name);
|
||||
item->setText(COLUMN_FILENAME, soundManager->eventFilename(event));
|
||||
item->setText(COLUMN_FILENAME, SoundManager::eventFilename(event));
|
||||
groupItem->addChild(item);
|
||||
|
||||
return item;
|
||||
@ -113,8 +113,8 @@ bool SoundPage::save(QString &/*errmsg*/)
|
||||
|
||||
if (item->type() == TYPE_ITEM) {
|
||||
const QString event = item->data(COLUMN_DATA, ROLE_EVENT).toString();
|
||||
soundManager->setEventEnabled(event, item->checkState(COLUMN_NAME) == Qt::Checked);
|
||||
soundManager->setEventFilename(event, item->text(COLUMN_FILENAME));
|
||||
SoundManager::setEventEnabled(event, item->checkState(COLUMN_NAME) == Qt::Checked);
|
||||
SoundManager::setEventFilename(event, item->text(COLUMN_FILENAME));
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ void SoundPage::load()
|
||||
|
||||
/* add sound events */
|
||||
SoundEvents events;
|
||||
soundManager->soundEvents(events);
|
||||
SoundManager::soundEvents(events);
|
||||
|
||||
QString event;
|
||||
foreach (event, events.mEventInfos.keys()) {
|
||||
@ -165,7 +165,7 @@ void SoundPage::eventChanged(QTreeWidgetItem *current, QTreeWidgetItem */*previo
|
||||
ui.eventName->setText(eventName);
|
||||
|
||||
QString event = current->data(COLUMN_DATA, ROLE_EVENT).toString();
|
||||
ui.defaultButton->setDisabled(soundManager->defaultFilename(event, true).isEmpty());
|
||||
ui.defaultButton->setDisabled(SoundManager::defaultFilename(event, true).isEmpty());
|
||||
}
|
||||
|
||||
void SoundPage::filenameChanged(QString filename)
|
||||
@ -186,7 +186,7 @@ void SoundPage::defaultButtonClicked()
|
||||
}
|
||||
|
||||
QString event = item->data(COLUMN_DATA, ROLE_EVENT).toString();
|
||||
ui.filenameEdit->setText(soundManager->defaultFilename(event, true));
|
||||
ui.filenameEdit->setText(SoundManager::defaultFilename(event, true));
|
||||
}
|
||||
|
||||
void SoundPage::browseButtonClicked()
|
||||
@ -206,5 +206,5 @@ void SoundPage::playButtonClicked()
|
||||
}
|
||||
|
||||
QString filename = item->text(COLUMN_FILENAME);
|
||||
soundManager->playFile(filename);
|
||||
SoundManager::playFile(filename);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ SoundStatus::SoundStatus(QWidget *parent)
|
||||
|
||||
setLayout(hbox);
|
||||
|
||||
bool isMute = soundManager->isMute();
|
||||
bool isMute = SoundManager::isMute();
|
||||
imageButton->setChecked(isMute);
|
||||
|
||||
connect(soundManager, SIGNAL(mute(bool)), this, SLOT(mute(bool)));
|
||||
|
@ -335,7 +335,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Settings->setValue(QString::fromUtf8("FirstRun"), false);
|
||||
|
||||
soundManager->initDefault();
|
||||
SoundManager::initDefault();
|
||||
|
||||
#ifdef __APPLE__
|
||||
/* For OSX, we set the default to "cleanlooks", as the AQUA style hides some input boxes
|
||||
|
Loading…
Reference in New Issue
Block a user