Skip to content

Commit 29bfcc4

Browse files
committed
Add option for word wrapping in Edit Database Cell
A new option, in the toolbar of the Edit Database Cell, is added for setting word wrapping for the text editor modes. It is now independent of the SQL preference. The configuration reading the editor/wrap_lines setting is moved to the particular SQL editor class. Added icon from the Silk icon set. See issue #1796
1 parent fa66937 commit 29bfcc4

File tree

8 files changed

+54
-5
lines changed

8 files changed

+54
-5
lines changed

src/EditDialog.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include <QClipboard>
2323
#include <QTextDocument>
2424

25+
#include <Qsci/qsciscintilla.h>
26+
2527
EditDialog::EditDialog(QWidget* parent)
2628
: QDialog(parent),
2729
ui(new Ui::EditDialog),
@@ -65,6 +67,8 @@ EditDialog::EditDialog(QWidget* parent)
6567
ui->actionIndent->setChecked(mustIndentAndCompact);
6668

6769
ui->buttonAutoSwitchMode->setChecked(Settings::getValue("databrowser", "auto_switch_mode").toBool());
70+
ui->actionWordWrap->setChecked(Settings::getValue("databrowser", "editor_word_wrap").toBool());
71+
setWordWrapping(ui->actionWordWrap->isChecked());
6872

6973
reloadSettings();
7074
}
@@ -73,6 +77,7 @@ EditDialog::~EditDialog()
7377
{
7478
Settings::setValue("databrowser", "indent_compact", mustIndentAndCompact);
7579
Settings::setValue("databrowser", "auto_switch_mode", ui->buttonAutoSwitchMode->isChecked());
80+
Settings::setValue("databrowser", "editor_word_wrap", ui->actionWordWrap->isChecked());
7681
delete ui;
7782
}
7883

@@ -1012,3 +1017,9 @@ void EditDialog::copyHexAscii()
10121017
{
10131018
QApplication::clipboard()->setText(hexEdit->selectionToReadableString());
10141019
}
1020+
1021+
void EditDialog::setWordWrapping(bool value)
1022+
{
1023+
// Set wrap lines
1024+
sciEdit->setWrapMode(value ? QsciScintilla::WrapWord : QsciScintilla::WrapNone);
1025+
}

src/EditDialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ private slots:
4646
void openPrintDialog();
4747
void openPrintImageDialog();
4848
void copyHexAscii();
49+
void setWordWrapping(bool value);
4950

5051
signals:
5152
void recordTextUpdated(const QPersistentModelIndex& idx, const QByteArray& data, bool isBlob);

src/EditDialog.ui

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
</item>
116116
<item>
117117
<widget class="QToolBar" name="editCellToolbar">
118+
<addaction name="actionWordWrap"/>
118119
<addaction name="actionIndent"/>
119120
<addaction name="actionImport"/>
120121
<addaction name="actionExport"/>
@@ -150,8 +151,8 @@ Errors are indicated with a red squiggle underline.</string>
150151
<rect>
151152
<x>0</x>
152153
<y>0</y>
153-
<width>598</width>
154-
<height>265</height>
154+
<width>85</width>
155+
<height>35</height>
155156
</rect>
156157
</property>
157158
<layout class="QVBoxLayout" name="verticalLayout_2">
@@ -359,6 +360,24 @@ Errors are indicated with a red squiggle underline.</string>
359360
<string>Erases the contents of the cell</string>
360361
</property>
361362
</action>
363+
<action name="actionWordWrap">
364+
<property name="checkable">
365+
<bool>true</bool>
366+
</property>
367+
<property name="checked">
368+
<bool>true</bool>
369+
</property>
370+
<property name="icon">
371+
<iconset resource="icons/icons.qrc">
372+
<normaloff>:/icons/word_wrap</normaloff>:/icons/word_wrap</iconset>
373+
</property>
374+
<property name="text">
375+
<string>Word Wrap</string>
376+
</property>
377+
<property name="toolTip">
378+
<string>Wrap lines on word boundaries</string>
379+
</property>
380+
</action>
362381
</widget>
363382
<tabstops>
364383
<tabstop>comboMode</tabstop>
@@ -529,6 +548,22 @@ Errors are indicated with a red squiggle underline.</string>
529548
</hint>
530549
</hints>
531550
</connection>
551+
<connection>
552+
<sender>actionWordWrap</sender>
553+
<signal>toggled(bool)</signal>
554+
<receiver>EditDialog</receiver>
555+
<slot>setWordWrapping(bool)</slot>
556+
<hints>
557+
<hint type="sourcelabel">
558+
<x>-1</x>
559+
<y>-1</y>
560+
</hint>
561+
<hint type="destinationlabel">
562+
<x>308</x>
563+
<y>190</y>
564+
</hint>
565+
</hints>
566+
</connection>
532567
</connections>
533568
<slots>
534569
<slot>importData()</slot>

src/ExtendedScintilla.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,6 @@ void ExtendedScintilla::reloadLexerSettings(QsciLexer *lexer)
198198
if(lexer)
199199
lexer->refreshProperties();
200200

201-
// Set wrap lines
202-
setWrapMode(static_cast<QsciScintilla::WrapMode>(Settings::getValue("editor", "wrap_lines").toInt()));
203-
204201
// Check if error indicators are enabled and clear them if they just got disabled
205202
showErrorIndicators = Settings::getValue("editor", "error_indicators").toBool();
206203
if(!showErrorIndicators)

src/Settings.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ QVariant Settings::getDefaultValue(const QString& group, const QString& name)
207207
return false;
208208
if(name == "auto_switch_mode")
209209
return true;
210+
if(name == "editor_word_wrap")
211+
return true;
210212
if(name == "null_text")
211213
return "NULL";
212214
if(name == "blob_text")

src/icons/icons.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,6 @@
7979
<file alias="project_save_as">package_rename.png</file>
8080
<file alias="field_fk">page_foreign_key.png</file>
8181
<file alias="save_all">save_all.png</file>
82+
<file alias="word_wrap">page_white_text.png</file>
8283
</qresource>
8384
</RCC>

src/icons/page_white_text.png

342 Bytes
Loading

src/sqltextedit.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ void SqlTextEdit::reloadSettings()
6161
} else {
6262
setAutoCompletionThreshold(0);
6363
}
64+
// Set wrap lines
65+
setWrapMode(static_cast<QsciScintilla::WrapMode>(Settings::getValue("editor", "wrap_lines").toInt()));
6466

6567
ExtendedScintilla::reloadSettings();
6668

0 commit comments

Comments
 (0)