1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge branch 'master' into friend_list

This commit is contained in:
zero-one 2015-03-23 02:35:20 -07:00
commit c15cc60137
10 changed files with 53 additions and 21 deletions

View File

@ -159,6 +159,7 @@ QByteArray Core::getSaltFromFile(QString filename)
} }
QByteArray res = QByteArray::fromRawData(reinterpret_cast<const char*>(salt), tox_pass_salt_length()); QByteArray res = QByteArray::fromRawData(reinterpret_cast<const char*>(salt), tox_pass_salt_length());
delete[] salt;
return res; return res;
} }

View File

@ -35,6 +35,11 @@ Friend::Friend(int FriendId, const ToxID &UserId)
widget = new FriendWidget(friendId, getDisplayedName()); widget = new FriendWidget(friendId, getDisplayedName());
chatForm = new ChatForm(this); chatForm = new ChatForm(this);
if (Settings::getInstance().getEnableLogging())
{
chatForm->loadHistory(QDateTime::currentDateTime().addDays(-7), true);
widget->historyLoaded = true;
}
} }
Friend::~Friend() Friend::~Friend()

View File

@ -209,6 +209,7 @@ void Settings::load()
checkUpdates = s.value("checkUpdates", false).toBool(); checkUpdates = s.value("checkUpdates", false).toBool();
showWindow = s.value("showWindow", true).toBool(); showWindow = s.value("showWindow", true).toBool();
showInFront = s.value("showInFront", false).toBool(); showInFront = s.value("showInFront", false).toBool();
notifySound = s.value("notifySound", true).toBool();
groupAlwaysNotify = s.value("groupAlwaysNotify", false).toBool(); groupAlwaysNotify = s.value("groupAlwaysNotify", false).toBool();
fauxOfflineMessaging = s.value("fauxOfflineMessaging", true).toBool(); fauxOfflineMessaging = s.value("fauxOfflineMessaging", true).toBool();
autoSaveEnabled = s.value("autoSaveEnabled", false).toBool(); autoSaveEnabled = s.value("autoSaveEnabled", false).toBool();
@ -381,6 +382,7 @@ void Settings::saveGlobal(QString path)
s.setValue("checkUpdates", checkUpdates); s.setValue("checkUpdates", checkUpdates);
s.setValue("showWindow", showWindow); s.setValue("showWindow", showWindow);
s.setValue("showInFront", showInFront); s.setValue("showInFront", showInFront);
s.setValue("notifySound", notifySound);
s.setValue("groupAlwaysNotify", groupAlwaysNotify); s.setValue("groupAlwaysNotify", groupAlwaysNotify);
s.setValue("fauxOfflineMessaging", fauxOfflineMessaging); s.setValue("fauxOfflineMessaging", fauxOfflineMessaging);
s.setValue("compactLayout", compactLayout); s.setValue("compactLayout", compactLayout);
@ -695,6 +697,16 @@ void Settings::setShowInFront(bool newValue)
showInFront = newValue; showInFront = newValue;
} }
bool Settings::getNotifySound() const
{
return notifySound;
}
void Settings::setNotifySound(bool newValue)
{
notifySound = newValue;
}
bool Settings::getGroupAlwaysNotify() const bool Settings::getGroupAlwaysNotify() const
{ {
return groupAlwaysNotify; return groupAlwaysNotify;

View File

@ -128,6 +128,9 @@ public:
bool getShowInFront() const; bool getShowInFront() const;
void setShowInFront(bool newValue); void setShowInFront(bool newValue);
bool getNotifySound() const;
void setNotifySound(bool newValue);
bool getGroupAlwaysNotify() const; bool getGroupAlwaysNotify() const;
void setGroupAlwaysNotify(bool newValue); void setGroupAlwaysNotify(bool newValue);
@ -284,6 +287,7 @@ private:
bool checkUpdates; bool checkUpdates;
bool showWindow; bool showWindow;
bool showInFront; bool showInFront;
bool notifySound;
bool groupAlwaysNotify; bool groupAlwaysNotify;
bool forceTCP; bool forceTCP;

View File

@ -73,6 +73,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
bodyUI->autoSaveFilesDir->setText(Settings::getInstance().getGlobalAutoAcceptDir()); bodyUI->autoSaveFilesDir->setText(Settings::getInstance().getGlobalAutoAcceptDir());
bodyUI->showWindow->setChecked(Settings::getInstance().getShowWindow()); bodyUI->showWindow->setChecked(Settings::getInstance().getShowWindow());
bodyUI->showInFront->setChecked(Settings::getInstance().getShowInFront()); bodyUI->showInFront->setChecked(Settings::getInstance().getShowInFront());
bodyUI->notifySound->setChecked(Settings::getInstance().getNotifySound());
bodyUI->groupAlwaysNotify->setChecked(Settings::getInstance().getGroupAlwaysNotify()); bodyUI->groupAlwaysNotify->setChecked(Settings::getInstance().getGroupAlwaysNotify());
bodyUI->cbFauxOfflineMessaging->setChecked(Settings::getInstance().getFauxOfflineMessaging()); bodyUI->cbFauxOfflineMessaging->setChecked(Settings::getInstance().getFauxOfflineMessaging());
bodyUI->cbCompactLayout->setChecked(Settings::getInstance().getCompactLayout()); bodyUI->cbCompactLayout->setChecked(Settings::getInstance().getCompactLayout());
@ -133,6 +134,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
connect(bodyUI->autoAwaySpinBox, SIGNAL(editingFinished()), this, SLOT(onAutoAwayChanged())); connect(bodyUI->autoAwaySpinBox, SIGNAL(editingFinished()), this, SLOT(onAutoAwayChanged()));
connect(bodyUI->showWindow, &QCheckBox::stateChanged, this, &GeneralForm::onShowWindowChanged); connect(bodyUI->showWindow, &QCheckBox::stateChanged, this, &GeneralForm::onShowWindowChanged);
connect(bodyUI->showInFront, &QCheckBox::stateChanged, this, &GeneralForm::onSetShowInFront); connect(bodyUI->showInFront, &QCheckBox::stateChanged, this, &GeneralForm::onSetShowInFront);
connect(bodyUI->notifySound, &QCheckBox::stateChanged, this, &GeneralForm::onSetNotifySound);
connect(bodyUI->groupAlwaysNotify, &QCheckBox::stateChanged, this, &GeneralForm::onSetGroupAlwaysNotify); connect(bodyUI->groupAlwaysNotify, &QCheckBox::stateChanged, this, &GeneralForm::onSetGroupAlwaysNotify);
connect(bodyUI->autoacceptFiles, &QCheckBox::stateChanged, this, &GeneralForm::onAutoAcceptFileChange); connect(bodyUI->autoacceptFiles, &QCheckBox::stateChanged, this, &GeneralForm::onAutoAcceptFileChange);
if (bodyUI->autoacceptFiles->isChecked()) if (bodyUI->autoacceptFiles->isChecked())
@ -373,6 +375,11 @@ void GeneralForm::onSetShowInFront()
Settings::getInstance().setShowInFront(bodyUI->showInFront->isChecked()); Settings::getInstance().setShowInFront(bodyUI->showInFront->isChecked());
} }
void GeneralForm::onSetNotifySound()
{
Settings::getInstance().setNotifySound(bodyUI->notifySound->isChecked());
}
void GeneralForm::onSetGroupAlwaysNotify() void GeneralForm::onSetGroupAlwaysNotify()
{ {
Settings::getInstance().setGroupAlwaysNotify(bodyUI->groupAlwaysNotify->isChecked()); Settings::getInstance().setGroupAlwaysNotify(bodyUI->groupAlwaysNotify->isChecked());

View File

@ -56,6 +56,7 @@ private slots:
void onCheckUpdateChanged(); void onCheckUpdateChanged();
void onShowWindowChanged(); void onShowWindowChanged();
void onSetShowInFront(); void onSetShowInFront();
void onSetNotifySound();
void onSetGroupAlwaysNotify(); void onSetGroupAlwaysNotify();
void onFauxOfflineMessaging(); void onFauxOfflineMessaging();
void onCompactLayout(); void onCompactLayout();

View File

@ -345,6 +345,16 @@ instead of system taskbar.</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="notifySound">
<property name="toolTip">
<string comment="toolTip for Notify sound setting">Play a sound when you recieve message.</string>
</property>
<property name="text">
<string>Play sound</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item row="1" column="2"> <item row="1" column="2">

View File

@ -130,16 +130,6 @@ void FriendWidget::setAsActiveChatroom()
if (isDefaultAvatar) if (isDefaultAvatar)
avatar->setPixmap(QPixmap(":img/contact_dark.svg"), Qt::transparent); avatar->setPixmap(QPixmap(":img/contact_dark.svg"), Qt::transparent);
if(!historyLoaded)
{
Friend* f = FriendList::findFriend(friendId);
if (Settings::getInstance().getEnableLogging())
{
f->getChatForm()->loadHistory(QDateTime::currentDateTime().addDays(-7), true);
historyLoaded = true;
}
}
} }
void FriendWidget::setAsInactiveChatroom() void FriendWidget::setAsInactiveChatroom()

View File

@ -237,7 +237,6 @@ bool Widget::eventFilter(QObject *obj, QEvent *event)
wasMaximized = false; wasMaximized = false;
} }
} }
event->accept();
return false; return false;
} }
@ -753,17 +752,20 @@ void Widget::newMessageAlert(GenericChatroomWidget* chat)
setWindowState(Qt::WindowActive); setWindowState(Qt::WindowActive);
} }
static QFile sndFile(":audio/notification.pcm"); if (Settings::getInstance().getNotifySound())
static QByteArray sndData;
if (sndData.isEmpty())
{ {
sndFile.open(QIODevice::ReadOnly); static QFile sndFile(":audio/notification.pcm");
sndData = sndFile.readAll(); static QByteArray sndData;
sndFile.close();
}
Audio::playMono16Sound(sndData); if (sndData.isEmpty())
{
sndFile.open(QIODevice::ReadOnly);
sndData = sndFile.readAll();
sndFile.close();
}
Audio::playMono16Sound(sndData);
}
} }
void Widget::playRingtone() void Widget::playRingtone()

View File

@ -1,7 +1,7 @@
QTextEdit QTextEdit
{ {
background: white; background: white;
color: back; color: black;
} }
QGraphicsView QGraphicsView