mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Save splitter sizes in the Execute SQL areas
Whenever the splitters between the SQL editor, the table result and the last execution results panes are moved, the sizes are saved to memory (for performance) so the next SQL tab to be opened restores them. When an area is destroyed the last saved settings are saved to disk, so they are ready for the next execution without much impact in disk utilisation. Issue #1889
This commit is contained in:
@@ -295,6 +295,14 @@ QVariant Settings::getDefaultValue(const std::string& group, const std::string&
|
||||
if(group == "editor" && name == "horizontal_tiling")
|
||||
return false;
|
||||
|
||||
// editor/splitter1_sizes?
|
||||
if(group == "editor" && name == "splitter1_sizes")
|
||||
return QVariant();
|
||||
|
||||
// editor/splitter2_sizes?
|
||||
if(group == "editor" && name == "splitter2_sizes")
|
||||
return QVariant();
|
||||
|
||||
// extensions/list?
|
||||
if(group == "extensions" && name == "list")
|
||||
return QStringList();
|
||||
|
||||
@@ -40,6 +40,14 @@ SqlExecutionArea::SqlExecutionArea(DBBrowserDB& _db, QWidget* parent) :
|
||||
|
||||
connect(&fileSystemWatch, &QFileSystemWatcher::fileChanged, this, &SqlExecutionArea::fileChanged);
|
||||
|
||||
// Save to settings when sppliter is moved, but only to memory.
|
||||
connect(ui->splitter, &QSplitter::splitterMoved, this, [this]() {
|
||||
Settings::setValue("editor", "splitter1_sizes", ui->splitter->saveState(), /* dont_save_to_disk */ true);
|
||||
});
|
||||
connect(ui->splitter_2, &QSplitter::splitterMoved, this, [this]() {
|
||||
Settings::setValue("editor", "splitter2_sizes", ui->splitter_2->saveState(), /* dont_save_to_disk */ true);
|
||||
});
|
||||
|
||||
// Set collapsible the editErrors panel
|
||||
ui->splitter_2->setCollapsible(1, true);
|
||||
|
||||
@@ -49,6 +57,10 @@ SqlExecutionArea::SqlExecutionArea(DBBrowserDB& _db, QWidget* parent) :
|
||||
|
||||
SqlExecutionArea::~SqlExecutionArea()
|
||||
{
|
||||
// Save to disk last stored splitter sizes
|
||||
Settings::setValue("editor", "splitter1_sizes", Settings::getValue("editor", "splitter1_sizes"));
|
||||
Settings::setValue("editor", "splitter2_sizes", Settings::getValue("editor", "splitter1_sizes"));
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@@ -134,6 +146,9 @@ void SqlExecutionArea::reloadSettings()
|
||||
else
|
||||
ui->splitter->setOrientation(Qt::Vertical);
|
||||
|
||||
ui->splitter->restoreState(Settings::getValue("editor", "splitter1_sizes").toByteArray());
|
||||
ui->splitter_2->restoreState(Settings::getValue("editor", "splitter2_sizes").toByteArray());
|
||||
|
||||
// Set prefetch settings
|
||||
model->setChunkSize(static_cast<std::size_t>(Settings::getValue("db", "prefetchsize").toUInt()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user