summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Cullmann <cullmann@kde.org>2014-01-21 15:16:13 (GMT)
committerChristoph Cullmann <cullmann@kde.org>2014-01-21 15:16:13 (GMT)
commitccd7be29a41122857a734dfc5a44a48eb3c2a995 (patch)
tree3f6eb9ff67d98d2ea9c90c236d16aebd32787e7a
parent25c484af021e62d010b92c882029bb2d01ea2b5f (diff)
add Qt style api for disabling the status bar
-rw-r--r--src/include/ktexteditor/view.h18
-rw-r--r--src/utils/ktexteditor.cpp24
-rw-r--r--src/view/kateview.cpp23
-rw-r--r--src/view/kateview.h14
4 files changed, 73 insertions, 6 deletions
diff --git a/src/include/ktexteditor/view.h b/src/include/ktexteditor/view.h
index 27de130..e07913f 100644
--- a/src/include/ktexteditor/view.h
+++ b/src/include/ktexteditor/view.h
@@ -596,9 +596,6 @@ public:
*/
virtual bool insertText(const QString &text);
- /*
- * Access to print routines
- */
public:
/**
* Print the document. This should result in showing the print dialog.
@@ -612,6 +609,21 @@ public:
*/
virtual void printPreview() = 0;
+ /**
+ * Is the status bar enabled?
+ *
+ * @return status bar enabled?
+ */
+ bool isStatusBarEnabled() const;
+
+ /**
+ * Show/hide the status bar of the view.
+ * Per default, the status bar is enabled.
+ *
+ * @param enable should the status bar be enabled?
+ */
+ void setStatusBarEnabled(bool enable);
+
private:
/**
* private d-pointer, pointing to the internal implementation
diff --git a/src/utils/ktexteditor.cpp b/src/utils/ktexteditor.cpp
index 8bf3631..a9c87f0 100644
--- a/src/utils/ktexteditor.cpp
+++ b/src/utils/ktexteditor.cpp
@@ -17,7 +17,7 @@
Boston, MA 02110-1301, USA.
*/
-#include <QtDBus>
+#include "kateview.h"
#include "cursor.h"
@@ -83,6 +83,28 @@ bool View::insertText(const QString &text)
return doc->insertText(cursorPosition(), text, blockSelection());
}
+bool View::isStatusBarEnabled() const
+{
+ /**
+ * is the status bar around?
+ */
+ return !!d->statusBar();
+}
+
+void View::setStatusBarEnabled(bool enable)
+{
+ /**
+ * no state change, do nothing
+ */
+ if (enable == !!d->statusBar())
+ return;
+
+ /**
+ * else toggle it
+ */
+ d->toggleStatusBar ();
+}
+
ConfigPage::ConfigPage(QWidget *parent)
: QWidget(parent)
, d(0)
diff --git a/src/view/kateview.cpp b/src/view/kateview.cpp
index e62bd65..0dc4a22 100644
--- a/src/view/kateview.cpp
+++ b/src/view/kateview.cpp
@@ -129,6 +129,7 @@ KTextEditor::ViewPrivate::ViewPrivate(KTextEditor::DocumentPrivate *doc, QWidget
, m_floatTopMessageWidget(0)
, m_floatBottomMessageWidget(0)
, m_mainWindow(mainWindow)
+ , m_statusBar(nullptr)
{
// queued connect to collapse view updates for range changes, INIT THIS EARLY ENOUGH!
connect(this, SIGNAL(delayedUpdateOfView()), this, SLOT(slotDelayedUpdateOfView()), Qt::QueuedConnection);
@@ -222,8 +223,7 @@ KTextEditor::ViewPrivate::ViewPrivate(KTextEditor::DocumentPrivate *doc, QWidget
/**
* create the status bar of this view
*/
- m_statusBar = new KateStatusBar(this);
- bottomViewBar()->addPermanentBarWidget(m_statusBar);
+ toggleStatusBar();
// add layout for floating message widgets to KateViewInternal
m_notificationLayout = new QVBoxLayout(m_viewInternal);
@@ -302,6 +302,25 @@ KTextEditor::ViewPrivate::~ViewPrivate()
KTextEditor::EditorPrivate::self()->deregisterView(this);
}
+void KTextEditor::ViewPrivate::toggleStatusBar()
+{
+ /**
+ * if there, delete it
+ */
+ if (m_statusBar) {
+ bottomViewBar()->removePermanentBarWidget(m_statusBar);
+ delete m_statusBar;
+ m_statusBar = nullptr;
+ return;
+ }
+
+ /**
+ * else: create it
+ */
+ m_statusBar = new KateStatusBar(this);
+ bottomViewBar()->addPermanentBarWidget(m_statusBar);
+}
+
void KTextEditor::ViewPrivate::setupConnections()
{
connect(m_doc, SIGNAL(undoChanged()),
diff --git a/src/view/kateview.h b/src/view/kateview.h
index 2016e78..6865c67 100644
--- a/src/view/kateview.h
+++ b/src/view/kateview.h
@@ -935,6 +935,20 @@ public Q_SLOTS:
virtual bool print();
virtual void printPreview();
+public:
+ /**
+ * Get the view status bar
+ * @return status bar, in enabled
+ */
+ KateStatusBar *statusBar () const {
+ return m_statusBar;
+ }
+
+ /**
+ * Toogle status bar, e.g. create or remove it
+ */
+ void toggleStatusBar ();
+
private:
/**
* the status bar of this view