added distant chat settings

This commit is contained in:
defnax 2019-10-14 02:29:20 +02:00
parent bdea4a66ed
commit cbfe49f0f3
9 changed files with 2733 additions and 61 deletions

View file

@ -363,8 +363,8 @@ void ChatWidget::init(const ChatId &chat_id, const QString &title)
QString customStateString = QString::fromUtf8(rsMsgs->getCustomStateString(chatId.toPeerId()).c_str());
updatePeersCustomStateString(QString::fromStdString(chatId.toPeerId().toStdString()), customStateString);
} else if (chatType() == CHATTYPE_DISTANT){
hist_chat_type = RS_HISTORY_TYPE_PRIVATE ;
messageCount = Settings->getPrivateChatHistoryCount();
hist_chat_type = RS_HISTORY_TYPE_DISTANT ;
messageCount = Settings->getDistantChatHistoryCount();
} else if(chatId.isBroadcast()){
hist_chat_type = RS_HISTORY_TYPE_PUBLIC;
messageCount = Settings->getPublicChatHistoryCount();
@ -435,8 +435,8 @@ ChatWidget::ChatType ChatWidget::chatType()
void ChatWidget::blockSending(QString msg)
{
#ifndef RS_ASYNC_CHAT
sendingBlocked = true;
ui->sendButton->setEnabled(false);
// sendingBlocked = true;
// ui->sendButton->setEnabled(false);
#endif
ui->sendButton->setToolTip(msg);
}

View file

@ -166,14 +166,18 @@ void ChatPage::updateHistoryParams()
Settings->setPublicChatHistoryCount(ui.publicChatLoadCount->value());
Settings->setPrivateChatHistoryCount(ui.privateChatLoadCount->value());
Settings->setLobbyChatHistoryCount(ui.lobbyChatLoadCount->value());
Settings->setDistantChatHistoryCount(ui.distantChatLoadCount->value());
rsHistory->setEnable(RS_HISTORY_TYPE_PUBLIC , ui.publicChatEnable->isChecked());
rsHistory->setEnable(RS_HISTORY_TYPE_PRIVATE, ui.privateChatEnable->isChecked());
rsHistory->setEnable(RS_HISTORY_TYPE_LOBBY , ui.lobbyChatEnable->isChecked());
rsHistory->setEnable(RS_HISTORY_TYPE_DISTANT, ui.distantChatEnable->isChecked());
rsHistory->setSaveCount(RS_HISTORY_TYPE_PUBLIC , ui.publicChatSaveCount->value());
rsHistory->setSaveCount(RS_HISTORY_TYPE_PRIVATE, ui.privateChatSaveCount->value());
rsHistory->setSaveCount(RS_HISTORY_TYPE_LOBBY , ui.lobbyChatSaveCount->value());
rsHistory->setSaveCount(RS_HISTORY_TYPE_DISTANT, ui.distantChatSaveCount->value());
}
void ChatPage::updatePublicStyle()
@ -247,13 +251,19 @@ ChatPage::ChatPage(QWidget * parent, Qt::WindowFlags flags)
connect(ui.publicChatLoadCount, SIGNAL(valueChanged(int)), this, SLOT(updateHistoryParams()));
connect(ui.privateChatLoadCount, SIGNAL(valueChanged(int)), this, SLOT(updateHistoryParams()));
connect(ui.distantChatLoadCount, SIGNAL(valueChanged(int)), this, SLOT(updateHistoryParams()));
connect(ui.lobbyChatLoadCount, SIGNAL(valueChanged(int)), this, SLOT(updateHistoryParams()));
connect(ui.publicChatEnable, SIGNAL(toggled(bool)), this, SLOT(updateHistoryParams()));
connect(ui.privateChatEnable, SIGNAL(toggled(bool)), this, SLOT(updateHistoryParams()));
connect(ui.distantChatEnable, SIGNAL(toggled(bool)), this, SLOT(updateHistoryParams()));
connect(ui.lobbyChatEnable, SIGNAL(toggled(bool)), this, SLOT(updateHistoryParams()));
connect(ui.publicChatSaveCount, SIGNAL(valueChanged(int)), this, SLOT(updateHistoryParams()));
connect(ui.privateChatSaveCount, SIGNAL(valueChanged(int)), this, SLOT(updateHistoryParams()));
connect(ui.lobbyChatSaveCount, SIGNAL(valueChanged(int)), this, SLOT(updateHistoryParams()));
connect(ui.distantChatSaveCount, SIGNAL(valueChanged(int)), this, SLOT(updateHistoryParams()));
connect(ui.publicStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(updatePublicStyle())) ;
connect(ui.publicComboBoxVariant, SIGNAL(currentIndexChanged(int)), this, SLOT(updatePublicStyle())) ;
@ -349,14 +359,18 @@ ChatPage::load()
whileBlocking(ui.publicChatLoadCount)->setValue(Settings->getPublicChatHistoryCount());
whileBlocking(ui.privateChatLoadCount)->setValue(Settings->getPrivateChatHistoryCount());
whileBlocking(ui.lobbyChatLoadCount)->setValue(Settings->getLobbyChatHistoryCount());
whileBlocking(ui.distantChatLoadCount)->setValue(Settings->getDistantChatHistoryCount());
whileBlocking(ui.publicChatEnable)->setChecked(rsHistory->getEnable(RS_HISTORY_TYPE_PUBLIC));
whileBlocking(ui.privateChatEnable)->setChecked(rsHistory->getEnable(RS_HISTORY_TYPE_PRIVATE));
whileBlocking(ui.lobbyChatEnable)->setChecked(rsHistory->getEnable(RS_HISTORY_TYPE_LOBBY));
whileBlocking(ui.distantChatEnable)->setChecked(rsHistory->getEnable(RS_HISTORY_TYPE_DISTANT));
whileBlocking(ui.publicChatSaveCount)->setValue(rsHistory->getSaveCount(RS_HISTORY_TYPE_PUBLIC));
whileBlocking(ui.privateChatSaveCount)->setValue(rsHistory->getSaveCount(RS_HISTORY_TYPE_PRIVATE));
whileBlocking(ui.lobbyChatSaveCount)->setValue(rsHistory->getSaveCount(RS_HISTORY_TYPE_LOBBY));
whileBlocking(ui.distantChatSaveCount)->setValue(rsHistory->getSaveCount(RS_HISTORY_TYPE_DISTANT));
// using fontTempChat.rawname() does not always work!
// see http://doc.qt.digia.com/qt-maemo/qfont.html#rawName

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1216</width>
<height>1127</height>
<width>800</width>
<height>600</height>
</rect>
</property>
<layout class="QGridLayout">
@ -598,8 +598,21 @@
<layout class="QHBoxLayout" name="histSetupVLayout">
<item>
<layout class="QGridLayout" name="histSetupGLayout">
<item row="0" column="1">
<widget class="QLabel" name="publicHeaderLabel">
<item row="1" column="0">
<widget class="QLabel" name="labelChatEnable">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Enabled:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="lobbyHeaderLabel">
<property name="font">
<font>
<weight>75</weight>
@ -607,7 +620,7 @@
</font>
</property>
<property name="text">
<string>Group chat</string>
<string>Chatlobbies</string>
</property>
</widget>
</item>
@ -624,8 +637,8 @@
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="lobbyHeaderLabel">
<item row="0" column="1">
<widget class="QLabel" name="publicHeaderLabel">
<property name="font">
<font>
<weight>75</weight>
@ -633,20 +646,7 @@
</font>
</property>
<property name="text">
<string>Chatlobbies</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelChatEnable">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Enabled:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<string>Group chat</string>
</property>
</widget>
</item>
@ -657,20 +657,6 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="privateChatEnable">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="lobbyChatEnable">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelChatSaveCount">
<property name="text">
@ -681,6 +667,13 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="privateChatEnable">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="publicChatSaveCount">
<property name="maximumSize">
@ -700,27 +693,15 @@
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QSpinBox" name="privateChatSaveCount">
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="suffix">
<item row="1" column="4">
<widget class="QCheckBox" name="lobbyChatEnable">
<property name="text">
<string/>
</property>
<property name="prefix">
<string/>
</property>
<property name="maximum">
<number>1000000000</number>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QSpinBox" name="lobbyChatSaveCount">
<item row="2" column="2">
<widget class="QSpinBox" name="privateChatSaveCount">
<property name="maximumSize">
<size>
<width>60</width>
@ -761,6 +742,25 @@
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QSpinBox" name="lobbyChatSaveCount">
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="suffix">
<string/>
</property>
<property name="prefix">
<string/>
</property>
<property name="maximum">
<number>1000000000</number>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QSpinBox" name="privateChatLoadCount">
<property name="maximumSize">
@ -774,7 +774,7 @@
</property>
</widget>
</item>
<item row="3" column="3">
<item row="3" column="4">
<widget class="QSpinBox" name="lobbyChatLoadCount">
<property name="maximumSize">
<size>
@ -787,6 +787,32 @@
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="distantchatHeaderLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Distant chat</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="distantChatEnable">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QSpinBox" name="distantChatSaveCount"/>
</item>
<item row="3" column="3">
<widget class="QSpinBox" name="distantChatLoadCount"/>
</item>
</layout>
</item>
<item>
@ -866,7 +892,7 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="publicTab">
<attribute name="title">

View file

@ -728,6 +728,16 @@ void RshareSettings::setPrivateChatHistoryCount(int value)
setValueToGroup("Chat", "PrivateChatHistoryCount", value);
}
int RshareSettings::getDistantChatHistoryCount()
{
return valueFromGroup("Chat", "DistantChatHistoryCount", 20).toInt();
}
void RshareSettings::setDistantChatHistoryCount(int value)
{
setValueToGroup("Chat", "DistantChatHistoryCount", value);
}
/** Returns true if RetroShare is set to run on system boot. */
bool
RshareSettings::runRetroshareOnBoot(bool &minimized)

View file

@ -273,6 +273,9 @@ public:
int getLobbyChatHistoryCount();
void setLobbyChatHistoryCount(int value);
int getDistantChatHistoryCount();
void setDistantChatHistoryCount(int value);
//! Save placement, state and size information of a window.
void saveWidgetInformation(QWidget *widget);