Commit 66feb51e authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

enable forward/backwards actions differently

avoid explicit button handling, just keep
actions in the right state
parent e05869c3
......@@ -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));
......
......@@ -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
......
......@@ -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();
......
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment