void PreferencesDialog::loadSettings() { ui->encodingComboBox->setCurrentIndex(ui->encodingComboBox->findText(getSettingsValue("db", "defaultencoding").toString(), Qt::MatchFixedString)); ui->comboDefaultLocation->setCurrentIndex(getSettingsValue("db", "savedefaultlocation").toInt()); ui->locationEdit->setText(getSettingsValue("db", "defaultlocation").toString()); ui->checkUpdates->setChecked(getSettingsValue("checkversion", "enabled").toBool()); ui->checkHideSchemaLinebreaks->setChecked(getSettingsValue("db", "hideschemalinebreaks").toBool()); ui->foreignKeysCheckBox->setChecked(getSettingsValue("db", "foreignkeys").toBool()); ui->spinPrefetchSize->setValue(getSettingsValue("db", "prefetchsize").toInt()); ui->editDatabaseDefaultSqlText->setText(getSettingsValue("db", "defaultsqltext").toString()); ui->comboDataBrowserFont->setCurrentIndex(ui->comboEditorFont->findText(getSettingsValue("databrowser", "font").toString())); ui->spinDataBrowserFontSize->setValue(getSettingsValue("databrowser", "fontsize").toInt()); loadColorSetting(ui->fr_null_fg, "null_fg"); loadColorSetting(ui->fr_null_bg, "null_bg"); loadColorSetting(ui->fr_reg_fg, "reg_fg"); loadColorSetting(ui->fr_reg_bg, "reg_bg"); loadColorSetting(ui->fr_bin_fg, "bin_fg"); loadColorSetting(ui->fr_bin_bg, "bin_bg"); ui->txtNull->setText(getSettingsValue("databrowser", "null_text").toString()); ui->editFilterEscape->setText(getSettingsValue("databrowser", "filter_escape").toString()); ui->spinFilterDelay->setValue(getSettingsValue("databrowser", "filter_delay").toInt()); for(int i=0; i < ui->treeSyntaxHighlighting->topLevelItemCount(); ++i) { QString name = ui->treeSyntaxHighlighting->topLevelItem(i)->text(0); QString colorname = getSettingsValue("syntaxhighlighter", name + "_colour").toString(); QColor color = QColor(colorname); ui->treeSyntaxHighlighting->topLevelItem(i)->setTextColor(2, color); ui->treeSyntaxHighlighting->topLevelItem(i)->setBackgroundColor(2, color); ui->treeSyntaxHighlighting->topLevelItem(i)->setText(2, colorname); if (name != "null") { ui->treeSyntaxHighlighting->topLevelItem(i)->setCheckState(3, getSettingsValue("syntaxhighlighter", name + "_bold").toBool() ? Qt::Checked : Qt::Unchecked); ui->treeSyntaxHighlighting->topLevelItem(i)->setCheckState(4, getSettingsValue("syntaxhighlighter", name + "_italic").toBool() ? Qt::Checked : Qt::Unchecked); ui->treeSyntaxHighlighting->topLevelItem(i)->setCheckState(5, getSettingsValue("syntaxhighlighter", name + "_underline").toBool() ? Qt::Checked : Qt::Unchecked); } } ui->comboEditorFont->setCurrentIndex(ui->comboEditorFont->findText(getSettingsValue("editor", "font").toString())); ui->spinEditorFontSize->setValue(getSettingsValue("editor", "fontsize").toInt()); ui->spinTabSize->setValue(getSettingsValue("editor", "tabsize").toInt()); ui->spinLogFontSize->setValue(getSettingsValue("log", "fontsize").toInt()); ui->checkAutoCompletion->setChecked(getSettingsValue("editor", "auto_completion").toBool()); ui->checkErrorIndicators->setChecked(getSettingsValue("editor", "error_indicators").toBool()); ui->checkHorizontalTiling->setChecked(getSettingsValue("editor", "horizontal_tiling").toBool()); ui->listExtensions->addItems(getSettingsValue("extensions", "list").toStringList()); ui->checkRegexDisabled->setChecked(getSettingsValue("extensions", "disableregex").toBool()); fillLanguageBox(); }
void PreferencesDialog::loadSettings() { ui->encodingComboBox->setCurrentIndex(ui->encodingComboBox->findText(getSettingsValue("db", "defaultencoding").toString(), Qt::MatchFixedString)); ui->comboDefaultLocation->setCurrentIndex(getSettingsValue("db", "savedefaultlocation").toInt()); ui->locationEdit->setText(getSettingsValue("db", "defaultlocation").toString()); ui->checkUpdates->setChecked(getSettingsValue("checkversion", "enabled").toBool()); ui->checkHideSchemaLinebreaks->setChecked(getSettingsValue("db", "hideschemalinebreaks").toBool()); ui->foreignKeysCheckBox->setChecked(getSettingsValue("db", "foreignkeys").toBool()); ui->spinPrefetchSize->setValue(getSettingsValue("db", "prefetchsize").toInt()); QPalette palette = ui->frameNullBgColour->palette(); palette.setColor(ui->frameNullBgColour->backgroundRole(), QColor(getSettingsValue("databrowser", "null_bg_colour").toString())); ui->frameNullBgColour->setPalette(palette); palette = ui->frameNullFgColour->palette(); palette.setColor(ui->frameNullFgColour->backgroundRole(), QColor(getSettingsValue("databrowser", "null_fg_colour").toString())); ui->frameNullFgColour->setPalette(palette); ui->txtNull->setText(getSettingsValue("databrowser", "null_text").toString()); for(int i=0; i < ui->treeSyntaxHighlighting->topLevelItemCount(); ++i) { QString name = ui->treeSyntaxHighlighting->topLevelItem(i)->text(0); QString colorname = getSettingsValue("syntaxhighlighter", name + "_colour").toString(); QColor color = QColor(colorname); ui->treeSyntaxHighlighting->topLevelItem(i)->setTextColor(2, color); ui->treeSyntaxHighlighting->topLevelItem(i)->setBackgroundColor(2, color); ui->treeSyntaxHighlighting->topLevelItem(i)->setText(2, colorname); if (name != "null") { ui->treeSyntaxHighlighting->topLevelItem(i)->setCheckState(3, getSettingsValue("syntaxhighlighter", name + "_bold").toBool() ? Qt::Checked : Qt::Unchecked); ui->treeSyntaxHighlighting->topLevelItem(i)->setCheckState(4, getSettingsValue("syntaxhighlighter", name + "_italic").toBool() ? Qt::Checked : Qt::Unchecked); ui->treeSyntaxHighlighting->topLevelItem(i)->setCheckState(5, getSettingsValue("syntaxhighlighter", name + "_underline").toBool() ? Qt::Checked : Qt::Unchecked); } } ui->comboEditorFont->setCurrentIndex(ui->comboEditorFont->findText(getSettingsValue("editor", "font").toString())); ui->spinEditorFontSize->setValue(getSettingsValue("editor", "fontsize").toInt()); ui->spinTabSize->setValue(getSettingsValue("editor", "tabsize").toInt()); ui->spinLogFontSize->setValue(getSettingsValue("log", "fontsize").toInt()); ui->listExtensions->addItems(getSettingsValue("extensions", "list").toStringList()); ui->checkRegexDisabled->setChecked(getSettingsValue("extensions", "disableregex").toBool()); fillLanguageBox(); }
void PreferencesDialog::loadSettings() { ui->encodingComboBox->setCurrentIndex(ui->encodingComboBox->findText(Settings::getValue("db", "defaultencoding").toString(), Qt::MatchFixedString)); ui->comboDefaultLocation->setCurrentIndex(Settings::getValue("db", "savedefaultlocation").toInt()); ui->locationEdit->setText(Settings::getValue("db", "defaultlocation").toString()); ui->checkUpdates->setChecked(Settings::getValue("checkversion", "enabled").toBool()); ui->checkHideSchemaLinebreaks->setChecked(Settings::getValue("db", "hideschemalinebreaks").toBool()); ui->foreignKeysCheckBox->setChecked(Settings::getValue("db", "foreignkeys").toBool()); ui->spinPrefetchSize->setValue(Settings::getValue("db", "prefetchsize").toInt()); ui->editDatabaseDefaultSqlText->setText(Settings::getValue("db", "defaultsqltext").toString()); ui->defaultFieldTypeComboBox->addItems(DBBrowserDB::Datatypes); int defaultFieldTypeIndex = Settings::getValue("db", "defaultfieldtype").toInt(); if (defaultFieldTypeIndex < DBBrowserDB::Datatypes.count()) { ui->defaultFieldTypeComboBox->setCurrentIndex(defaultFieldTypeIndex); } // Gracefully handle the preferred Data Browser font not being available int matchingFont = ui->comboDataBrowserFont->findText(Settings::getValue("databrowser", "font").toString(), Qt::MatchExactly); if (matchingFont == -1) matchingFont = ui->comboDataBrowserFont->findText(Settings::getDefaultValue("databrowser", "font").toString()); ui->comboDataBrowserFont->setCurrentIndex(matchingFont); ui->spinDataBrowserFontSize->setValue(Settings::getValue("databrowser", "fontsize").toInt()); loadColorSetting(ui->fr_null_fg, "null_fg"); loadColorSetting(ui->fr_null_bg, "null_bg"); loadColorSetting(ui->fr_bin_fg, "bin_fg"); loadColorSetting(ui->fr_bin_bg, "bin_bg"); loadColorSetting(ui->fr_reg_fg, "reg_fg"); loadColorSetting(ui->fr_reg_bg, "reg_bg"); ui->spinSymbolLimit->setValue(Settings::getValue("databrowser", "symbol_limit").toInt()); ui->spinCompleteThreshold->setValue(Settings::getValue("databrowser", "complete_threshold").toInt()); ui->txtNull->setText(Settings::getValue("databrowser", "null_text").toString()); ui->txtBlob->setText(Settings::getValue("databrowser", "blob_text").toString()); ui->editFilterEscape->setText(Settings::getValue("databrowser", "filter_escape").toString()); ui->spinFilterDelay->setValue(Settings::getValue("databrowser", "filter_delay").toInt()); for(int i=0; i < ui->treeSyntaxHighlighting->topLevelItemCount(); ++i) { std::string name = ui->treeSyntaxHighlighting->topLevelItem(i)->text(0).toStdString(); QString colorname = Settings::getValue("syntaxhighlighter", name + "_colour").toString(); QColor color = QColor(colorname); ui->treeSyntaxHighlighting->topLevelItem(i)->setTextColor(2, color); ui->treeSyntaxHighlighting->topLevelItem(i)->setBackgroundColor(2, color); ui->treeSyntaxHighlighting->topLevelItem(i)->setText(2, colorname); if (name != "null" && name != "currentline" && name != "background" && name != "foreground") { ui->treeSyntaxHighlighting->topLevelItem(i)->setCheckState(3, Settings::getValue("syntaxhighlighter", name + "_bold").toBool() ? Qt::Checked : Qt::Unchecked); ui->treeSyntaxHighlighting->topLevelItem(i)->setCheckState(4, Settings::getValue("syntaxhighlighter", name + "_italic").toBool() ? Qt::Checked : Qt::Unchecked); ui->treeSyntaxHighlighting->topLevelItem(i)->setCheckState(5, Settings::getValue("syntaxhighlighter", name + "_underline").toBool() ? Qt::Checked : Qt::Unchecked); } } // Remote settings ui->checkUseRemotes->setChecked(Settings::getValue("remote", "active").toBool()); { auto ca_certs = static_cast<Application*>(qApp)->mainWindow()->getRemote().caCertificates(); ui->tableCaCerts->setRowCount(ca_certs.size()); for(int i=0;i<ca_certs.size();i++) { QSslCertificate cert = ca_certs.at(i); QTableWidgetItem* cert_cn = new QTableWidgetItem(cert.subjectInfo(QSslCertificate::CommonName).at(0)); cert_cn->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); ui->tableCaCerts->setItem(i, 0, cert_cn); QTableWidgetItem* cert_o = new QTableWidgetItem(cert.subjectInfo(QSslCertificate::Organization).at(0)); cert_o->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); ui->tableCaCerts->setItem(i, 1, cert_o); QTableWidgetItem* cert_from = new QTableWidgetItem(cert.effectiveDate().toString()); cert_from->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); ui->tableCaCerts->setItem(i, 2, cert_from); QTableWidgetItem* cert_to = new QTableWidgetItem(cert.expiryDate().toString()); cert_to->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); ui->tableCaCerts->setItem(i, 3, cert_to); QTableWidgetItem* cert_serialno = new QTableWidgetItem(QString(cert.serialNumber())); cert_serialno->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); ui->tableCaCerts->setItem(i, 4, cert_serialno); } } { QStringList client_certs = Settings::getValue("remote", "client_certificates").toStringList(); for(const QString& file : client_certs) { auto certs = QSslCertificate::fromPath(file); for(const QSslCertificate& cert : certs) addClientCertToTable(file, cert); } } ui->editRemoteCloneDirectory->setText(Settings::getValue("remote", "clonedirectory").toString()); // Gracefully handle the preferred Editor font not being available matchingFont = ui->comboEditorFont->findText(Settings::getValue("editor", "font").toString(), Qt::MatchExactly); if (matchingFont == -1) matchingFont = ui->comboDataBrowserFont->findText(Settings::getDefaultValue("editor", "font").toString()); ui->comboEditorFont->setCurrentIndex(matchingFont); ui->spinEditorFontSize->setValue(Settings::getValue("editor", "fontsize").toInt()); ui->spinTabSize->setValue(Settings::getValue("editor", "tabsize").toInt()); ui->spinLogFontSize->setValue(Settings::getValue("log", "fontsize").toInt()); ui->wrapComboBox->setCurrentIndex(Settings::getValue("editor", "wrap_lines").toInt()); ui->quoteComboBox->setCurrentIndex(Settings::getValue("editor", "identifier_quotes").toInt()); ui->checkAutoCompletion->setChecked(Settings::getValue("editor", "auto_completion").toBool()); ui->checkCompleteUpper->setEnabled(Settings::getValue("editor", "auto_completion").toBool()); ui->checkCompleteUpper->setChecked(Settings::getValue("editor", "upper_keywords").toBool()); ui->checkErrorIndicators->setChecked(Settings::getValue("editor", "error_indicators").toBool()); ui->checkHorizontalTiling->setChecked(Settings::getValue("editor", "horizontal_tiling").toBool()); ui->listExtensions->addItems(Settings::getValue("extensions", "list").toStringList()); ui->checkRegexDisabled->setChecked(Settings::getValue("extensions", "disableregex").toBool()); ui->checkAllowLoadExtension->setChecked(Settings::getValue("extensions", "enable_load_extension").toBool()); fillLanguageBox(); ui->appStyleCombo->setCurrentIndex(Settings::getValue("General", "appStyle").toInt()); ui->toolbarStyleComboMain->setCurrentIndex(Settings::getValue("General", "toolbarStyle").toInt()); ui->toolbarStyleComboStructure->setCurrentIndex(Settings::getValue("General", "toolbarStyleStructure").toInt()); ui->toolbarStyleComboBrowse->setCurrentIndex(Settings::getValue("General", "toolbarStyleBrowse").toInt()); ui->toolbarStyleComboSql->setCurrentIndex(Settings::getValue("General", "toolbarStyleSql").toInt()); ui->toolbarStyleComboEditCell->setCurrentIndex(Settings::getValue("General", "toolbarStyleEditCell").toInt()); }