18#include "katedialogs.h"
20#include <ktexteditor/message.h>
21#include <ktexteditor_version.h>
23#include "kateautoindent.h"
24#include "katebuffer.h"
25#include "kateconfig.h"
26#include "katedocument.h"
27#include "kateglobal.h"
28#include "katemodeconfigpage.h"
30#include "spellcheck/spellcheck.h"
33#include "ui_bordersappearanceconfigwidget.h"
34#include "ui_completionconfigtab.h"
35#include "ui_editconfigwidget.h"
36#include "ui_indentationconfigwidget.h"
37#include "ui_navigationconfigwidget.h"
38#include "ui_opensaveconfigadvwidget.h"
39#include "ui_opensaveconfigwidget.h"
40#include "ui_spellcheckconfigwidget.h"
41#include "ui_statusbarconfigwidget.h"
42#include "ui_textareaappearanceconfigwidget.h"
45#include <KIO/JobUiDelegateFactory>
46#include <KIO/OpenUrlJob>
48#include "kateabstractinputmodefactory.h"
49#include "katepartdebug.h"
50#include <KActionCollection>
53#include <KEncodingProber>
54#include <KFontRequester>
55#include <KLocalization>
63#include <QDomDocument>
66#include <QFontDatabase>
72#include <QRadioButton>
78#include <QTemporaryFile>
86KateIndentConfigTab::KateIndentConfigTab(
QWidget *parent)
87 : KateConfigPage(parent)
94 ui =
new Ui::IndentationConfigWidget();
95 ui->setupUi(newWidget);
107 observeChanges(ui->chkAutoDetectIndent);
108 observeChanges(ui->chkBackspaceUnindents);
109 observeChanges(ui->chkIndentPaste);
110 observeChanges(ui->chkKeepExtraSpaces);
111 observeChanges(ui->cmbMode);
112 observeChanges(ui->rbIndentMixed);
113 observeChanges(ui->rbIndentWithSpaces);
114 observeChanges(ui->rbIndentWithTabs);
117 observeChanges(ui->rbTabAdvances);
118 observeChanges(ui->rbTabIndents);
119 observeChanges(ui->rbTabSmart);
120 observeChanges(ui->sbIndentWidth);
121 observeChanges(ui->sbTabWidth);
126KateIndentConfigTab::~KateIndentConfigTab()
131void KateIndentConfigTab::slotChanged()
135 if (ui->rbIndentWithTabs->isChecked()) {
136 ui->sbIndentWidth->setValue(ui->sbTabWidth->value());
142void KateIndentConfigTab::showWhatsThis(
const QString &text)
147void KateIndentConfigTab::apply()
157 KateDocumentConfig::global()->setBackspaceIndents(ui->chkBackspaceUnindents->isChecked());
158 KateDocumentConfig::global()->setIndentPastedText(ui->chkIndentPaste->isChecked());
160 KateDocumentConfig::global()->setIndentationWidth(ui->sbIndentWidth->value());
161 KateDocumentConfig::global()->setKeepExtraSpaces(ui->chkKeepExtraSpaces->isChecked());
162 KateDocumentConfig::global()->setReplaceTabsDyn(ui->rbIndentWithSpaces->isChecked());
163 KateDocumentConfig::global()->setTabWidth(ui->sbTabWidth->value());
164 KateDocumentConfig::global()->setAutoDetectIndent(ui->chkAutoDetectIndent->isChecked());
166 if (ui->rbTabAdvances->isChecked()) {
167 KateDocumentConfig::global()->setTabHandling(KateDocumentConfig::tabInsertsTab);
168 }
else if (ui->rbTabIndents->isChecked()) {
169 KateDocumentConfig::global()->setTabHandling(KateDocumentConfig::tabIndents);
171 KateDocumentConfig::global()->setTabHandling(KateDocumentConfig::tabSmart);
174 KateDocumentConfig::global()->
configEnd();
177void KateIndentConfigTab::reload()
179 ui->chkBackspaceUnindents->setChecked(KateDocumentConfig::global()->backspaceIndents());
180 ui->chkIndentPaste->setChecked(KateDocumentConfig::global()->indentPastedText());
181 ui->chkKeepExtraSpaces->setChecked(KateDocumentConfig::global()->keepExtraSpaces());
183 ui->chkAutoDetectIndent->setChecked(KateDocumentConfig::global()->autoDetectIndent());
185 ui->sbIndentWidth->setValue(KateDocumentConfig::global()->indentationWidth());
187 ui->sbTabWidth->setValue(KateDocumentConfig::global()->tabWidth());
189 ui->rbTabAdvances->setChecked(KateDocumentConfig::global()->tabHandling() == KateDocumentConfig::tabInsertsTab);
190 ui->rbTabIndents->setChecked(KateDocumentConfig::global()->tabHandling() == KateDocumentConfig::tabIndents);
191 ui->rbTabSmart->setChecked(KateDocumentConfig::global()->tabHandling() == KateDocumentConfig::tabSmart);
195 if (KateDocumentConfig::global()->replaceTabsDyn()) {
196 ui->rbIndentWithSpaces->setChecked(
true);
198 if (KateDocumentConfig::global()->indentationWidth() == KateDocumentConfig::global()->tabWidth()) {
199 ui->rbIndentWithTabs->setChecked(
true);
201 ui->rbIndentMixed->setChecked(
true);
205 ui->sbIndentWidth->setEnabled(!ui->rbIndentWithTabs->isChecked());
208QString KateIndentConfigTab::name()
const
210 return i18n(
"Indentation");
216KateCompletionConfigTab::KateCompletionConfigTab(
QWidget *parent)
217 : KateConfigPage(parent)
224 ui =
new Ui::CompletionConfigTab();
225 ui->setupUi(newWidget);
231 observeChanges(ui->chkAutoCompletionEnabled);
232 observeChanges(ui->chkAutoSelectFirstEntry);
233 observeChanges(ui->chkTabCompletion);
234 observeChanges(ui->chkEnterCompletion);
235 observeChanges(ui->gbKeywordCompletion);
236 observeChanges(ui->gbShowDoc);
237 observeChanges(ui->gbWordCompletion);
238 observeChanges(ui->minimalWordLength);
239 observeChanges(ui->removeTail);
244KateCompletionConfigTab::~KateCompletionConfigTab()
249void KateCompletionConfigTab::showWhatsThis(
const QString &text)
254void KateCompletionConfigTab::apply()
264 KateViewConfig::global()->
setValue(KateViewConfig::AutomaticCompletionInvocation, ui->chkAutoCompletionEnabled->isChecked());
265 KateViewConfig::global()->
setValue(KateViewConfig::AutomaticCompletionPreselectFirst, ui->chkAutoSelectFirstEntry->isChecked());
266 KateViewConfig::global()->
setValue(KateViewConfig::TabCompletion, ui->chkTabCompletion->isChecked());
267 KateViewConfig::global()->
setValue(KateViewConfig::EnterToInsertCompletion, ui->chkEnterCompletion->isChecked());
268 KateViewConfig::global()->
setValue(KateViewConfig::KeywordCompletion, ui->gbKeywordCompletion->isChecked());
269 KateViewConfig::global()->
setValue(KateViewConfig::WordCompletion, ui->gbWordCompletion->isChecked());
270 KateViewConfig::global()->
setValue(KateViewConfig::WordCompletionMinimalWordLength, ui->minimalWordLength->value());
271 KateViewConfig::global()->
setValue(KateViewConfig::WordCompletionRemoveTail, ui->removeTail->isChecked());
272 KateViewConfig::global()->
setValue(KateViewConfig::ShowDocWithCompletion, ui->gbShowDoc->isChecked());
277void KateCompletionConfigTab::reload()
279 ui->chkAutoCompletionEnabled->setChecked(KateViewConfig::global()->automaticCompletionInvocation());
280 ui->chkAutoSelectFirstEntry->setChecked(KateViewConfig::global()->automaticCompletionPreselectFirst());
281 ui->chkTabCompletion->setChecked(KateViewConfig::global()->tabCompletion());
282 ui->chkEnterCompletion->setChecked(KateViewConfig::global()->value(KateViewConfig::EnterToInsertCompletion).toBool());
284 ui->gbKeywordCompletion->setChecked(KateViewConfig::global()->keywordCompletion());
285 ui->gbWordCompletion->setChecked(KateViewConfig::global()->wordCompletion());
286 ui->gbShowDoc->setChecked(KateViewConfig::global()->showDocWithCompletion());
288 ui->minimalWordLength->setValue(KateViewConfig::global()->wordCompletionMinimalWordLength());
289 ui->removeTail->setChecked(KateViewConfig::global()->wordCompletionRemoveTail());
292QString KateCompletionConfigTab::name()
const
294 return i18n(
"Auto Completion");
300KateSpellCheckConfigTab::KateSpellCheckConfigTab(
QWidget *parent)
301 : KateConfigPage(parent)
308 ui =
new Ui::SpellCheckConfigWidget();
309 ui->setupUi(newWidget);
322KateSpellCheckConfigTab::~KateSpellCheckConfigTab()
327void KateSpellCheckConfigTab::showWhatsThis(
const QString &text)
332void KateSpellCheckConfigTab::apply()
343 m_sonnetConfigWidget->save();
344 QSettings settings(QStringLiteral(
"KDE"), QStringLiteral(
"Sonnet"));
345 KateDocumentConfig::global()->setOnTheFlySpellCheck(settings.value(QStringLiteral(
"checkerEnabledByDefault"),
false).toBool());
346 KateDocumentConfig::global()->
configEnd();
354void KateSpellCheckConfigTab::reload()
359QString KateSpellCheckConfigTab::name()
const
361 return i18n(
"Spellcheck");
367KateNavigationConfigTab::KateNavigationConfigTab(
QWidget *parent)
368 : KateConfigPage(parent)
375 ui =
new Ui::NavigationConfigWidget();
376 ui->setupUi(newWidget);
378 initMulticursorModifierComboBox();
384 observeChanges(ui->cbTextSelectionMode);
385 observeChanges(ui->chkBackspaceRemoveComposed);
386 observeChanges(ui->chkPagingMovesCursor);
387 observeChanges(ui->chkScrollPastEnd);
388 observeChanges(ui->chkSmartHome);
389 observeChanges(ui->sbAutoCenterCursor);
390 observeChanges(ui->chkCamelCursor);
391 observeChanges(ui->cmbMultiCursorModifier);
396KateNavigationConfigTab::~KateNavigationConfigTab()
401void KateNavigationConfigTab::initMulticursorModifierComboBox()
405 auto *c = ui->cmbMultiCursorModifier;
424void KateNavigationConfigTab::apply()
435 KateDocumentConfig::global()->setPageUpDownMovesCursor(ui->chkPagingMovesCursor->isChecked());
436 KateDocumentConfig::global()->setSmartHome(ui->chkSmartHome->isChecked());
437 KateDocumentConfig::global()->setCamelCursor(ui->chkCamelCursor->isChecked());
439 KateViewConfig::global()->
setValue(KateViewConfig::AutoCenterLines, ui->sbAutoCenterCursor->value());
440 KateViewConfig::global()->
setValue(KateViewConfig::BackspaceRemoveComposedCharacters, ui->chkBackspaceRemoveComposed->isChecked());
441 KateViewConfig::global()->
setValue(KateViewConfig::PersistentSelection, ui->cbTextSelectionMode->currentIndex() == 1);
442 KateViewConfig::global()->
setValue(KateViewConfig::ScrollPastEnd, ui->chkScrollPastEnd->isChecked());
444 const int modifers = ui->cmbMultiCursorModifier->currentData().toInt();
447 KateDocumentConfig::global()->
configEnd();
451void KateNavigationConfigTab::reload()
453 ui->cbTextSelectionMode->setCurrentIndex(KateViewConfig::global()->persistentSelection() ? 1 : 0);
455 ui->chkBackspaceRemoveComposed->setChecked(KateViewConfig::global()->backspaceRemoveComposed());
456 ui->chkPagingMovesCursor->setChecked(KateDocumentConfig::global()->pageUpDownMovesCursor());
457 ui->chkScrollPastEnd->setChecked(KateViewConfig::global()->scrollPastEnd());
458 ui->chkSmartHome->setChecked(KateDocumentConfig::global()->smartHome());
459 ui->chkCamelCursor->setChecked(KateDocumentConfig::global()->camelCursor());
461 ui->sbAutoCenterCursor->setValue(KateViewConfig::global()->autoCenterLines());
463 const int mods = KateViewConfig::global()->multiCursorModifiers();
464 const auto count = ui->cmbMultiCursorModifier->count();
465 for (
int i = 0; i < count; ++i) {
466 int idxMods = ui->cmbMultiCursorModifier->itemData(i).toInt();
467 if (idxMods == mods) {
468 ui->cmbMultiCursorModifier->setCurrentIndex(i);
474QString KateNavigationConfigTab::name()
const
476 return i18n(
"Text Navigation");
482KateEditGeneralConfigTab::KateEditGeneralConfigTab(
QWidget *parent)
483 : KateConfigPage(parent)
487 ui =
new Ui::EditConfigWidget();
488 ui->setupUi(newWidget);
491 ui->cmbInputMode->addItem(fact->name(),
static_cast<int>(fact->inputMode()));
498 observeChanges(ui->chkAutoBrackets);
499 observeChanges(ui->chkMousePasteAtCursorPosition);
500 observeChanges(ui->chkShowStaticWordWrapMarker);
501 observeChanges(ui->chkTextDragAndDrop);
502 observeChanges(ui->chkSmartCopyCut);
503 observeChanges(ui->sbClipboardHistoryEntries);
504 observeChanges(ui->chkStaticWordWrap);
505 observeChanges(ui->cmbEncloseSelection);
508 const int index = ui->cmbEncloseSelection->currentIndex();
509 const QString text = ui->cmbEncloseSelection->currentText();
511 if (index >= UserData && text.isEmpty()) {
512 ui->cmbEncloseSelection->removeItem(index);
516 }
else if (ui->cmbEncloseSelection->findText(text) < 0) {
517 ui->cmbEncloseSelection->addItem(text);
520 ui->cmbEncloseSelection->setCurrentIndex(ui->cmbEncloseSelection->findText(text));
522 observeChanges(ui->cmbInputMode);
523 observeChanges(ui->sbWordWrap);
524 observeChanges(ui->chkAccessibility);
529KateEditGeneralConfigTab::~KateEditGeneralConfigTab()
534void KateEditGeneralConfigTab::apply()
545 KateDocumentConfig::global()->setWordWrap(ui->chkStaticWordWrap->isChecked());
546 KateDocumentConfig::global()->setWordWrapAt(ui->sbWordWrap->value());
548 KateRendererConfig::global()->setWordWrapMarker(ui->chkShowStaticWordWrapMarker->isChecked());
550 KateViewConfig::global()->
setValue(KateViewConfig::AutoBrackets, ui->chkAutoBrackets->isChecked());
551 KateViewConfig::global()->
setValue(KateViewConfig::CharsToEncloseSelection, ui->cmbEncloseSelection->currentText());
553 for (
int i = UserData; i < ui->cmbEncloseSelection->count(); ++i) {
554 userLetters.
append(ui->cmbEncloseSelection->itemText(i));
556 KateViewConfig::global()->
setValue(KateViewConfig::UserSetsOfCharsToEncloseSelection, userLetters);
557 KateViewConfig::global()->
setValue(KateViewConfig::InputMode, ui->cmbInputMode->currentData().toInt());
558 KateViewConfig::global()->
setValue(KateViewConfig::MousePasteAtCursorPosition, ui->chkMousePasteAtCursorPosition->isChecked());
559 KateViewConfig::global()->
setValue(KateViewConfig::TextDragAndDrop, ui->chkTextDragAndDrop->isChecked());
560 KateViewConfig::global()->
setValue(KateViewConfig::SmartCopyCut, ui->chkSmartCopyCut->isChecked());
561 KateViewConfig::global()->
setValue(KateViewConfig::ClipboardHistoryEntries, ui->sbClipboardHistoryEntries->value());
562 KateViewConfig::global()->
setValue(KateViewConfig::EnableAccessibility, ui->chkAccessibility->isChecked());
564 KateDocumentConfig::global()->
configEnd();
568void KateEditGeneralConfigTab::reload()
570 ui->chkAutoBrackets->setChecked(KateViewConfig::global()->autoBrackets());
571 ui->chkMousePasteAtCursorPosition->setChecked(KateViewConfig::global()->mousePasteAtCursorPosition());
572 ui->chkShowStaticWordWrapMarker->setChecked(KateRendererConfig::global()->wordWrapMarker());
573 ui->chkTextDragAndDrop->setChecked(KateViewConfig::global()->textDragAndDrop());
574 ui->chkSmartCopyCut->setChecked(KateViewConfig::global()->smartCopyCut());
575 ui->chkStaticWordWrap->setChecked(KateDocumentConfig::global()->wordWrap());
576 ui->sbClipboardHistoryEntries->setValue(KateViewConfig::global()->clipboardHistoryEntries());
579 ui->sbWordWrap->setValue(KateDocumentConfig::global()->wordWrapAt());
581 ui->cmbEncloseSelection->clear();
582 ui->cmbEncloseSelection->lineEdit()->setClearButtonEnabled(
true);
583 ui->cmbEncloseSelection->lineEdit()->setPlaceholderText(
i18n(
"Feature is not active"));
584 ui->cmbEncloseSelection->addItem(
QString(), None);
586 ui->cmbEncloseSelection->addItem(QStringLiteral(
"`*_~"), MarkDown);
587 ui->cmbEncloseSelection->setItemData(1,
i18n(
"May be handy with Markdown"),
Qt::ToolTipRole);
588 ui->cmbEncloseSelection->addItem(QStringLiteral(
"<>(){}[]'\""), MirrorChar);
589 ui->cmbEncloseSelection->setItemData(2,
i18n(
"Mirror characters, similar but not exactly like auto brackets"),
Qt::ToolTipRole);
590 ui->cmbEncloseSelection->addItem(QStringLiteral(
"´`_.:|#@~*!?$%/=,;-+^°§&"), NonLetters);
593 for (
int i = 0; i < userLetters.
size(); ++i) {
594 ui->cmbEncloseSelection->addItem(userLetters.
at(i), UserData + i);
596 ui->cmbEncloseSelection->setCurrentIndex(ui->cmbEncloseSelection->findText(KateViewConfig::global()->charsToEncloseSelection()));
598 const int id =
static_cast<int>(KateViewConfig::global()->inputMode());
599 ui->cmbInputMode->setCurrentIndex(ui->cmbInputMode->findData(
id));
600 ui->chkAccessibility->setChecked(KateViewConfig::global()->value(KateViewConfig::EnableAccessibility).toBool());
603QString KateEditGeneralConfigTab::name()
const
605 return i18n(
"General");
611KateEditConfigTab::KateEditConfigTab(
QWidget *parent)
612 : KateConfigPage(parent)
613 , editConfigTab(new KateEditGeneralConfigTab(this))
614 , navigationConfigTab(new KateNavigationConfigTab(this))
615 , indentConfigTab(new KateIndentConfigTab(this))
616 , completionConfigTab(new KateCompletionConfigTab(this))
617 , spellCheckConfigTab(new KateSpellCheckConfigTab(this))
625 tabWidget->
insertTab(0, editConfigTab, editConfigTab->name());
626 tabWidget->
insertTab(1, navigationConfigTab, navigationConfigTab->name());
627 tabWidget->
insertTab(2, indentConfigTab, indentConfigTab->name());
628 tabWidget->
insertTab(3, completionConfigTab, completionConfigTab->name());
629 tabWidget->
insertTab(4, spellCheckConfigTab, spellCheckConfigTab->name());
631 observeChanges(editConfigTab);
632 observeChanges(navigationConfigTab);
633 observeChanges(indentConfigTab);
634 observeChanges(completionConfigTab);
635 observeChanges(spellCheckConfigTab);
637 int i = tabWidget->
count();
639 KateConfigPage *tab = factory->createConfigPage(
this);
641 m_inputModeConfigTabs.push_back(tab);
651KateEditConfigTab::~KateEditConfigTab()
653 qDeleteAll(m_inputModeConfigTabs);
656void KateEditConfigTab::apply()
659 editConfigTab->apply();
660 navigationConfigTab->apply();
661 indentConfigTab->apply();
662 completionConfigTab->apply();
663 spellCheckConfigTab->apply();
664 for (KateConfigPage *tab : m_inputModeConfigTabs) {
669void KateEditConfigTab::reload()
671 editConfigTab->reload();
672 navigationConfigTab->reload();
673 indentConfigTab->reload();
674 completionConfigTab->reload();
675 spellCheckConfigTab->reload();
676 for (KateConfigPage *tab : m_inputModeConfigTabs) {
681void KateEditConfigTab::reset()
683 editConfigTab->reset();
684 navigationConfigTab->reset();
685 indentConfigTab->reset();
686 completionConfigTab->reset();
687 spellCheckConfigTab->reset();
688 for (KateConfigPage *tab : m_inputModeConfigTabs) {
693void KateEditConfigTab::defaults()
695 editConfigTab->defaults();
696 navigationConfigTab->defaults();
697 indentConfigTab->defaults();
698 completionConfigTab->defaults();
699 spellCheckConfigTab->defaults();
700 for (KateConfigPage *tab : m_inputModeConfigTabs) {
705QString KateEditConfigTab::name()
const
707 return i18n(
"Editing");
710QString KateEditConfigTab::fullName()
const
712 return i18n(
"Editing Options");
715QIcon KateEditConfigTab::icon()
const
723KateViewDefaultsConfig::KateViewDefaultsConfig(
QWidget *parent)
724 : KateConfigPage(parent)
725 , textareaUi(new Ui::TextareaAppearanceConfigWidget())
726 , bordersUi(new Ui::BordersAppearanceConfigWidget())
727 , statusBarUi(new Ui::StatusbarConfigWidget())
736 textareaUi->setupUi(textareaTab);
737 tabWidget->
addTab(textareaTab,
i18n(
"General"));
740 bordersUi->setupUi(bordersTab);
741 tabWidget->
addTab(bordersTab,
i18n(
"Borders"));
744 statusBarUi->setupUi(statusbarTab);
745 tabWidget->
addTab(statusbarTab,
i18n(
"Statusbar"));
747 textareaUi->cmbDynamicWordWrapIndicator->addItem(
i18n(
"Off"));
748 textareaUi->cmbDynamicWordWrapIndicator->addItem(
i18n(
"Follow Line Numbers"));
749 textareaUi->cmbDynamicWordWrapIndicator->addItem(
i18n(
"Always On"));
755 observeChanges(textareaUi->kfontrequester);
757 observeChanges(textareaUi->chkAnimateBracketMatching);
758 observeChanges(textareaUi->chkDynWrapAnywhere);
759 observeChanges(textareaUi->chkDynWrapAtStaticMarker);
760 observeChanges(textareaUi->chkFoldFirstLine);
761 observeChanges(textareaUi->chkShowBracketMatchPreview);
762 observeChanges(textareaUi->chkShowIndentationLines);
763 observeChanges(textareaUi->chkShowLineCount);
764 observeChanges(textareaUi->chkShowTabs);
765 observeChanges(textareaUi->chkShowWholeBracketExpression);
766 observeChanges(textareaUi->chkShowWordCount);
767 observeChanges(textareaUi->cmbDynamicWordWrapIndicator);
768 observeChanges(textareaUi->cbxWordWrap);
769 observeChanges(textareaUi->spbLineHeightMultiplier);
770 auto a = [ui = textareaUi, cbx = textareaUi->cbxWordWrap]() {
771 ui->chkDynWrapAtStaticMarker->setEnabled(cbx->isChecked());
772 ui->chkDynWrapAnywhere->setEnabled(cbx->isChecked());
773 ui->cmbDynamicWordWrapIndicator->setEnabled(cbx->isChecked());
774 ui->sbDynamicWordWrapDepth->setEnabled(cbx->isChecked());
776#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
779 connect(textareaUi->cbxWordWrap, &QCheckBox::checkStateChanged,
this, a);
782 auto b = [cbx = textareaUi->cbxIndentWrappedLines, sb = textareaUi->sbDynamicWordWrapDepth]() {
783 sb->setEnabled(cbx->isChecked());
786#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
789 connect(textareaUi->cbxIndentWrappedLines, &QCheckBox::checkStateChanged,
this, b);
791 observeChanges(textareaUi->cbxIndentWrappedLines);
792 observeChanges(textareaUi->sbDynamicWordWrapDepth);
793 observeChanges(textareaUi->sliSetMarkerSize);
794 observeChanges(textareaUi->spacesComboBox);
796 observeChanges(bordersUi->chkIconBorder);
797 observeChanges(bordersUi->chkLineNumbers);
798 observeChanges(bordersUi->chkScrollbarMarks);
799 observeChanges(bordersUi->chkScrollbarMiniMap);
800 observeChanges(bordersUi->chkScrollbarMiniMapAll);
801 bordersUi->chkScrollbarMiniMapAll->hide();
802 observeChanges(bordersUi->chkScrollbarPreview);
803 observeChanges(bordersUi->chkShowFoldingMarkers);
804 observeChanges(bordersUi->chkShowFoldingPreview);
805 observeChanges(bordersUi->chkShowLineModification);
806 observeChanges(bordersUi->cmbShowScrollbars);
807 observeChanges(bordersUi->rbSortBookmarksByCreation);
808 observeChanges(bordersUi->rbSortBookmarksByPosition);
809 observeChanges(bordersUi->spBoxMiniMapWidth);
810 observeChanges(bordersUi->cmbFoldingArrowVisiblity);
813 observeChanges(statusBarUi->cbShowActiveDictionary);
814 observeChanges(statusBarUi->cbShowHighlightingMode);
815 observeChanges(statusBarUi->cbShowInputMode);
816 observeChanges(statusBarUi->cbShowLineColumn);
817 observeChanges(statusBarUi->cbShowTabSetting);
818 observeChanges(statusBarUi->cbShowEncoding);
819 observeChanges(statusBarUi->cbShowEOL);
822KateViewDefaultsConfig::~KateViewDefaultsConfig()
829void KateViewDefaultsConfig::apply()
840 KateDocumentConfig::global()->setMarkerSize(textareaUi->sliSetMarkerSize->value());
841 KateDocumentConfig::global()->setShowSpaces(KateDocumentConfig::WhitespaceRendering(textareaUi->spacesComboBox->currentIndex()));
842 KateDocumentConfig::global()->setShowTabs(textareaUi->chkShowTabs->isChecked());
844 KateRendererConfig::global()->setFont(textareaUi->kfontrequester->font());
845 KateRendererConfig::global()->setAnimateBracketMatching(textareaUi->chkAnimateBracketMatching->isChecked());
846 KateRendererConfig::global()->setShowIndentationLines(textareaUi->chkShowIndentationLines->isChecked());
847 KateRendererConfig::global()->setShowWholeBracketExpression(textareaUi->chkShowWholeBracketExpression->isChecked());
848 KateRendererConfig::global()->setLineHeightMultiplier(textareaUi->spbLineHeightMultiplier->value());
850 KateViewConfig::global()->setDynWordWrap(textareaUi->cbxWordWrap->isChecked());
851 KateViewConfig::global()->setShowWordCount(textareaUi->chkShowWordCount->isChecked());
852 KateViewConfig::global()->
setValue(KateViewConfig::BookmarkSorting, bordersUi->rbSortBookmarksByPosition->isChecked() ? 0 : 1);
853 if (!textareaUi->cbxIndentWrappedLines->isChecked()) {
854 KateViewConfig::global()->
setValue(KateViewConfig::DynWordWrapAlignIndent, 0);
856 KateViewConfig::global()->
setValue(KateViewConfig::DynWordWrapAlignIndent, textareaUi->sbDynamicWordWrapDepth->value());
858 KateViewConfig::global()->
setValue(KateViewConfig::DynWordWrapIndicators, textareaUi->cmbDynamicWordWrapIndicator->currentIndex());
859 KateViewConfig::global()->
setValue(KateViewConfig::DynWrapAnywhere, textareaUi->chkDynWrapAnywhere->isChecked());
860 KateViewConfig::global()->
setValue(KateViewConfig::DynWrapAtStaticMarker, textareaUi->chkDynWrapAtStaticMarker->isChecked());
861 KateViewConfig::global()->
setValue(KateViewConfig::FoldFirstLine, textareaUi->chkFoldFirstLine->isChecked());
862 KateViewConfig::global()->
setValue(KateViewConfig::ScrollBarMiniMapWidth, bordersUi->spBoxMiniMapWidth->value());
863 KateViewConfig::global()->
setValue(KateViewConfig::ShowBracketMatchPreview, textareaUi->chkShowBracketMatchPreview->isChecked());
864 KateViewConfig::global()->
setValue(KateViewConfig::ShowFoldingBar, bordersUi->chkShowFoldingMarkers->isChecked());
865 KateViewConfig::global()->
setValue(KateViewConfig::ShowFoldingPreview, bordersUi->chkShowFoldingPreview->isChecked());
866 KateViewConfig::global()->
setValue(KateViewConfig::ShowIconBar, bordersUi->chkIconBorder->isChecked());
867 KateViewConfig::global()->
setValue(KateViewConfig::ShowLineCount, textareaUi->chkShowLineCount->isChecked());
868 KateViewConfig::global()->
setValue(KateViewConfig::ShowLineModification, bordersUi->chkShowLineModification->isChecked());
869 KateViewConfig::global()->
setValue(KateViewConfig::ShowLineNumbers, bordersUi->chkLineNumbers->isChecked());
870 KateViewConfig::global()->
setValue(KateViewConfig::ShowScrollBarMarks, bordersUi->chkScrollbarMarks->isChecked());
871 KateViewConfig::global()->
setValue(KateViewConfig::ShowScrollBarMiniMap, bordersUi->chkScrollbarMiniMap->isChecked());
872 KateViewConfig::global()->
setValue(KateViewConfig::ShowScrollBarMiniMapAll, bordersUi->chkScrollbarMiniMapAll->isChecked());
873 KateViewConfig::global()->
setValue(KateViewConfig::ShowScrollBarPreview, bordersUi->chkScrollbarPreview->isChecked());
874 KateViewConfig::global()->
setValue(KateViewConfig::ShowScrollbars, bordersUi->cmbShowScrollbars->currentIndex());
875 bool showOnHoverOnly = bordersUi->cmbFoldingArrowVisiblity->currentIndex() == 0;
876 KateViewConfig::global()->
setValue(KateViewConfig::ShowFoldingOnHoverOnly, showOnHoverOnly);
879 KateViewConfig::global()->
setValue(KateViewConfig::ShowStatusbarDictionary, statusBarUi->cbShowActiveDictionary->isChecked());
880 KateViewConfig::global()->
setValue(KateViewConfig::ShowStatusbarHighlightingMode, statusBarUi->cbShowHighlightingMode->isChecked());
881 KateViewConfig::global()->
setValue(KateViewConfig::ShowStatusbarInputMode, statusBarUi->cbShowInputMode->isChecked());
882 KateViewConfig::global()->
setValue(KateViewConfig::ShowStatusbarLineColumn, statusBarUi->cbShowLineColumn->isChecked());
883 KateViewConfig::global()->
setValue(KateViewConfig::ShowStatusbarTabSettings, statusBarUi->cbShowTabSetting->isChecked());
884 KateViewConfig::global()->
setValue(KateViewConfig::ShowStatusbarFileEncoding, statusBarUi->cbShowEncoding->isChecked());
885 KateViewConfig::global()->
setValue(KateViewConfig::ShowStatusbarEOL, statusBarUi->cbShowEOL->isChecked());
887 KateRendererConfig::global()->
configEnd();
891void KateViewDefaultsConfig::reload()
893 bordersUi->chkIconBorder->setChecked(KateViewConfig::global()->iconBar());
894 bordersUi->chkLineNumbers->setChecked(KateViewConfig::global()->lineNumbers());
895 bordersUi->chkScrollbarMarks->setChecked(KateViewConfig::global()->scrollBarMarks());
896 bordersUi->chkScrollbarMiniMap->setChecked(KateViewConfig::global()->scrollBarMiniMap());
897 bordersUi->chkScrollbarMiniMapAll->setChecked(KateViewConfig::global()->scrollBarMiniMapAll());
898 bordersUi->chkScrollbarPreview->setChecked(KateViewConfig::global()->scrollBarPreview());
899 bordersUi->chkShowFoldingMarkers->setChecked(KateViewConfig::global()->foldingBar());
900 bordersUi->chkShowFoldingPreview->setChecked(KateViewConfig::global()->foldingPreview());
901 bordersUi->chkShowLineModification->setChecked(KateViewConfig::global()->lineModification());
902 bordersUi->cmbShowScrollbars->setCurrentIndex(KateViewConfig::global()->showScrollbars());
903 bordersUi->rbSortBookmarksByCreation->setChecked(KateViewConfig::global()->bookmarkSort() == 1);
904 bordersUi->rbSortBookmarksByPosition->setChecked(KateViewConfig::global()->bookmarkSort() == 0);
905 bordersUi->spBoxMiniMapWidth->setValue(KateViewConfig::global()->scrollBarMiniMapWidth());
906 bordersUi->cmbFoldingArrowVisiblity->setCurrentIndex(KateViewConfig::global()->showFoldingOnHoverOnly() ? 0 : 1);
908 textareaUi->kfontrequester->setFont(KateRendererConfig::global()->baseFont());
910 textareaUi->chkAnimateBracketMatching->setChecked(KateRendererConfig::global()->animateBracketMatching());
911 textareaUi->chkDynWrapAnywhere->setChecked(KateViewConfig::global()->dynWrapAnywhere());
912 textareaUi->chkDynWrapAtStaticMarker->setChecked(KateViewConfig::global()->dynWrapAtStaticMarker());
913 textareaUi->chkFoldFirstLine->setChecked(KateViewConfig::global()->foldFirstLine());
914 textareaUi->chkShowBracketMatchPreview->setChecked(KateViewConfig::global()->value(KateViewConfig::ShowBracketMatchPreview).toBool());
915 textareaUi->chkShowIndentationLines->setChecked(KateRendererConfig::global()->showIndentationLines());
916 textareaUi->chkShowLineCount->setChecked(KateViewConfig::global()->showLineCount());
917 textareaUi->chkShowTabs->setChecked(KateDocumentConfig::global()->showTabs());
918 textareaUi->chkShowWholeBracketExpression->setChecked(KateRendererConfig::global()->showWholeBracketExpression());
919 textareaUi->chkShowWordCount->setChecked(KateViewConfig::global()->showWordCount());
920 textareaUi->cmbDynamicWordWrapIndicator->setCurrentIndex(KateViewConfig::global()->dynWordWrapIndicators());
921 textareaUi->cbxWordWrap->setChecked(KateViewConfig::global()->dynWordWrap());
922 textareaUi->cbxIndentWrappedLines->setChecked(KateViewConfig::global()->dynWordWrapAlignIndent() != 0);
923 textareaUi->sbDynamicWordWrapDepth->setValue(KateViewConfig::global()->dynWordWrapAlignIndent());
924 textareaUi->sliSetMarkerSize->setValue(KateDocumentConfig::global()->markerSize());
925 textareaUi->spacesComboBox->setCurrentIndex(KateDocumentConfig::global()->showSpaces());
926 textareaUi->spbLineHeightMultiplier->setValue(KateRendererConfig::global()->lineHeightMultiplier());
928 statusBarUi->cbShowLineColumn->setChecked(KateViewConfig::global()->value(KateViewConfig::ShowStatusbarLineColumn).toBool());
929 statusBarUi->cbShowActiveDictionary->setChecked(KateViewConfig::global()->value(KateViewConfig::ShowStatusbarDictionary).toBool());
930 statusBarUi->cbShowTabSetting->setChecked(KateViewConfig::global()->value(KateViewConfig::ShowStatusbarTabSettings).toBool());
931 statusBarUi->cbShowHighlightingMode->setChecked(KateViewConfig::global()->value(KateViewConfig::ShowStatusbarHighlightingMode).toBool());
932 statusBarUi->cbShowInputMode->setChecked(KateViewConfig::global()->value(KateViewConfig::ShowStatusbarInputMode).toBool());
933 statusBarUi->cbShowEncoding->setChecked(KateViewConfig::global()->value(KateViewConfig::ShowStatusbarFileEncoding).toBool());
934 statusBarUi->cbShowEOL->setChecked(KateViewConfig::global()->value(KateViewConfig::ShowStatusbarEOL).toBool());
937void KateViewDefaultsConfig::reset()
941void KateViewDefaultsConfig::defaults()
945QString KateViewDefaultsConfig::name()
const
947 return i18n(
"Appearance");
950QString KateViewDefaultsConfig::fullName()
const
952 return i18n(
"Appearance");
955QIcon KateViewDefaultsConfig::icon()
const
963KateSaveConfigTab::KateSaveConfigTab(
QWidget *parent)
964 : KateConfigPage(parent)
965 , modeConfigPage(new ModeConfigPage(this))
978 ui =
new Ui::OpenSaveConfigWidget();
979 ui->setupUi(newWidget);
984 uiadv =
new Ui::OpenSaveConfigAdvWidget();
985 uiadv->setupUi(newWidget2);
986 uiadv->lblExplanatory->setText(
987 i18n(
"%1 backs up unsaved files to \"swap files.\" Swap files allow %1 to recover your work in the case of a system crash. Disabling swap files may "
988 "cause data loss in case of a system crash.",
996 observeChanges(ui->cbRemoveTrailingSpaces);
997 observeChanges(ui->chkDetectEOL);
998 observeChanges(ui->chkEnableBOM);
999 observeChanges(ui->chkNewLineAtEof);
1000 observeChanges(ui->cmbEOL);
1001 observeChanges(ui->cmbEncoding);
1002 observeChanges(ui->cmbEncodingDetection);
1003 observeChanges(ui->cmbEncodingFallback);
1004 observeChanges(ui->lineLengthLimit);
1005 observeChanges(ui->gbAutoSave);
1006 observeChanges(ui->cbAutoSaveOnFocus);
1007 observeChanges(ui->spbAutoSaveInterval);
1009 observeChanges(uiadv->chkAutoReloadVersionControl);
1011 observeChanges(uiadv->chkBackupLocalFiles);
1012 observeChanges(uiadv->chkBackupRemoteFiles);
1013 observeChanges(uiadv->cmbSwapFileMode);
1016 observeChanges(uiadv->edtBackupPrefix);
1017 observeChanges(uiadv->edtBackupSuffix);
1018 observeChanges(uiadv->kurlSwapDirectory);
1019 observeChanges(uiadv->spbSwapFileSync);
1020 observeChanges(uiadv->chkEditorConfig);
1028 tabWidget->
insertTab(2, modeConfigPage, modeConfigPage->name());
1030 observeChanges(modeConfigPage);
1036 {QStringLiteral(
"Date:Locale"),
1037 QStringLiteral(
"Date:ISO"),
1038 QStringLiteral(
"Date:"),
1039 QStringLiteral(
"Time:Locale"),
1040 QStringLiteral(
"Time:ISO"),
1041 QStringLiteral(
"Time:"),
1042 QStringLiteral(
"ENV:"),
1043 QStringLiteral(
"JS:"),
1044 QStringLiteral(
"UUID")});
1047KateSaveConfigTab::~KateSaveConfigTab()
1053void KateSaveConfigTab::swapFileModeChanged(
int idx)
1055 const KateDocumentConfig::SwapFileMode mode =
static_cast<KateDocumentConfig::SwapFileMode
>(idx);
1057 case KateDocumentConfig::DisableSwapFile:
1058 uiadv->lblSwapDirectory->setEnabled(
false);
1059 uiadv->kurlSwapDirectory->setEnabled(
false);
1060 uiadv->lblSwapFileSync->setEnabled(
false);
1061 uiadv->spbSwapFileSync->setEnabled(
false);
1063 case KateDocumentConfig::EnableSwapFile:
1064 uiadv->lblSwapDirectory->setEnabled(
false);
1065 uiadv->kurlSwapDirectory->setEnabled(
false);
1066 uiadv->lblSwapFileSync->setEnabled(
true);
1067 uiadv->spbSwapFileSync->setEnabled(
true);
1069 case KateDocumentConfig::SwapFilePresetDirectory:
1070 uiadv->lblSwapDirectory->setEnabled(
true);
1071 uiadv->kurlSwapDirectory->setEnabled(
true);
1072 uiadv->lblSwapFileSync->setEnabled(
true);
1073 uiadv->spbSwapFileSync->setEnabled(
true);
1078void KateSaveConfigTab::apply()
1080 modeConfigPage->apply();
1083 if (!hasChanged()) {
1091 if (uiadv->edtBackupSuffix->text().isEmpty() && uiadv->edtBackupPrefix->text().isEmpty()) {
1093 uiadv->edtBackupSuffix->setText(QStringLiteral(
"~"));
1096 KateDocumentConfig::global()->setBackupOnSaveLocal(uiadv->chkBackupLocalFiles->isChecked());
1097 KateDocumentConfig::global()->setBackupOnSaveRemote(uiadv->chkBackupRemoteFiles->isChecked());
1098 KateDocumentConfig::global()->setBackupPrefix(uiadv->edtBackupPrefix->text());
1099 KateDocumentConfig::global()->setBackupSuffix(uiadv->edtBackupSuffix->text());
1101 KateDocumentConfig::global()->setSwapFileMode(uiadv->cmbSwapFileMode->currentIndex());
1102 KateDocumentConfig::global()->setSwapDirectory(uiadv->kurlSwapDirectory->url().toLocalFile());
1103 KateDocumentConfig::global()->setSwapSyncInterval(uiadv->spbSwapFileSync->value());
1105 KateDocumentConfig::global()->setRemoveSpaces(ui->cbRemoveTrailingSpaces->currentIndex());
1107 KateDocumentConfig::global()->setNewLineAtEof(ui->chkNewLineAtEof->isChecked());
1110 KateDocumentConfig::global()->setEncoding(
KCharsets::charsets()->encodingForName(ui->cmbEncoding->currentText()));
1112 KateGlobalConfig::global()->
setValue(KateGlobalConfig::EncodingProberType, (KEncodingProber::ProberType)ui->cmbEncodingDetection->currentIndex());
1113 KateGlobalConfig::global()->setFallbackEncoding(
KCharsets::charsets()->encodingForName(ui->cmbEncodingFallback->currentText()));
1115 KateDocumentConfig::global()->setEol(ui->cmbEOL->currentIndex());
1116 KateDocumentConfig::global()->setAllowEolDetection(ui->chkDetectEOL->isChecked());
1117 KateDocumentConfig::global()->setBom(ui->chkEnableBOM->isChecked());
1119 KateDocumentConfig::global()->setLineLengthLimit(ui->lineLengthLimit->value());
1121 KateDocumentConfig::global()->
setValue(KateDocumentConfig::AutoSave, ui->gbAutoSave->isChecked());
1122 KateDocumentConfig::global()->
setValue(KateDocumentConfig::AutoSaveOnFocusOut, ui->cbAutoSaveOnFocus->isChecked());
1123 KateDocumentConfig::global()->
setValue(KateDocumentConfig::AutoSaveInteral, ui->spbAutoSaveInterval->value());
1125 KateDocumentConfig::global()->
setValue(KateDocumentConfig::AutoReloadIfStateIsInVersionControl, uiadv->chkAutoReloadVersionControl->isChecked());
1126 KateDocumentConfig::global()->
setValue(KateDocumentConfig::UseEditorConfig, uiadv->chkEditorConfig->isChecked());
1128 KateDocumentConfig::global()->
configEnd();
1129 KateGlobalConfig::global()->
configEnd();
1132void KateSaveConfigTab::reload()
1134 modeConfigPage->reload();
1137 ui->cmbEncoding->clear();
1138 ui->cmbEncodingFallback->clear();
1140 for (
int i = 0; i < encodings.count(); i++) {
1143 ui->cmbEncoding->addItem(encodings[i]);
1144 ui->cmbEncodingFallback->addItem(encodings[i]);
1146 if (encodingName == KateDocumentConfig::global()->encoding()) {
1147 ui->cmbEncoding->setCurrentIndex(i);
1150 if (encodingName == KateGlobalConfig::global()->fallbackEncoding()) {
1152 ui->cmbEncodingFallback->setCurrentIndex(i);
1157 ui->cmbEncodingDetection->clear();
1159 const auto proberType = (KEncodingProber::ProberType)KateGlobalConfig::global()->value(KateGlobalConfig::EncodingProberType).toInt();
1162 if (i == proberType) {
1163 ui->cmbEncodingDetection->setCurrentIndex(ui->cmbEncodingDetection->count() - 1);
1168 ui->cmbEncodingDetection->setCurrentIndex(KEncodingProber::Universal);
1172 ui->cmbEOL->setCurrentIndex(KateDocumentConfig::global()->eol());
1173 ui->chkDetectEOL->setChecked(KateDocumentConfig::global()->allowEolDetection());
1174 ui->chkEnableBOM->setChecked(KateDocumentConfig::global()->
bom());
1175 ui->lineLengthLimit->setValue(KateDocumentConfig::global()->lineLengthLimit());
1177 ui->cbRemoveTrailingSpaces->setCurrentIndex(KateDocumentConfig::global()->removeSpaces());
1178 ui->chkNewLineAtEof->setChecked(KateDocumentConfig::global()->newLineAtEof());
1181 uiadv->chkBackupLocalFiles->setChecked(KateDocumentConfig::global()->backupOnSaveLocal());
1182 uiadv->chkBackupRemoteFiles->setChecked(KateDocumentConfig::global()->backupOnSaveRemote());
1183 uiadv->edtBackupPrefix->setText(KateDocumentConfig::global()->backupPrefix());
1184 uiadv->edtBackupSuffix->setText(KateDocumentConfig::global()->backupSuffix());
1186 uiadv->cmbSwapFileMode->setCurrentIndex(KateDocumentConfig::global()->swapFileMode());
1187 uiadv->kurlSwapDirectory->setUrl(
QUrl::fromLocalFile(KateDocumentConfig::global()->swapDirectory()));
1188 uiadv->spbSwapFileSync->setValue(KateDocumentConfig::global()->swapSyncInterval());
1189 swapFileModeChanged(KateDocumentConfig::global()->swapFileMode());
1191 ui->gbAutoSave->setChecked(KateDocumentConfig::global()->autoSave());
1192 ui->cbAutoSaveOnFocus->setChecked(KateDocumentConfig::global()->autoSaveOnFocusOut());
1193 ui->spbAutoSaveInterval->setValue(KateDocumentConfig::global()->autoSaveInterval());
1195 uiadv->chkAutoReloadVersionControl->setChecked(KateDocumentConfig::global()->value(KateDocumentConfig::AutoReloadIfStateIsInVersionControl).toBool());
1196 uiadv->chkEditorConfig->setChecked(KateDocumentConfig::global()->value(KateDocumentConfig::UseEditorConfig).toBool());
1199void KateSaveConfigTab::reset()
1201 modeConfigPage->reset();
1204void KateSaveConfigTab::defaults()
1206 modeConfigPage->defaults();
1208 ui->cbRemoveTrailingSpaces->setCurrentIndex(0);
1210 uiadv->chkBackupLocalFiles->setChecked(
true);
1211 uiadv->chkBackupRemoteFiles->setChecked(
false);
1212 uiadv->edtBackupPrefix->setText(
QString());
1213 uiadv->edtBackupSuffix->setText(QStringLiteral(
"~"));
1215 uiadv->cmbSwapFileMode->setCurrentIndex(1);
1216 uiadv->kurlSwapDirectory->setDisabled(
true);
1217 uiadv->lblSwapDirectory->setDisabled(
true);
1218 uiadv->spbSwapFileSync->setValue(15);
1221QString KateSaveConfigTab::name()
const
1223 return i18n(
"Open/Save");
1226QString KateSaveConfigTab::fullName()
const
1228 return i18n(
"File Opening & Saving");
1231QIcon KateSaveConfigTab::icon()
const
1240 : KateViewBarWidget(true, parent)
1243 Q_ASSERT(m_view !=
nullptr);
1281 btn->
setDefaultAction(m_view->action(QStringLiteral(
"modified_line_down")));
1289 setFocusProxy(m_gotoRange);
1292void KateGotoBar::showEvent(
QShowEvent *event)
1299void KateGotoBar::closed()
1304bool KateGotoBar::eventFilter(
QObject *
object,
QEvent *event)
1306 if (
object == m_modifiedUp ||
object == m_modifiedDown) {
1313 if (m_wheelDelta != 0 && (m_wheelDelta < 0) != (delta < 0)) {
1317 m_wheelDelta += delta;
1319 if (m_wheelDelta >= 120) {
1321 m_modifiedUp->
click();
1322 }
else if (m_wheelDelta <= -120) {
1324 m_modifiedDown->
click();
1331void KateGotoBar::gotoClipboard()
1339 if (lineNo >= m_gotoRange->
minimum() && lineNo <= m_gotoRange->maximum()) {
1344 message->setWordWrap(
true);
1345 message->setAutoHide(2000);
1351void KateGotoBar::updateData()
1364void KateGotoBar::keyPressEvent(
QKeyEvent *event)
1366 int key =
event->key();
1374void KateGotoBar::gotoLine()
1377 if (kv && kv->selection() && !kv->config()->persistentSelection()) {
1378 kv->clearSelection();
1381 int gotoValue = m_gotoRange->
value();
1382 if (gotoValue < 0) {
1384 }
else if (gotoValue > 0) {
1395KateDictionaryBar::KateDictionaryBar(KTextEditor::ViewPrivate *view,
QWidget *parent)
1396 : KateViewBarWidget(true, parent)
1399 Q_ASSERT(m_view !=
nullptr);
1406 connect(view->doc(), &KTextEditor::DocumentPrivate::defaultDictionaryChanged,
this, &KateDictionaryBar::updateData);
1408 label->setBuddy(m_dictionaryComboBox);
1411 topLayout->
addWidget(m_dictionaryComboBox, 1);
1416KateDictionaryBar::~KateDictionaryBar()
1420void KateDictionaryBar::updateData()
1423 QString dictionary = document->defaultDictionary();
1430void KateDictionaryBar::dictionaryChanged(
const QString &dictionary)
1434 const bool blockmode = m_view->blockSelection();
1435 m_view->doc()->setDictionary(dictionary, selection, blockmode);
1437 m_view->doc()->setDefaultDictionary(dictionary);
1448 , m_fullDiffPath(
QStandardPaths::findExecutable(QStringLiteral(
"diff")))
1450 , m_diffFile(nullptr)
1451 , m_diffAction(nullptr)
1454 m_message->setWordWrap(
true);
1458 if (!onDiskDeleted) {
1462 i18n(
"Reloads and will automatically reload without warning about disk changes from now until you close either the tab or window."));
1463 m_message->addAction(aAutoReload,
false);
1466 if (!m_fullDiffPath.isEmpty()) {
1467 m_diffAction =
new QAction(
i18n(
"View &Difference"),
this);
1468 m_diffAction->setIcon(
QIcon::fromTheme(QStringLiteral(
"document-multiple")));
1469 m_diffAction->setToolTip(
i18n(
"Shows a diff of the changes."));
1470 m_message->addAction(m_diffAction,
false);
1476 aReload->
setToolTip(
i18n(
"Reloads the file from disk. Unsaved changes will be lost."));
1477 m_message->addAction(aReload);
1480 QAction *closeFile =
new QAction(
i18nc(
"@action:button closes the opened file",
"&Close File"),
this);
1482 closeFile->
setToolTip(
i18n(
"Closes the file, discarding its content."));
1483 m_message->addAction(closeFile,
false);
1486 auto *aSaveAs =
new QAction(
i18nc(
"@action",
"&Save As…"),
this);
1488 aSaveAs->setToolTip(
i18n(
"Lets you select a location and save the file again."));
1489 m_message->addAction(aSaveAs,
false);
1494 aIgnore->
setToolTip(
i18n(
"Ignores the changes on disk without any action."));
1496 m_message->addAction(aIgnore);
1499 m_doc->postMessage(m_message);
1502KateModOnHdPrompt::~KateModOnHdPrompt()
1509 m_diffFile =
nullptr;
1514void KateModOnHdPrompt::slotDiff()
1526 *m_proc << m_fullDiffPath << QStringLiteral(
"-u") << QStringLiteral(
"-") << m_doc->
url().
toLocalFile();
1536 int lastln = m_doc->
lines() - 1;
1537 for (
int l = 0; l < lastln; ++l) {
1538 ts << m_doc->
line(l) <<
'\n';
1540 ts << m_doc->
line(lastln);
1545void KateModOnHdPrompt::slotDataAvailable()
1550void KateModOnHdPrompt::slotPDone()
1560 i18n(
"The diff command failed. Please make sure that "
1561 "diff(1) is installed and in your PATH."),
1562 i18n(
"Error Creating Diff"));
1564 m_diffFile =
nullptr;
1568 if (m_diffFile->
size() == 0) {
1571 m_diffFile =
nullptr;
1578 m_diffFile =
nullptr;
1588#include "moc_katedialogs.cpp"
QString encodingForName(const QString &descriptiveName) const
static KCharsets * charsets()
static QString nameForProberType(ProberType proberType)
void setDeleteTemporaryFile(bool b)
void setUiDelegate(KJobUiDelegate *delegate)
void setOutputChannelMode(OutputChannelMode mode)
virtual void apply()=0
This slot is called whenever the button Apply or OK was clicked.
virtual void reset()=0
This slot is called whenever the button Reset was clicked.
virtual QString name() const =0
Get a readable name for the config page.
virtual void defaults()=0
Sets default options This slot is called whenever the button Defaults was clicked.
The Cursor represents a position in a Document.
constexpr int line() const noexcept
Retrieve the line on which this cursor is situated.
Backend of KTextEditor::Document related public KTextEditor interfaces.
QString line(int line) const override
Get a single text line.
int lines() const override
Get the count of lines of the document.
A KParts derived class representing a text document.
void textChanged(KTextEditor::Document *document)
The document emits this signal whenever its text changes.
virtual int lines() const =0
Get the count of lines of the document.
virtual bool postMessage(Message *message)=0
Post message to the Document and its Views.
ModifiedOnDiskReason
Reasons why a document is modified on disk.
@ OnDiskDeleted
The file was deleted or moved on disk.
static KTextEditor::EditorPrivate * self()
Kate Part Internal stuff ;)
QList< KTextEditor::Document * > documents() override
Returns a list of all documents of this editor.
static Editor * instance()
Accessor to get the Editor instance.
void addVariableExpansion(const QList< QWidget * > &widgets, const QStringList &variables=QStringList()) const
Adds a QAction to the widget in widgets that whenever focus is gained.
This class holds a Message to display in Views.
@ AboveView
show message above view.
@ BottomInView
show message as view overlay in the bottom right corner.
An object representing a section of text, from one Cursor to another.
constexpr bool isEmpty() const noexcept
Returns true if this range contains no characters, ie.
constexpr bool isValid() const noexcept
Validity check.
A text widget with KXMLGUIClient that represents a Document.
virtual bool setCursorPosition(Cursor position)=0
Set the view's new cursor to position.
virtual Document * document() const =0
Get the view's document, that means the view is a view of the returned document.
virtual Cursor cursorPosition() const =0
Get the view's current cursor position.
static uint modeNumber(const QString &name)
Maps name -> index.
const QString & modeName() const
mode name
static QStringList listModes()
List all possible modes by name, i.e.
void configEnd()
End a config change transaction, update the concerned KateDocumentConfig/KateDocumentConfig/KateDocum...
void configStart()
Start some config changes.
bool setValue(const int key, const QVariant &value)
Set a config value.
QVariant value(const int key) const
Get a config value.
void dictionaryChanged(const QString &dictionary)
void setCurrentByDictionary(const QString &dictionary)
KLocalizedString KI18N_EXPORT ki18np(const char *singular, const char *plural)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
KLocalizedString KI18N_EXPORT ki18ncp(const char *context, const char *singular, const char *plural)
QString i18n(const char *text, const TYPE &arg...)
KIOCORE_EXPORT KJobUiDelegate * createDefaultJobUiDelegate()
void setupSpinBoxFormatString(T *spinBox, const KLocalizedString &formatString)
void information(QWidget *parent, const QString &text, const QString &title=QString(), const QString &dontShowAgainName=QString(), Options options=Notify)
void error(QWidget *parent, const QString &text, const QString &title, const KGuiItem &buttonOk, Options options=Notify)
const QList< QKeySequence > & reload()
QString label(StandardShortcut id)
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
void setText(const QString &text)
void setIcon(const QIcon &icon)
void triggered(bool checked)
void addStretch(int stretch)
bool setStretchFactor(QLayout *layout, int stretch)
void stateChanged(int state)
void currentIndexChanged(int index)
virtual qint64 size() const const override
QFont systemFont(SystemFont type)
QIcon fromTheme(const QString &name)
qint64 write(const QByteArray &data)
void linkActivated(const QString &link)
void setContentsMargins(const QMargins &margins)
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
qsizetype size() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
void installEventFilter(QObject *filterObj)
T qobject_cast(QObject *object)
QProcess::ExitStatus exitStatus() const const
void finished(int exitCode, QProcess::ExitStatus exitStatus)
bool isEmpty() const const
typedef KeyboardModifiers
QTextStream & bom(QTextStream &stream)
virtual QString fileName() const const override
void setAutoRemove(bool b)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QUrl fromLocalFile(const QString &localFile)
QString toLocalFile() const const
QStringList toStringList() const const
void showText(const QPoint &pos, const QString &text, QWidget *w)