Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
forked from 陈炳煌/sqlitebrowser
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (16)
Tags (31)
master
coverity_scan
v3.11.x
issue1831_v1
qdarkstyle
no_savepoints_ro_db
v3.10.x
v3.9.x
v3.6.x
v3.5.x
v3.4.x
v3.3.x
utf8grammar
sqlb-3.2.x
sqlb-3.1.x
sqlb-3.x
continuous
v3.11.2
v3.11.1v2
v3.11.1
v3.11.0
v3.11.0-beta3
v3.11.0-beta2
v3.11.0-beta1
v3.11.0-alpha1
v3.10.1
v3.10.0
v3.10.0-beta2
v3.10.0-beta1
v3.9.1
v3.9.0
v3.9.0-beta1
v3.8.0
v3.7.0
v3.6.0
v3.5.1
master
Branches (16)
Tags (31)
master
coverity_scan
v3.11.x
issue1831_v1
qdarkstyle
no_savepoints_ro_db
v3.10.x
v3.9.x
v3.6.x
v3.5.x
v3.4.x
v3.3.x
utf8grammar
sqlb-3.2.x
sqlb-3.1.x
sqlb-3.x
continuous
v3.11.2
v3.11.1v2
v3.11.1
v3.11.0
v3.11.0-beta3
v3.11.0-beta2
v3.11.0-beta1
v3.11.0-alpha1
v3.10.1
v3.10.0
v3.10.0-beta2
v3.10.0-beta1
v3.9.1
v3.9.0
v3.9.0-beta1
v3.8.0
v3.7.0
v3.6.0
v3.5.1
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (16)
Tags (31)
master
coverity_scan
v3.11.x
issue1831_v1
qdarkstyle
no_savepoints_ro_db
v3.10.x
v3.9.x
v3.6.x
v3.5.x
v3.4.x
v3.3.x
utf8grammar
sqlb-3.2.x
sqlb-3.1.x
sqlb-3.x
continuous
v3.11.2
v3.11.1v2
v3.11.1
v3.11.0
v3.11.0-beta3
v3.11.0-beta2
v3.11.0-beta1
v3.11.0-alpha1
v3.10.1
v3.10.0
v3.10.0-beta2
v3.10.0-beta1
v3.9.1
v3.9.0
v3.9.0-beta1
v3.8.0
v3.7.0
v3.6.0
v3.5.1
sqlitebrowser
/
src
/
PreferencesDialog.cpp
sqlitebrowser
/
src
/
PreferencesDialog.cpp
PreferencesDialog.cpp 30.07 KB
Copy Edit Raw Blame History
Martin Kleusberg authored 2019年05月09日 21:11 +08:00 . dbhub: Add proxy configuration support
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683
#include "PreferencesDialog.h"
#include "ui_PreferencesDialog.h"
#include "FileDialog.h"
#include "Settings.h"
#include "Application.h"
#include "MainWindow.h"
#include "RemoteDatabase.h"
#include "FileExtensionManager.h"
#include "ProxyDialog.h"
#include <QDir>
#include <QColorDialog>
#include <QMessageBox>
#include <QKeyEvent>
#include <QStandardPaths>
PreferencesDialog::PreferencesDialog(QWidget* parent, Tabs tab)
: QDialog(parent),
ui(new Ui::PreferencesDialog),
m_proxyDialog(new ProxyDialog(this)),
m_dbFileExtensions(Settings::getValue("General", "DBFileExtensions").toString().split(";;"))
{
ui->setupUi(this);
ui->treeSyntaxHighlighting->setColumnHidden(0, true);
ui->labelDatabaseDefaultSqlText->setVisible(false);
ui->editDatabaseDefaultSqlText->setVisible(false);
ui->tableClientCerts->setColumnHidden(0, true);
ui->fr_bin_bg->installEventFilter(this);
ui->fr_bin_fg->installEventFilter(this);
ui->fr_reg_bg->installEventFilter(this);
ui->fr_reg_fg->installEventFilter(this);
ui->fr_null_bg->installEventFilter(this);
ui->fr_null_fg->installEventFilter(this);
connect(ui->comboDataBrowserFont, SIGNAL(currentIndexChanged(int)), this, SLOT(updatePreviewFont()));
connect(ui->spinDataBrowserFontSize, SIGNAL(valueChanged(int)), this, SLOT(updatePreviewFont()));
#ifndef CHECKNEWVERSION
ui->labelUpdates->setVisible(false);
ui->checkUpdates->setVisible(false);
#endif
loadSettings();
connect(ui->appStyleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(adjustColorsToStyle(int)));
// Avoid different heights due to having check boxes or not
ui->treeSyntaxHighlighting->setUniformRowHeights(true);
// Set current tab
ui->tabWidget->setCurrentIndex(tab);
}
/*
* Destroys the object and frees any allocated resources
*/
PreferencesDialog::~PreferencesDialog()
{
delete ui;
}
void PreferencesDialog::chooseLocation()
{
QString s = FileDialog::getExistingDirectory(
NoSpecificType,
this,
tr("Choose a directory"),
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if(!s.isEmpty())
ui->locationEdit->setText(s);
}
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());
}
void PreferencesDialog::saveSettings()
{
QApplication::setOverrideCursor(Qt::WaitCursor);
Settings::setValue("db", "defaultencoding", ui->encodingComboBox->currentText());
Settings::setValue("db", "defaultlocation", ui->locationEdit->text());
Settings::setValue("db", "savedefaultlocation", ui->comboDefaultLocation->currentIndex());
Settings::setValue("db", "hideschemalinebreaks", ui->checkHideSchemaLinebreaks->isChecked());
Settings::setValue("db", "foreignkeys", ui->foreignKeysCheckBox->isChecked());
Settings::setValue("db", "prefetchsize", ui->spinPrefetchSize->value());
Settings::setValue("db", "defaultsqltext", ui->editDatabaseDefaultSqlText->text());
Settings::setValue("db", "defaultfieldtype", ui->defaultFieldTypeComboBox->currentIndex());
Settings::setValue("checkversion", "enabled", ui->checkUpdates->isChecked());
Settings::setValue("databrowser", "font", ui->comboDataBrowserFont->currentText());
Settings::setValue("databrowser", "fontsize", ui->spinDataBrowserFontSize->value());
saveColorSetting(ui->fr_null_fg, "null_fg");
saveColorSetting(ui->fr_null_bg, "null_bg");
saveColorSetting(ui->fr_reg_fg, "reg_fg");
saveColorSetting(ui->fr_reg_bg, "reg_bg");
saveColorSetting(ui->fr_bin_fg, "bin_fg");
saveColorSetting(ui->fr_bin_bg, "bin_bg");
Settings::setValue("databrowser", "symbol_limit", ui->spinSymbolLimit->value());
Settings::setValue("databrowser", "complete_threshold", ui->spinCompleteThreshold->value());
Settings::setValue("databrowser", "null_text", ui->txtNull->text());
Settings::setValue("databrowser", "blob_text", ui->txtBlob->text());
Settings::setValue("databrowser", "filter_escape", ui->editFilterEscape->text());
Settings::setValue("databrowser", "filter_delay", ui->spinFilterDelay->value());
for(int i=0; i < ui->treeSyntaxHighlighting->topLevelItemCount(); ++i)
{
std::string name = ui->treeSyntaxHighlighting->topLevelItem(i)->text(0).toStdString();
Settings::setValue("syntaxhighlighter", name + "_colour", ui->treeSyntaxHighlighting->topLevelItem(i)->text(2));
Settings::setValue("syntaxhighlighter", name + "_bold", ui->treeSyntaxHighlighting->topLevelItem(i)->checkState(3) == Qt::Checked);
Settings::setValue("syntaxhighlighter", name + "_italic", ui->treeSyntaxHighlighting->topLevelItem(i)->checkState(4) == Qt::Checked);
Settings::setValue("syntaxhighlighter", name + "_underline", ui->treeSyntaxHighlighting->topLevelItem(i)->checkState(5) == Qt::Checked);
}
Settings::setValue("editor", "font", ui->comboEditorFont->currentText());
Settings::setValue("editor", "fontsize", ui->spinEditorFontSize->value());
Settings::setValue("editor", "tabsize", ui->spinTabSize->value());
Settings::setValue("log", "fontsize", ui->spinLogFontSize->value());
Settings::setValue("editor", "wrap_lines", ui->wrapComboBox->currentIndex());
Settings::setValue("editor", "identifier_quotes", ui->quoteComboBox->currentIndex());
Settings::setValue("editor", "auto_completion", ui->checkAutoCompletion->isChecked());
Settings::setValue("editor", "upper_keywords", ui->checkCompleteUpper->isChecked());
Settings::setValue("editor", "error_indicators", ui->checkErrorIndicators->isChecked());
Settings::setValue("editor", "horizontal_tiling", ui->checkHorizontalTiling->isChecked());
QStringList extList;
for(const QListWidgetItem* item : ui->listExtensions->findItems(QString("*"), Qt::MatchWrap | Qt::MatchWildcard))
extList.append(item->text());
Settings::setValue("extensions", "list", extList);
Settings::setValue("extensions", "disableregex", ui->checkRegexDisabled->isChecked());
Settings::setValue("extensions", "enable_load_extension", ui->checkAllowLoadExtension->isChecked());
// Save remote settings
Settings::setValue("remote", "active", ui->checkUseRemotes->isChecked());
QStringList old_client_certs = Settings::getValue("remote", "client_certificates").toStringList();
QStringList new_client_certs;
for(int i=0;i<ui->tableClientCerts->rowCount();i++)
{
// Loop through the new list of client certs
// If this certificate was already imported, remove it from the list of old certificates. All remaining certificates on this
// list will be deleted later on.
QString path = ui->tableClientCerts->item(i, 0)->text();
if(old_client_certs.contains(path))
{
// This is a cert that is already imported
old_client_certs.removeAll(path);
new_client_certs.push_back(path);
} else {
// This is a new certificate. Copy file to a safe place.
// Generate unique destination file name
QString copy_to = QStandardPaths::writableLocation(
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
QStandardPaths::AppDataLocation
#else
QStandardPaths::GenericDataLocation
#endif
).append("/").append(QFileInfo(path).fileName());
int suffix = 0;
do
{
suffix++;
} while(QFile::exists(copy_to + QString::number(suffix)));
// Copy file
copy_to.append(QString::number(suffix));
QDir().mkpath(QStandardPaths::writableLocation(
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
QStandardPaths::AppDataLocation
#else
QStandardPaths::GenericDataLocation
#endif
));
QFile::copy(path, copy_to);
new_client_certs.push_back(copy_to);
}
}
for(const QString& file : old_client_certs)
{
// Now only the deleted client certs are still in the old list. Delete the cert files associated with them.
QFile::remove(file);
}
Settings::setValue("remote", "client_certificates", new_client_certs);
Settings::setValue("remote", "clonedirectory", ui->editRemoteCloneDirectory->text());
// Warn about restarting to change language
QVariant newLanguage = ui->languageComboBox->itemData(ui->languageComboBox->currentIndex());
if (newLanguage != Settings::getValue("General", "language"))
QMessageBox::information(this, QApplication::applicationName(),
tr("The language will change after you restart the application."));
Settings::setValue("General", "language", newLanguage);
Settings::setValue("General", "appStyle", ui->appStyleCombo->currentIndex());
Settings::setValue("General", "toolbarStyle", ui->toolbarStyleComboMain->currentIndex());
Settings::setValue("General", "toolbarStyleStructure", ui->toolbarStyleComboStructure->currentIndex());
Settings::setValue("General", "toolbarStyleBrowse", ui->toolbarStyleComboBrowse->currentIndex());
Settings::setValue("General", "toolbarStyleSql", ui->toolbarStyleComboSql->currentIndex());
Settings::setValue("General", "toolbarStyleEditCell", ui->toolbarStyleComboEditCell->currentIndex());
Settings::setValue("General", "DBFileExtensions", m_dbFileExtensions.join(";;") );
m_proxyDialog->saveSettings();
accept();
QApplication::restoreOverrideCursor();
}
void PreferencesDialog::showColourDialog(QTreeWidgetItem* item, int column)
{
if(item->text(column).left(1) != "#")
return;
QColor colour = QColorDialog::getColor(QColor(item->text(column)), this);
if(colour.isValid())
{
item->setTextColor(column, colour);
item->setBackgroundColor(column, colour);
item->setText(column, colour.name());
}
}
bool PreferencesDialog::eventFilter(QObject *obj, QEvent *event)
{
// Use mouse click and enter press on the frames to pop up a colour dialog
if (obj == ui->fr_bin_bg || obj == ui->fr_bin_fg ||
obj == ui->fr_reg_bg || obj == ui->fr_reg_fg ||
obj == ui->fr_null_bg || obj == ui->fr_null_fg)
{
if (event->type() == QEvent::KeyPress)
{
QKeyEvent *key = static_cast<QKeyEvent *>(event);
// Not interesting, so send to the parent (might be shortcuts)
if((key->key() != Qt::Key_Enter) && (key->key() != Qt::Key_Return))
{
return QDialog::eventFilter(obj, event);
}
}
else if (event->type() != QEvent::MouseButtonPress)
{
// Not a key event neither a mouse event, send to the parent
return QDialog::eventFilter(obj, event);
}
QFrame *frame = qobject_cast<QFrame *>(obj);
QColor oldColour = frame->palette().color(frame->backgroundRole());
QColor colour = QColorDialog::getColor(oldColour, frame);
if (colour.isValid())
{
setColorSetting(frame, colour);
}
// Consume
return true;
}
// Send any other events to the parent
return QDialog::eventFilter(obj, event);
}
void PreferencesDialog::addExtension()
{
QString file = FileDialog::getOpenFileName(
OpenExtensionFile,
this,
tr("Select extension file"),
tr("Extensions(*.so *.dylib *.dll);;All files(*)"));
if(QFile::exists(file))
ui->listExtensions->addItem(file);
}
void PreferencesDialog::removeExtension()
{
if(ui->listExtensions->currentIndex().isValid())
ui->listExtensions->takeItem(ui->listExtensions->currentIndex().row());
}
void PreferencesDialog::fillLanguageBox()
{
QDir translationsDir(QCoreApplication::applicationDirPath() + "/translations",
"sqlb_*.qm");
QLocale systemLocale = QLocale::system();
// Add default language
if (systemLocale.name() == "en_US")
{
ui->languageComboBox->addItem(QIcon(":/flags/en_US"),
"English (United States) [System Language]",
"en_US");
}
else
{
ui->languageComboBox->addItem(QIcon(":/flags/en_US"),
"English (United States) [Default Language]",
"en_US");
}
// Get available *.qm files from translation dir near executable as well as from resources
QFileInfoList file_infos = translationsDir.entryInfoList();
file_infos += QDir(":/translations").entryInfoList();
for(const QFileInfo& file : file_infos)
{
QLocale locale(file.baseName().remove("sqlb_"));
// Skip invalid locales
if(locale.name() == "C")
continue;
// Skip translations that were already loaded
if (ui->languageComboBox->findData(locale.name(), Qt::UserRole, Qt::MatchExactly) != -1)
continue;
QString language = QLocale::languageToString(locale.language()) + " (" +
QLocale::countryToString(locale.country()) + ")";
if (locale == systemLocale)
language += " [System language]";
ui->languageComboBox->addItem(QIcon(":/flags/" + locale.name()), language, locale.name());
}
ui->languageComboBox->model()->sort(0);
// Try to select the language for the stored locale
int index = ui->languageComboBox->findData(Settings::getValue("General", "language"),
Qt::UserRole, Qt::MatchExactly);
// If there's no translation for the current locale, default to English
if(index < 0)
index = ui->languageComboBox->findData("en_US", Qt::UserRole, Qt::MatchExactly);
QString chosenLanguage = ui->languageComboBox->itemText(index);
QVariant chosenLocale = ui->languageComboBox->itemData(index);
QIcon chosenIcon = ui->languageComboBox->itemIcon(index);
// There's no "move" method, so we remove and add the chosen language again at the top
ui->languageComboBox->removeItem(index);
ui->languageComboBox->insertItem(0, chosenIcon, chosenLanguage, chosenLocale);
ui->languageComboBox->setCurrentIndex(0);
}
void PreferencesDialog::loadColorSetting(QFrame *frame, const std::string& settingName)
{
QColor color = QColor(Settings::getValue("databrowser", settingName + "_colour").toString());
setColorSetting(frame, color);
}
void PreferencesDialog::setColorSetting(QFrame *frame, const QColor &color)
{
QPalette::ColorRole role;
QString style;
QLineEdit *line;
if (frame == ui->fr_bin_bg) {
line = ui->txtBlob;
role = line->backgroundRole();
style = QString("background-color");
} else if (frame == ui->fr_bin_fg) {
line = ui->txtBlob;
role = line->foregroundRole();
style = QString("color");
} else if (frame == ui->fr_reg_bg) {
line = ui->txtRegular;
role = line->backgroundRole();
style = QString("background-color");
} else if (frame == ui->fr_reg_fg) {
line = ui->txtRegular;
role = line->foregroundRole();
style = QString("color");
} else if (frame == ui->fr_null_bg) {
line = ui->txtNull;
role = line->backgroundRole();
style = QString("background-color");
} else if (frame == ui->fr_null_fg) {
line = ui->txtNull;
role = line->foregroundRole();
style = QString("color");
} else
return;
QPalette palette = frame->palette();
palette.setColor(frame->backgroundRole(), color);
frame->setPalette(palette);
frame->setStyleSheet(QString(".QFrame {background-color: %2}").arg(color.name()));
palette = line->palette();
palette.setColor(role, color);
line->setPalette(palette);
line->setStyleSheet(QString(".QLineEdit {color: %1; background-color: %2}").arg(palette.color(line->foregroundRole()).name(),
palette.color(line->backgroundRole()).name()));
}
void PreferencesDialog::saveColorSetting(QFrame* frame, const std::string& settingName)
{
Settings::setValue("databrowser", settingName + "_colour",
frame->palette().color(frame->backgroundRole()));
}
void PreferencesDialog::adjustColorsToStyle(int style)
{
Settings::AppStyle appStyle = static_cast<Settings::AppStyle>(style);
setColorSetting(ui->fr_null_fg, Settings::getDefaultColorValue("databrowser", "null_fg_colour", appStyle));
setColorSetting(ui->fr_null_bg, Settings::getDefaultColorValue("databrowser", "null_bg_colour", appStyle));
setColorSetting(ui->fr_bin_fg, Settings::getDefaultColorValue("databrowser", "bin_fg_colour", appStyle));
setColorSetting(ui->fr_bin_bg, Settings::getDefaultColorValue("databrowser", "bin_bg_colour", appStyle));
setColorSetting(ui->fr_reg_fg, Settings::getDefaultColorValue("databrowser", "reg_fg_colour", appStyle));
setColorSetting(ui->fr_reg_bg, Settings::getDefaultColorValue("databrowser", "reg_bg_colour", appStyle));
for(int i=0; i < ui->treeSyntaxHighlighting->topLevelItemCount(); ++i)
{
std::string name = ui->treeSyntaxHighlighting->topLevelItem(i)->text(0).toStdString();
QColor color = Settings::getDefaultColorValue("syntaxhighlighter", name + "_colour", appStyle);
ui->treeSyntaxHighlighting->topLevelItem(i)->setTextColor(2, color);
ui->treeSyntaxHighlighting->topLevelItem(i)->setBackgroundColor(2, color);
ui->treeSyntaxHighlighting->topLevelItem(i)->setText(2, color.name());
}
}
void PreferencesDialog::activateRemoteTab(bool active)
{
ui->tabWidget->setTabEnabled(ui->tabWidget->indexOf(ui->tabRemote), active);
}
void PreferencesDialog::addClientCertificate()
{
// Get certificate file to import and abort here if no file gets selected
// NOTE: We assume here that this file contains both, certificate and private key!
QString path = FileDialog::getOpenFileName(OpenCertificateFile, this, tr("Import certificate file"), "*.pem");
if(path.isEmpty())
return;
// Open file and check if any certificates were imported
auto certs = QSslCertificate::fromPath(path);
if(certs.size() == 0)
{
QMessageBox::warning(this, qApp->applicationName(), tr("No certificates found in this file."));
return;
}
// Add certificates to list
for(int i=0;i<certs.size();i++)
addClientCertToTable(path, certs.at(i));
}
void PreferencesDialog::removeClientCertificate()
{
// Any row selected?
int row = ui->tableClientCerts->currentRow();
if(row == -1)
return;
// Double check
if(QMessageBox::question(this, qApp->applicationName(), tr("Are you sure you want do remove this certificate? All certificate "
"data will be deleted from the application settings!"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)
{
ui->tableClientCerts->removeRow(row);
}
}
void PreferencesDialog::addClientCertToTable(const QString& path, const QSslCertificate& cert)
{
// Do nothing if the file doesn't even exist
if(!QFile::exists(path))
return;
// Add new row
int row = ui->tableClientCerts->rowCount();
ui->tableClientCerts->setRowCount(row + 1);
// Fill row with data
QTableWidgetItem* cert_file = new QTableWidgetItem(path);
cert_file->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
ui->tableClientCerts->setItem(row, 0, cert_file);
QTableWidgetItem* cert_subject_cn = new QTableWidgetItem(cert.subjectInfo(QSslCertificate::CommonName).at(0));
cert_subject_cn->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
ui->tableClientCerts->setItem(row, 1, cert_subject_cn);
QTableWidgetItem* cert_issuer_cn = new QTableWidgetItem(cert.issuerInfo(QSslCertificate::CommonName).at(0));
cert_issuer_cn->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
ui->tableClientCerts->setItem(row, 2, cert_issuer_cn);
QTableWidgetItem* cert_from = new QTableWidgetItem(cert.effectiveDate().toString());
cert_from->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
ui->tableClientCerts->setItem(row, 3, cert_from);
QTableWidgetItem* cert_to = new QTableWidgetItem(cert.expiryDate().toString());
cert_to->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
ui->tableClientCerts->setItem(row, 4, cert_to);
QTableWidgetItem* cert_serialno = new QTableWidgetItem(QString(cert.serialNumber()));
cert_serialno->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
ui->tableClientCerts->setItem(row, 5, cert_serialno);
}
void PreferencesDialog::chooseRemoteCloneDirectory()
{
QString s = FileDialog::getExistingDirectory(
NoSpecificType,
this,
tr("Choose a directory"),
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if(!s.isEmpty())
ui->editRemoteCloneDirectory->setText(s);
}
void PreferencesDialog::updatePreviewFont()
{
if (ui->spinDataBrowserFontSize->value() != 0) {
QFont textFont(ui->comboDataBrowserFont->currentText());
textFont.setPointSize(ui->spinDataBrowserFontSize->value());
ui->txtRegular->setFont(textFont);
textFont.setItalic(true);
ui->txtNull->setFont(textFont);
ui->txtBlob->setFont(textFont);
}
}
void PreferencesDialog::on_buttonManageFileExtension_clicked()
{
FileExtensionManager *manager = new FileExtensionManager(m_dbFileExtensions, this);
if(manager->exec() == QDialog::Accepted)
{
m_dbFileExtensions = manager->getDBFileExtensions();
}
}
void PreferencesDialog::on_buttonBox_clicked(QAbstractButton* button)
{
if (button == ui->buttonBox->button(QDialogButtonBox::Cancel))
reject();
else if (button == ui->buttonBox->button(QDialogButtonBox::Save))
saveSettings();
else if (button == ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)) {
if (QMessageBox::warning(this, QApplication::applicationName(), tr("Are you sure you want to clear all the saved settings?\nAll your preferences will be lost and default values will be used."),
QMessageBox::RestoreDefaults | QMessageBox::Cancel, QMessageBox::Cancel) == QMessageBox::RestoreDefaults)
{
Settings::restoreDefaults();
accept();
}
}
}
void PreferencesDialog::configureProxy()
{
m_proxyDialog->show();
}
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

Official home of the DB Browser for SQLite (DB4S) project. Previously known as "SQLite Database Browser" and "Database Browser for SQLite". Website at:
Cancel

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/my_open_source_software/sqlitebrowser.git
git@gitee.com:my_open_source_software/sqlitebrowser.git
my_open_source_software
sqlitebrowser
sqlitebrowser
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /