converted the last CONFIG pages to interactive mode

This commit is contained in:
csoler 2017-01-30 21:38:06 +01:00
parent 60d9ea006f
commit 66bbf4d61c
6 changed files with 201 additions and 111 deletions

View File

@ -93,25 +93,7 @@ static QString loadStyleInfo(ChatStyle::enumStyleType type, QListWidget *listWid
} }
return stylePath; return stylePath;
} }
void ChatPage::updateFontsAndEmotes()
/** Constructor */
ChatPage::ChatPage(QWidget * parent, Qt::WindowFlags flags)
: ConfigPage(parent, 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
}
/** Saves the changes on this page */
bool
ChatPage::save(QString &/*errmsg*/)
{ {
Settings->beginGroup(QString("Chat")); Settings->beginGroup(QString("Chat"));
Settings->setValue("Emoteicons_PrivatChat", ui.checkBox_emoteprivchat->isChecked()); Settings->setValue("Emoteicons_PrivatChat", ui.checkBox_emoteprivchat->isChecked());
@ -123,6 +105,11 @@ ChatPage::save(QString &/*errmsg*/)
Settings->setValue("EnableItalics", ui.checkBox_enableItalics->isChecked()); Settings->setValue("EnableItalics", ui.checkBox_enableItalics->isChecked());
Settings->setValue("MinimumContrast", ui.minimumContrast->value()); Settings->setValue("MinimumContrast", ui.minimumContrast->value());
Settings->endGroup(); Settings->endGroup();
}
/** Saves the changes on this page */
void ChatPage::updateChatParams()
{
// state of distant Chat combobox // state of distant Chat combobox
Settings->setValue("DistantChat", ui.distantChatComboBox->currentIndex()); Settings->setValue("DistantChat", ui.distantChatComboBox->currentIndex());
@ -133,7 +120,10 @@ ChatPage::save(QString &/*errmsg*/)
Settings->setChatSendAsPlainTextByDef(ui.sendAsPlainTextByDef->isChecked()); Settings->setChatSendAsPlainTextByDef(ui.sendAsPlainTextByDef->isChecked());
Settings->setChatLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked()); Settings->setChatLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked());
Settings->setChatDoNotSendIsTyping(ui.DontSendTyping->isChecked()); Settings->setChatDoNotSendIsTyping(ui.DontSendTyping->isChecked());
}
void ChatPage::updateChatSearchParams()
{
Settings->setChatSearchCharToStartSearch(ui.sbSearch_CharToStart->value()); Settings->setChatSearchCharToStartSearch(ui.sbSearch_CharToStart->value());
Settings->setChatSearchCaseSensitively(ui.cbSearch_CaseSensitively->isChecked()); Settings->setChatSearchCaseSensitively(ui.cbSearch_CaseSensitively->isChecked());
Settings->setChatSearchWholeWords(ui.cbSearch_WholeWords->isChecked()); Settings->setChatSearchWholeWords(ui.cbSearch_WholeWords->isChecked());
@ -141,7 +131,25 @@ ChatPage::save(QString &/*errmsg*/)
Settings->setChatSearchSearchWithoutLimit(ui.cbSearch_WithoutLimit->isChecked()); Settings->setChatSearchSearchWithoutLimit(ui.cbSearch_WithoutLimit->isChecked());
Settings->setChatSearchMaxSearchLimitColor(ui.sbSearch_MaxLimitColor->value()); Settings->setChatSearchMaxSearchLimitColor(ui.sbSearch_MaxLimitColor->value());
Settings->setChatSearchFoundColor(rgbChatSearchFoundColor); 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->setPublicChatHistoryCount(ui.publicChatLoadCount->value());
Settings->setPrivateChatHistoryCount(ui.privateChatLoadCount->value()); Settings->setPrivateChatHistoryCount(ui.privateChatLoadCount->value());
Settings->setLobbyChatHistoryCount(ui.lobbyChatLoadCount->value()); Settings->setLobbyChatHistoryCount(ui.lobbyChatLoadCount->value());
@ -153,18 +161,10 @@ ChatPage::save(QString &/*errmsg*/)
rsHistory->setSaveCount(RS_HISTORY_TYPE_PUBLIC , ui.publicChatSaveCount->value()); rsHistory->setSaveCount(RS_HISTORY_TYPE_PUBLIC , ui.publicChatSaveCount->value());
rsHistory->setSaveCount(RS_HISTORY_TYPE_PRIVATE, ui.privateChatSaveCount->value()); rsHistory->setSaveCount(RS_HISTORY_TYPE_PRIVATE, ui.privateChatSaveCount->value());
rsHistory->setSaveCount(RS_HISTORY_TYPE_LOBBY , ui.lobbyChatSaveCount->value()); rsHistory->setSaveCount(RS_HISTORY_TYPE_LOBBY , ui.lobbyChatSaveCount->value());
}
RsGxsId chosen_id ; void ChatPage::updatePublicStyle()
switch(ui.chatLobbyIdentity_IC->getChosenId(chosen_id)) {
{
case GxsIdChooser::KnowId:
case GxsIdChooser::UnKnowId:
rsMsgs->setDefaultIdentityForChatLobby(chosen_id) ;
break ;
default:;
}
ChatStyleInfo info; ChatStyleInfo info;
QListWidgetItem *item = ui.publicList->currentItem(); QListWidgetItem *item = ui.publicList->currentItem();
if (item) { if (item) {
@ -174,8 +174,12 @@ ChatPage::save(QString &/*errmsg*/)
NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PUBLIC); NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PUBLIC);
} }
} }
}
item = ui.privateList->currentItem(); void ChatPage::updatePrivateStyle()
{
ChatStyleInfo info;
QListWidgetItem *item = ui.privateList->currentItem();
if (item) { if (item) {
info = item->data(Qt::UserRole).value<ChatStyleInfo>(); info = item->data(Qt::UserRole).value<ChatStyleInfo>();
if (privateStylePath != info.stylePath || privateStyleVariant != ui.privateComboBoxVariant->currentText()) { if (privateStylePath != info.stylePath || privateStyleVariant != ui.privateComboBoxVariant->currentText()) {
@ -183,8 +187,12 @@ ChatPage::save(QString &/*errmsg*/)
NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PRIVATE); NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PRIVATE);
} }
} }
}
item = ui.historyList->currentItem(); void ChatPage::updateHistoryStyle()
{
ChatStyleInfo info;
QListWidgetItem *item = ui.historyList->currentItem();
if (item) { if (item) {
info = item->data(Qt::UserRole).value<ChatStyleInfo>(); info = item->data(Qt::UserRole).value<ChatStyleInfo>();
if (historyStylePath != info.stylePath || historyStyleVariant != ui.historyComboBoxVariant->currentText()) { if (historyStylePath != info.stylePath || historyStyleVariant != ui.historyComboBoxVariant->currentText()) {
@ -192,9 +200,77 @@ ChatPage::save(QString &/*errmsg*/)
NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_HISTORY); NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_HISTORY);
} }
} }
}
rsHistory->setMaxStorageDuration(ui.max_storage_period->value() * 86400) ; void ChatPage::updateHistoryStorage() { rsHistory->setMaxStorageDuration(ui.max_storage_period->value() * 86400) ; }
/** Constructor */
ChatPage::ChatPage(QWidget * parent, Qt::WindowFlags flags)
: ConfigPage(parent, flags)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
#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; uint chatflags = 0;
if (ui.chat_NewWindow->isChecked()) if (ui.chat_NewWindow->isChecked())
@ -207,15 +283,16 @@ ChatPage::save(QString &/*errmsg*/)
chatflags |= RS_CHAT_BLINK; chatflags |= RS_CHAT_BLINK;
Settings->setChatFlags(chatflags); Settings->setChatFlags(chatflags);
}
void ChatPage::updateChatLobbyFlags()
{
uint chatLobbyFlags = 0; uint chatLobbyFlags = 0;
if (ui.chatLobby_Blink->isChecked()) if (ui.chatLobby_Blink->isChecked())
chatLobbyFlags |= RS_CHATLOBBY_BLINK; chatLobbyFlags |= RS_CHATLOBBY_BLINK;
Settings->setChatLobbyFlags(chatLobbyFlags); Settings->setChatLobbyFlags(chatLobbyFlags);
return true;
} }
/** Loads the settings for this page */ /** Loads the settings for this page */

View File

@ -56,6 +56,17 @@ class ChatPage : public ConfigPage
void distantChatComboBoxChanged(int); 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: private:
void setPreviewMessages(QString &stylePath, QString styleVariant, QTextBrowser *textBrowser); void setPreviewMessages(QString &stylePath, QString styleVariant, QTextBrowser *textBrowser);

View File

@ -46,6 +46,7 @@ SoundPage::SoundPage(QWidget * parent, Qt::WindowFlags flags)
connect(ui.defaultButton, SIGNAL(clicked()), this, SLOT(defaultButtonClicked())); connect(ui.defaultButton, SIGNAL(clicked()), this, SLOT(defaultButtonClicked()));
connect(ui.browseButton, SIGNAL(clicked()), this, SLOT(browseButtonClicked())); connect(ui.browseButton, SIGNAL(clicked()), this, SLOT(browseButtonClicked()));
connect(ui.playButton, SIGNAL(clicked()), this, SLOT(playButtonClicked())); connect(ui.playButton, SIGNAL(clicked()), this, SLOT(playButtonClicked()));
connect(ui.eventTreeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(updateSounds()));
ui.eventTreeWidget->setColumnCount(COLUMN_COUNT); ui.eventTreeWidget->setColumnCount(COLUMN_COUNT);
@ -100,7 +101,7 @@ QTreeWidgetItem *SoundPage::addItem(QTreeWidgetItem *groupItem, const QString &n
} }
/** Saves the changes on this page */ /** Saves the changes on this page */
bool SoundPage::save(QString &/*errmsg*/) void SoundPage::updateSounds()
{ {
QTreeWidgetItemIterator itemIterator(ui.eventTreeWidget); QTreeWidgetItemIterator itemIterator(ui.eventTreeWidget);
QTreeWidgetItem *item = NULL; QTreeWidgetItem *item = NULL;
@ -113,8 +114,6 @@ bool SoundPage::save(QString &/*errmsg*/)
SoundManager::setEventFilename(event, item->text(COLUMN_FILENAME)); SoundManager::setEventFilename(event, item->text(COLUMN_FILENAME));
} }
} }
return true;
} }
/** Loads the settings for this page */ /** Loads the settings for this page */

View File

@ -50,6 +50,7 @@ private slots:
void defaultButtonClicked(); void defaultButtonClicked();
void browseButtonClicked(); void browseButtonClicked();
void playButtonClicked(); void playButtonClicked();
void updateSounds();
private: private:
QTreeWidgetItem *addGroup(const QString &name); QTreeWidgetItem *addGroup(const QString &name);

View File

@ -33,7 +33,7 @@ WebuiPage::~WebuiPage()
} }
bool WebuiPage::save(QString &errmsg) bool WebuiPage::updateParams(QString &errmsg)
{ {
std::cerr << "WebuiPage::save()" << std::endl; std::cerr << "WebuiPage::save()" << std::endl;
bool ok = true; bool ok = true;
@ -153,7 +153,7 @@ void WebuiPage::onEnableCBClicked(bool checked)
void WebuiPage::onApplyClicked() void WebuiPage::onApplyClicked()
{ {
QString errmsg; QString errmsg;
bool ok = save(errmsg); bool ok = updateParams(errmsg);
if(!ok) if(!ok)
{ {
QMessageBox::warning(0, tr("failed to start Webinterface"), "Failed to start the webinterface."); QMessageBox::warning(0, tr("failed to start Webinterface"), "Failed to start the webinterface.");

View File

@ -45,6 +45,8 @@ private:
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::WebuiPage ui; Ui::WebuiPage ui;
bool updateParams(QString &errmsg);
static resource_api::ApiServer* apiServer; static resource_api::ApiServer* apiServer;
static resource_api::ApiServerMHD* apiServerMHD; static resource_api::ApiServerMHD* apiServerMHD;
#ifdef LIBRESAPI_LOCAL_SERVER #ifdef LIBRESAPI_LOCAL_SERVER