From kde-core-devel Thu Jan 31 21:25:01 2002 From: Hans Meine Date: Thu, 31 Jan 2002 21:25:01 +0000 To: kde-core-devel Subject: PATCH: artsbuilder / dock widgets X-MARC-Message: https://marc.info/?l=kde-core-devel&m=101251222118825 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--=-=-=" --=-=-= 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 *,. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=showhide.diff 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 #include #include +#include #include @@ -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 @@ &View + + 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(); --=-=-=--