[rkward-cvs] SF.net SVN: rkward: [1579] trunk/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Wed Mar 14 16:21:28 UTC 2007
Revision: 1579
http://svn.sourceforge.net/rkward/?rev=1579&view=rev
Author: tfry
Date: 2007-03-14 09:21:28 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
Add run selection action to the HTML windows
Modified Paths:
--------------
trunk/rkward/ChangeLog
trunk/rkward/rkward/rkconsole.cpp
trunk/rkward/rkward/rkconsole.h
trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
trunk/rkward/rkward/windows/rkcommandeditorwindowpart.cpp
trunk/rkward/rkward/windows/rkcommandeditorwindowpart.h
trunk/rkward/rkward/windows/rkcommandlog.cpp
trunk/rkward/rkward/windows/rkhelpwindow.rc
trunk/rkward/rkward/windows/rkhtmlwindow.cpp
trunk/rkward/rkward/windows/rkhtmlwindow.h
Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog 2007-03-14 16:01:30 UTC (rev 1578)
+++ trunk/rkward/ChangeLog 2007-03-14 16:21:28 UTC (rev 1579)
@@ -1,3 +1,4 @@
+- add run selection action to all HTML windows
- add custom icons for run line/selection/all
- make sure not to run parts of an incomplete user command. It would lead to all sorts of subtle problems
- if an incomplete command was piped through the console, the console does not become blocked for piping
Modified: trunk/rkward/rkward/rkconsole.cpp
===================================================================
--- trunk/rkward/rkward/rkconsole.cpp 2007-03-14 16:01:30 UTC (rev 1578)
+++ trunk/rkward/rkward/rkconsole.cpp 2007-03-14 16:21:28 UTC (rev 1579)
@@ -754,6 +754,13 @@
new KAction (i18n ("Configure"), 0, this, SLOT (configure ()), ac, "rkconsole_configure");
}
+void RKConsole::pipeUserCommand (const QString &command) {
+ RK_TRACE (APP);
+
+ RCommand *cmd = new RCommand (command, RCommand::User);
+ pipeUserCommand (cmd);
+}
+
void RKConsole::pipeUserCommand (RCommand *command) {
RK_TRACE (APP);
@@ -772,6 +779,8 @@
int res = KMessageBox::questionYesNo (this, i18n ("You have configured RKWrad to run script commands through the console. However, the console is currently busy (either a command is running, or you have started to enter text in the console). Do you want to bypass the console this one time, or do you want to try again later?"), i18n ("Console is busy"), KGuiItem (i18n ("Bypass console")), KGuiItem (i18n ("Cancel")));
if (res == KMessageBox::Yes) {
RKGlobals::rInterface ()->issueCommand (command);
+ } else {
+ delete command;
}
} else {
QString command_string = command->command ();
Modified: trunk/rkward/rkward/rkconsole.h
===================================================================
--- trunk/rkward/rkward/rkconsole.h 2007-03-14 16:01:30 UTC (rev 1578)
+++ trunk/rkward/rkward/rkconsole.h 2007-03-14 16:21:28 UTC (rev 1579)
@@ -77,6 +77,8 @@
bool isBusy () { return (current_command || command_incomplete); };
/** Run a user command (through console, if applicable */
static void pipeUserCommand (RCommand *command);
+/** Overload for the above function: Use this, if you just need to run a string with no specials */
+ static void pipeUserCommand (const QString &command);
protected:
/** Handle keystrokes before they reach the kate-part. Return TRUE if we want the kate-part to ignore it
\param e the QKeyEvent */
Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp 2007-03-14 16:01:30 UTC (rev 1578)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp 2007-03-14 16:21:28 UTC (rev 1579)
@@ -315,7 +315,7 @@
QString command = m_doc->text ();
if (command.isEmpty ()) return;
- RKConsole::pipeUserCommand (new RCommand (command, RCommand::User, QString::null));
+ RKConsole::pipeUserCommand (command);
}
Modified: trunk/rkward/rkward/windows/rkcommandeditorwindowpart.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindowpart.cpp 2007-03-14 16:01:30 UTC (rev 1578)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindowpart.cpp 2007-03-14 16:21:28 UTC (rev 1579)
@@ -2,7 +2,7 @@
rkeditordataframepart - description
-------------------
begin : Wed Sep 14 2005
- copyright : (C) 2005 by Thomas Friedrichsmeier
+ copyright : (C) 2005, 2007 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
Modified: trunk/rkward/rkward/windows/rkcommandeditorwindowpart.h
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindowpart.h 2007-03-14 16:01:30 UTC (rev 1578)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindowpart.h 2007-03-14 16:21:28 UTC (rev 1579)
@@ -2,7 +2,7 @@
rkeditordataframepart - description
-------------------
begin : Wed Sep 14 2005
- copyright : (C) 2005 by Thomas Friedrichsmeier
+ copyright : (C) 2005, 2007 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
Modified: trunk/rkward/rkward/windows/rkcommandlog.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandlog.cpp 2007-03-14 16:01:30 UTC (rev 1578)
+++ trunk/rkward/rkward/windows/rkcommandlog.cpp 2007-03-14 16:21:28 UTC (rev 1579)
@@ -223,7 +223,7 @@
void RKCommandLog::runSelection () {
RK_TRACE (APP);
- RKConsole::pipeUserCommand (new RCommand (getView ()->selectedText (), RCommand::User, QString::null));
+ RKConsole::pipeUserCommand (getView ()->selectedText ());
}
////////////////////////// END RKCommandLog ///////////////////////////
Modified: trunk/rkward/rkward/windows/rkhelpwindow.rc
===================================================================
--- trunk/rkward/rkward/windows/rkhelpwindow.rc 2007-03-14 16:01:30 UTC (rev 1578)
+++ trunk/rkward/rkward/windows/rkhelpwindow.rc 2007-03-14 16:21:28 UTC (rev 1579)
@@ -7,9 +7,15 @@
<Menu name="edit">
<Action name="copy"/>
</Menu>
+ <Menu name="run">
+ <Action name="run_selection"/>
+ </Menu>
</MenuBar>
<ToolBar fullWidth="true" name="navigation_toolbar">
<Action name="help_back"/>
<Action name="help_forward"/>
</ToolBar>
+ <ToolBar name="runToolBar">
+ <Action name="run_selection"/>
+ </ToolBar>
</kpartgui>
Modified: trunk/rkward/rkward/windows/rkhtmlwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.cpp 2007-03-14 16:01:30 UTC (rev 1578)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.cpp 2007-03-14 16:21:28 UTC (rev 1579)
@@ -34,6 +34,7 @@
#include "../rkglobals.h"
#include "rkhelpsearchwindow.h"
#include "../rkward.h"
+#include "../rkconsole.h"
#include "../settings/rksettingsmodulegeneral.h"
#include "../misc/rkcommonfunctions.h"
#include "../misc/xmlhelper.h"
@@ -61,7 +62,7 @@
connect (khtmlpart, SIGNAL (completed ()), this, SLOT (loadDone ()));
url_history.setAutoDelete (true);
- back = forward = print = 0; // initialization done in subclasses
+ back = forward = print = run_selection = 0; // initialization done in subclasses
url_change_is_from_history = false;
}
@@ -88,8 +89,32 @@
// enable copy
KStdAction::copy (khtmlpart->browserExtension (), SLOT (copy ()), action_collection, "copy");
+
+ // run selection
+ run_selection = new KAction (i18n ("Run selection"), QIconSet (RKCommonFunctions::getRKWardDataDir () + "icons/run_selection.png"), KShortcut ("F8"), this, SLOT (runSelection ()), action_collection, "run_selection");
+
+ // needed to enable / disable the run selection action
+ connect (khtmlpart, SIGNAL (selectionChanged()), this, SLOT (selectionChanged()));
+ selectionChanged ();
}
+void RKHTMLWindow::selectionChanged () {
+ RK_TRACE (APP);
+
+ if (!run_selection) {
+ RK_ASSERT (false);
+ return;
+ }
+
+ run_selection->setEnabled (khtmlpart->hasSelection ());
+}
+
+void RKHTMLWindow::runSelection () {
+ RK_TRACE (APP);
+
+ RKConsole::pipeUserCommand (khtmlpart->selectedText ());
+}
+
void RKHTMLWindow::doGotoAnchor (const QString &anchor_name) {
RK_TRACE (APP);
Modified: trunk/rkward/rkward/windows/rkhtmlwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkhtmlwindow.h 2007-03-14 16:01:30 UTC (rev 1578)
+++ trunk/rkward/rkward/windows/rkhtmlwindow.h 2007-03-14 16:21:28 UTC (rev 1579)
@@ -67,6 +67,8 @@
void slotPrint ();
void slotForward ();
void slotBack ();
+ void selectionChanged ();
+ void runSelection ();
private slots:
/** This slot is called when the new page has finished loading. Sets scroll position to scroll_position */
void loadDone ();
@@ -85,6 +87,7 @@
KAction *back;
KAction *forward;
KAction *print;
+ KAction *run_selection;
bool url_change_is_from_history; // dirty!!!
QString goto_anchor_name;
};
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