void UserInterfaceForm::on_smileyPackBrowser_currentIndexChanged(int index) { QString filename = bodyUI->smileyPackBrowser->itemData(index).toString(); Settings::getInstance().setSmileyPack(filename); reloadSmileys(); }
/** * @brief Constructor of UserInterfaceForm. * @param myParent Setting widget which will contain this form as tab. * * Restores all controls from the settings. */ UserInterfaceForm::UserInterfaceForm(SettingsWidget* myParent) : GenericForm(QPixmap(":/img/settings/general.png")) { parent = myParent; bodyUI = new Ui::UserInterfaceSettings; bodyUI->setupUi(this); // block all child signals during initialization const RecursiveSignalBlocker signalBlocker(this); Settings& s = Settings::getInstance(); const QFont chatBaseFont = s.getChatMessageFont(); bodyUI->txtChatFontSize->setValue(QFontInfo(chatBaseFont).pixelSize()); bodyUI->txtChatFont->setCurrentFont(chatBaseFont); int index = static_cast<int>(s.getStylePreference()); bodyUI->textStyleComboBox->setCurrentIndex(index); bool showWindow = s.getShowWindow(); bodyUI->showWindow->setChecked(showWindow); bodyUI->showInFront->setChecked(s.getShowInFront()); bodyUI->showInFront->setEnabled(showWindow); bodyUI->groupAlwaysNotify->setChecked(s.getGroupAlwaysNotify()); bodyUI->cbGroupchatPosition->setChecked(s.getGroupchatPosition()); bodyUI->cbCompactLayout->setChecked(s.getCompactLayout()); bodyUI->cbSeparateWindow->setChecked(s.getSeparateWindow()); bodyUI->cbDontGroupWindows->setChecked(s.getDontGroupWindows()); bodyUI->cbDontGroupWindows->setEnabled(s.getSeparateWindow()); bodyUI->useEmoticons->setChecked(s.getUseEmoticons()); for (auto entry : SmileyPack::listSmileyPacks()) bodyUI->smileyPackBrowser->addItem(entry.first, entry.second); smileLabels = {bodyUI->smile1, bodyUI->smile2, bodyUI->smile3, bodyUI->smile4, bodyUI->smile5}; int currentPack = bodyUI->smileyPackBrowser->findData(s.getSmileyPack()); bodyUI->smileyPackBrowser->setCurrentIndex(currentPack); reloadSmileys(); bodyUI->smileyPackBrowser->setEnabled(bodyUI->useEmoticons->isChecked()); bodyUI->styleBrowser->addItem(tr("None")); bodyUI->styleBrowser->addItems(QStyleFactory::keys()); QString style; if (QStyleFactory::keys().contains(s.getStyle())) style = s.getStyle(); else style = tr("None"); bodyUI->styleBrowser->setCurrentText(style); for (QString color : Style::getThemeColorNames()) bodyUI->themeColorCBox->addItem(color); bodyUI->themeColorCBox->setCurrentIndex(s.getThemeColor()); bodyUI->emoticonSize->setValue(s.getEmojiFontPointSize()); QLocale ql; QStringList timeFormats; timeFormats << ql.timeFormat(QLocale::ShortFormat) << ql.timeFormat(QLocale::LongFormat) << "hh:mm AP" << "hh:mm:ss AP" << "hh:mm:ss"; timeFormats.removeDuplicates(); bodyUI->timestamp->addItems(timeFormats); QRegularExpression re(QString("^[^\\n]{0,%0}$").arg(MAX_FORMAT_LENGTH)); QRegularExpressionValidator* validator = new QRegularExpressionValidator(re, this); QString timeFormat = s.getTimestampFormat(); if (!re.match(timeFormat).hasMatch()) timeFormat = timeFormats[0]; bodyUI->timestamp->setCurrentText(timeFormat); bodyUI->timestamp->setValidator(validator); on_timestamp_editTextChanged(timeFormat); QStringList dateFormats; dateFormats << QStringLiteral("yyyy-MM-dd") // ISO 8601 // format strings from system locale << ql.dateFormat(QLocale::LongFormat) << ql.dateFormat(QLocale::ShortFormat) << ql.dateFormat(QLocale::NarrowFormat) << "dd-MM-yyyy" << "d-MM-yyyy" << "dddd dd-MM-yyyy" << "dddd d-MM"; dateFormats.removeDuplicates(); bodyUI->dateFormats->addItems(dateFormats); QString dateFormat = s.getDateFormat(); if (!re.match(dateFormat).hasMatch()) dateFormat = dateFormats[0]; bodyUI->dateFormats->setCurrentText(dateFormat); bodyUI->dateFormats->setValidator(validator); on_dateFormats_editTextChanged(dateFormat); eventsInit(); Translator::registerHandler(std::bind(&UserInterfaceForm::retranslateUi, this), this); }
/** * @brief Constructor of UserInterfaceForm. * @param myParent Setting widget which will contain this form as tab. * * Restores all controls from the settings. */ UserInterfaceForm::UserInterfaceForm(SettingsWidget* myParent) : GenericForm(QPixmap(":/img/settings/general.png")) { parent = myParent; bodyUI = new Ui::UserInterfaceSettings; bodyUI->setupUi(this); // block all child signals during initialization const RecursiveSignalBlocker signalBlocker(this); Settings &s = Settings::getInstance(); const QFont chatBaseFont = s.getChatMessageFont(); bodyUI->txtChatFontSize->setValue(QFontInfo(chatBaseFont).pixelSize()); bodyUI->txtChatFont->setCurrentFont(chatBaseFont); int index = static_cast<int>(s.getStylePreference()); bodyUI->textStyleComboBox->setCurrentIndex(index); bool showWindow = s.getShowWindow(); bodyUI->showWindow->setChecked(showWindow); bodyUI->showInFront->setChecked(s.getShowInFront()); bodyUI->showInFront->setEnabled(showWindow); bodyUI->groupAlwaysNotify->setChecked(s.getGroupAlwaysNotify()); bodyUI->cbGroupchatPosition->setChecked(s.getGroupchatPosition()); bodyUI->cbCompactLayout->setChecked(s.getCompactLayout()); bodyUI->cbSeparateWindow->setChecked(s.getSeparateWindow()); bodyUI->cbDontGroupWindows->setChecked(s.getDontGroupWindows()); bodyUI->cbDontGroupWindows->setEnabled(s.getSeparateWindow()); bodyUI->useEmoticons->setChecked(s.getUseEmoticons()); for (auto entry : SmileyPack::listSmileyPacks()) bodyUI->smileyPackBrowser->addItem(entry.first, entry.second); smileLabels = {bodyUI->smile1, bodyUI->smile2, bodyUI->smile3, bodyUI->smile4, bodyUI->smile5}; int currentPack = bodyUI->smileyPackBrowser->findData(s.getSmileyPack()); bodyUI->smileyPackBrowser->setCurrentIndex(currentPack); reloadSmileys(); bodyUI->smileyPackBrowser->setEnabled(bodyUI->useEmoticons->isChecked()); bodyUI->styleBrowser->addItem(tr("None")); bodyUI->styleBrowser->addItems(QStyleFactory::keys()); QString style; if (QStyleFactory::keys().contains(s.getStyle())) style = s.getStyle(); else style = tr("None"); bodyUI->styleBrowser->setCurrentText(style); for (QString color : Style::getThemeColorNames()) bodyUI->themeColorCBox->addItem(color); bodyUI->themeColorCBox->setCurrentIndex(s.getThemeColor()); bodyUI->emoticonSize->setValue(s.getEmojiFontPointSize()); QStringList timestamps; for (QString timestamp : timeFormats) timestamps << QString("%1 - %2").arg(timestamp, QTime::currentTime().toString(timestamp)); bodyUI->timestamp->addItems(timestamps); QLocale ql; QStringList datestamps; dateFormats.append(ql.dateFormat()); dateFormats.append(ql.dateFormat(QLocale::LongFormat)); dateFormats.removeDuplicates(); timeFormats.append(ql.timeFormat()); timeFormats.append(ql.timeFormat(QLocale::LongFormat)); timeFormats.removeDuplicates(); for (QString datestamp : dateFormats) datestamps << QString("%1 - %2").arg(datestamp, QDate::currentDate().toString(datestamp)); bodyUI->dateFormats->addItems(datestamps); bodyUI->timestamp->setCurrentText(QString("%1 - %2").arg(s.getTimestampFormat(), QTime::currentTime().toString(s.getTimestampFormat()))); bodyUI->dateFormats->setCurrentText(QString("%1 - %2").arg(s.getDateFormat(), QDate::currentDate().toString(s.getDateFormat()))); eventsInit(); Translator::registerHandler(std::bind(&UserInterfaceForm::retranslateUi, this), this); }