summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Haumann <dhaumann@kde.org>2014-01-22 17:02:25 (GMT)
committerDominik Haumann <dhaumann@kde.org>2014-01-22 17:02:31 (GMT)
commitc65410cb03efbf7748aef9da68d16abc8cc358c5 (patch)
treed43e9ac751907910adbf4cef039e1da940596156
parent9c2d2d709404058ccaa3ea82b6714f720320c684 (diff)
add split actions to view space bar
-rw-r--r--kate/app/katemainwindow.cpp2
-rw-r--r--kate/app/katetabbar.cpp25
-rw-r--r--kate/app/katetabbar.h10
-rw-r--r--kate/app/kateviewspace.cpp51
-rw-r--r--kate/app/kateviewspace.h5
5 files changed, 56 insertions, 37 deletions
diff --git a/kate/app/katemainwindow.cpp b/kate/app/katemainwindow.cpp
index e6bfc28..0e38867 100644
--- a/kate/app/katemainwindow.cpp
+++ b/kate/app/katemainwindow.cpp
@@ -195,8 +195,6 @@ KateMainWindow::KateMainWindow (KConfig *sconfig, const QString &sgroup)
connect(KateSessionManager::self(), SIGNAL(sessionChanged()), this, SLOT(updateCaption()));
connect(this,SIGNAL(sigShowPluginConfigPage(KTextEditor::ConfigPageInterface *,uint)),this,SLOT(showPluginConfigPage(KTextEditor::ConfigPageInterface *,uint)));
-
-
}
KateMainWindow::~KateMainWindow()
diff --git a/kate/app/katetabbar.cpp b/kate/app/katetabbar.cpp
index f6d5a60..edd7880 100644
--- a/kate/app/katetabbar.cpp
+++ b/kate/app/katetabbar.cpp
@@ -123,13 +123,6 @@ KateTabBar::KateTabBar(QWidget *parent)
m_activeButton = 0L;
- // functions called in ::load() will set settings for the nav buttons
- m_moreButton = new QToolButton(this);
- m_moreButton->setAutoRaise(true);
- m_moreButton->setText(i18n("..."));
- m_moreButton->setToolTip(i18n("Quick Open"));
- connect(m_moreButton, SIGNAL(clicked()), this, SIGNAL(moreButtonClicked()));
-
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
updateFixedHeight();
}
@@ -663,14 +656,12 @@ void KateTabBar::tabButtonCloseAllRequest()
void KateTabBar::resizeEvent(QResizeEvent *event)
{
// qDebug() << "resizeEvent";
- // if there are no tabs there is nothing to do. Do not delete otherwise
- // division by zero is possible.
+ // if there are no tabs there is nothing to do
if (m_tabButtons.count() == 0) {
- updateHelperButtons(event->size());
return;
}
- int tabbar_width = event->size().width() - m_navigateSize;
+ int tabbar_width = event->size().width();
int tabs_per_row = tabbar_width / minimumTabWidth();
if (tabs_per_row == 0) {
tabs_per_row = 1;
@@ -684,8 +675,6 @@ void KateTabBar::resizeEvent(QResizeEvent *event)
// more ugly if there is a lot wasted space on the right.
tab_width = tabbar_width / tabs_per_row;
- updateHelperButtons(event->size());
-
KateTabButton *tabButton;
foreach(tabButton, m_tabButtons)
@@ -715,16 +704,6 @@ void KateTabBar::updateFixedHeight()
triggerResizeEvent();
}
-/**
- * May modifies current row if more tabs fit into a row.
- * Sets geometry for the buttons 'up', 'down' and 'configure'.
- */
-void KateTabBar::updateHelperButtons(QSize new_size)
-{
- m_moreButton->setGeometry(new_size.width() - m_moreButton->minimumSizeHint().width(),
- 0, m_moreButton->minimumSizeHint().width(), tabHeight());
-}
-
void KateTabBar::updateSort()
{
global_sortType = tabSortType();
diff --git a/kate/app/katetabbar.h b/kate/app/katetabbar.h
index 93e95a2..818815b 100644
--- a/kate/app/katetabbar.h
+++ b/kate/app/katetabbar.h
@@ -122,11 +122,6 @@ Q_SIGNALS:
void closeRequest(int button_id);
/**
- * This signal is emitted whenever the more button is clicked.
- */
- void moreButtonClicked();
-
- /**
* This signal is emitted whenever a highlight mark changes.
* Usually this is used to synchronice several tabbars.
*/
@@ -146,7 +141,6 @@ protected:
void updateFixedHeight();
void triggerResizeEvent();
void updateSort();
- void updateHelperButtons(QSize new_size);
private:
int m_minimumTabWidth;
@@ -158,10 +152,6 @@ private:
KateTabButton *m_activeButton;
- // config/more button
- QToolButton * m_moreButton;
- int m_navigateSize;
-
int m_nextID;
// map of highlighted tabs and colors
diff --git a/kate/app/kateviewspace.cpp b/kate/app/kateviewspace.cpp
index 71c6716..5b3be5b 100644
--- a/kate/app/kateviewspace.cpp
+++ b/kate/app/kateviewspace.cpp
@@ -28,6 +28,7 @@
#include "katesessionmanager.h"
#include "katedebug.h"
#include "katetabbar.h"
+#include "kactioncollection.h"
#include <KSqueezedTextLabel>
#include <KStringHandler>
@@ -37,6 +38,7 @@
#include <KXMLGUIFactory>
#include <QTimer>
+#include <QToolButton>
#include <QCursor>
#include <QMouseEvent>
#include <QMenu>
@@ -54,10 +56,40 @@ KateViewSpace::KateViewSpace( KateViewManager *viewManager,
layout->setSpacing(0);
layout->setMargin(0);
+ //BEGIN tab bar
+ QHBoxLayout * hLayout = new QHBoxLayout();
+
+ // add tab bar
m_tabBar = new KateTabBar(this);
layout->addWidget(m_tabBar);
connect(m_tabBar, &KateTabBar::currentChanged, this, &KateViewSpace::changeView);
- connect(m_tabBar, &KateTabBar::moreButtonClicked, m_viewManager->mainWindow(), &KateMainWindow::slotQuickOpen);
+ hLayout->addWidget(m_tabBar);
+
+ // add vertical split view space
+ QToolButton * split = new QToolButton(this);
+ split->setAutoRaise(true);
+ split->setDefaultAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_split_vert")));
+ split->setWhatsThis(i18n("Split this view horizontally into two views."));
+ split->installEventFilter(this); // on click, active this view space
+ hLayout->addWidget(split);
+
+ // add horizontally split view space
+ split = new QToolButton(this);
+ split->setAutoRaise(true);
+ split->setDefaultAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_split_horiz")));
+ split->setWhatsThis(i18n("Split this view vertically into two views."));
+ split->installEventFilter(this); // on click, active this view space
+ hLayout->addWidget(split);
+
+ // add quick open
+ QToolButton * quickOpen = new QToolButton(this);
+ quickOpen->setAutoRaise(true);
+ quickOpen->setDefaultAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_quick_open")));
+ quickOpen->installEventFilter(this); // on click, active this view space
+ hLayout->addWidget(quickOpen);
+
+ layout->addLayout(hLayout);
+ //END tab bar
stack = new QStackedWidget( this );
stack->setFocus();
@@ -78,6 +110,15 @@ KateViewSpace::KateViewSpace( KateViewManager *viewManager,
KateViewSpace::~KateViewSpace()
{}
+bool KateViewSpace::eventFilter(QObject *obj, QEvent *event)
+{
+ if (! isActiveSpace() && qobject_cast<QToolButton*>(obj) && event->type() == QEvent::MouseButtonPress) {
+ m_viewManager->setActiveSpace(this);
+ m_viewManager->activateView(currentView()->document());
+ }
+ return false;
+}
+
void KateViewSpace::statusBarToggled ()
{
Q_FOREACH(auto view, mViewList) {
@@ -144,8 +185,14 @@ void KateViewSpace::removeView(KTextEditor::View* v)
return;
// the last recently used viewspace is always at the end of the list
- if (!mViewList.isEmpty())
+ if (!mViewList.isEmpty()) {
showView(mViewList.last());
+ }
+ // if we still have tabs, use these
+ else if (! m_docToTabId.isEmpty()) {
+ QList<KTextEditor::Document*> keys = m_docToTabId.keys();
+ m_viewManager->createView(keys.first());
+ }
}
KTextEditor::View * KateViewSpace::viewForDocument(KTextEditor::Document * doc) const
diff --git a/kate/app/kateviewspace.h b/kate/app/kateviewspace.h
index e7e6de7..2f5bbf5 100644
--- a/kate/app/kateviewspace.h
+++ b/kate/app/kateviewspace.h
@@ -78,6 +78,11 @@ class KateViewSpace : public QFrame
*/
void registerDocument(KTextEditor::Document *doc);
+ /**
+ * Event filter to catch events from view space tool buttons.
+ */
+ bool eventFilter(QObject *obj, QEvent *event);
+
public Q_SLOTS:
void documentDestroyed(QObject * doc);
void updateDocumentName(KTextEditor::Document* doc);