Commit 4877df8e authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

add status bar to bottom row

first non-crashing version

only doesn't crash if status bar is enabled

internally we need to always enable it,
the toggle should just hide the statusbarstack
parent 52dc6842
......@@ -1143,19 +1143,47 @@ void KateMainWindow::restoreWindowConfig(const KConfigGroup &config)
void KateMainWindow::slotUpdateBottomViewBar()
{
// qCDebug(LOG_KATE)<<"slotUpdateHorizontalViewBar()"<<endl;
// get active view if any, if none => just hide bar
KTextEditor::View *view = m_viewManager->activeView();
BarState bs = m_bottomViewBarMapping[view];
if (bs.bar() && bs.state()) {
if (!view) {
if (auto wid = m_bottomContainerStack->currentWidget()) {
wid->hide();
}
m_bottomViewBarContainer->hide();
return;
}
// get bar state, we must have a bar widget here, KateView always creates one!
BarState &bs = m_bottomViewBarMapping[view];
Q_ASSERT(bs.bar());
// extract statusbar if not already done
if (!bs.statusBar()) {
// we search for the status bar by class, this MUST work, we ensure that it is enabled in the view
const auto widgets = bs.bar()->findChildren<QWidget *>(QString(), Qt::FindChildrenRecursively);
for (auto *w : widgets) {
if (w && w->metaObject()->className() == QByteArrayLiteral("KateStatusBar")) {
bs.setStatusBar(w);
}
}
Q_ASSERT(bs.statusBar());
// ensure we don't mess up the vertical sizing
bs.statusBar()->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
// add the status bar to our status bar stack, there we will show/hide it
statusBarStackedWidget()->addWidget(bs.statusBar());
}
// hide or show the bar
if (bs.state()) {
m_bottomContainerStack->setCurrentWidget(bs.bar());
m_bottomContainerStack->currentWidget()->show();
m_bottomViewBarContainer->show();
} else {
QWidget *wid = m_bottomContainerStack->currentWidget();
if (wid) {
if (auto wid = m_bottomContainerStack->currentWidget()) {
wid->hide();
}
// qCDebug(LOG_KATE)<<wid<<"hiding container"<<endl;
m_bottomViewBarContainer->hide();
}
}
......
......@@ -272,6 +272,7 @@ public:
m_bottomViewBarContainer->hide();
}
delete state.bar();
delete state.statusBar();
}
}
......@@ -594,10 +595,28 @@ private:
{
m_state = state;
}
QWidget *statusBar()
{
return m_statusBar;
}
void setStatusBar(QWidget *statusBar)
{
Q_ASSERT(statusBar);
Q_ASSERT(!m_statusBar);
m_statusBar = statusBar;
}
private:
QWidget *m_bar = nullptr;
bool m_state = false;
/**
* status bar widget
* if already extracted from the bar itself
* we can't extract this on creation of the bar widget, but do this lazy
* later, as the construction order in KateView doesn't allow for that.
*/
QWidget *m_statusBar = nullptr;
};
QHash<KTextEditor::View *, BarState> m_bottomViewBarMapping;
......
......@@ -27,6 +27,7 @@
#include <QLabel>
#include <QMenu>
#include <QSizePolicy>
#include <QStackedWidget>
#include <QStyle>
#include <QTimer>
#include <QVBoxLayout>
......@@ -918,7 +919,12 @@ MainWindow::MainWindow(QWidget *parentWidget)
m_vSplitter->setStretchFactor(m_vSplitter->indexOf(m_centralWidget), 1);
m_sidebars[KMultiTabBar::Bottom] = std::make_unique<Sidebar>(KMultiTabBar::Bottom, this, vb);
vlayout->addWidget(m_sidebars[KMultiTabBar::Bottom].get());
auto bottomHBoxLaout = new QHBoxLayout;
bottomHBoxLaout->addWidget(m_sidebars[KMultiTabBar::Bottom].get());
m_statusBarStackedWidget = new QStackedWidget(this);
m_statusBarStackedWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
bottomHBoxLaout->addWidget(m_statusBarStackedWidget);
vlayout->addLayout(bottomHBoxLaout);
m_sidebars[KMultiTabBar::Bottom]->setSplitter(m_vSplitter);
m_sidebars[KMultiTabBar::Right] = std::make_unique<Sidebar>(KMultiTabBar::Right, this, hb);
......
......@@ -31,6 +31,7 @@ class KActionMenu;
class QAction;
class QLabel;
class QPixmap;
class QStackedWidget;
class KConfigBase;
namespace KTextEditor
......@@ -353,6 +354,15 @@ protected:
*/
QWidget *centralWidget() const;
/**
* Status bar area stacked widget.
* We plug in our status bars from the KTextEditor::Views here
*/
QStackedWidget *statusBarStackedWidget() const
{
return m_statusBarStackedWidget;
}
/**
* modifiers for existing toolviews
*/
......@@ -457,6 +467,11 @@ private:
*/
GUIClient *m_guiClient;
/**
* stacked widget for status bars
*/
QStackedWidget *m_statusBarStackedWidget;
Q_SIGNALS:
void sigShowPluginConfigPage(KTextEditor::Plugin *configpageinterface, int id);
};
......
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