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

Merge branch 'pr691'

This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-11-10 10:52:32 +01:00
commit f9cb19a157
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
8 changed files with 117 additions and 52 deletions

View File

@ -120,6 +120,7 @@ void Settings::load()
currentProfile = s.value("currentProfile", "").toString();
autoAwayTime = s.value("autoAwayTime", 10).toInt();
checkUpdates = s.value("checkUpdates", false).toBool();
showInFront = s.value("showInFront", false).toBool();
s.endGroup();
s.beginGroup("Widgets");
@ -257,6 +258,7 @@ void Settings::save(QString path)
s.setValue("currentProfile", currentProfile);
s.setValue("autoAwayTime", autoAwayTime);
s.setValue("checkUpdates", checkUpdates);
s.setValue("showInFront", showInFront);
s.endGroup();
s.beginGroup("Widgets");
@ -480,6 +482,16 @@ void Settings::setStatusChangeNotificationEnabled(bool newValue)
statusChangeNotificationEnabled = newValue;
}
bool Settings::getShowInFront() const
{
return showInFront;
}
void Settings::setShowInFront(bool newValue)
{
showInFront = newValue;
}
QString Settings::getTranslation() const
{
return translation;

View File

@ -102,6 +102,9 @@ public:
bool getCheckUpdates() const;
void setCheckUpdates(bool newValue);
bool getShowInFront() const;
void setShowInFront(bool newValue);
QPixmap getSavedAvatar(const QString& ownerId);
void saveAvatar(QPixmap& pic, const QString& ownerId);
@ -223,6 +226,7 @@ private:
bool minimizeToTray;
bool useEmoticons;
bool checkUpdates;
bool showInFront;
bool forceTCP;

View File

@ -188,7 +188,7 @@ void ChatForm::onFileRecvRequest(ToxFile file)
Widget* w = Widget::getInstance();
if (!w->isFriendWidgetCurActiveWidget(f)|| w->isMinimized() || !w->isActiveWindow())
{
w->newMessageAlert();
w->newMessageAlert(f->getFriendWidget());
f->setEventFlag(true);
f->getFriendWidget()->updateStatusLight();
}
@ -240,7 +240,7 @@ void ChatForm::onAvInvite(int FriendId, int CallId, bool video)
Widget* w = Widget::getInstance();
if (!w->isFriendWidgetCurActiveWidget(f)|| w->isMinimized() || !w->isActiveWindow())
{
w->newMessageAlert();
w->newMessageAlert(f->getFriendWidget());
f->setEventFlag(true);
f->getFriendWidget()->updateStatusLight();
}

View File

@ -44,6 +44,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
bodyUI->checkUpdates->setVisible(AUTOUPDATE_ENABLED);
bodyUI->checkUpdates->setChecked(Settings::getInstance().getCheckUpdates());
bodyUI->trayLayout->addStretch();
bodyUI->cbEnableIPv6->setChecked(Settings::getInstance().getEnableIPv6());
for (int i = 0; i < langs.size(); i++)
@ -57,6 +58,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
bodyUI->useEmoticons->setChecked(Settings::getInstance().getUseEmoticons());
bodyUI->autoacceptFiles->setChecked(Settings::getInstance().getAutoSaveEnabled());
bodyUI->autoSaveFilesDir->setText(Settings::getInstance().getGlobalAutoAcceptDir());
bodyUI->showInFront->setChecked(Settings::getInstance().getShowInFront());
for (auto entry : SmileyPack::listSmileyPacks())
{
@ -106,6 +108,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
connect(bodyUI->minimizeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetMinimizeToTray);
connect(bodyUI->statusChanges, &QCheckBox::stateChanged, this, &GeneralForm::onSetStatusChange);
connect(bodyUI->autoAwaySpinBox, SIGNAL(editingFinished()), this, SLOT(onAutoAwayChanged()));
connect(bodyUI->showInFront, &QCheckBox::stateChanged, this, &GeneralForm::onSetShowInFront);
connect(bodyUI->autoacceptFiles, &QCheckBox::stateChanged, this, &GeneralForm::onAutoAcceptFileChange);
if(bodyUI->autoacceptFiles->isChecked())
connect(bodyUI->autoSaveFilesDir, SIGNAL(clicked()), this, SLOT(onAutoSaveDirChange()));
@ -291,3 +294,9 @@ void GeneralForm::onCheckUpdateChanged()
{
Settings::getInstance().setCheckUpdates(bodyUI->checkUpdates->isChecked());
}
void GeneralForm::onSetShowInFront()
{
Settings::getInstance().setShowInFront(bodyUI->showInFront->isChecked());
}

View File

@ -52,6 +52,7 @@ private slots:
void onAutoAcceptFileChange();
void onAutoSaveDirChange();
void onCheckUpdateChanged();
void onSetShowInFront();
private:
Ui::GeneralSettings *bodyUI;

View File

@ -40,7 +40,7 @@
<x>0</x>
<y>0</y>
<width>511</width>
<height>720</height>
<height>796</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,1">
@ -94,25 +94,47 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="startInTray">
<property name="text">
<string>Start in tray</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="closeToTray">
<property name="text">
<string>Close to tray</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="minimizeToTray">
<property name="text">
<string>Minimize to tray</string>
</property>
</widget>
<layout class="QHBoxLayout" name="trayLayout">
<item>
<widget class="QCheckBox" name="startInTray">
<property name="text">
<string>Start in tray</string>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="closeToTray">
<property name="text">
<string>Close to tray</string>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="minimizeToTray">
<property name="text">
<string>Minimize to tray</string>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="statusChanges">
@ -128,6 +150,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="showInFront">
<property name="text">
<string>Focus qTox when a message is received</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item alignment="Qt::AlignLeft">
@ -171,33 +200,37 @@
</layout>
</item>
<item>
<widget class="QCheckBox" name="autoacceptFiles">
<property name="text">
<string>Autoaccept files</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="saveFilesHLayout">
<layout class="QHBoxLayout" name="fileLayout">
<item>
<widget class="QLabel" name="autoSaveFilesDirLabel">
<widget class="QCheckBox" name="autoacceptFiles">
<property name="text">
<string>Save files in</string>
<string>Autoaccept files</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="autoSaveFilesDir">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>PushButton</string>
</property>
</widget>
<layout class="QHBoxLayout" name="saveFilesHLayout">
<item>
<widget class="QLabel" name="autoSaveFilesDirLabel">
<property name="text">
<string>Save files in</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="autoSaveFilesDir">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
@ -398,7 +431,7 @@
<item>
<widget class="QCheckBox" name="cbEnableUDP">
<property name="toolTip">
<string extracomment="force tcp checkbox tooltip">This allows, e.g., toxing over Tor. It adds load to the Tox network however, so use only when necessary.</string>
<string extracomment="force tcp checkbox tooltip">Disabling this allows, e.g., toxing over Tor. It adds load to the Tox network however, so uncheck only when necessary.</string>
</property>
<property name="text">
<string extracomment="Text on checkbox to disable UDP">Enable UDP (recommended)</string>

View File

@ -329,8 +329,7 @@ void Widget::changeEvent(QEvent *event)
{
if (event->type() == QEvent::WindowStateChange)
{
if(isMinimized() == true
&& Settings::getInstance().getMinimizeToTray() == true)
if(isMinimized() && Settings::getInstance().getMinimizeToTray())
{
this->hide();
}
@ -675,7 +674,7 @@ void Widget::onFriendStatusChanged(int friendId, Status status)
//won't print the message if there were no messages before
if(!f->getChatForm()->isEmpty()
&& Settings::getInstance().getStatusChangeNotificationEnabled() == true)
&& Settings::getInstance().getStatusChangeNotificationEnabled())
{
QString fStatus = "";
switch(f->getStatus()){
@ -750,23 +749,30 @@ void Widget::onFriendMessageReceived(int friendId, const QString& message, bool
if ((static_cast<GenericChatroomWidget*>(f->getFriendWidget()) != activeChatroomWidget) || isMinimized() || !isActiveWindow())
{
f->setEventFlag(true);
newMessageAlert();
newMessageAlert(f->getFriendWidget());
}
}
else
{
f->setEventFlag(true);
newMessageAlert();
newMessageAlert(f->getFriendWidget());
}
f->getFriendWidget()->updateStatusLight();
}
void Widget::newMessageAlert()
void Widget::newMessageAlert(GenericChatroomWidget* chat)
{
QApplication::alert(this);
static QFile sndFile(":audio/notification.pcm");
if ((isMinimized() || !isActiveWindow()) && Settings::getInstance().getShowInFront())
{
this->show();
showNormal();
activateWindow();
emit chat->chatroomWidgetClicked(chat);
}
static QByteArray sndData;
if (sndData.isEmpty())
{
@ -878,7 +884,7 @@ void Widget::onGroupMessageReceived(int groupnumber, const QString& message, con
g->hasNewMessages = 1;
if (targeted)
{
newMessageAlert();
newMessageAlert(g->widget);
g->userWasMentioned = 1; // useful for highlighting line or desktop notifications
}
g->widget->updateStatusLight();

View File

@ -57,7 +57,7 @@ public:
QThread* getCoreThread();
Camera* getCamera();
static Widget* getInstance();
void newMessageAlert();
void newMessageAlert(GenericChatroomWidget* chat);
bool isFriendWidgetCurActiveWidget(Friend* f);
bool getIsWindowMinimized();
static QList<QString> searchProfiles();