diff options
| author | 2025-01-16 01:58:22 -0500 | |
|---|---|---|
| committer | 2025-01-16 01:58:22 -0500 | |
| commit | a5ae79be08125b31bb6b8d9703090a98c6fd2e30 (patch) | |
| tree | 569ee612c9de85b2bb423efa485688ef1d43852e /SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.cpp | |
| parent | 21966b4f924b0a1933d9662e75ff253bd154fdb7 (diff) | |
| parent | 81a21e6ce040e7740de86340c8ea4dba30e69bc3 (diff) | |
Update upstream source from tag 'upstream/3.4.13+dfsg'
Update to upstream version '3.4.13+dfsg'
with Debian dir bf81ee0219cb8e4562a4751df17d75814772d2d6
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.cpp')
| -rw-r--r-- | SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.cpp b/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.cpp index e6a53db..2b85be3 100644 --- a/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.cpp @@ -145,6 +145,8 @@ void DbDialog::init() ui->testConnIcon->setVisible(false); + connect(ui->existingDatabaseRadio, SIGNAL(clicked()), this, SLOT(updateCreateMode())); + connect(ui->createDatabaseRadio, SIGNAL(clicked()), this, SLOT(updateCreateMode())); connect(ui->fileEdit, SIGNAL(textChanged(QString)), this, SLOT(fileChanged(QString))); connect(ui->nameEdit, SIGNAL(textEdited(QString)), this, SLOT(nameModified(QString))); connect(ui->browseOpenButton, SIGNAL(clicked()), this, SLOT(browseClicked())); @@ -172,7 +174,9 @@ void DbDialog::updateOptions() customBrowseHandler = nullptr; ui->pathGroup->setTitle(tr("File")); - ui->browseOpenButton->setToolTip(tr("Select new or existing file on local computer")); + ui->existingDatabaseRadio->setChecked(true); + ui->createDatabaseRadio->setChecked(false); + updateCreateMode(); optionWidgets.clear(); optionKeyToWidget.clear(); @@ -209,6 +213,10 @@ void DbDialog::addOption(const DbPluginOption& option, int& row) // This option does not add any editor, but has it's own label for path edit. row--; ui->pathGroup->setTitle(option.label); + ui->existingDatabaseRadio->setChecked(true); + ui->createDatabaseRadio->setChecked(false); + ui->createDatabaseRadio->setVisible(false); + updateCreateMode(); if (!option.toolTip.isEmpty()) ui->browseOpenButton->setToolTip(option.toolTip); @@ -567,6 +575,13 @@ bool DbDialog::validate() setValidState(ui->fileEdit, false, tr("Enter a database file path.")); fileState = false; } + else if (QFileInfo(getPath()).isRelative()) + { + setValidStateWarning(ui->fileEdit, + tr("You're using a relative file path, which will be resolved to \"%1\" according to the application's working directory. It's always better to use absolute file path to avoid unexpected database location.") + .arg(QFileInfo(getPath()).absoluteFilePath())); + fileState = false; + } if (fileState) { @@ -689,7 +704,7 @@ void DbDialog::browseClicked() else dir = getFileDialogInitPath(); - QString path = getDbPath(dir); + QString path = getDbPath(createMode, dir); if (path.isNull()) return; @@ -728,6 +743,15 @@ void DbDialog::nameModified(const QString &value) updateState(); } +void DbDialog::updateCreateMode() +{ + createMode = ui->createDatabaseRadio->isChecked(); + ui->browseOpenButton->setToolTip( + createMode ? tr("Choose a location for the new database file") + : tr("Browse for existing database file on local computer") + ); +} + void DbDialog::accept() { QString name = getName(); |
