Skip to content
GitLab
Menu
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
66feb51e
Commit
66feb51e
authored
Mar 04, 2021
by
Christoph Cullmann
🐮
Browse files
enable forward/backwards actions differently
avoid explicit button handling, just keep actions in the right state
parent
e05869c3
Changes
4
Hide whitespace changes
Inline
Side-by-side
kate/katemainwindow.cpp
View file @
66feb51e
...
...
@@ -251,12 +251,20 @@ void KateMainWindow::setupImportantActions()
// actionCollection()->setDefaultShortcut(a, QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_O));
connect
(
a
,
&
QAction
::
triggered
,
this
,
&
KateMainWindow
::
goBack
);
// ensure they have the right state, start with no history
a
->
setEnabled
(
false
);
connect
(
this
,
&
KateMainWindow
::
backButtonEnabled
,
a
,
&
QAction
::
setEnabled
);
a
=
actionCollection
()
->
addAction
(
QStringLiteral
(
"view_history_forward"
));
a
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"arrow-right"
)));
a
->
setText
(
i18n
(
"Jump to next location"
));
// actionCollection()->setDefaultShortcut(a, QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_O));
connect
(
a
,
&
QAction
::
triggered
,
this
,
&
KateMainWindow
::
goForward
);
// ensure they have the right state, start with no history
a
->
setEnabled
(
false
);
connect
(
this
,
&
KateMainWindow
::
forwardButtonEnabled
,
a
,
&
QAction
::
setEnabled
);
// kate command bar
a
=
actionCollection
()
->
addAction
(
QStringLiteral
(
"view_commandbar_open"
));
actionCollection
()
->
setDefaultShortcut
(
a
,
QKeySequence
(
Qt
::
CTRL
|
Qt
::
ALT
|
Qt
::
Key_I
));
...
...
kate/kateviewmanager.cpp
View file @
66feb51e
...
...
@@ -87,17 +87,6 @@ KateViewManager::KateViewManager(QWidget *parentW, KateMainWindow *parent)
documentCreated
(
doc
);
}
connect
(
m_mainWindow
,
&
KateMainWindow
::
backButtonEnabled
,
this
,
[
this
](
bool
v
)
{
if
(
auto
avs
=
activeViewSpace
())
{
avs
->
setBackButtonEnabled
(
v
);
}
});
connect
(
m_mainWindow
,
&
KateMainWindow
::
forwardButtonEnabled
,
this
,
[
this
](
bool
v
)
{
if
(
auto
avs
=
activeViewSpace
())
{
avs
->
setForwardButtonEnabled
(
v
);
}
});
m_blockViewCreationAndActivation
=
false
;
// init done
...
...
kate/kateviewspace.cpp
View file @
66feb51e
...
...
@@ -48,29 +48,25 @@ KateViewSpace::KateViewSpace(KateViewManager *viewManager, QWidget *parent, cons
hLayout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
// add left <-> right history buttons
m_
historyLeft
=
new
QToolButton
(
this
);
auto
historyLeft
=
new
QToolButton
(
this
);
auto
hlAct
=
m_viewManager
->
mainWindow
()
->
actionCollection
()
->
action
(
QStringLiteral
(
"view_history_back"
));
m_
historyLeft
->
setDefaultAction
(
hlAct
);
m_
historyLeft
->
setToolTip
(
hlAct
->
text
());
m_
historyLeft
->
setIcon
(
hlAct
->
icon
());
m_
historyLeft
->
setAutoRaise
(
true
);
KAcceleratorManager
::
setNoAccel
(
m_
historyLeft
);
m_
historyLeft
->
installEventFilter
(
this
);
// on click, active this view space
hLayout
->
addWidget
(
m_
historyLeft
);
m_
historyRight
=
new
QToolButton
(
this
);
historyLeft
->
setDefaultAction
(
hlAct
);
historyLeft
->
setToolTip
(
hlAct
->
text
());
historyLeft
->
setIcon
(
hlAct
->
icon
());
historyLeft
->
setAutoRaise
(
true
);
KAcceleratorManager
::
setNoAccel
(
historyLeft
);
historyLeft
->
installEventFilter
(
this
);
// on click, active this view space
hLayout
->
addWidget
(
historyLeft
);
auto
historyRight
=
new
QToolButton
(
this
);
auto
hrAct
=
m_viewManager
->
mainWindow
()
->
actionCollection
()
->
action
(
QStringLiteral
(
"view_history_forward"
));
m_historyRight
->
setDefaultAction
(
hrAct
);
m_historyRight
->
setIcon
(
hrAct
->
icon
());
m_historyRight
->
setToolTip
(
hrAct
->
text
());
m_historyRight
->
setAutoRaise
(
true
);
KAcceleratorManager
::
setNoAccel
(
m_historyRight
);
m_historyRight
->
installEventFilter
(
this
);
// on click, active this view space
hLayout
->
addWidget
(
m_historyRight
);
// deactive in the beginning for now
setBackButtonEnabled
(
false
);
setForwardButtonEnabled
(
false
);
historyRight
->
setDefaultAction
(
hrAct
);
historyRight
->
setIcon
(
hrAct
->
icon
());
historyRight
->
setToolTip
(
hrAct
->
text
());
historyRight
->
setAutoRaise
(
true
);
KAcceleratorManager
::
setNoAccel
(
historyRight
);
historyRight
->
installEventFilter
(
this
);
// on click, active this view space
hLayout
->
addWidget
(
historyRight
);
// add tab bar
m_tabBar
=
new
KateTabBar
(
this
);
...
...
@@ -467,16 +463,6 @@ void KateViewSpace::focusNextTab()
}
}
void
KateViewSpace
::
setForwardButtonEnabled
(
bool
active
)
{
m_historyRight
->
setEnabled
(
active
);
}
void
KateViewSpace
::
setBackButtonEnabled
(
bool
active
)
{
m_historyLeft
->
setEnabled
(
active
);
}
int
KateViewSpace
::
hiddenDocuments
()
const
{
const
int
hiddenDocs
=
KateApp
::
self
()
->
documents
().
count
()
-
m_tabBar
->
count
();
...
...
kate/kateviewspace.h
View file @
66feb51e
...
...
@@ -91,16 +91,6 @@ public:
*/
void
focusNextTab
();
/**
* set Forward Button Active
*/
void
setForwardButtonEnabled
(
bool
active
);
/**
* set Back Button Active
*/
void
setBackButtonEnabled
(
bool
active
);
public
Q_SLOTS
:
void
documentDestroyed
(
QObject
*
doc
);
void
updateDocumentName
(
KTextEditor
::
Document
*
doc
);
...
...
@@ -181,9 +171,6 @@ private:
// quick open action
QToolButton
*
m_quickOpen
;
QToolButton
*
m_historyLeft
;
QToolButton
*
m_historyRight
;
};
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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