|
|
|
@ -292,7 +292,7 @@ void MainWindow::setupSoundFromConfig() { |
|
|
|
SoundManager* sm = SoundManager::instance(); |
|
|
|
SoundManager* sm = SoundManager::instance(); |
|
|
|
if (!sm->init()) return; |
|
|
|
if (!sm->init()) return; |
|
|
|
|
|
|
|
|
|
|
|
QString soundDir, msgInFile, msgOutFile, connectFile, disconnectFile; |
|
|
|
QString soundDir, msgInFile, msgOutFile, connectFile, disconnectFile, callInFile; |
|
|
|
QFile cfgFile(m_cfgPath); |
|
|
|
QFile cfgFile(m_cfgPath); |
|
|
|
if (cfgFile.open(QIODevice::ReadOnly | QIODevice::Text)) { |
|
|
|
if (cfgFile.open(QIODevice::ReadOnly | QIODevice::Text)) { |
|
|
|
bool inGui = false; |
|
|
|
bool inGui = false; |
|
|
|
@ -307,6 +307,7 @@ void MainWindow::setupSoundFromConfig() { |
|
|
|
else if (line.startsWith("sound_msg_outgoing=")) msgOutFile = line.mid(19).trimmed(); |
|
|
|
else if (line.startsWith("sound_msg_outgoing=")) msgOutFile = line.mid(19).trimmed(); |
|
|
|
else if (line.startsWith("sound_connect=")) connectFile = line.mid(14).trimmed(); |
|
|
|
else if (line.startsWith("sound_connect=")) connectFile = line.mid(14).trimmed(); |
|
|
|
else if (line.startsWith("sound_disconnect=")) disconnectFile = line.mid(17).trimmed(); |
|
|
|
else if (line.startsWith("sound_disconnect=")) disconnectFile = line.mid(17).trimmed(); |
|
|
|
|
|
|
|
else if (line.startsWith("sound_call_incoming=")) callInFile = line.mid(20).trimmed(); |
|
|
|
} |
|
|
|
} |
|
|
|
cfgFile.close(); |
|
|
|
cfgFile.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -321,16 +322,21 @@ void MainWindow::setupSoundFromConfig() { |
|
|
|
else |
|
|
|
else |
|
|
|
sm->loadSound("msg_incoming", resolvePath(msgInFile)); |
|
|
|
sm->loadSound("msg_incoming", resolvePath(msgInFile)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (callInFile.isEmpty()) |
|
|
|
|
|
|
|
sm->loadSound("call_incoming", ":/sounds/call_incoming.mp3"); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
sm->loadSound("call_incoming", resolvePath(callInFile)); |
|
|
|
|
|
|
|
|
|
|
|
if (!msgOutFile.isEmpty()) sm->loadSound("msg_outgoing", resolvePath(msgOutFile)); |
|
|
|
if (!msgOutFile.isEmpty()) sm->loadSound("msg_outgoing", resolvePath(msgOutFile)); |
|
|
|
if (!connectFile.isEmpty()) sm->loadSound("connect", resolvePath(connectFile)); |
|
|
|
if (!connectFile.isEmpty()) sm->loadSound("connect", resolvePath(connectFile)); |
|
|
|
if (!disconnectFile.isEmpty()) sm->loadSound("disconnect", resolvePath(disconnectFile)); |
|
|
|
if (!disconnectFile.isEmpty()) sm->loadSound("disconnect", resolvePath(disconnectFile)); |
|
|
|
if (m_db && m_db->isOpen()) { |
|
|
|
if (m_db && m_db->isOpen()) { |
|
|
|
sm->setEnabled(m_db->getUiStateInt("sound_enabled", 1)); |
|
|
|
sm->setEnabled(m_db->getUiStateInt("sound_enabled", 1)); |
|
|
|
sm->setVolume(m_db->getUiStateInt("sound_volume", 80) / 100.0f); |
|
|
|
sm->setVolume(m_db->getUiStateInt("sound_volume", 80) / 100.0f); |
|
|
|
QString se[] = {"msg_incoming", "msg_outgoing", "connect", "disconnect"}; |
|
|
|
QString se[] = {"msg_incoming", "msg_outgoing", "connect", "disconnect", "call_incoming"}; |
|
|
|
for (int i = 0; i < 4; i++) { |
|
|
|
for (int i = 0; i < 5; i++) { |
|
|
|
const QString& ek = se[i]; |
|
|
|
const QString& ek = se[i]; |
|
|
|
sm->setEvent(ek, m_db->getUiStateInt(QStringLiteral("sound_%1_on").arg(ek), i == 0 ? 1 : 0), |
|
|
|
sm->setEvent(ek, m_db->getUiStateInt(QStringLiteral("sound_%1_on").arg(ek), (i == 0 || i == 4) ? 1 : 0), |
|
|
|
m_db->getUiStateInt(QStringLiteral("sound_%1_vol").arg(ek), 80) / 100.0f); |
|
|
|
m_db->getUiStateInt(QStringLiteral("sound_%1_vol").arg(ek), 80) / 100.0f); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -528,6 +534,12 @@ void MainWindow::onCallIncoming(const QString& chId, quint64 caller, quint64 cal |
|
|
|
QString name = m_db->getDisplayName(caller); |
|
|
|
QString name = m_db->getDisplayName(caller); |
|
|
|
if (name.isEmpty()) name = QStringLiteral("0x%1").arg(caller, 16, 16, QChar('0')); |
|
|
|
if (name.isEmpty()) name = QStringLiteral("0x%1").arg(caller, 16, 16, QChar('0')); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SoundManager::instance()->playLoop("call_incoming"); |
|
|
|
|
|
|
|
if (!isVisible() || isMinimized()) { |
|
|
|
|
|
|
|
m_trayIcon->showMessage("vibechat", QStringLiteral("Incoming call from %1").arg(name), |
|
|
|
|
|
|
|
QSystemTrayIcon::Information, 5000); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CallWindow* w = new CallWindow(this); |
|
|
|
CallWindow* w = new CallWindow(this); |
|
|
|
w->setCallId(callId); |
|
|
|
w->setCallId(callId); |
|
|
|
w->setPeerName(name); |
|
|
|
w->setPeerName(name); |
|
|
|
@ -545,6 +557,7 @@ void MainWindow::onCallRinging(quint64 callId) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::onCallAccepted(quint64 callId) { |
|
|
|
void MainWindow::onCallAccepted(quint64 callId) { |
|
|
|
|
|
|
|
SoundManager::instance()->stopLoop(); |
|
|
|
CallWindow* w = m_activeCalls.value(callId, nullptr); |
|
|
|
CallWindow* w = m_activeCalls.value(callId, nullptr); |
|
|
|
if (w) w->setState(CallWindow::Active); |
|
|
|
if (w) w->setState(CallWindow::Active); |
|
|
|
if (m_db) |
|
|
|
if (m_db) |
|
|
|
@ -561,6 +574,7 @@ void MainWindow::onCallEnded(quint64 callId, uint8_t reason) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::closeCallWindow(quint64 callId) { |
|
|
|
void MainWindow::closeCallWindow(quint64 callId) { |
|
|
|
|
|
|
|
SoundManager::instance()->stopLoop(); |
|
|
|
CallWindow* w = m_activeCalls.take(callId); |
|
|
|
CallWindow* w = m_activeCalls.take(callId); |
|
|
|
if (!w) return; |
|
|
|
if (!w) return; |
|
|
|
w->disconnect(this); |
|
|
|
w->disconnect(this); |
|
|
|
|