Branch: master

4724b1a8 2014-10-07 23:26:42 Timothy Pearson
Push the following patches from Bug 1499:
 tdebase: updates default Xorg arguments in TDM
 tdebase: add ability to restrict the konqueror side bar
M konqueror/sidebar/sidebar_widget.cpp
M konqueror/sidebar/sidebar_widget.h
M tdm/config.def
diff --git a/konqueror/sidebar/sidebar_widget.cpp b/konqueror/sidebar/sidebar_widget.cpp
index 62a26cb..e8e2f9f 100644
--- a/konqueror/sidebar/sidebar_widget.cpp
+++ b/konqueror/sidebar/sidebar_widget.cpp
@@ -44,6 +44,7 @@
 #include <kinputdialog.h>
 #include <tdefiledialog.h>
 #include <kdesktopfile.h>
+#include <tdeapplication.h>
 #include "konqsidebar.h"
 
 #include "sidebar_widget.h"
@@ -65,10 +66,19 @@
 
 void addBackEnd::aboutToShowAddMenu()
 {
+	TQStringList m_restrictedViews( dynamic_cast<Sidebar_Widget *>( m_parent )->getRestrictedViews() );
 	if (!menu)
 		return;
 	TDEStandardDirs *dirs = TDEGlobal::dirs();
-	TQStringList list = dirs->findAllResources("data","konqsidebartng/add/*.desktop",true,true);
+	TQStringList list;
+
+	if ( ! m_restrictedViews.empty() ) {
+		for ( TQStringList::Iterator it = m_restrictedViews.begin(); it != m_restrictedViews.end(); ++it ) {
+			list += dirs->findAllResources("data","konqsidebartng/add/" + *it + ".desktop",true,true);
+		}
+	} else {
+		list = dirs->findAllResources( "data","konqsidebartng/add/*.desktop",true,true );
+	}
 	libNames.setAutoDelete(true);
 	libNames.resize(0);
 	libParam.setAutoDelete(true);
@@ -645,17 +655,16 @@
 
 void Sidebar_Widget::readConfig()
 {
-        m_disableConfig = m_config->readBoolEntry("DisableConfig",false);
+	m_disableConfig = m_config->readBoolEntry("DisableConfig",false);
 	m_singleWidgetMode = m_config->readBoolEntry("SingleWidgetMode",true);
-        m_immutableSingleWidgetMode =
-                m_config->entryIsImmutable("SingleWidgetMode");
+	m_immutableSingleWidgetMode = m_config->entryIsImmutable("SingleWidgetMode");
 	m_showExtraButtons = m_config->readBoolEntry("ShowExtraButtons",false);
-        m_immutableShowExtraButtons =
-                m_config->entryIsImmutable("ShowExtraButtons");
+	m_immutableShowExtraButtons = m_config->entryIsImmutable("ShowExtraButtons");
 	m_showTabsLeft = m_config->readBoolEntry("ShowTabsLeft", true);
-        m_immutableShowTabsLeft = m_config->entryIsImmutable("ShowTabsLeft");
+	m_immutableShowTabsLeft = m_config->entryIsImmutable("ShowTabsLeft");
 	m_hideTabs = m_config->readBoolEntry("HideTabs", false);
-        m_immutableHideTabs = m_config->entryIsImmutable("HideTabs");
+	m_immutableHideTabs = m_config->entryIsImmutable("HideTabs");
+	m_restrictedViews = m_config->readListEntry( "RestrictViews" );
 
 	if (m_initial) {
 		m_openViews = m_config->readListEntry("OpenViews");
@@ -722,9 +731,19 @@
 	{
 		kdDebug()<<"m_path: "<<m_path<<endl;
 		TQDir dir(m_path);
-		TQStringList list=dir.entryList("*.desktop");
+		TQStringList list;
+
+		if ( ! m_restrictedViews.empty() ) {
+			for ( TQStringList::Iterator it = m_restrictedViews.begin(); it != m_restrictedViews.end(); ++it ) {
+				list += dir.entryList( *it + ".desktop");
+			}
+		} else {
+			list = dir.entryList("*.desktop");
+		}
+
 		for (TQStringList::Iterator it=list.begin(); it!=list.end(); ++it)
 		{
+			kdDebug() << "Sidebar buttons: " << *it << endl;
 			addButton(*it);
 		}
 	}
@@ -833,47 +852,48 @@
 
 bool Sidebar_Widget::eventFilter(TQObject *obj, TQEvent *ev)
 {
-
-	if (ev->type()==TQEvent::MouseButtonPress && ((TQMouseEvent *)ev)->button()==Qt::RightButton)
-	{
-		KMultiTabBarTab *bt=tqt_dynamic_cast<KMultiTabBarTab*>(obj);
-		if (bt)
+	if ( kapp->authorize( "action/konqsidebarmenu" ) ) {
+		if (ev->type()==TQEvent::MouseButtonPress && ((TQMouseEvent *)ev)->button()==Qt::RightButton)
 		{
-			kdDebug()<<"Request for popup"<<endl;
-			m_currentButton = 0;
-			for (uint i=0;i<m_buttons.count();i++)
+			KMultiTabBarTab *bt=tqt_dynamic_cast<KMultiTabBarTab*>(obj);
+			if (bt)
 			{
-				if (bt==m_buttonBar->tab(i))
+				kdDebug()<<"Request for popup"<<endl;
+				m_currentButton = 0;
+				for (uint i=0;i<m_buttons.count();i++)
 				{
-					m_currentButton = m_buttons.at(i);
-					break;
+					if (bt==m_buttonBar->tab(i))
+					{
+						m_currentButton = m_buttons.at(i);
+						break;
+					}
 				}
-			}
 
-			if (m_currentButton)
-			{
-				if (!m_buttonPopup)
+				if (m_currentButton)
 				{
-					m_buttonPopup=new TDEPopupMenu(this, "Sidebar_Widget::ButtonPopup");
-					m_buttonPopup->insertTitle(SmallIcon("unknown"), "", 50);
-					m_buttonPopup->insertItem(SmallIconSet("text"), i18n("Set Name..."),4); // Item to open a dialog to change the name of the sidebar item (by Pupeno)
-					m_buttonPopup->insertItem(SmallIconSet("www"), i18n("Set URL..."),2);
-					m_buttonPopup->insertItem(SmallIconSet("icons"), i18n("Set Icon..."),1);
-					m_buttonPopup->insertSeparator();
-					m_buttonPopup->insertItem(SmallIconSet("editdelete"), i18n("Remove"),3);
-					m_buttonPopup->insertSeparator();
-					m_buttonPopup->insertItem(SmallIconSet("configure"), i18n("Configure Navigation Panel"), m_menu, 4);
-					connect(m_buttonPopup, TQT_SIGNAL(activated(int)),
-						this, TQT_SLOT(buttonPopupActivate(int)));
+					if (!m_buttonPopup)
+					{
+						m_buttonPopup=new TDEPopupMenu(this, "Sidebar_Widget::ButtonPopup");
+						m_buttonPopup->insertTitle(SmallIcon("unknown"), "", 50);
+						m_buttonPopup->insertItem(SmallIconSet("text"), i18n("Set Name..."),4); // Item to open a dialog to change the name of the sidebar item (by Pupeno)
+						m_buttonPopup->insertItem(SmallIconSet("www"), i18n("Set URL..."),2);
+						m_buttonPopup->insertItem(SmallIconSet("icons"), i18n("Set Icon..."),1);
+						m_buttonPopup->insertSeparator();
+						m_buttonPopup->insertItem(SmallIconSet("editdelete"), i18n("Remove"),3);
+						m_buttonPopup->insertSeparator();
+						m_buttonPopup->insertItem(SmallIconSet("configure"), i18n("Configure Navigation Panel"), m_menu, 4);
+						connect(m_buttonPopup, TQT_SIGNAL(activated(int)),
+							this, TQT_SLOT(buttonPopupActivate(int)));
+					}
+					m_buttonPopup->setItemEnabled(2,!m_currentButton->URL.isEmpty());
+						m_buttonPopup->changeTitle(50,SmallIcon(m_currentButton->iconName),
+							m_currentButton->displayName);
+					if (!m_disableConfig)
+									{ m_buttonPopup->exec(TQCursor::pos()); }
 				}
-				m_buttonPopup->setItemEnabled(2,!m_currentButton->URL.isEmpty());
-			        m_buttonPopup->changeTitle(50,SmallIcon(m_currentButton->iconName),
-						m_currentButton->displayName);
-				if (!m_disableConfig)
-                                { m_buttonPopup->exec(TQCursor::pos()); }
-			}
-			return true;
+				return true;
 
+			}
 		}
 	}
 	return false;
@@ -881,10 +901,11 @@
 
 void Sidebar_Widget::mousePressEvent(TQMouseEvent *ev)
 {
-	if (ev->type()==TQEvent::MouseButtonPress &&
-            ((TQMouseEvent *)ev)->button()==Qt::RightButton &&
-            !m_disableConfig)
-        { m_menu->exec(TQCursor::pos()); }
+	if ( kapp->authorize( "action/konqsidebarmenu" ) ) {
+		if (ev->type()==TQEvent::MouseButtonPress && ((TQMouseEvent *)ev)->button()==Qt::RightButton) {
+			m_menu->exec(TQCursor::pos());
+		}
+	}
 }
 
 KonqSidebarPlugin *Sidebar_Widget::loadModule(TQWidget *par,TQString &desktopName,TQString lib_name,ButtonInfo* bi)
diff --git a/konqueror/sidebar/sidebar_widget.h b/konqueror/sidebar/sidebar_widget.h
index 36612a0..b45f79b 100644
--- a/konqueror/sidebar/sidebar_widget.h
+++ b/konqueror/sidebar/sidebar_widget.h
@@ -142,6 +142,7 @@
 //        virtual void showMessage(TQString &);    for later extension
 	/* end of interface implementation */
 
+	TQStringList getRestrictedViews() const { return m_restrictedViews; }
 
  /* The following public slots are wrappers for browserextension fields */
 public slots:
@@ -217,6 +218,7 @@
 	TQString m_currentProfile;
 	TQStringList m_visibleViews; // The views that are actually open
 	TQStringList m_openViews; // The views that should be opened
+	TQStringList m_restrictedViews;
 
 signals:
 	void panelHasBeenExpanded(bool);
diff --git a/tdm/config.def b/tdm/config.def
index 9ad3ba2..cea1d71 100644
--- a/tdm/config.def
+++ b/tdm/config.def
@@ -1368,9 +1368,9 @@
 
 Key: ServerArgsLocal
 Type: string
-Default: ""
+Default: "-nolisten tcp"
 User: core
-Instance: :*/"-nolisten tcp"
+Instance: :*/"-deferglyphs 16 -nolisten tcp"
 Comment: &
 Description:
  Additional arguments for the &X-Server;s for local sessions.