Commit 1a166ac1 authored by Markus Brenneis's avatar Markus Brenneis Committed by Christoph Cullmann
Browse files

Make filetree toolbar hidable

parent a498981a
......@@ -89,6 +89,11 @@ KateFileTreeConfigPage::KateFileTreeConfigPage(QWidget *parent, KateFileTreePlug
cbShowFullPath = new QCheckBox(i18n("&Show Full Path"), this);
lo4->addWidget(cbShowFullPath);
QHBoxLayout *lo5 = new QHBoxLayout;
layout->addLayout(lo5);
cbShowToolbar = new QCheckBox(i18n("Show &Toolbar"), this);
lo5->addWidget(cbShowToolbar);
cbShowClose = new QCheckBox(i18n("Show Close Button"), this);
layout->addWidget(cbShowClose);
layout->addWidget(new QLabel(i18n("When enabled, this will show a close button for opened documents on hover.")));
......@@ -109,6 +114,9 @@ KateFileTreeConfigPage::KateFileTreeConfigPage(QWidget *parent, KateFileTreePlug
i18n("When enabled, in tree mode, top level folders will show up with their full path "
"rather than just the last folder name."));
cbShowToolbar->setWhatsThis(
i18n("When enabled, a toolbar with actions like “Save” are displayed above the list of documents."));
// cmbSort->setWhatsThis( i18n(
// "Set the sorting method for the documents.") );
......@@ -120,6 +128,7 @@ KateFileTreeConfigPage::KateFileTreeConfigPage(QWidget *parent, KateFileTreePlug
connect(cmbSort, QOverload<int>::of(&QComboBox::activated), this, &KateFileTreeConfigPage::slotMyChanged);
connect(cmbMode, QOverload<int>::of(&QComboBox::activated), this, &KateFileTreeConfigPage::slotMyChanged);
connect(cbShowFullPath, &QCheckBox::stateChanged, this, &KateFileTreeConfigPage::slotMyChanged);
connect(cbShowToolbar, &QCheckBox::stateChanged, this, &KateFileTreeConfigPage::slotMyChanged);
connect(cbShowClose, &QCheckBox::stateChanged, this, &KateFileTreeConfigPage::slotMyChanged);
}
......@@ -153,6 +162,7 @@ void KateFileTreeConfigPage::apply()
cmbMode->itemData(cmbMode->currentIndex()).toBool(),
cmbSort->itemData(cmbSort->currentIndex()).toInt(),
cbShowFullPath->checkState() == Qt::Checked,
cbShowToolbar->checkState() == Qt::Checked,
cbShowClose->isChecked());
}
......@@ -166,6 +176,7 @@ void KateFileTreeConfigPage::reset()
cmbSort->setCurrentIndex(cmbSort->findData(settings.sortRole()));
cmbMode->setCurrentIndex(settings.listMode());
cbShowFullPath->setCheckState(settings.showFullPathOnRoots() ? Qt::Checked : Qt::Unchecked);
cbShowToolbar->setCheckState(settings.showToolbar() ? Qt::Checked : Qt::Unchecked);
cbShowClose->setChecked(settings.showCloseButton());
m_changed = false;
......
......@@ -47,6 +47,7 @@ private:
class QLabel *lEditShade, *lViewShade, *lSort, *lMode;
QComboBox *cmbSort, *cmbMode;
class QCheckBox *cbShowFullPath;
class QCheckBox *cbShowToolbar;
class QCheckBox *cbShowClose;
KateFileTreePlugin *m_plug;
......
......@@ -90,6 +90,7 @@ void KateFileTreePlugin::applyConfig(bool shadingEnabled,
bool listMode,
int sortRole,
bool showFullPath,
bool showToolbar,
bool showCloseButton)
{
// save to settings
......@@ -100,6 +101,7 @@ void KateFileTreePlugin::applyConfig(bool shadingEnabled,
m_settings.setListMode(listMode);
m_settings.setSortRole(sortRole);
m_settings.setShowFullPathOnRoots(showFullPath);
m_settings.setShowToolbar(showToolbar);
m_settings.setShowCloseButton(showCloseButton);
m_settings.save();
......@@ -112,6 +114,7 @@ void KateFileTreePlugin::applyConfig(bool shadingEnabled,
view->setListMode(listMode);
view->proxy()->setSortRole(sortRole);
view->model()->setShowFullPathOnRoots(showFullPath);
view->setToolbarVisible(showToolbar);
view->tree()->setShowCloseButton(showCloseButton);
}
}
......@@ -208,6 +211,8 @@ KateFileTreePluginView::KateFileTreePluginView(KTextEditor::MainWindow *mainWind
setupActions();
mainWindow->guiFactory()->addClient(this);
setToolbarVisible(m_plug->settings().showToolbar());
m_proxyModel->setSortRole(Qt::DisplayRole);
......@@ -311,6 +316,11 @@ void KateFileTreePluginView::documentClosed(KTextEditor::Document *doc)
m_proxyModel->invalidate();
}
void KateFileTreePluginView::setToolbarVisible(bool visible)
{
m_toolbar->setVisible(visible);
}
void KateFileTreePluginView::viewChanged(KTextEditor::View *)
{
KTextEditor::View *view = m_mainWindow->activeView();
......
......@@ -46,7 +46,7 @@ public:
const KateFileTreePluginSettings &settings();
void applyConfig(bool shadingEnabled, const QColor &viewShade, const QColor &editShade, bool listMode, int sortRole, bool showFulPath, bool closeButton);
void applyConfig(bool shadingEnabled, const QColor &viewShade, const QColor &editShade, bool listMode, int sortRole, bool showFullPath, bool showToolbar, bool closeButton);
public Q_SLOTS:
void viewDestroyed(QObject *view);
......@@ -93,6 +93,7 @@ public:
*/
KateFileTree *tree() const;
void setToolbarVisible(bool);
void setListMode(bool listMode);
bool hasLocalPrefs() const;
......
......@@ -25,6 +25,8 @@ KateFileTreePluginSettings::KateFileTreePluginSettings()
m_sortRole = m_group.readEntry("sortRole", int(Qt::DisplayRole));
m_showFullPathOnRoots = m_group.readEntry("showFullPathOnRoots", false);
m_showToolbar = m_group.readEntry("showToolbar", true);
m_showCloseButton = m_group.readEntry("showCloseButton", false);
}
......@@ -37,6 +39,7 @@ void KateFileTreePluginSettings::save()
m_group.writeEntry("listMode", m_listMode);
m_group.writeEntry("sortRole", m_sortRole);
m_group.writeEntry("showFullPathOnRoots", m_showFullPathOnRoots);
m_group.writeEntry("showToolbar", m_showToolbar);
m_group.writeEntry("showCloseButton", m_showCloseButton);
m_group.sync();
......@@ -102,6 +105,16 @@ void KateFileTreePluginSettings::setShowFullPathOnRoots(bool s)
m_showFullPathOnRoots = s;
}
bool KateFileTreePluginSettings::showToolbar() const
{
return m_showToolbar;
}
void KateFileTreePluginSettings::setShowToolbar(bool s)
{
m_showToolbar = s;
}
bool KateFileTreePluginSettings::showCloseButton() const
{
return m_showCloseButton;
......
......@@ -36,6 +36,9 @@ public:
bool showFullPathOnRoots() const;
void setShowFullPathOnRoots(bool);
bool showToolbar() const;
void setShowToolbar(bool);
bool showCloseButton() const;
void setShowCloseButton(bool);
......@@ -50,6 +53,7 @@ private:
int m_sortRole;
bool m_showFullPathOnRoots;
bool m_showToolbar;
bool m_showCloseButton;
};
......
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