/** * @class GeneralForm * * This form contains all settings that are not suited to other forms */ GeneralForm::GeneralForm(SettingsWidget* myParent) : GenericForm(QPixmap(":/img/settings/general.png")) , bodyUI(new Ui::GeneralSettings) { parent = myParent; bodyUI->setupUi(this); // block all child signals during initialization const RecursiveSignalBlocker signalBlocker(this); Settings& s = Settings::getInstance(); bodyUI->checkUpdates->setVisible(AUTOUPDATE_ENABLED); bodyUI->checkUpdates->setChecked(s.getCheckUpdates()); for (int i = 0; i < langs.size(); ++i) bodyUI->transComboBox->insertItem(i, langs[i]); bodyUI->transComboBox->setCurrentIndex(locales.indexOf(s.getTranslation())); bodyUI->cbAutorun->setChecked(s.getAutorun()); bodyUI->lightTrayIcon->setChecked(s.getLightTrayIcon()); bool showSystemTray = s.getShowSystemTray(); bodyUI->showSystemTray->setChecked(showSystemTray); bodyUI->startInTray->setChecked(s.getAutostartInTray()); bodyUI->startInTray->setEnabled(showSystemTray); bodyUI->minimizeToTray->setChecked(s.getMinimizeToTray()); bodyUI->minimizeToTray->setEnabled(showSystemTray); bodyUI->closeToTray->setChecked(s.getCloseToTray()); bodyUI->closeToTray->setEnabled(showSystemTray); bodyUI->notifySound->setChecked(s.getNotifySound()); bodyUI->busySound->setChecked(s.getBusySound()); bodyUI->busySound->setEnabled(s.getNotifySound()); bodyUI->statusChanges->setChecked(s.getStatusChangeNotificationEnabled()); bodyUI->cbFauxOfflineMessaging->setChecked(s.getFauxOfflineMessaging()); bodyUI->autoAwaySpinBox->setValue(s.getAutoAwayTime()); bodyUI->autoSaveFilesDir->setText(s.getGlobalAutoAcceptDir()); bodyUI->autoacceptFiles->setChecked(s.getAutoSaveEnabled()); #ifndef QTOX_PLATFORM_EXT bodyUI->autoAwayLabel->setEnabled( false); // these don't seem to change the appearance of the widgets, bodyUI->autoAwaySpinBox->setEnabled(false); // though they are unusable #endif eventsInit(); Translator::registerHandler(std::bind(&GeneralForm::retranslateUi, this), this); }
PrivacyForm::PrivacyForm() : GenericForm(QPixmap(":/img/settings/privacy.png")) , bodyUI(new Ui::PrivacySettings) { bodyUI->setupUi(this); // block all child signals during initialization const RecursiveSignalBlocker signalBlocker(this); eventsInit(); Translator::registerHandler(std::bind(&PrivacyForm::retranslateUi, this), this); }
AVForm::AVForm() : GenericForm(QPixmap(":/img/settings/av.png")) , subscribedToAudioIn(false) , camVideoSurface(nullptr) , camera(CameraSource::getInstance()) { setupUi(this); // block all child signals during initialization const RecursiveSignalBlocker signalBlocker(this); const Audio& audio = Audio::getInstance(); const Settings& s = Settings::getInstance(); cbEnableTestSound->setChecked(s.getEnableTestSound()); cbEnableTestSound->setToolTip( tr("Play a test sound while changing the output volume.")); connect(rescanButton, &QPushButton::clicked, this, &AVForm::rescanDevices); playbackSlider->setTracking(false); playbackSlider->setValue(s.getOutVolume()); playbackSlider->installEventFilter(this); microphoneSlider->setToolTip( tr("Use slider to set the gain of your input device ranging" " from %1dB to %2dB.").arg(audio.minInputGain()) .arg(audio.maxInputGain())); microphoneSlider->setMinimum(qRound(audio.minInputGain()) * 10); microphoneSlider->setMaximum(qRound(audio.maxInputGain()) * 10); microphoneSlider->setTickPosition(QSlider::TicksBothSides); microphoneSlider->setTickInterval( (qAbs(microphoneSlider->minimum()) + microphoneSlider->maximum()) / 4); microphoneSlider->setTracking(false); microphoneSlider->installEventFilter(this); eventsInit(); QDesktopWidget *desktop = QApplication::desktop(); connect(desktop, &QDesktopWidget::resized, this, &AVForm::rescanDevices); connect(desktop, &QDesktopWidget::screenCountChanged, this, &AVForm::rescanDevices); Translator::registerHandler(std::bind(&AVForm::retranslateUi, this), this); }
AdvancedForm::AdvancedForm() : GenericForm(QPixmap(":/img/settings/general.png")) , bodyUI (new Ui::AdvancedSettings) { bodyUI->setupUi(this); // block all child signals during initialization const RecursiveSignalBlocker signalBlocker(this); Settings &s = Settings::getInstance(); bodyUI->cbEnableIPv6->setChecked(s.getEnableIPv6()); bodyUI->cbMakeToxPortable->setChecked(Settings::getInstance().getMakeToxPortable()); bodyUI->cbEnableUDP->setChecked(!s.getForceTCP()); bodyUI->proxyAddr->setText(s.getProxyAddr()); quint16 port = s.getProxyPort(); if (port > 0) bodyUI->proxyPort->setValue(port); int index = static_cast<int>(s.getProxyType()); bodyUI->proxyType->setCurrentIndex(index); on_proxyType_currentIndexChanged(index); QString warningBody = tr("Unless you %1 know what you are doing, " "please do %2 change anything here. Changes " "made here may lead to problems with qTox, and even " "to loss of your data, e.g. history.") .arg(QString("<b>%1</b>").arg(tr("really"))) .arg(QString("<b>%1</b>").arg(tr("not"))); QString warning = QString("<div style=\"color:#ff0000;\">" "<p><b>%1</b></p><p>%2</p></div>") .arg(tr("IMPORTANT NOTE")).arg(warningBody); bodyUI->warningLabel->setText(warning); eventsInit(); Translator::registerHandler(std::bind(&AdvancedForm::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()); 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); }
/** * @class GeneralForm * * This form contains all settings that are not suited to other forms */ GeneralForm::GeneralForm(SettingsWidget* myParent) : GenericForm(QPixmap(":/img/settings/general.png")) , bodyUI(new Ui::GeneralSettings) { parent = myParent; bodyUI->setupUi(this); // block all child signals during initialization const RecursiveSignalBlocker signalBlocker(this); Settings& s = Settings::getInstance(); #ifdef AUTOUPDATE_ENABLED bodyUI->checkUpdates->setVisible(AUTOUPDATE_ENABLED); #else bodyUI->checkUpdates->setVisible(false); #endif #ifndef SPELL_CHECKING bodyUI->cbSpellChecking->setVisible(false); #endif bodyUI->checkUpdates->setChecked(s.getCheckUpdates()); for (int i = 0; i < locales.size(); ++i) { QString langName; if (locales[i].startsWith(QLatin1String("eo"))) // QTBUG-57802 langName = QLocale::languageToString(QLocale::Esperanto); else if (locales[i].startsWith(QLatin1String("jbo"))) langName = QLatin1String("Lojban"); else if (locales[i].startsWith(QLatin1String("pr"))) langName = QLatin1String("Pirate"); else langName = QLocale(locales[i]).nativeLanguageName(); bodyUI->transComboBox->insertItem(i, langName); } bodyUI->transComboBox->setCurrentIndex(locales.indexOf(s.getTranslation())); bodyUI->cbAutorun->setChecked(s.getAutorun()); bodyUI->cbSpellChecking->setChecked(s.getSpellCheckingEnabled()); bodyUI->lightTrayIcon->setChecked(s.getLightTrayIcon()); bool showSystemTray = s.getShowSystemTray(); bodyUI->showSystemTray->setChecked(showSystemTray); bodyUI->startInTray->setChecked(s.getAutostartInTray()); bodyUI->startInTray->setEnabled(showSystemTray); bodyUI->minimizeToTray->setChecked(s.getMinimizeToTray()); bodyUI->minimizeToTray->setEnabled(showSystemTray); bodyUI->closeToTray->setChecked(s.getCloseToTray()); bodyUI->closeToTray->setEnabled(showSystemTray); bodyUI->statusChanges->setChecked(s.getStatusChangeNotificationEnabled()); bodyUI->cbFauxOfflineMessaging->setChecked(s.getFauxOfflineMessaging()); bodyUI->autoAwaySpinBox->setValue(s.getAutoAwayTime()); bodyUI->autoSaveFilesDir->setText(s.getGlobalAutoAcceptDir()); bodyUI->maxAutoAcceptSizeMB->setValue(static_cast<double>(s.getMaxAutoAcceptSize()) / 1024 / 1024); bodyUI->autoacceptFiles->setChecked(s.getAutoSaveEnabled()); #ifndef QTOX_PLATFORM_EXT bodyUI->autoAwayLabel->setEnabled(false); // these don't seem to change the appearance of the widgets, bodyUI->autoAwaySpinBox->setEnabled(false); // though they are unusable #endif eventsInit(); Translator::registerHandler(std::bind(&GeneralForm::retranslateUi, this), this); }