[rkward-cvs] SF.net SVN: rkward:[3516] trunk/rkward/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Tue Apr 19 13:13:14 UTC 2011
Revision: 3516
http://rkward.svn.sourceforge.net/rkward/?rev=3516&view=rev
Author: tfry
Date: 2011-04-19 13:13:14 +0000 (Tue, 19 Apr 2011)
Log Message:
-----------
Re-arrange (and clean) startup code a bit. This obsoletes a bunch of boring code in RKToplevelWindowGUI.
Modified Paths:
--------------
trunk/rkward/rkward/rkward.cpp
trunk/rkward/rkward/rkward.h
trunk/rkward/rkward/windows/rktoolwindowlist.cpp
trunk/rkward/rkward/windows/rktoolwindowlist.h
trunk/rkward/rkward/windows/rktoplevelwindowgui.cpp
trunk/rkward/rkward/windows/rktoplevelwindowgui.h
Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp 2011-04-18 11:56:57 UTC (rev 3515)
+++ trunk/rkward/rkward/rkward.cpp 2011-04-19 13:13:14 UTC (rev 3516)
@@ -113,7 +113,7 @@
RK_TRACE (APP);
RK_ASSERT (rkward_mainwin == 0);
- gui_rebuild_locked = false;
+ gui_rebuild_locked = true;
rkward_mainwin = this;
RKGlobals::rinter = 0;
RKSettings::settings_tracker = new RKSettingsTracker (this);
@@ -129,6 +129,15 @@
setCentralWidget (RKWorkplace::mainWorkplace ());
connect (RKWorkplace::mainWorkplace ()->view (), SIGNAL (captionChanged (const QString &)), this, SLOT (setCaption (const QString &)));
+ part_manager = new KParts::PartManager (this);
+ // When the manager says the active part changes,
+ // the builder updates (recreates) the GUI
+ connect (partManager (), SIGNAL (activePartChanged (KParts::Part *)), this, SLOT (partChanged (KParts::Part *)));
+
+ readOptions();
+ RKGlobals::mtracker = new RKModificationTracker (this);
+ initToolViewsAndR ();
+
///////////////////////////////////////////////////////////////////
// build the interface
@@ -141,22 +150,12 @@
proxy_import->setMenu (dynamic_cast<QMenu*>(guiFactory ()->container ("import", this)));
proxy_export->setMenu (dynamic_cast<QMenu*>(guiFactory ()->container ("export", this)));
- RKGlobals::mtracker = new RKModificationTracker (this);
RKComponentMap::initialize ();
- if (options) {
- startup_options = options;
- } else {
- startup_options = new RKWardStartupOptions;
- startup_options->initial_url = KUrl();
- }
+ startup_options = options;
- QTimer::singleShot (50, this, SLOT (doPostInit ()));
-
- part_manager = new KParts::PartManager (this);
- // When the manager says the active part changes,
- // the builder updates (recreates) the GUI
- connect (partManager (), SIGNAL (activePartChanged (KParts::Part *)), this, SLOT (partChanged (KParts::Part *)));
+ // stuff which should wait until the event loop is running
+ QTimer::singleShot (0, this, SLOT (doPostInit ()));
}
RKWardMainWindow::~RKWardMainWindow() {
@@ -197,44 +196,15 @@
KMessageBox::error (this, i18n ("<p>RKWard either could not find its resource files at all, or only an old version of those files. The most likely cause is that the last installation failed to place the files in the correct place. This can lead to all sorts of problems, from single missing features to complete failure to function.</p><p><b>You should quit RKWard, now, and fix your installation</b>. For help with that, see <a href=\"http://p.sf.net/rkward/compiling\">http://p.sf.net/rkward/compiling</a>.</p>"), i18n ("Broken installation"), KMessageBox::Notify | KMessageBox::AllowLink);
}
- setUpdatesEnabled (false);
-
- readOptions();
- RObjectBrowser::object_browser = new RObjectBrowser (0, true);
- RObjectBrowser::mainBrowser ()->setCaption (i18n ("Workspace"));
- RKToolWindowList::registerToolWindow (RObjectBrowser::mainBrowser (), "workspace", RKToolWindowList::Left);
-
- RKCommandLog::rkcommand_log = new RKCommandLog (0, true);
- RKToolWindowList::registerToolWindow (RKCommandLog::rkcommand_log, "commandlog", RKToolWindowList::Bottom);
-
// startup options will be deleted from the R thread (TODO correct this!), so we need to copy the initial_url here, or run into race conditions
- KUrl open_url = startup_options->initial_url;
- QString evaluate_code = startup_options->evaluate;
+ KUrl open_url = startup_options ? startup_options->initial_url : KUrl ();
+ QString evaluate_code = startup_options ? startup_options->evaluate : QString ();
delete startup_options;
startup_options = 0;
- startR ();
-
+
initPlugins ();
+ gui_rebuild_locked = false;
- RKFileBrowser::main_browser = new RKFileBrowser (0, true);
- RKFileBrowser::main_browser->setCaption (i18n ("Files"));
- RKToolWindowList::registerToolWindow (RKFileBrowser::main_browser, "filebrowser", RKToolWindowList::Left);
-
- RControlWindow::control_window = new RControlWindow (0, true);
- RControlWindow::getControl ()->setCaption (i18n ("Pending Jobs"));
- RKToolWindowList::registerToolWindow (RControlWindow::getControl (), "pendingjobs", RKToolWindowList::Nowhere);
-
- RKConsole *console = new RKConsole (0, true);
- RKConsole::setMainConsole (console);
- RKToolWindowList::registerToolWindow (console, "console", RKToolWindowList::Bottom);
-
- RKHelpSearchWindow *help_search = new RKHelpSearchWindow (0, true);
- RKHelpSearchWindow::main_help_search = help_search;
- RKToolWindowList::registerToolWindow (help_search, "helpsearch", RKToolWindowList::Bottom);
-
- RKWorkplace::mainWorkplace ()->placeToolWindows ();
-
- setUpdatesEnabled (true);
show ();
KUrl recover_url = RKRecoverDialog::checkRecoverCrashedWorkspace ();
@@ -316,6 +286,37 @@
RKGlobals::rInterface ()->cancelAll ();
}
+void RKWardMainWindow::initToolViewsAndR () {
+ RK_TRACE (APP);
+
+ RObjectBrowser::object_browser = new RObjectBrowser (0, true);
+ RObjectBrowser::mainBrowser ()->setCaption (i18n ("Workspace"));
+ RKToolWindowList::registerToolWindow (RObjectBrowser::mainBrowser (), "workspace", RKToolWindowList::Left, Qt::AltModifier + Qt::Key_1);
+
+ RKCommandLog::rkcommand_log = new RKCommandLog (0, true);
+ RKToolWindowList::registerToolWindow (RKCommandLog::rkcommand_log, "commandlog", RKToolWindowList::Bottom, Qt::AltModifier + Qt::Key_3);
+
+ startR ();
+
+ RKFileBrowser::main_browser = new RKFileBrowser (0, true);
+ RKFileBrowser::main_browser->setCaption (i18n ("Files"));
+ RKToolWindowList::registerToolWindow (RKFileBrowser::main_browser, "filebrowser", RKToolWindowList::Left, Qt::AltModifier + Qt::Key_2);
+
+ RControlWindow::control_window = new RControlWindow (0, true);
+ RControlWindow::getControl ()->setCaption (i18n ("Pending Jobs"));
+ RKToolWindowList::registerToolWindow (RControlWindow::getControl (), "pendingjobs", RKToolWindowList::Nowhere, Qt::AltModifier + Qt::Key_4);
+
+ RKConsole *console = new RKConsole (0, true);
+ RKConsole::setMainConsole (console);
+ RKToolWindowList::registerToolWindow (console, "console", RKToolWindowList::Bottom, Qt::AltModifier + Qt::Key_5);
+
+ RKHelpSearchWindow *help_search = new RKHelpSearchWindow (0, true);
+ RKHelpSearchWindow::main_help_search = help_search;
+ RKToolWindowList::registerToolWindow (help_search, "helpsearch", RKToolWindowList::Bottom, Qt::AltModifier + Qt::Key_6);
+
+ RKWorkplace::mainWorkplace ()->placeToolWindows ();
+}
+
void RKWardMainWindow::initActions() {
RK_TRACE (APP);
KAction *action;
Modified: trunk/rkward/rkward/rkward.h
===================================================================
--- trunk/rkward/rkward/rkward.h 2011-04-18 11:56:57 UTC (rev 3515)
+++ trunk/rkward/rkward/rkward.h 2011-04-19 13:13:14 UTC (rev 3516)
@@ -26,18 +26,6 @@
class QLabel;
class QCloseEvent;
class KActionMenu;
-// forward declaration of the RKward classes
-class RSettings;
-class RKMenu;
-class RObjectBrowser;
-class RKSettingsModule;
-class RKSettings;
-class RInterface;
-class RKEditorManager;
-class RKMenuList;
-class RKCommandEditorWindow;
-class KMdiToolViewAccessor;
-class RKMDIWindow;
class RKTopLevelWindowGUI;
class KRecentFilesAction;
class KSqueezedTextLabel;
@@ -88,6 +76,8 @@
/** sets up the statusbar for the main window by initialzing a statuslabel.
*/
void initStatusBar();
+ /** sets up the various tool windows, and starts the R engine */
+ void initToolViewsAndR ();
/** reimplemented from KMainWindow to call our doQueryClose (), and then (if quitting was not cancelled), invoke an RKQuitAgent to wait for the R-backend to finish up before actually quitting. */
virtual void closeEvent (QCloseEvent *e);
signals:
Modified: trunk/rkward/rkward/windows/rktoolwindowlist.cpp
===================================================================
--- trunk/rkward/rkward/windows/rktoolwindowlist.cpp 2011-04-18 11:56:57 UTC (rev 3515)
+++ trunk/rkward/rkward/windows/rktoolwindowlist.cpp 2011-04-19 13:13:14 UTC (rev 3516)
@@ -28,13 +28,14 @@
return RKToolWindowListPrivate::registered_tool_windows;
}
-void RKToolWindowList::registerToolWindow (RKMDIWindow *window, const QString &id, Placement default_placement) {
+void RKToolWindowList::registerToolWindow (RKMDIWindow *window, const QString &id, Placement default_placement, int default_shortcut) {
RK_TRACE (APP);
ToolWindowRepresentation tr;
tr.window = window;
tr.id = id;
tr.default_placement = default_placement;
+ tr.default_shortcut = default_shortcut;
RKToolWindowListPrivate::registered_tool_windows.append (tr);
}
Modified: trunk/rkward/rkward/windows/rktoolwindowlist.h
===================================================================
--- trunk/rkward/rkward/windows/rktoolwindowlist.h 2011-04-18 11:56:57 UTC (rev 3515)
+++ trunk/rkward/rkward/windows/rktoolwindowlist.h 2011-04-19 13:13:14 UTC (rev 3516)
@@ -37,9 +37,10 @@
RKMDIWindow *window;
QString id;
Placement default_placement;
+ int default_shortcut;
};
- void registerToolWindow (RKMDIWindow *window, const QString &id, Placement default_placement);
+ void registerToolWindow (RKMDIWindow *window, const QString &id, Placement default_placement, int default_shortcut);
void unregisterToolWindow (RKMDIWindow *window);
RKMDIWindow* findToolWindowById (const QString &id);
QString idOfWindow (RKMDIWindow *window);
Modified: trunk/rkward/rkward/windows/rktoplevelwindowgui.cpp
===================================================================
--- trunk/rkward/rkward/windows/rktoplevelwindowgui.cpp 2011-04-18 11:56:57 UTC (rev 3515)
+++ trunk/rkward/rkward/windows/rktoplevelwindowgui.cpp 2011-04-19 13:13:14 UTC (rev 3516)
@@ -2,7 +2,7 @@
rktoplevelwindowgui - description
-------------------
begin : Tue Apr 24 2007
- copyright : (C) 2007, 2009 by Thomas Friedrichsmeier
+ copyright : (C) 2007, 2009, 2011 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -70,31 +70,13 @@
// window menu
KAction *action;
- // NOTE: Why don't we just iterate over RKToolWindowList::registeredToolWindows ()? Because that is not yet filled at the time that the RKToplevelWindowGUI for the main window is constructed! What a pity...
- action = actionCollection ()->addAction ("window_show_workspace", this, SLOT(toggleWorkspace()));
- action->setText (i18n ("Show/Hide Workspace Browser"));
- action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::WindowWorkspaceBrowser));
- action->setShortcut (Qt::AltModifier + Qt::Key_1);
- action = actionCollection ()->addAction ("window_show_filebrowser", this, SLOT(toggleFilebrowser()));
- action->setText (i18n ("Show/Hide Filesystem Browser"));
- action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::WindowFileBrowser));
- action->setShortcut (Qt::AltModifier + Qt::Key_2);
- action = actionCollection ()->addAction ("window_show_commandlog", this, SLOT(toggleCommandLog()));
- action->setText (i18n ("Show/Hide Command Log"));
- action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::WindowCommandLog));
- action->setShortcut (Qt::AltModifier + Qt::Key_3);
- action = actionCollection ()->addAction ("window_show_pendingjobs", this, SLOT(togglePendingJobs()));
- action->setText (i18n ("Show/Hide Pending Jobs"));
- action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::WindowPendingJobs));
- action->setShortcut (Qt::AltModifier + Qt::Key_4);
- action = actionCollection ()->addAction ("window_show_console", this, SLOT(toggleConsole()));
- action->setText (i18n ("Show/Hide Console"));
- action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::WindowConsole));
- action->setShortcut (Qt::AltModifier + Qt::Key_5);
- action = actionCollection ()->addAction ("window_show_helpsearch", this, SLOT(toggleHelpSearch()));
- action->setText (i18n ("Show/Hide R Help Search"));
- action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::WindowSearchHelp));
- action->setShortcut (Qt::AltModifier + Qt::Key_6);
+ foreach (RKToolWindowList::ToolWindowRepresentation rep, RKToolWindowList::registeredToolWindows ()) {
+ action = actionCollection ()->addAction ("window_show_" + rep.id, this, SLOT (toggleToolView()));
+ action->setText (i18n ("Show/Hide %1", rep.window->shortCaption ()));
+ action->setIcon (rep.window->windowIcon ());
+ action->setShortcut (rep.default_shortcut);
+ action->setData (rep.id);
+ }
action = actionCollection ()->addAction ("window_activate_docview", this, SLOT(activateDocumentView()));
action->setText (i18n ("Activate Document view"));
action->setShortcut (Qt::AltModifier + Qt::Key_0);
@@ -158,9 +140,8 @@
void RKTopLevelWindowGUI::showAboutApplication () {
RK_TRACE (APP);
- KAboutApplicationDialog *about = new KAboutApplicationDialog (KCmdLineArgs::aboutData ());
- about->exec ();
- delete about;
+ KAboutApplicationDialog about (KCmdLineArgs::aboutData ());
+ about.exec ();
}
void RKTopLevelWindowGUI::toggleToolView (RKMDIWindow *tool_window) {
@@ -175,6 +156,16 @@
}
}
+void RKTopLevelWindowGUI::toggleToolView () {
+ RK_TRACE (APP);
+ QAction *act = dynamic_cast<QAction*> (sender ());
+ RK_ASSERT (act);
+
+ RKMDIWindow *win = RKToolWindowList::findToolWindowById (act->data ().toString ());
+ RK_ASSERT (win);
+ toggleToolView (win);
+}
+
void RKTopLevelWindowGUI::showHelpSearch () {
RK_TRACE (APP);
@@ -187,42 +178,6 @@
RKWorkplace::mainWorkplace ()->openHelpWindow (KUrl ("rkward://page/rkward_welcome"), true);
}
-void RKTopLevelWindowGUI::toggleHelpSearch () {
- RK_TRACE (APP);
-
- toggleToolView (RKHelpSearchWindow::mainHelpSearch ());
-}
-
-void RKTopLevelWindowGUI::toggleConsole () {
- RK_TRACE (APP);
-
- toggleToolView (RKConsole::mainConsole ());
-}
-
-void RKTopLevelWindowGUI::toggleCommandLog () {
- RK_TRACE (APP);
-
- toggleToolView (RKCommandLog::getLog ());
-}
-
-void RKTopLevelWindowGUI::togglePendingJobs () {
- RK_TRACE (APP);
-
- toggleToolView (RControlWindow::getControl ());
-}
-
-void RKTopLevelWindowGUI::toggleWorkspace () {
- RK_TRACE (APP);
-
- toggleToolView (RObjectBrowser::mainBrowser ());
-}
-
-void RKTopLevelWindowGUI::toggleFilebrowser () {
- RK_TRACE (APP);
-
- toggleToolView (RKFileBrowser::getMainBrowser ());
-}
-
void RKTopLevelWindowGUI::activateDocumentView () {
RK_TRACE (APP);
Modified: trunk/rkward/rkward/windows/rktoplevelwindowgui.h
===================================================================
--- trunk/rkward/rkward/windows/rktoplevelwindowgui.h 2011-04-18 11:56:57 UTC (rev 3515)
+++ trunk/rkward/rkward/windows/rktoplevelwindowgui.h 2011-04-19 13:13:14 UTC (rev 3516)
@@ -2,7 +2,7 @@
rktoplevelwindowgui - description
-------------------
begin : Tue Apr 24 2007
- copyright : (C) 2007, 2009 by Thomas Friedrichsmeier
+ copyright : (C) 2007, 2009, 2011 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -35,18 +35,6 @@
// windows menu
/** Raise the help search window */
void showHelpSearch ();
- /** Toggle the help search window */
- void toggleHelpSearch ();
- /** Toggle the console window */
- void toggleConsole ();
- /** Toggle the command log window */
- void toggleCommandLog ();
- /** Toggle the pending jobs window */
- void togglePendingJobs ();
- /** Toggle the workspace browser window */
- void toggleWorkspace ();
- /** Toggle the filesystem browser window */
- void toggleFilebrowser ();
/** Activate the current (non tools) window in the workspace */
void activateDocumentView ();
/** ensure output window is shown. */
@@ -69,6 +57,8 @@
void configureShortcuts ();
/** configure key bindings. Reimplemented to show notice before the actual dialog. */
void configureToolbars ();
+private slots:
+ void toggleToolView ();
private:
KXmlGuiWindow *for_window;
void toggleToolView (RKMDIWindow *tool_window);
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