[rkward-cvs] SF.net SVN: rkward: [1837] trunk/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Mon Apr 23 19:51:33 UTC 2007
Revision: 1837
http://svn.sourceforge.net/rkward/?rev=1837&view=rev
Author: tfry
Date: 2007-04-23 12:51:32 -0700 (Mon, 23 Apr 2007)
Log Message:
-----------
Make tool windows behave more like regular windows, esp. concerning detaching
Modified Paths:
--------------
trunk/rkward/ChangeLog
trunk/rkward/rkward/rkconsole.cpp
trunk/rkward/rkward/rkconsolepart.rc
trunk/rkward/rkward/rkward.cpp
trunk/rkward/rkward/windows/detachedwindowcontainer.cpp
trunk/rkward/rkward/windows/detachedwindowcontainer.h
trunk/rkward/rkward/windows/rkmdiwindow.cpp
trunk/rkward/rkward/windows/rkmdiwindow.h
trunk/rkward/rkward/windows/rkworkplace.cpp
Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog 2007-04-23 05:47:38 UTC (rev 1836)
+++ trunk/rkward/ChangeLog 2007-04-23 19:51:32 UTC (rev 1837)
@@ -1,3 +1,5 @@
+- tool windows can be closed and detached in the same way as regular windows
+- fix a crash with detached tool windows
- add command line option --disable-stack-check for systems where R C stack checking is buggy
- the modifier "not" for boolean properties returns a (negated) boolean sub-propery instead of just a string
- add possibility to blacklist packages from fetching structure information. Package GO is blacklisted by default.
Modified: trunk/rkward/rkward/rkconsole.cpp
===================================================================
--- trunk/rkward/rkward/rkconsole.cpp 2007-04-23 05:47:38 UTC (rev 1836)
+++ trunk/rkward/rkward/rkconsole.cpp 2007-04-23 19:51:32 UTC (rev 1837)
@@ -341,7 +341,7 @@
++i;
}
if (i > 0) {
- if (common.length() > (word_end - word_start)) { // more than there already is
+ if ((int) common.length() > (word_end - word_start)) { // more than there already is
insertCompletion (line_num, word_start, word_end, common);
return false; // will beep to signal completion is not complete
}
@@ -428,7 +428,6 @@
doPopupMenu (m->globalPos ());
return (true);
}
- return (false);
} else if (e->type () == QEvent::MouseButtonRelease){
QMouseEvent *m = (QMouseEvent *)e;
if (m->button() == Qt::MidButton) {
@@ -447,10 +446,10 @@
view->scroll (0, y - y2);
}
} */ // not good, yet: always jumps to bottom of view
- return (false);
- } else {
- return false;
}
+
+ if (acceptsEventsFor (o)) return RKMDIWindow::eventFilter (o, e);
+ return false;
}
QString RKConsole::currentCommand () {
Modified: trunk/rkward/rkward/rkconsolepart.rc
===================================================================
--- trunk/rkward/rkward/rkconsolepart.rc 2007-04-23 05:47:38 UTC (rev 1836)
+++ trunk/rkward/rkward/rkconsolepart.rc 2007-04-23 19:51:32 UTC (rev 1837)
@@ -1,7 +1,7 @@
<!DOCTYPE kpartgui>
-<kpartgui name="rkward" version="0.4.5">
+<kpartgui name="rkward" version="0.4.8">
<MenuBar>
- <Menu name="edit">
+ <Menu name="edit"><text>&Edit</text>
<Action name="rkconsole_copy"></Action>
<Action name="rkconsole_copy_literal"></Action>
<Action name="rkconsole_paste"></Action>
@@ -14,7 +14,7 @@
<Action name="run_selection"/>
<Action name="interrupt"/>
</Menu>
- <Menu name="settings">
+ <Menu name="settings"><text>&Settings</text>
<Action name="rkconsole_configure"></Action>
</Menu>
<Menu name="help"><text>&Help</text>
Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp 2007-04-23 05:47:38 UTC (rev 1836)
+++ trunk/rkward/rkward/rkward.cpp 2007-04-23 19:51:32 UTC (rev 1837)
@@ -191,7 +191,7 @@
RControlWindow::control_window = new RControlWindow (0, true, "rcontrol"); // the control window needs to be initialized before startR () is called.
RKCommandLog *log = new RKCommandLog (0, true, "Command log");
- log->setIcon (SmallIcon ("text_block"));
+ log->setIcon (SmallIcon ("text_block"));
log->setToolWrapper (addToolWindow (log, KDockWidget::DockBottom, getMainDockWidget (), 10));
RKWorkplace::mainWorkplace ()->registerToolWindow (log);
RKCommandLog::rkcommand_log = log;
Modified: trunk/rkward/rkward/windows/detachedwindowcontainer.cpp
===================================================================
--- trunk/rkward/rkward/windows/detachedwindowcontainer.cpp 2007-04-23 05:47:38 UTC (rev 1836)
+++ trunk/rkward/rkward/windows/detachedwindowcontainer.cpp 2007-04-23 19:51:32 UTC (rev 1837)
@@ -45,6 +45,7 @@
widget_to_capture->reparent (this, QPoint (0, 0));
setCentralWidget (widget_to_capture);
createGUI (widget_to_capture->getPart ());
+ captured = widget_to_capture;
// should self-destruct, when child widget is destroyed
connect (widget_to_capture, SIGNAL (destroyed (QObject *)), this, SLOT (viewDestroyed (QObject *)));
@@ -65,7 +66,7 @@
void DetachedWindowContainer::updateCaption (RKMDIWindow *widget) {
RK_TRACE (APP);
- RK_ASSERT (widget == centralWidget ());
+ RK_ASSERT (widget == captured);
setCaption (widget->fullCaption ());
}
@@ -73,13 +74,12 @@
void DetachedWindowContainer::slotReattach () {
RK_TRACE (APP);
- RKMDIWindow *window = static_cast<RKMDIWindow *> (centralWidget ());
// we will not handle any more signals from the window
- disconnect (window, SIGNAL (destroyed (QObject *)), this, SLOT (viewDestroyed (QObject *)));
- disconnect (window, SIGNAL (captionChanged (RKMDIWindow *)), this, SLOT (updateCaption (RKMDIWindow *)));
+ disconnect (captured, SIGNAL (destroyed (QObject *)), this, SLOT (viewDestroyed (QObject *)));
+ disconnect (captured, SIGNAL (captionChanged (RKMDIWindow *)), this, SLOT (updateCaption (RKMDIWindow *)));
- window->reparent (0, QPoint (0, 0));
- RKWorkplace::mainWorkplace ()->attachWindow (window);
+ captured->reparent (0, QPoint (0, 0));
+ RKWorkplace::mainWorkplace ()->attachWindow (captured);
hide ();
deleteLater ();
@@ -88,8 +88,7 @@
void DetachedWindowContainer::closeEvent (QCloseEvent *e) {
RK_TRACE (APP);
- RKMDIWindow *window = static_cast<RKMDIWindow *> (centralWidget ());
- if (window->close (true)) {
+ if (captured->close (true)) {
e->accept ();
} else {
e->ignore ();
Modified: trunk/rkward/rkward/windows/detachedwindowcontainer.h
===================================================================
--- trunk/rkward/rkward/windows/detachedwindowcontainer.h 2007-04-23 05:47:38 UTC (rev 1836)
+++ trunk/rkward/rkward/windows/detachedwindowcontainer.h 2007-04-23 19:51:32 UTC (rev 1837)
@@ -46,6 +46,8 @@
protected:
/** when receiving a close event, dispatch to the embedded window */
void closeEvent (QCloseEvent *e);
+private:
+ RKMDIWindow *captured;
};
#endif
Modified: trunk/rkward/rkward/windows/rkmdiwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkmdiwindow.cpp 2007-04-23 05:47:38 UTC (rev 1836)
+++ trunk/rkward/rkward/windows/rkmdiwindow.cpp 2007-04-23 19:51:32 UTC (rev 1837)
@@ -19,6 +19,7 @@
#include <qapplication.h>
#include <qpainter.h>
+#include <qtimer.h>
#include <kparts/event.h>
@@ -31,8 +32,8 @@
RK_TRACE (APP);
RKMDIWindow::type = type;
- if (tool_window) state = ToolWindow;
- else state = Attached;
+ if (tool_window) RK_ASSERT (type & ToolWindow);
+ state = Attached;
wrapper = 0;
part = 0;
active = false;
@@ -67,21 +68,21 @@
// WORKAROUND for KMDI: it will always grab focus, so we need to make sure to release it again, if needed
QWidget *old_focus = qApp->focusWidget ();
- if (isToolWindow ()) {
- RK_ASSERT (wrapper);
- wrapper->show ();
- wrapper->wrapperWidget ()->topLevelWidget ()->show ();
- wrapper->wrapperWidget ()->topLevelWidget ()->raise ();
- } else {
- if (isAttached ()) {
+ if (isAttached ()) {
+ if (isToolWindow ()) {
+ RK_ASSERT (wrapper);
+ wrapper->show ();
+ wrapper->wrapperWidget ()->topLevelWidget ()->show ();
+ wrapper->wrapperWidget ()->topLevelWidget ()->raise ();
+ } else {
RKWorkplace::mainWorkplace ()->view ()->setActivePage (this);
- } else {
- topLevelWidget ()->show ();
- topLevelWidget ()->raise ();
}
+ } else {
+ topLevelWidget ()->show ();
+ topLevelWidget ()->raise ();
}
- if (with_focus) setFocus ();
+ if (with_focus) setFocus();
else {
if (old_focus) old_focus->setFocus ();
}
@@ -91,6 +92,12 @@
RK_TRACE (APP);
if (isToolWindow ()) {
+ if (!isAttached ()) {
+ topLevelWidget ()->deleteLater ();
+ // flee the dying DetachedWindowContainer
+ RKWorkplace::mainWorkplace ()->attachWindow (this);
+ }
+
RK_ASSERT (wrapper);
wrapper->hide ();
return true;
@@ -102,39 +109,67 @@
void RKMDIWindow::prepareToBeAttached () {
RK_TRACE (APP);
- RK_ASSERT (!isToolWindow ());
+ if (isToolWindow ()) {
+ static_cast<KDockWidget *>(wrapper->wrapperWidget ())->setWidget (this);
+ wrapper->show ();
+ }
}
void RKMDIWindow::prepareToBeDetached () {
RK_TRACE (APP);
- RK_ASSERT (!isToolWindow ());
+ if (isToolWindow ()) {
+ wrapper->hide ();
+ }
}
bool RKMDIWindow::eventFilter (QObject *watched, QEvent *e) {
// WARNING: The derived object and the part may both the destroyed at this point of time!
// Make sure not to call any virtual function on this object!
+ RK_ASSERT (acceptsEventsFor (watched));
- RK_ASSERT (watched == getPart ());
- if (KParts::PartActivateEvent::test (e)) {
- RK_TRACE (APP); // trace only the "interesting" calls to this function
-
- KParts::PartActivateEvent *ev = static_cast<KParts::PartActivateEvent *> (e);
- if (ev->activated ()) {
- emit (windowActivated (this));
- setFocus (); // focus doesn't always work correctly for the kate part
- active = true;
- } else {
- active = false;
+ if (watched == getPart ()) {
+ if (KParts::PartActivateEvent::test (e)) {
+ RK_TRACE (APP); // trace only the "interesting" calls to this function
+
+ KParts::PartActivateEvent *ev = static_cast<KParts::PartActivateEvent *> (e);
+ if (ev->activated ()) {
+ emit (windowActivated (this));
+ setFocus (); // focus doesn't always work correctly for the kate part
+ active = true;
+ } else {
+ active = false;
+ }
+ if (layout()->margin () < 1) {
+ layout()->setMargin (1);
+ }
+ update ();
}
- if (layout()->margin () < 1) {
- layout()->setMargin (1);
+ } else {
+ RK_ASSERT (isToolWindow ());
+ if (watched == wrapper->wrapperWidget ()) {
+ // don't show the wrapper if detached. Instead, show this window.
+ if (e->type () == QEvent::Show) {
+ if (!isAttached ()) {
+ // calling hide() on the wrapper directly is unsafe for some obscure reason
+ QTimer::singleShot (0, wrapper, SLOT (hide()));
+ activate (true);
+ return true;
+ }
+ }
}
- update ();
}
- return FALSE;
+ return false;
}
+bool RKMDIWindow::acceptsEventsFor (QObject *object) {
+ // called very often. Don't trace
+
+ if (object == getPart ()) return true;
+ if (isToolWindow () && (object == wrapper->wrapperWidget ())) return true;
+ return false;
+}
+
void RKMDIWindow::initializeActivationSignals () {
RK_TRACE (APP);
@@ -157,4 +192,13 @@
}
}
+void RKMDIWindow::setToolWrapper (KMdiToolViewAccessor *wrapper_widget) {
+ RK_TRACE (APP);
+
+ wrapper = wrapper_widget;
+ wrapper->wrapperWidget ()->installEventFilter (this);
+ static_cast<KDockWidget *> (wrapper->wrapperWidget ())->setEnableDocking (KDockWidget::DockFullSite);
+}
+
+
#include "rkmdiwindow.moc"
Modified: trunk/rkward/rkward/windows/rkmdiwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkmdiwindow.h 2007-04-23 05:47:38 UTC (rev 1836)
+++ trunk/rkward/rkward/windows/rkmdiwindow.h 2007-04-23 19:51:32 UTC (rev 1837)
@@ -40,15 +40,14 @@
WorkspaceBrowserWindow=128,
SearchHelpWindow=256,
PendingJobsWindow=512,
- AnyType=DataEditorWindow | CommandEditorWindow | OutputWindow | HelpWindow | ConsoleWindow | CommandLogWindow | WorkspaceBrowserWindow | SearchHelpWindow | PendingJobsWindow
+ ToolWindow = ConsoleWindow | CommandLogWindow | WorkspaceBrowserWindow | SearchHelpWindow | PendingJobsWindow,
+ AnyType=DataEditorWindow | CommandEditorWindow | OutputWindow | HelpWindow | ToolWindow
};
enum State {
Attached=1,
Detached=2,
- AnyNormalWindow=Attached | Detached,
- ToolWindow=4,
- AnyWindowState=AnyNormalWindow | ToolWindow
+ AnyWindowState=Attached | Detached
};
protected:
/** constructor
@@ -74,7 +73,7 @@
@returns true if attached, false if detached */
bool isAttached () { return (state == Attached); };
/** Is this a tool window? */
- bool isToolWindow () { return (state == ToolWindow); };
+ bool isToolWindow () { return (type & ToolWindow); };
/** Activate (raise) this window, regardless of whether it is attached or detached
@param with_focus Should the window also get keyboard focus? */
void activate (bool with_focus=true);
@@ -85,8 +84,9 @@
/** Tool windows will only hide themselves, and ignore the also_delete flag */
virtual bool close (bool also_delete);
/** For tool windows only (and perhaps for KDE3 only): set the wrapper widget that should be shown/raised on activation */
- void setToolWrapper (KMdiToolViewAccessor *wrapper_widget) { wrapper = wrapper_widget; };
+ void setToolWrapper (KMdiToolViewAccessor *wrapper_widget);
bool eventFilter (QObject *watched, QEvent *e);
+ bool acceptsEventsFor (QObject *object);
/** Whether the window is active. This seems to be more reliable than hasFocus () */
bool isActive () { return active; };
signals:
Modified: trunk/rkward/rkward/windows/rkworkplace.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkworkplace.cpp 2007-04-23 05:47:38 UTC (rev 1836)
+++ trunk/rkward/rkward/windows/rkworkplace.cpp 2007-04-23 19:51:32 UTC (rev 1837)
@@ -74,9 +74,11 @@
RK_TRACE (APP);
RK_ASSERT (windows.find (window) != windows.end ()); // This should not happen for now.
+ if (!window->isAttached ()) window->prepareToBeAttached ();
+
+ // all the rest is done, even if the window was previously "Attached", as this may also mean it was freshly created
+ window->state = RKMDIWindow::Attached;
if (!window->isToolWindow ()) {
- window->prepareToBeAttached ();
- window->state = RKMDIWindow::Attached;
view ()->addPage (window);
}
@@ -95,7 +97,7 @@
RK_ASSERT (window->getPart ());
if (was_attached) {
RKWardMainWindow::getMain ()->partManager ()->removePart (window->getPart ());
- view ()->removePage (window);
+ if (!window->isToolWindow ()) view ()->removePage (window);
}
DetachedWindowContainer *detached = new DetachedWindowContainer (window);
@@ -284,7 +286,6 @@
RKMDIWindow *w = activeAttachedWindow ();
if (w) closeWindow (w);
- else RK_ASSERT (false); // this is benign, and maybe even ok, but I'd like to see when this happens
}
RKWorkplace::RKWorkplaceObjectList RKWorkplace::getObjectList (int type, int state) {
@@ -320,7 +321,17 @@
RKMDIWindow *RKWorkplace::activeAttachedWindow () {
RK_TRACE (APP);
- return (static_cast<RKMDIWindow *> (view ()->activePage ()));
+ RKMDIWindow *ret = 0;
+ for (RKWorkplaceObjectList::const_iterator it = windows.constBegin (); it != windows.constEnd (); ++it) {
+ if (!(*it)->isAttached()) continue;
+
+ if ((*it)->isActive ()) {
+ ret = *it;
+ break;
+ }
+ }
+
+ return (ret);
}
QString RKWorkplace::makeWorkplaceDescription (const QString &sep, bool quote) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list