From 66bbf4d61c2c1af78d12daa5c4266e1bb81d862d Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 30 Jan 2017 21:38:06 +0100 Subject: [PATCH] converted the last CONFIG pages to interactive mode --- retroshare-gui/src/gui/settings/ChatPage.cpp | 289 +++++++++++------- retroshare-gui/src/gui/settings/ChatPage.h | 11 + retroshare-gui/src/gui/settings/SoundPage.cpp | 5 +- retroshare-gui/src/gui/settings/SoundPage.h | 1 + retroshare-gui/src/gui/settings/WebuiPage.cpp | 4 +- retroshare-gui/src/gui/settings/WebuiPage.h | 2 + 6 files changed, 201 insertions(+), 111 deletions(-) diff --git a/retroshare-gui/src/gui/settings/ChatPage.cpp b/retroshare-gui/src/gui/settings/ChatPage.cpp index 8f74c69d9..b2f5d8478 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.cpp +++ b/retroshare-gui/src/gui/settings/ChatPage.cpp @@ -93,6 +93,117 @@ static QString loadStyleInfo(ChatStyle::enumStyleType type, QListWidget *listWid } return stylePath; } +void ChatPage::updateFontsAndEmotes() +{ + Settings->beginGroup(QString("Chat")); + Settings->setValue("Emoteicons_PrivatChat", ui.checkBox_emoteprivchat->isChecked()); + Settings->setValue("Emoteicons_GroupChat", ui.checkBox_emotegroupchat->isChecked()); + Settings->setValue("EnableCustomFonts", ui.checkBox_enableCustomFonts->isChecked()); + Settings->setValue("EnableCustomFontSize", ui.checkBox_enableCustomFontSize->isChecked()); + Settings->setValue("MinimumFontSize", ui.minimumFontSize->value()); + Settings->setValue("EnableBold", ui.checkBox_enableBold->isChecked()); + Settings->setValue("EnableItalics", ui.checkBox_enableItalics->isChecked()); + Settings->setValue("MinimumContrast", ui.minimumContrast->value()); + Settings->endGroup(); +} + +/** Saves the changes on this page */ +void ChatPage::updateChatParams() +{ + // state of distant Chat combobox + Settings->setValue("DistantChat", ui.distantChatComboBox->currentIndex()); + + Settings->setChatScreenFont(fontTempChat.toString()); + NotifyQt::getInstance()->notifyChatFontChanged(); + + Settings->setChatSendMessageWithCtrlReturn(ui.sendMessageWithCtrlReturn->isChecked()); + Settings->setChatSendAsPlainTextByDef(ui.sendAsPlainTextByDef->isChecked()); + Settings->setChatLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked()); + Settings->setChatDoNotSendIsTyping(ui.DontSendTyping->isChecked()); +} + +void ChatPage::updateChatSearchParams() +{ + Settings->setChatSearchCharToStartSearch(ui.sbSearch_CharToStart->value()); + Settings->setChatSearchCaseSensitively(ui.cbSearch_CaseSensitively->isChecked()); + Settings->setChatSearchWholeWords(ui.cbSearch_WholeWords->isChecked()); + Settings->setChatSearchMoveToCursor(ui.cbSearch_MoveToCursor->isChecked()); + Settings->setChatSearchSearchWithoutLimit(ui.cbSearch_WithoutLimit->isChecked()); + Settings->setChatSearchMaxSearchLimitColor(ui.sbSearch_MaxLimitColor->value()); + Settings->setChatSearchFoundColor(rgbChatSearchFoundColor); +} + +void ChatPage::updateDefaultLobbyIdentity() +{ + RsGxsId chosen_id ; + switch(ui.chatLobbyIdentity_IC->getChosenId(chosen_id)) + { + case GxsIdChooser::KnowId: + case GxsIdChooser::UnKnowId: + rsMsgs->setDefaultIdentityForChatLobby(chosen_id) ; + break ; + + default:; + } +} + + +void ChatPage::updateHistoryParams() +{ + Settings->setPublicChatHistoryCount(ui.publicChatLoadCount->value()); + Settings->setPrivateChatHistoryCount(ui.privateChatLoadCount->value()); + Settings->setLobbyChatHistoryCount(ui.lobbyChatLoadCount->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->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()); +} + +void ChatPage::updatePublicStyle() +{ + ChatStyleInfo info; + QListWidgetItem *item = ui.publicList->currentItem(); + if (item) { + info = item->data(Qt::UserRole).value(); + if (publicStylePath != info.stylePath || publicStyleVariant != ui.publicComboBoxVariant->currentText()) { + Settings->setPublicChatStyle(info.stylePath, ui.publicComboBoxVariant->currentText()); + NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PUBLIC); + } + } +} + +void ChatPage::updatePrivateStyle() +{ + ChatStyleInfo info; + QListWidgetItem *item = ui.privateList->currentItem(); + if (item) { + info = item->data(Qt::UserRole).value(); + if (privateStylePath != info.stylePath || privateStyleVariant != ui.privateComboBoxVariant->currentText()) { + Settings->setPrivateChatStyle(info.stylePath, ui.privateComboBoxVariant->currentText()); + NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PRIVATE); + } + } +} + +void ChatPage::updateHistoryStyle() +{ + ChatStyleInfo info; + QListWidgetItem *item = ui.historyList->currentItem(); + if (item) { + info = item->data(Qt::UserRole).value(); + if (historyStylePath != info.stylePath || historyStyleVariant != ui.historyComboBoxVariant->currentText()) { + Settings->setHistoryChatStyle(info.stylePath, ui.historyComboBoxVariant->currentText()); + NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_HISTORY); + } + } +} + +void ChatPage::updateHistoryStorage() { rsHistory->setMaxStorageDuration(ui.max_storage_period->value() * 86400) ; } + /** Constructor */ ChatPage::ChatPage(QWidget * parent, Qt::WindowFlags flags) @@ -101,121 +212,87 @@ ChatPage::ChatPage(QWidget * parent, Qt::WindowFlags flags) /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); - connect(ui.distantChatComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(distantChatComboBoxChanged(int))); - #if QT_VERSION < 0x040600 ui.minimumContrastLabel->hide(); ui.minimumContrast->hide(); #endif + connect(ui.distantChatComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(distantChatComboBoxChanged(int))); + + connect(ui.checkBox_emoteprivchat, SIGNAL(toggled(bool)), this, SLOT(updateFontsAndEmotes())); + connect(ui.checkBox_emotegroupchat, SIGNAL(toggled(bool)), this, SLOT(updateFontsAndEmotes())); + connect(ui.checkBox_enableCustomFonts, SIGNAL(toggled(bool)), this, SLOT(updateFontsAndEmotes())); + connect(ui.minimumFontSize, SIGNAL(valueChanged(int)), this, SLOT(updateFontsAndEmotes())); + connect(ui.checkBox_enableBold, SIGNAL(toggled(bool)), this, SLOT(updateFontsAndEmotes())); + connect(ui.checkBox_enableItalics, SIGNAL(toggled(bool)), this, SLOT(updateFontsAndEmotes())); + connect(ui.minimumContrast, SIGNAL(valueChanged(int)), this, SLOT(updateFontsAndEmotes())); + + connect(ui.distantChatComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateChatParams())); + connect(ui.sendMessageWithCtrlReturn, SIGNAL(toggled(bool)), this, SLOT(updateChatParams())); + connect(ui.sendAsPlainTextByDef, SIGNAL(toggled(bool)), this, SLOT(updateChatParams())); + connect(ui.loadEmbeddedImages, SIGNAL(toggled(bool)), this, SLOT(updateChatParams())); + connect(ui.DontSendTyping, SIGNAL(toggled(bool)), this, SLOT(updateChatParams())); + + connect(ui.sbSearch_CharToStart, SIGNAL(valueChanged(int)), this, SLOT(updateChatSearchParams())); + connect(ui.cbSearch_CaseSensitively, SIGNAL(toggled(bool)), this, SLOT(updateChatSearchParams())); + connect(ui.cbSearch_WholeWords, SIGNAL(toggled(bool)), this, SLOT(updateChatSearchParams())); + connect(ui.cbSearch_MoveToCursor, SIGNAL(toggled(bool)), this, SLOT(updateChatSearchParams())); + connect(ui.cbSearch_WithoutLimit, SIGNAL(toggled(bool)), this, SLOT(updateChatSearchParams())); + connect(ui.sbSearch_MaxLimitColor, SIGNAL(valueChanged(int)), this, SLOT(updateChatSearchParams())); + + connect(ui.chatLobbyIdentity_IC, SIGNAL(currentIndexChanged(int)), this, SLOT(updateDefaultLobbyIdentity())); + + connect(ui.publicChatLoadCount, SIGNAL(valueChanged(int)), this, SLOT(updateHistoryParams())); + connect(ui.privateChatLoadCount, 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.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.publicList, SIGNAL(currentRowChanged(int)), this, SLOT(updatePublicStyle())) ; + connect(ui.publicComboBoxVariant, SIGNAL(currentIndexChanged(int)), this, SLOT(updatePublicStyle())) ; + + connect(ui.privateList, SIGNAL(currentRowChanged(int)), this, SLOT(updatePrivateStyle())) ; + connect(ui.privateComboBoxVariant, SIGNAL(currentIndexChanged(int)), this, SLOT(updatePrivateStyle())) ; + + connect(ui.historyList, SIGNAL(currentRowChanged(int)), this, SLOT(updateHistoryStyle())) ; + connect(ui.historyComboBoxVariant, SIGNAL(currentIndexChanged(int)), this, SLOT(updateHistoryStyle())) ; + + connect(ui.max_storage_period, SIGNAL(valueChanged(int)), this, SLOT(updateHistoryStorage())) ; + + connect(ui.chat_NewWindow, SIGNAL(toggled(bool)), this, SLOT(updateChatFlags())); + connect(ui.chat_Focus, SIGNAL(toggled(bool)), this, SLOT(updateChatFlags())); + connect(ui.chat_tabbedWindow, SIGNAL(toggled(bool)), this, SLOT(updateChatFlags())); + connect(ui.chat_Blink, SIGNAL(toggled(bool)), this, SLOT(updateChatFlags())); + + connect(ui.chatLobby_Blink, SIGNAL(toggled(bool)), this, SLOT(updateChatLobbyFlags())); +} +void ChatPage::updateChatFlags() +{ + uint chatflags = 0; + + if (ui.chat_NewWindow->isChecked()) + chatflags |= RS_CHAT_OPEN; + if (ui.chat_Focus->isChecked()) + chatflags |= RS_CHAT_FOCUS; + if (ui.chat_tabbedWindow->isChecked()) + chatflags |= RS_CHAT_TABBED_WINDOW; + if (ui.chat_Blink->isChecked()) + chatflags |= RS_CHAT_BLINK; + + Settings->setChatFlags(chatflags); } -/** Saves the changes on this page */ -bool -ChatPage::save(QString &/*errmsg*/) +void ChatPage::updateChatLobbyFlags() { - Settings->beginGroup(QString("Chat")); - Settings->setValue("Emoteicons_PrivatChat", ui.checkBox_emoteprivchat->isChecked()); - Settings->setValue("Emoteicons_GroupChat", ui.checkBox_emotegroupchat->isChecked()); - Settings->setValue("EnableCustomFonts", ui.checkBox_enableCustomFonts->isChecked()); - Settings->setValue("EnableCustomFontSize", ui.checkBox_enableCustomFontSize->isChecked()); - Settings->setValue("MinimumFontSize", ui.minimumFontSize->value()); - Settings->setValue("EnableBold", ui.checkBox_enableBold->isChecked()); - Settings->setValue("EnableItalics", ui.checkBox_enableItalics->isChecked()); - Settings->setValue("MinimumContrast", ui.minimumContrast->value()); - Settings->endGroup(); - // state of distant Chat combobox - Settings->setValue("DistantChat", ui.distantChatComboBox->currentIndex()); + uint chatLobbyFlags = 0; - Settings->setChatScreenFont(fontTempChat.toString()); - NotifyQt::getInstance()->notifyChatFontChanged(); + if (ui.chatLobby_Blink->isChecked()) + chatLobbyFlags |= RS_CHATLOBBY_BLINK; - Settings->setChatSendMessageWithCtrlReturn(ui.sendMessageWithCtrlReturn->isChecked()); - Settings->setChatSendAsPlainTextByDef(ui.sendAsPlainTextByDef->isChecked()); - Settings->setChatLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked()); - Settings->setChatDoNotSendIsTyping(ui.DontSendTyping->isChecked()); - - Settings->setChatSearchCharToStartSearch(ui.sbSearch_CharToStart->value()); - Settings->setChatSearchCaseSensitively(ui.cbSearch_CaseSensitively->isChecked()); - Settings->setChatSearchWholeWords(ui.cbSearch_WholeWords->isChecked()); - Settings->setChatSearchMoveToCursor(ui.cbSearch_MoveToCursor->isChecked()); - Settings->setChatSearchSearchWithoutLimit(ui.cbSearch_WithoutLimit->isChecked()); - Settings->setChatSearchMaxSearchLimitColor(ui.sbSearch_MaxLimitColor->value()); - Settings->setChatSearchFoundColor(rgbChatSearchFoundColor); - - Settings->setPublicChatHistoryCount(ui.publicChatLoadCount->value()); - Settings->setPrivateChatHistoryCount(ui.privateChatLoadCount->value()); - Settings->setLobbyChatHistoryCount(ui.lobbyChatLoadCount->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->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()); - - RsGxsId chosen_id ; - switch(ui.chatLobbyIdentity_IC->getChosenId(chosen_id)) - { - case GxsIdChooser::KnowId: - case GxsIdChooser::UnKnowId: - rsMsgs->setDefaultIdentityForChatLobby(chosen_id) ; - break ; - - default:; - } - - ChatStyleInfo info; - QListWidgetItem *item = ui.publicList->currentItem(); - if (item) { - info = item->data(Qt::UserRole).value(); - if (publicStylePath != info.stylePath || publicStyleVariant != ui.publicComboBoxVariant->currentText()) { - Settings->setPublicChatStyle(info.stylePath, ui.publicComboBoxVariant->currentText()); - NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PUBLIC); - } - } - - item = ui.privateList->currentItem(); - if (item) { - info = item->data(Qt::UserRole).value(); - if (privateStylePath != info.stylePath || privateStyleVariant != ui.privateComboBoxVariant->currentText()) { - Settings->setPrivateChatStyle(info.stylePath, ui.privateComboBoxVariant->currentText()); - NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PRIVATE); - } - } - - item = ui.historyList->currentItem(); - if (item) { - info = item->data(Qt::UserRole).value(); - if (historyStylePath != info.stylePath || historyStyleVariant != ui.historyComboBoxVariant->currentText()) { - Settings->setHistoryChatStyle(info.stylePath, ui.historyComboBoxVariant->currentText()); - NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_HISTORY); - } - } - - rsHistory->setMaxStorageDuration(ui.max_storage_period->value() * 86400) ; - - uint chatflags = 0; - - if (ui.chat_NewWindow->isChecked()) - chatflags |= RS_CHAT_OPEN; - if (ui.chat_Focus->isChecked()) - chatflags |= RS_CHAT_FOCUS; - if (ui.chat_tabbedWindow->isChecked()) - chatflags |= RS_CHAT_TABBED_WINDOW; - if (ui.chat_Blink->isChecked()) - chatflags |= RS_CHAT_BLINK; - - Settings->setChatFlags(chatflags); - - uint chatLobbyFlags = 0; - - if (ui.chatLobby_Blink->isChecked()) - chatLobbyFlags |= RS_CHATLOBBY_BLINK; - - Settings->setChatLobbyFlags(chatLobbyFlags); - - return true; + Settings->setChatLobbyFlags(chatLobbyFlags); } /** Loads the settings for this page */ diff --git a/retroshare-gui/src/gui/settings/ChatPage.h b/retroshare-gui/src/gui/settings/ChatPage.h index 838fcc2ad..8f7048e2c 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.h +++ b/retroshare-gui/src/gui/settings/ChatPage.h @@ -56,6 +56,17 @@ class ChatPage : public ConfigPage void distantChatComboBoxChanged(int); + void updateFontsAndEmotes(); + void updateChatParams(); + void updateChatSearchParams(); + void updateDefaultLobbyIdentity() ; + void updateHistoryParams(); + void updatePublicStyle() ; + void updatePrivateStyle() ; + void updateHistoryStyle() ; + void updateHistoryStorage(); + void updateChatFlags(); + void updateChatLobbyFlags(); private: void setPreviewMessages(QString &stylePath, QString styleVariant, QTextBrowser *textBrowser); diff --git a/retroshare-gui/src/gui/settings/SoundPage.cpp b/retroshare-gui/src/gui/settings/SoundPage.cpp index ef93c7679..8b3f79a39 100644 --- a/retroshare-gui/src/gui/settings/SoundPage.cpp +++ b/retroshare-gui/src/gui/settings/SoundPage.cpp @@ -46,6 +46,7 @@ SoundPage::SoundPage(QWidget * parent, Qt::WindowFlags flags) connect(ui.defaultButton, SIGNAL(clicked()), this, SLOT(defaultButtonClicked())); connect(ui.browseButton, SIGNAL(clicked()), this, SLOT(browseButtonClicked())); connect(ui.playButton, SIGNAL(clicked()), this, SLOT(playButtonClicked())); + connect(ui.eventTreeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(updateSounds())); ui.eventTreeWidget->setColumnCount(COLUMN_COUNT); @@ -100,7 +101,7 @@ QTreeWidgetItem *SoundPage::addItem(QTreeWidgetItem *groupItem, const QString &n } /** Saves the changes on this page */ -bool SoundPage::save(QString &/*errmsg*/) +void SoundPage::updateSounds() { QTreeWidgetItemIterator itemIterator(ui.eventTreeWidget); QTreeWidgetItem *item = NULL; @@ -113,8 +114,6 @@ bool SoundPage::save(QString &/*errmsg*/) SoundManager::setEventFilename(event, item->text(COLUMN_FILENAME)); } } - - return true; } /** Loads the settings for this page */ diff --git a/retroshare-gui/src/gui/settings/SoundPage.h b/retroshare-gui/src/gui/settings/SoundPage.h index 0fc8b315c..989fcc1a2 100644 --- a/retroshare-gui/src/gui/settings/SoundPage.h +++ b/retroshare-gui/src/gui/settings/SoundPage.h @@ -50,6 +50,7 @@ private slots: void defaultButtonClicked(); void browseButtonClicked(); void playButtonClicked(); + void updateSounds(); private: QTreeWidgetItem *addGroup(const QString &name); diff --git a/retroshare-gui/src/gui/settings/WebuiPage.cpp b/retroshare-gui/src/gui/settings/WebuiPage.cpp index f8923a174..dc168057b 100644 --- a/retroshare-gui/src/gui/settings/WebuiPage.cpp +++ b/retroshare-gui/src/gui/settings/WebuiPage.cpp @@ -33,7 +33,7 @@ WebuiPage::~WebuiPage() } -bool WebuiPage::save(QString &errmsg) +bool WebuiPage::updateParams(QString &errmsg) { std::cerr << "WebuiPage::save()" << std::endl; bool ok = true; @@ -153,7 +153,7 @@ void WebuiPage::onEnableCBClicked(bool checked) void WebuiPage::onApplyClicked() { QString errmsg; - bool ok = save(errmsg); + bool ok = updateParams(errmsg); if(!ok) { QMessageBox::warning(0, tr("failed to start Webinterface"), "Failed to start the webinterface."); diff --git a/retroshare-gui/src/gui/settings/WebuiPage.h b/retroshare-gui/src/gui/settings/WebuiPage.h index 6d14500a5..c7e167ff8 100644 --- a/retroshare-gui/src/gui/settings/WebuiPage.h +++ b/retroshare-gui/src/gui/settings/WebuiPage.h @@ -45,6 +45,8 @@ private: /** Qt Designer generated object */ Ui::WebuiPage ui; + bool updateParams(QString &errmsg); + static resource_api::ApiServer* apiServer; static resource_api::ApiServerMHD* apiServerMHD; #ifdef LIBRESAPI_LOCAL_SERVER