Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
41d027e6
Commit
41d027e6
authored
Sep 02, 2022
by
Waqar Ahmed
Committed by
Christoph Cullmann
Sep 03, 2022
Browse files
Add diff style to config dialog
parent
2165e21e
Changes
4
Hide whitespace changes
Inline
Side-by-side
apps/lib/diffeditor.h
View file @
41d027e6
...
...
@@ -20,7 +20,7 @@ struct LineHighlight {
bool
added
;
};
enum
DiffStyle
{
SideBySide
,
Unified
,
Raw
};
enum
DiffStyle
{
SideBySide
=
0
,
Unified
,
Raw
};
class
DiffEditor
:
public
QPlainTextEdit
{
...
...
apps/lib/diffwidget.cpp
View file @
41d027e6
...
...
@@ -3,7 +3,6 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include
"diffwidget.h"
#include
"diffeditor.h"
#include
"ktexteditor_utils.h"
#include
"gitprocess.h"
...
...
@@ -17,6 +16,8 @@
#include
<QScrollBar>
#include
<QSyntaxHighlighter>
#include
<KConfigGroup>
#include
<KSharedConfig>
#include
<KSyntaxHighlighting/Definition>
#include
<KSyntaxHighlighting/Format>
#include
<KSyntaxHighlighting/Repository>
...
...
@@ -61,6 +62,10 @@ DiffWidget::DiffWidget(QWidget *parent)
for
(
auto
*
e
:
{
m_left
,
m_right
})
{
connect
(
e
,
&
DiffEditor
::
switchStyle
,
this
,
&
DiffWidget
::
handleStyleChange
);
}
KSharedConfig
::
Ptr
config
=
KSharedConfig
::
openConfig
();
KConfigGroup
cgGeneral
=
KConfigGroup
(
config
,
"General"
);
handleStyleChange
(
cgGeneral
.
readEntry
(
"Diff Show Style"
,
(
int
)
SideBySide
));
}
void
DiffWidget
::
handleStyleChange
(
int
newStyle
)
...
...
@@ -69,21 +74,21 @@ void DiffWidget::handleStyleChange(int newStyle)
return
;
}
m_style
=
(
DiffStyle
)
newStyle
;
m_left
->
clearData
()
;
m_right
->
clearData
();
const
auto
diff
=
m_rawDiff
;
clearData
();
if
(
m_style
==
SideBySide
)
{
m_left
->
setVisible
(
true
);
m_right
->
setVisible
(
true
);
openDiff
(
m_rawD
iff
);
openDiff
(
d
iff
);
}
else
if
(
m_style
==
Unified
)
{
m_left
->
setVisible
(
true
);
m_right
->
setVisible
(
false
);
openDiff
(
m_rawD
iff
);
openDiff
(
d
iff
);
}
else
if
(
m_style
==
Raw
)
{
m_left
->
setVisible
(
true
);
m_right
->
setVisible
(
false
);
openDiff
(
m_rawD
iff
);
openDiff
(
d
iff
);
}
else
{
qWarning
()
<<
"Unexpected diff style value: "
<<
newStyle
;
Q_UNREACHABLE
();
...
...
apps/lib/kateconfigdialog.cpp
View file @
41d027e6
...
...
@@ -282,6 +282,21 @@ void KateConfigDialog::addBehaviorPage()
buttonGroup
->
setLayout
(
vbox
);
/** DIFF **/
buttonGroup
=
new
QGroupBox
(
i18n
(
"Diff"
),
generalFrame
);
vbox
=
new
QVBoxLayout
(
buttonGroup
);
hlayout
=
new
QHBoxLayout
;
vbox
->
addLayout
(
hlayout
);
layout
->
addWidget
(
buttonGroup
);
m_diffStyle
=
new
QComboBox
;
m_diffStyle
->
addItem
(
i18n
(
"Side By Side"
));
m_diffStyle
->
addItem
(
i18n
(
"Unified"
));
m_diffStyle
->
addItem
(
i18n
(
"Raw"
));
hlayout
->
addWidget
(
new
QLabel
(
i18n
(
"Diff Style:"
)));
hlayout
->
addWidget
(
m_diffStyle
);
m_diffStyle
->
setCurrentIndex
(
cgGeneral
.
readEntry
(
"Diff Show Style"
,
0
));
connect
(
m_diffStyle
,
static_cast
<
void
(
QComboBox
::*
)(
int
)
>
(
&
QComboBox
::
currentIndexChanged
),
this
,
&
KateConfigDialog
::
slotChanged
);
layout
->
addStretch
(
1
);
// :-] works correct without autoadd
}
...
...
@@ -518,6 +533,8 @@ void KateConfigDialog::slotApply()
cg
.
writeEntry
(
"Allow Tab Scrolling"
,
m_tabsScrollable
->
isChecked
());
cg
.
writeEntry
(
"Elide Tab Text"
,
m_tabsElided
->
isChecked
());
cg
.
writeEntry
(
"Diff Show Style"
,
m_diffStyle
->
currentIndex
());
// patch document modified warn state
const
QList
<
KTextEditor
::
Document
*>
&
docs
=
KateApp
::
self
()
->
documentManager
()
->
documentList
();
for
(
KTextEditor
::
Document
*
doc
:
docs
)
{
...
...
apps/lib/kateconfigdialog.h
View file @
41d027e6
...
...
@@ -102,6 +102,7 @@ private:
QCheckBox
*
m_tabMiddleClickCloseDocument
;
QCheckBox
*
m_tabsScrollable
=
nullptr
;
QCheckBox
*
m_tabsElided
=
nullptr
;
QComboBox
*
m_diffStyle
=
nullptr
;
Ui
::
SessionConfigWidget
sessionConfigUi
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment