aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.cpp')
-rw-r--r--SQLiteStudio3/guiSQLiteStudio/dialogs/dbdialog.cpp28
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();