Commit b7cffaee authored by Christoph Cullmann's avatar Christoph Cullmann

allow to show/hide tabs

parent b2f42a51
......@@ -100,6 +100,7 @@
</Menu>
<Menu name="settings"><text>&amp;Settings</text>
<Action name="settings_show_tab_bar" append="show_merge"/>
<Action name="settings_show_full_path" append="show_merge"/>
</Menu>
......
......@@ -232,10 +232,14 @@ KateMainWindow::~KateMainWindow()
void KateMainWindow::setupImportantActions()
{
// settings
m_paShowStatusBar = KStandardAction::showStatusbar(this, SLOT(toggleShowStatusBar()), actionCollection());
m_paShowStatusBar->setWhatsThis(i18n("Use this command to show or hide the view's statusbar"));
m_paShowTabBar = new KToggleAction(i18n("Sho&w Tabs"), this);
actionCollection()->addAction(QStringLiteral("settings_show_tab_bar"), m_paShowTabBar);
connect(m_paShowTabBar, SIGNAL(toggled(bool)), this, SLOT(toggleShowTabBar()));
m_paShowTabBar->setWhatsThis(i18n("Use this command to show or hide the tabs for the views"));
m_paShowPath = new KToggleAction(i18n("Sho&w Path in Titlebar"), this);
actionCollection()->addAction(QStringLiteral("settings_show_full_path"), m_paShowPath);
connect(m_paShowPath, SIGNAL(toggled(bool)), this, SLOT(updateCaption()));
......@@ -546,9 +550,11 @@ void KateMainWindow::readOptions()
m_paShowPath->setChecked(generalGroup.readEntry("Show Full Path in Title", false));
m_paShowStatusBar->setChecked(generalGroup.readEntry("Show Status Bar", true));
m_paShowTabBar->setChecked(generalGroup.readEntry("Show Tab Bar", true));
// emit signal to hide/show statusbars
toggleShowStatusBar();
toggleShowTabBar();
}
void KateMainWindow::saveOptions()
......@@ -563,6 +569,7 @@ void KateMainWindow::saveOptions()
generalGroup.writeEntry("Show Full Path in Title", m_paShowPath->isChecked());
generalGroup.writeEntry("Show Status Bar", m_paShowStatusBar->isChecked());
generalGroup.writeEntry("Show Tab Bar", m_paShowTabBar->isChecked());
}
void KateMainWindow::toggleShowStatusBar()
......@@ -575,6 +582,16 @@ bool KateMainWindow::showStatusBar()
return m_paShowStatusBar->isChecked();
}
void KateMainWindow::toggleShowTabBar()
{
emit tabBarToggled();
}
bool KateMainWindow::showTabBar()
{
return m_paShowTabBar->isChecked();
}
void KateMainWindow::slotWindowActivated()
{
if (m_viewManager->activeView()) {
......
......@@ -202,12 +202,15 @@ private Q_SLOTS:
private Q_SLOTS:
void toggleShowStatusBar();
void toggleShowTabBar();
public:
bool showStatusBar();
bool showTabBar();
Q_SIGNALS:
void statusBarToggled();
void tabBarToggled();
void unhandledShortcutOverride(QEvent *e);
public:
......@@ -466,6 +469,7 @@ private:
// options: show statusbar + show path
KToggleAction *m_paShowPath;
KToggleAction *m_paShowStatusBar;
KToggleAction *m_paShowTabBar;
QWidget *m_bottomViewBarContainer;
KateContainerStackedLayout *m_bottomContainerStack;
......
......@@ -29,6 +29,7 @@
#include "katedebug.h"
#include "katetabbar.h"
#include "kactioncollection.h"
#include "kateupdatedisabler.h"
#include <KLocalizedString>
#include <KConfigGroup>
......@@ -64,25 +65,25 @@ KateViewSpace::KateViewSpace(KateViewManager *viewManager,
hLayout->addWidget(m_tabBar);
// add vertical split view space
QToolButton *split = new QToolButton(this);
split->setAutoRaise(true);
split->setPopupMode(QToolButton::InstantPopup);
split->setIcon(QIcon::fromTheme(QStringLiteral("view-split-left-right")));
split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_split_vert")));
split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_split_horiz")));
split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_close_current_space")));
split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_close_others")));
split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_hide_others")));
split->setWhatsThis(i18n("Control view space splitting"));
split->installEventFilter(this); // on click, active this view space
hLayout->addWidget(split);
m_split = new QToolButton(this);
m_split->setAutoRaise(true);
m_split->setPopupMode(QToolButton::InstantPopup);
m_split->setIcon(QIcon::fromTheme(QStringLiteral("view-split-left-right")));
m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_split_vert")));
m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_split_horiz")));
m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_close_current_space")));
m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_close_others")));
m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_hide_others")));
m_split->setWhatsThis(i18n("Control view space splitting"));
m_split->installEventFilter(this); // on click, active this view space
hLayout->addWidget(m_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);
m_quickOpen = new QToolButton(this);
m_quickOpen->setAutoRaise(true);
m_quickOpen->setDefaultAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_quick_open")));
m_quickOpen->installEventFilter(this); // on click, active this view space
hLayout->addWidget(m_quickOpen);
// FIXME: better additional size
// m_tabBar->setMinimumHeight(int (QFontMetrics(font()).height() * 1.2));
......@@ -101,9 +102,11 @@ KateViewSpace::KateViewSpace(KateViewManager *viewManager,
// connect signal to hide/show statusbar
connect(m_viewManager->mainWindow(), SIGNAL(statusBarToggled()), this, SLOT(statusBarToggled()));
connect(m_viewManager->mainWindow(), SIGNAL(tabBarToggled()), this, SLOT(tabBarToggled()));
// init the statusbar...
// init the bars...
statusBarToggled();
tabBarToggled();
}
bool KateViewSpace::eventFilter(QObject *obj, QEvent *event)
......@@ -130,6 +133,7 @@ bool KateViewSpace::eventFilter(QObject *obj, QEvent *event)
void KateViewSpace::statusBarToggled()
{
KateUpdateDisabler updatesDisabled (m_viewManager->mainWindow());
Q_FOREACH(KTextEditor::Document * doc, m_lruDocList) {
if (m_docToView.contains(doc)) {
m_docToView[doc]->setStatusBarEnabled(m_viewManager->mainWindow()->showStatusBar());
......@@ -155,6 +159,14 @@ void KateViewSpace::mergeLruList(const QVector<KTextEditor::Document*> & lruList
}
}
void KateViewSpace::tabBarToggled()
{
KateUpdateDisabler updatesDisabled (m_viewManager->mainWindow());
m_tabBar->setVisible(m_viewManager->mainWindow()->showTabBar());
m_split->setVisible(m_viewManager->mainWindow()->showTabBar());
m_quickOpen->setVisible(m_viewManager->mainWindow()->showTabBar());
}
KTextEditor::View *KateViewSpace::createView(KTextEditor::Document *doc)
{
// should only be called if a view does not yet exist
......
......@@ -34,6 +34,7 @@ class KateViewManager;
class KateViewSpace;
class QStackedWidget;
class QLabel;
class QToolButton;
class KateTabBar;
class KateViewSpace : public QWidget
......@@ -93,6 +94,7 @@ public Q_SLOTS:
private Q_SLOTS:
void statusBarToggled();
void tabBarToggled();
void changeView(int buttonId);
/**
......@@ -147,6 +149,12 @@ private:
// tab bar that contains viewspace tabs
KateTabBar *m_tabBar;
// split action
QToolButton *m_split;
// quick open action
QToolButton *m_quickOpen;
// map from Document to button id
QHash<KTextEditor::Document *, int> m_docToTabId;
......
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