Add option for horizontal tiling between code editor and result view · Processoriented/sqlitebrowser@c235379 · GitHub
Skip to content

Commit c235379

Browse files
committed
Add option for horizontal tiling between code editor and result view
Add a new option to the Preferences Dialog which activates horizontal tiling between the SQL code editor and the result view in the Execute SQL tab, i.e. the two widgets are shown side by side instead of one over the other. See issue sqlitebrowser#380.
1 parent 6806a9b commit c235379

5 files changed

Lines changed: 56 additions & 12 deletions

File tree

‎src/MainWindow.cpp‎

Lines changed: 1 addition & 1 deletion

‎src/PreferencesDialog.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ void PreferencesDialog::loadSettings()
9090
ui->spinTabSize->setValue(getSettingsValue("editor", "tabsize").toInt());
9191
ui->spinLogFontSize->setValue(getSettingsValue("log", "fontsize").toInt());
9292
ui->checkErrorIndicators->setChecked(getSettingsValue("editor", "error_indicators").toBool());
93+
ui->checkHorizontalTiling->setChecked(getSettingsValue("editor", "horizontal_tiling").toBool());
9394

9495
ui->listExtensions->addItems(getSettingsValue("extensions", "list").toStringList());
9596
ui->checkRegexDisabled->setChecked(getSettingsValue("extensions", "disableregex").toBool());
@@ -128,6 +129,7 @@ void PreferencesDialog::saveSettings()
128129
setSettingsValue("editor", "tabsize", ui->spinTabSize->value());
129130
setSettingsValue("log", "fontsize", ui->spinLogFontSize->value());
130131
setSettingsValue("editor", "error_indicators", ui->checkErrorIndicators->isChecked());
132+
setSettingsValue("editor", "horizontal_tiling", ui->checkHorizontalTiling->isChecked());
131133

132134
QStringList extList;
133135
foreach(QListWidgetItem* item, ui->listExtensions->findItems(QString("*"), Qt::MatchWrap | Qt::MatchWildcard))
@@ -309,6 +311,10 @@ QVariant PreferencesDialog::getSettingsDefaultValue(const QString& group, const
309311
if(group == "editor" && name == "error_indicators")
310312
return true;
311313

314+
// editor/horizontal_tiling?
315+
if(group == "editor" && name == "horizontal_tiling")
316+
return false;
317+
312318
// extensions/list?
313319
if(group == "extensions" && name == "list")
314320
return QStringList();

‎src/PreferencesDialog.ui‎

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ QGroupBox::title {
737737
<item row="3" column="0">
738738
<widget class="QLabel" name="label_13">
739739
<property name="text">
740-
<string>Tab size:</string>
740+
<string>Tab size</string>
741741
</property>
742742
<property name="buddy">
743743
<cstring>spinTabSize</cstring>
@@ -790,6 +790,26 @@ QGroupBox::title {
790790
</property>
791791
</widget>
792792
</item>
793+
<item row="5" column="0">
794+
<widget class="QLabel" name="label_10">
795+
<property name="text">
796+
<string>Horizontal tiling</string>
797+
</property>
798+
<property name="buddy">
799+
<cstring>checkHorizontalTiling</cstring>
800+
</property>
801+
</widget>
802+
</item>
803+
<item row="5" column="1">
804+
<widget class="QCheckBox" name="checkHorizontalTiling">
805+
<property name="toolTip">
806+
<string>If enabled the SQL code editor and the result table view are shown side by side instead of one over the other.</string>
807+
</property>
808+
<property name="text">
809+
<string>enabled</string>
810+
</property>
811+
</widget>
812+
</item>
793813
</layout>
794814
</item>
795815
</layout>
@@ -886,6 +906,7 @@ QGroupBox::title {
886906
</layout>
887907
</widget>
888908
<tabstops>
909+
<tabstop>tabWidget</tabstop>
889910
<tabstop>comboDefaultLocation</tabstop>
890911
<tabstop>locationEdit</tabstop>
891912
<tabstop>setLocationButton</tabstop>
@@ -908,6 +929,7 @@ QGroupBox::title {
908929
<tabstop>spinLogFontSize</tabstop>
909930
<tabstop>spinTabSize</tabstop>
910931
<tabstop>checkErrorIndicators</tabstop>
932+
<tabstop>checkHorizontalTiling</tabstop>
911933
<tabstop>listExtensions</tabstop>
912934
<tabstop>buttonAddExtension</tabstop>
913935
<tabstop>buttonRemoveExtension</tabstop>
@@ -956,8 +978,8 @@ QGroupBox::title {
956978
<slot>addExtension()</slot>
957979
<hints>
958980
<hint type="sourcelabel">
959-
<x>567</x>
960-
<y>88</y>
981+
<x>119</x>
982+
<y>79</y>
961983
</hint>
962984
<hint type="destinationlabel">
963985
<x>245</x>
@@ -972,8 +994,8 @@ QGroupBox::title {
972994
<slot>removeExtension()</slot>
973995
<hints>
974996
<hint type="sourcelabel">
975-
<x>567</x>
976-
<y>117</y>
997+
<x>119</x>
998+
<y>79</y>
977999
</hint>
9781000
<hint type="destinationlabel">
9791001
<x>245</x>

‎src/SqlExecutionArea.cpp‎

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ SqlExecutionArea::SqlExecutionArea(QWidget* parent, DBBrowserDB* _db) :
1919
// Create UI
2020
ui->setupUi(this);
2121

22-
// Set font
23-
QFont logfont(PreferencesDialog::getSettingsValue("editor", "font").toString());
24-
logfont.setStyleHint(QFont::TypeWriter);
25-
logfont.setPointSize(PreferencesDialog::getSettingsValue("log", "fontsize").toInt());
26-
ui->editErrors->setFont(logfont);
27-
2822
// Create model
2923
model = new SqliteTableModel(this, db, PreferencesDialog::getSettingsValue("db", "prefetchsize").toInt());
3024
ui->tableResult->setModel(model);
@@ -34,6 +28,9 @@ SqlExecutionArea::SqlExecutionArea(QWidget* parent, DBBrowserDB* _db) :
3428
menuPopupSave->addAction(ui->actionExportCsv);
3529
menuPopupSave->addAction(ui->actionSaveAsView);
3630
ui->buttonSave->setMenu(menuPopupSave);
31+
32+
// Load settings
33+
reloadSettings();
3734
}
3835

3936
SqlExecutionArea::~SqlExecutionArea()
@@ -108,3 +105,21 @@ void SqlExecutionArea::saveAsView()
108105
else
109106
QMessageBox::warning(this, qApp->applicationName(), tr("Error creating view: %1").arg(db->lastErrorMessage));
110107
}
108+
109+
void SqlExecutionArea::reloadSettings()
110+
{
111+
// Reload editor settings
112+
ui->editEditor->reloadSettings();
113+
114+
// Set font
115+
QFont logfont(PreferencesDialog::getSettingsValue("editor", "font").toString());
116+
logfont.setStyleHint(QFont::TypeWriter);
117+
logfont.setPointSize(PreferencesDialog::getSettingsValue("log", "fontsize").toInt());
118+
ui->editErrors->setFont(logfont);
119+
120+
// Apply horizontal/vertical tiling option
121+
if(PreferencesDialog::getSettingsValue("editor", "horizontal_tiling").toBool())
122+
ui->splitter->setOrientation(Qt::Horizontal);
123+
else
124+
ui->splitter->setOrientation(Qt::Vertical);
125+
}

‎src/SqlExecutionArea.h‎

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)