[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r2981: The slot called when a shortcut is pressed doesn't have to b (vidalia/trunk/src/vidalia)
Author: edmanm
Date: 2008-08-17 01:49:08 -0400 (Sun, 17 Aug 2008)
New Revision: 2981
Modified:
vidalia/trunk/src/vidalia/vidalia.cpp
vidalia/trunk/src/vidalia/vidalia.h
Log:
The slot called when a shortcut is pressed doesn't have to belong to a widget;
it could just be a QObject. Also add a convenience method that takes the
shortcut as a QString, instead of a QKeySequence.
Modified: vidalia/trunk/src/vidalia/vidalia.cpp
===================================================================
--- vidalia/trunk/src/vidalia/vidalia.cpp 2008-08-17 04:14:25 UTC (rev 2980)
+++ vidalia/trunk/src/vidalia/vidalia.cpp 2008-08-17 05:49:08 UTC (rev 2981)
@@ -340,9 +340,17 @@
* <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)
+ QObject *receiver, const char *slot)
{
QShortcut *s = new QShortcut(key, sender);
connect(s, SIGNAL(activated()), receiver, slot);
}
+/** 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 QString &key, QWidget *sender,
+ QObject *receiver, const char *slot)
+{
+ createShortcut(QKeySequence(key), sender, receiver, slot);
+}
Modified: vidalia/trunk/src/vidalia/vidalia.h
===================================================================
--- vidalia/trunk/src/vidalia/vidalia.h 2008-08-17 04:14:25 UTC (rev 2980)
+++ vidalia/trunk/src/vidalia/vidalia.h 2008-08-17 05:49:08 UTC (rev 2981)
@@ -95,8 +95,13 @@
/** 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);
+ QObject *receiver, const char *slot);
+ /** 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 QString &key, QWidget *sender,
+ QObject *receiver, const char *slot);
+
signals:
/** Emitted when the application is running and the main event loop has
* started. */