[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r2004: Add a method Vidalia::createShortcut() for creating a shortc (in trunk: . src)
Author: edmanm
Date: 2007-10-11 23:42:24 -0400 (Thu, 11 Oct 2007)
New Revision: 2004
Modified:
trunk/
trunk/src/vidalia.cpp
trunk/src/vidalia.h
Log:
r2070@lysithea: edmanm | 2007-10-11 23:34:08 -0400
Add a method Vidalia::createShortcut() for creating a shortcut in the context
of some widget and binding that shortcut's activated() signal to a slot of
another widget.
Property changes on: trunk
___________________________________________________________________
svk:merge ticket from /local/vidalia/trunk [r2070] on dc66be73-d13e-47ba-a267-8dc7cda68c65
Modified: trunk/src/vidalia.cpp
===================================================================
--- trunk/src/vidalia.cpp 2007-10-12 03:42:16 UTC (rev 2003)
+++ trunk/src/vidalia.cpp 2007-10-12 03:42:24 UTC (rev 2004)
@@ -29,9 +29,10 @@
#include <QTimer>
#include <QTextStream>
#include <QStyleFactory>
+#include <QShortcut>
+#include <languagesupport.h>
+#include <vmessagebox.h>
#include <util/string.h>
-#include <lang/languagesupport.h>
-#include <gui/common/vmessagebox.h>
#include <util/html.h>
#include <stdlib.h>
@@ -352,9 +353,20 @@
return QDir::convertSeparators(dataDirectory() + "/vidalia.pid");
}
+/** Writes <b>msg</b> with severity <b>level</b> to Vidalia's log. */
Log::LogMessage
Vidalia::log(Log::LogLevel level, QString msg)
{
return _log.log(level, msg);
}
+/** Creates and binds a shortcut such that when <b>key</b> is pressed in
+ * <b>sender</b>'s context, <b>receiver</b>'s <b>slot</b> will be called. */
+void
+Vidalia::createShortcut(const QKeySequence &key, QWidget *sender,
+ QWidget *receiver, const char *slot)
+{
+ QShortcut *s = new QShortcut(key, sender);
+ connect(s, SIGNAL(activated()), receiver, slot);
+}
+
Modified: trunk/src/vidalia.h
===================================================================
--- trunk/src/vidalia.h 2007-10-12 03:42:16 UTC (rev 2003)
+++ trunk/src/vidalia.h 2007-10-12 03:42:24 UTC (rev 2004)
@@ -36,6 +36,7 @@
#include <QApplication>
#include <QMap>
#include <QString>
+#include <QKeySequence>
#include <util/log.h>
#include <helpbrowser.h>
@@ -103,7 +104,12 @@
/** Enters the main event loop and waits until exit() is called. The signal
* running() will be emitted when the event loop has started. */
static int run();
-
+
+ /** Creates and binds a shortcut such that when <b>key</b> is pressed in
+ * <b>sender</b>'s context, <b>receiver</b>'s <b>slot</b> will be called. */
+ static void createShortcut(const QKeySequence &key, QWidget *sender,
+ QWidget *receiver, const char *slot);
+
public slots:
/** Shows the specified help topic, or the default if empty. */
static void help(QString topic = QString());