[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    PATCH: artsbuilder / dock widgets
From:       Hans Meine <hans_meine () gmx ! net>
Date:       2002-01-31 21:25:01
[Download RAW message or body]

Hi!

This patch is quite trivial and I'd have liked to commit immediately,
though since Stefan is not able to review my patches ATM and since it
has sth. to do with KDockWidgets, I think it's better to post here.

PROBLEM: Some time ago, I implemented a docking property panel for
artsbuilder but until today, it's possible to "close" it and
impossible to show() it again.

SOLUTION: My patch works like the code in kate: Before showing
(aboutToShow) the menu with the "show xxx dockwidget" toggleaction,
put it in the right state.

LITTLE WEIRDNESS: However, I wonder if it's not possible to connect a
"myHideShowStateIs(bool)" signal to a KToggleAction, but the only
thing I see is the "iMBeingClosed()" signal. Seems to me like a good
addition to the KDockWidget API, no?

Shall I commit (it also introduces a string, but IMHO this is
important)?

-- 
Ciao,  /  /
      /--/
     /  / ANS                          .,* Hamburg, Germany *,.

[Attachment #3 (text/x-patch)]

Index: main.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/arts/builder/main.cpp,v
retrieving revision 1.54
diff -b -u -3 -p -d -r1.54 main.cpp
--- main.cpp	2002/01/26 00:51:43	1.54
+++ main.cpp	2002/01/31 20:19:39
@@ -55,6 +55,7 @@
 #include <kstandarddirs.h>
 #include <kartsserver.h>
 #include <qfile.h>
+#include <qpopupmenu.h>
 
 #include <soundserver.h>
 
@@ -271,6 +272,15 @@ ArtsBuilderWindow::ArtsBuilderWindow(con
 	arts_debug("PORT: activatemenu ok");
 	setupActions();
 	
+	createGUI();
+
+	// connect to aboutToShow to correctly show state of dockwidget there:
+	QPopupMenu *viewmenu = (QPopupMenu*)factory()->container("view", this);
+	if (viewmenu)
+		connect(viewmenu, SIGNAL(aboutToShow()), this, SLOT(viewMenuAboutToShow()));
+	else
+		arts_debug("view menu not found!");
+	
 	m_filename = QString::null;
 	setModified(false);
 
@@ -305,6 +315,9 @@ void ArtsBuilderWindow::setupActions()
 	KStdAction::selectAll(modulewidget, SLOT(selectAll()), actionCollection());
 
 	// View menu
+	viewPropertiesAction= new KToggleAction(i18n("&Property Panel"), 0,
+											propertyDock, SLOT(changeHideShowState()),
+											actionCollection(), "view_properties");
 	(void)new KAction(i18n("200%"), 0, this, SLOT(viewAt200()),
 					  actionCollection(), "view_200");
 	(void)new KAction(i18n("150%"), 0, this, SLOT(viewAt150()),
@@ -327,8 +340,6 @@ void ArtsBuilderWindow::setupActions()
 					  actionCollection(), "ports_implement_interface");
 	(void)new KAction(i18n("Change positions/names"), 0, this, SLOT(changePortPositions()),
 					  actionCollection(), "ports_change_positions");
-
-	createGUI();
 }
 
 void ArtsBuilderWindow::fillModuleMenu()
@@ -416,6 +427,11 @@ void ArtsBuilderWindow::quit()
 ArtsBuilderWindow::~ArtsBuilderWindow()
 {
 	delete structure;
+}
+
+void ArtsBuilderWindow::viewMenuAboutToShow()
+{
+	viewPropertiesAction->setChecked(propertyDock->isVisible());
 }
 
 void ArtsBuilderWindow::publish()
Index: artsbuilderui.rc
===================================================================
RCS file: /home/kde/kdemultimedia/arts/builder/artsbuilderui.rc,v
retrieving revision 1.3
diff -b -u -3 -p -d -r1.3 artsbuilderui.rc
--- artsbuilderui.rc	2001/11/22 19:50:42	1.3
+++ artsbuilderui.rc	2002/01/31 20:19:39
@@ -15,6 +15,8 @@
 		<Action name="edit_delete"/>
 	</Menu>
 	<Menu name="view"><text>&amp;View</text>
+		<Action name="view_properties"/>
+		<Separator/>
 		<Action name="view_200"/>
 		<Action name="view_150"/>
 		<Action name="view_100"/>
Index: main.h
===================================================================
RCS file: /home/kde/kdemultimedia/arts/builder/main.h,v
retrieving revision 1.18
diff -b -u -3 -p -d -r1.18 main.h
--- main.h	2002/01/24 15:11:23	1.18
+++ main.h	2002/01/31 20:19:39
@@ -35,6 +35,7 @@ class PropertyPanel;
 class Structure;
 class MenuMaker;
 class ExecDlg;
+class KToggleAction;
 
 class ArtsBuilderWindow: public KDockMainWindow
 {
@@ -46,6 +47,7 @@ protected:
 
 	KDockWidget* propertyDock;
 	PropertyPanel *propertyPanel;
+	KToggleAction *viewPropertiesAction;
 
 	MenuMaker *menumaker;
 
@@ -73,6 +75,7 @@ public:
 
 public slots:
 	void fillModuleMenu();
+	void viewMenuAboutToShow();
 
 	/* ports menu */
 	void createInAudioSignal();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic