Commit 06168866 authored by Dominik Haumann's avatar Dominik Haumann

double click in empty space of tab bar crates new empty document

parent 6d70b7b4
......@@ -434,3 +434,12 @@ int KateTabBar::maxTabCount() const
{
return qMax(1, width() / m_minimumTabWidth);
}
/**
* Override to request a new tab.
*/
void KateTabBar::mouseDoubleClickEvent(QMouseEvent *event)
{
event->accept();
emit newTabRequested();
}
......@@ -127,13 +127,21 @@ Q_SIGNALS:
*/
void lessTabsRequested(int count);
/**
* This signal is emitted whenever the users double clicks on the free
* space next to the tab bar. Typically, a new document should be
* created.
*/
void newTabRequested();
protected Q_SLOTS:
void tabButtonActivated(KateTabButton *tabButton);
void tabButtonHighlightChanged(KateTabButton *tabButton);
void tabButtonCloseRequest(KateTabButton *tabButton);
protected:
virtual void resizeEvent(QResizeEvent *event);
void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
protected:
void updateButtonPositions();
......
......@@ -266,6 +266,11 @@ void KateTabButton::mousePressEvent(QMouseEvent *ev)
}
}
void KateTabButton::mouseDoubleClickEvent(QMouseEvent *event)
{
event->accept();
}
void KateTabButton::setHighlightColor(const QColor &color)
{
if (color.isValid()) {
......
......@@ -118,11 +118,13 @@ protected Q_SLOTS:
protected:
/** paint eyecandy rectangles around the button */
virtual void paintEvent(QPaintEvent *ev);
void paintEvent(QPaintEvent *ev) Q_DECL_OVERRIDE;
/** support for context menu */
virtual void contextMenuEvent(QContextMenuEvent *ev);
void contextMenuEvent(QContextMenuEvent *ev) Q_DECL_OVERRIDE;
/** middle mouse button changes color */
virtual void mousePressEvent(QMouseEvent *ev);
void mousePressEvent(QMouseEvent *ev) Q_DECL_OVERRIDE;
/** eat double click events */
void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
private:
TabCloseButton * m_closeButton;
......
......@@ -62,6 +62,7 @@ KateViewSpace::KateViewSpace(KateViewManager *viewManager,
connect(m_tabBar, &KateTabBar::moreTabsRequested, this, &KateViewSpace::addTabs);
connect(m_tabBar, &KateTabBar::lessTabsRequested, this, &KateViewSpace::removeTabs);
connect(m_tabBar, &KateTabBar::closeTabRequested, this, &KateViewSpace::closeTabRequest);
connect(m_tabBar, &KateTabBar::newTabRequested, this, &KateViewSpace::createNewDocument);
hLayout->addWidget(m_tabBar);
// add vertical split view space
......@@ -435,6 +436,20 @@ void KateViewSpace::closeTabRequest(int id)
KateApp::self()->documentManager()->closeDocument(doc);
}
void KateViewSpace::createNewDocument()
{
// make sure we open the view in this view space
if (! isActiveSpace()) {
m_viewManager->setActiveSpace(this);
}
// create document
KTextEditor::Document *doc = KateApp::self()->documentManager()->createDoc();
// tell the view manager to show the document
m_viewManager->activateView(doc);
}
void KateViewSpace::saveConfig(KConfigBase *config, int myIndex , const QString &viewConfGrp)
{
// qCDebug(LOG_KATE)<<"KateViewSpace::saveConfig("<<myIndex<<", "<<viewConfGrp<<") - currentView: "<<currentView()<<")";
......
......@@ -124,6 +124,11 @@ private Q_SLOTS:
*/
void closeTabRequest(int id);
/**
* Called to create a new empty document.
*/
void createNewDocument();
private:
// Kate's view manager
KateViewManager *m_viewManager;
......
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