From 29bfcc4922f965ed9ef01a6028efcb1fedb6b01c Mon Sep 17 00:00:00 2001 From: mgrojo Date: Sun, 17 Mar 2019 19:23:02 +0100 Subject: [PATCH] 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 --- src/EditDialog.cpp | 11 ++++++++++ src/EditDialog.h | 1 + src/EditDialog.ui | 39 ++++++++++++++++++++++++++++++++-- src/ExtendedScintilla.cpp | 3 --- src/Settings.cpp | 2 ++ src/icons/icons.qrc | 1 + src/icons/page_white_text.png | Bin 0 -> 342 bytes src/sqltextedit.cpp | 2 ++ 8 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 src/icons/page_white_text.png diff --git a/src/EditDialog.cpp b/src/EditDialog.cpp index 9edd91db..e1279276 100644 --- a/src/EditDialog.cpp +++ b/src/EditDialog.cpp @@ -22,6 +22,8 @@ #include #include +#include + EditDialog::EditDialog(QWidget* parent) : QDialog(parent), ui(new Ui::EditDialog), @@ -65,6 +67,8 @@ EditDialog::EditDialog(QWidget* parent) ui->actionIndent->setChecked(mustIndentAndCompact); ui->buttonAutoSwitchMode->setChecked(Settings::getValue("databrowser", "auto_switch_mode").toBool()); + ui->actionWordWrap->setChecked(Settings::getValue("databrowser", "editor_word_wrap").toBool()); + setWordWrapping(ui->actionWordWrap->isChecked()); reloadSettings(); } @@ -73,6 +77,7 @@ EditDialog::~EditDialog() { Settings::setValue("databrowser", "indent_compact", mustIndentAndCompact); Settings::setValue("databrowser", "auto_switch_mode", ui->buttonAutoSwitchMode->isChecked()); + Settings::setValue("databrowser", "editor_word_wrap", ui->actionWordWrap->isChecked()); delete ui; } @@ -1012,3 +1017,9 @@ void EditDialog::copyHexAscii() { QApplication::clipboard()->setText(hexEdit->selectionToReadableString()); } + +void EditDialog::setWordWrapping(bool value) +{ + // Set wrap lines + sciEdit->setWrapMode(value ? QsciScintilla::WrapWord : QsciScintilla::WrapNone); +} diff --git a/src/EditDialog.h b/src/EditDialog.h index 70cb3d88..b814d048 100644 --- a/src/EditDialog.h +++ b/src/EditDialog.h @@ -46,6 +46,7 @@ private slots: void openPrintDialog(); void openPrintImageDialog(); void copyHexAscii(); + void setWordWrapping(bool value); signals: void recordTextUpdated(const QPersistentModelIndex& idx, const QByteArray& data, bool isBlob); diff --git a/src/EditDialog.ui b/src/EditDialog.ui index 519947de..a495eeab 100644 --- a/src/EditDialog.ui +++ b/src/EditDialog.ui @@ -115,6 +115,7 @@ + @@ -150,8 +151,8 @@ Errors are indicated with a red squiggle underline. 0 0 - 598 - 265 + 85 + 35 @@ -359,6 +360,24 @@ Errors are indicated with a red squiggle underline. Erases the contents of the cell + + + true + + + true + + + + :/icons/word_wrap:/icons/word_wrap + + + Word Wrap + + + Wrap lines on word boundaries + + comboMode @@ -529,6 +548,22 @@ Errors are indicated with a red squiggle underline. + + actionWordWrap + toggled(bool) + EditDialog + setWordWrapping(bool) + + + -1 + -1 + + + 308 + 190 + + + importData() diff --git a/src/ExtendedScintilla.cpp b/src/ExtendedScintilla.cpp index 04e80a94..2ecff1fd 100644 --- a/src/ExtendedScintilla.cpp +++ b/src/ExtendedScintilla.cpp @@ -198,9 +198,6 @@ void ExtendedScintilla::reloadLexerSettings(QsciLexer *lexer) if(lexer) lexer->refreshProperties(); - // Set wrap lines - setWrapMode(static_cast(Settings::getValue("editor", "wrap_lines").toInt())); - // Check if error indicators are enabled and clear them if they just got disabled showErrorIndicators = Settings::getValue("editor", "error_indicators").toBool(); if(!showErrorIndicators) diff --git a/src/Settings.cpp b/src/Settings.cpp index 6dcb123a..8f9b9097 100644 --- a/src/Settings.cpp +++ b/src/Settings.cpp @@ -207,6 +207,8 @@ QVariant Settings::getDefaultValue(const QString& group, const QString& name) return false; if(name == "auto_switch_mode") return true; + if(name == "editor_word_wrap") + return true; if(name == "null_text") return "NULL"; if(name == "blob_text") diff --git a/src/icons/icons.qrc b/src/icons/icons.qrc index ea3defd5..b406416a 100644 --- a/src/icons/icons.qrc +++ b/src/icons/icons.qrc @@ -79,5 +79,6 @@ package_rename.png page_foreign_key.png save_all.png + page_white_text.png diff --git a/src/icons/page_white_text.png b/src/icons/page_white_text.png new file mode 100644 index 0000000000000000000000000000000000000000..813f712f726c935f9adf8d2f2dd0d7683791ef11 GIT binary patch literal 342 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^zbpD<_bdI{u9mbgZg z1m~xflqVLYGB~E>C#5QQ<|d}62BjvZR2H60wE-%6;pyTSA|c6o&@eC9QG)Hj&ExYL zO&oVL^)+cM^qd@ApywS>pwx0H@RDN}hq;7mU-SKczYQ-hnrr=;iDAQMZQ+*g=YOM= z!QlMQEn7FbaD->uKAYgo_j9)W&$$zS*W9}m(ey0q$&7l-XEWO0Y(9M=SnhLbwy;d>@~SY$Ku*0xPvIOQeV1x7u_z-2-X>_74(yfh7C znXL|3GZ+d2`3re2hs?MK(Settings::getValue("editor", "wrap_lines").toInt())); ExtendedScintilla::reloadSettings();