[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdesdk/kate/plugins/filebrowser
From: Matthew Woehlke <mw_triad () users ! sourceforge ! net>
Date: 2009-08-19 19:56:16
Message-ID: 1250711776.448033.5618.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1013413 by mwoehlke:
Re-add ability to configure the toolbar of Kate's filesystem-browser plugin.
The default toolbar is unchanged, unfortunately the separator is lost, as the \
configuration currently does not support separators.
M +1 -1 CMakeLists.txt
M +55 -48 katefilebrowser.cpp
M +1 -0 katefilebrowser.h
A katefilebrowserconfig.cpp [License: LGPL (v2)]
A katefilebrowserconfig.h [License: LGPL (v2)]
M +37 -5 katefilebrowserplugin.cpp
M +15 -2 katefilebrowserplugin.h
--- trunk/KDE/kdesdk/kate/plugins/filebrowser/CMakeLists.txt #1013412:1013413
@@ -1,5 +1,5 @@
-set(katefilebrowserplugin_PART_SRCS katefilebrowserplugin.cpp katefilebrowser.cpp \
katebookmarkhandler.cpp ) +set(katefilebrowserplugin_PART_SRCS \
katefilebrowserplugin.cpp katefilebrowserconfig.cpp katefilebrowser.cpp \
katebookmarkhandler.cpp )
kde4_add_plugin(katefilebrowserplugin ${katefilebrowserplugin_PART_SRCS})
--- trunk/KDE/kdesdk/kate/plugins/filebrowser/katefilebrowser.cpp #1013412:1013413
@@ -77,6 +77,7 @@
connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
m_dirOperator, SLOT(setFocus()));
// now all actions exist in dir operator and we can use them in the toolbar
+ setupActions();
setupToolbar();
KHBox* filterBox = new KHBox(this);
@@ -115,60 +116,27 @@
//BEGIN Public Methods
void KateFileBrowser::setupToolbar()
{
+ KConfigGroup config(KGlobal::config(), "filebrowser");
+ QStringList actions = config.readEntry( "toolbar actions", QStringList() );
+ if ( actions.isEmpty() ) // default toolbar
+ actions << "back" << "forward" << "bookmarks" << "sync_dir" << "configure";
+
// remove all actions from the toolbar (there should be none)
m_toolbar->clear();
- // create action list
- QList<QAction*> actions;
- actions << m_dirOperator->actionCollection()->action("back");
- actions << m_dirOperator->actionCollection()->action("forward");
+ // now add all actions to the toolbar
+ foreach (QString it, actions)
+ {
+ QAction *ac = 0;
+ if (it.isEmpty()) continue;
+ if (it == "bookmarks" || it == "sync_dir" || it == "configure")
+ ac = actionCollection()->action(it);
+ else
+ ac = m_dirOperator->actionCollection()->action(it);
- // bookmarks action!
- KActionMenu *acmBookmarks = new KActionMenu(KIcon("bookmarks"), i18n("Bookmarks"), \
this);
- acmBookmarks->setDelayed(false);
- m_bookmarkHandler = new KateBookmarkHandler(this, acmBookmarks->menu());
- acmBookmarks->setShortcutContext(Qt::WidgetWithChildrenShortcut);
- actions << acmBookmarks;
-
- // action for synchronising the dir operator with the current document path
- KAction* syncFolder = new KAction(this);
- syncFolder->setShortcutContext(Qt::WidgetWithChildrenShortcut);
- syncFolder->setText(i18n("Current Document Folder"));
- syncFolder->setIcon(KIcon("system-switch-user"));
- connect(syncFolder, SIGNAL(triggered()), this, SLOT(setActiveDocumentDir()));
-
- actions << syncFolder;
-
- // now add all actions to the toolbar
- foreach (QAction* ac, actions) {
- if (ac) {
+ if (ac)
m_toolbar->addAction(ac);
- }
}
-
- m_actionCollection->addAction("sync_dir", syncFolder);
- m_actionCollection->addAction("bookmarks", acmBookmarks);
-
- // section for settings menu
- KActionMenu *optionsMenu = new KActionMenu(KIcon("configure"), i18n("Options"), \
this);
- optionsMenu->setDelayed(false);
- optionsMenu->addAction(m_dirOperator->actionCollection()->action("short view"));
- optionsMenu->addAction(m_dirOperator->actionCollection()->action("detailed \
view"));
- optionsMenu->addAction(m_dirOperator->actionCollection()->action("tree view"));
- optionsMenu->addAction(m_dirOperator->actionCollection()->action("detailed tree \
view"));
- optionsMenu->addSeparator();
- optionsMenu->addAction(m_dirOperator->actionCollection()->action("show hidden"));
-
- // action for synchronising the dir operator with the current document path
- m_autoSyncFolder = new KAction(this);
- m_autoSyncFolder->setCheckable(true);
- m_autoSyncFolder->setText(i18n("Automatically synchronize with current \
document"));
- m_autoSyncFolder->setIcon(KIcon("system-switch-user"));
- connect(m_autoSyncFolder, SIGNAL(triggered()), this, SLOT(autoSyncFolder()));
- optionsMenu->addAction(m_autoSyncFolder);
-
- m_toolbar->addSeparator();
- m_toolbar->addAction(optionsMenu);
}
void KateFileBrowser::readSessionConfig(KConfigBase *config, const QString & name)
@@ -312,6 +280,45 @@
return v->document()->url();
return KUrl();
}
+
+void KateFileBrowser::setupActions()
+{
+ // bookmarks action!
+ KActionMenu *acmBookmarks = new KActionMenu(KIcon("bookmarks"), i18n("Bookmarks"), \
this); + acmBookmarks->setDelayed(false);
+ m_bookmarkHandler = new KateBookmarkHandler(this, acmBookmarks->menu());
+ acmBookmarks->setShortcutContext(Qt::WidgetWithChildrenShortcut);
+
+ // action for synchronizing the dir operator with the current document path
+ KAction* syncFolder = new KAction(this);
+ syncFolder->setShortcutContext(Qt::WidgetWithChildrenShortcut);
+ syncFolder->setText(i18n("Current Document Folder"));
+ syncFolder->setIcon(KIcon("system-switch-user"));
+ connect(syncFolder, SIGNAL(triggered()), this, SLOT(setActiveDocumentDir()));
+
+ m_actionCollection->addAction("sync_dir", syncFolder);
+ m_actionCollection->addAction("bookmarks", acmBookmarks);
+
+ // section for settings menu
+ KActionMenu *optionsMenu = new KActionMenu(KIcon("configure"), i18n("Options"), \
this); + optionsMenu->setDelayed(false);
+ optionsMenu->addAction(m_dirOperator->actionCollection()->action("short view"));
+ optionsMenu->addAction(m_dirOperator->actionCollection()->action("detailed \
view")); + optionsMenu->addAction(m_dirOperator->actionCollection()->action("tree \
view")); + optionsMenu->addAction(m_dirOperator->actionCollection()->action("detailed \
tree view")); + optionsMenu->addSeparator();
+ optionsMenu->addAction(m_dirOperator->actionCollection()->action("show hidden"));
+
+ // action for synchronising the dir operator with the current document path
+ m_autoSyncFolder = new KAction(this);
+ m_autoSyncFolder->setCheckable(true);
+ m_autoSyncFolder->setText(i18n("Automatically synchronize with current \
document")); + m_autoSyncFolder->setIcon(KIcon("system-switch-user"));
+ connect(m_autoSyncFolder, SIGNAL(triggered()), this, SLOT(autoSyncFolder()));
+ optionsMenu->addAction(m_autoSyncFolder);
+
+ m_actionCollection->addAction("configure", optionsMenu);
+}
//END Protected
--- trunk/KDE/kdesdk/kate/plugins/filebrowser/katefilebrowser.h #1013412:1013413
@@ -82,6 +82,7 @@
protected:
KUrl activeDocumentUrl();
void openSelectedFiles();
+ void setupActions();
public:
Kate::MainWindow* mainWindow()
--- trunk/KDE/kdesdk/kate/plugins/filebrowser/katefilebrowserplugin.cpp \
#1013412:1013413 @@ -23,6 +23,7 @@
//BEGIN Includes
#include "katefilebrowserplugin.h"
#include "katefilebrowserplugin.moc"
+#include "katefilebrowserconfig.h"
#include "katefilebrowser.h"
#include <kate/mainwindow.h>
@@ -44,8 +45,40 @@
Kate::PluginView *KateFileBrowserPlugin::createView (Kate::MainWindow *mainWindow)
{
KateFileBrowserPluginView* kateFileSelectorPluginView = new \
KateFileBrowserPluginView (mainWindow); + m_fileBrowser = \
kateFileSelectorPluginView->m_fileBrowser; return kateFileSelectorPluginView;
}
+
+uint KateFileBrowserPlugin::configPages() const
+{
+ return 1;
+}
+
+Kate::PluginConfigPage *KateFileBrowserPlugin::configPage (uint number, QWidget \
*parent, const char *name) +{
+ if (number != 0)
+ return 0;
+ return new KateFileBrowserConfigPage(parent, name, m_fileBrowser);
+}
+
+QString KateFileBrowserPlugin::configPageName (uint number) const
+{
+ if (number != 0) return QString();
+ kDebug() << "Returning a config page name";
+ return i18n("Filesystem Browser");
+}
+
+QString KateFileBrowserPlugin::configPageFullName (uint number) const
+{
+ if (number != 0) return QString();
+ return i18n("Filesystem Browser Settings");
+}
+
+KIcon KateFileBrowserPlugin::configPageIcon (uint number) const
+{
+ if (number != 0) return KIcon();
+ return KIcon("document-open");
+}
//END KateFileBrowserPlugin
@@ -57,26 +90,25 @@
{
// init console
QWidget *toolview = mainWindow->createToolView \
("kate_private_plugin_katefileselectorplugin", Kate::MainWindow::Left, \
SmallIcon("document-open"), i18n("Filesystem Browser"));
- m_fileSelector = new KateFileBrowser(mainWindow, toolview);
+ m_fileBrowser = new KateFileBrowser(mainWindow, toolview);
}
KateFileBrowserPluginView::~KateFileBrowserPluginView ()
{
// cleanup, kill toolview + console
- delete m_fileSelector->parentWidget();
+ delete m_fileBrowser->parentWidget();
}
void KateFileBrowserPluginView::readSessionConfig(KConfigBase* config, const \
QString& group) {
- m_fileSelector->readSessionConfig(config, group);
+ m_fileBrowser->readSessionConfig(config, group);
}
void KateFileBrowserPluginView::writeSessionConfig(KConfigBase* config, const \
QString& group) {
- m_fileSelector->writeSessionConfig(config, group);
+ m_fileBrowser->writeSessionConfig(config, group);
}
//ENDKateFileBrowserPluginView
// kate: space-indent on; indent-width 2; replace-tabs on;
-
--- trunk/KDE/kdesdk/kate/plugins/filebrowser/katefilebrowserplugin.h \
#1013412:1013413 @@ -27,6 +27,8 @@
#include <ktexteditor/document.h>
#include <kate/plugin.h>
#include <kate/mainwindow.h>
+#include <ktexteditor/configpage.h>
+#include <kate/pluginconfigpageinterface.h>
#include <kurlcombobox.h>
#include <KVBox>
@@ -45,9 +47,10 @@
class KateFileBrowser;
-class KateFileBrowserPlugin: public Kate::Plugin
+class KateFileBrowserPlugin: public Kate::Plugin, public \
Kate::PluginConfigPageInterface {
Q_OBJECT
+ Q_INTERFACES(Kate::PluginConfigPageInterface)
public:
explicit KateFileBrowserPlugin( QObject* parent = 0, const QList<QVariant>& = \
QList<QVariant>() ); @@ -55,6 +58,15 @@
{}
Kate::PluginView *createView (Kate::MainWindow *mainWindow);
+
+ virtual uint configPages() const;
+ virtual Kate::PluginConfigPage *configPage (uint number = 0, QWidget *parent = \
0, const char *name = 0); + virtual QString configPageName (uint number = 0) \
const; + virtual QString configPageFullName (uint number = 0) const;
+ virtual KIcon configPageIcon (uint number = 0) const;
+
+ private:
+ KateFileBrowser *m_fileBrowser;
};
class KateFileBrowserPluginView : public Kate::PluginView
@@ -76,7 +88,8 @@
virtual void writeSessionConfig (KConfigBase* config, const QString& \
groupPrefix);
private:
- KateFileBrowser *m_fileSelector;
+ KateFileBrowser *m_fileBrowser;
+ friend class KateFileBrowserPlugin;
};
#endif //KATE_FILEBROWSER_PLUGIN_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic