[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r7414 - in gnunet-qt/src: common core
From: |
gnunet |
Subject: |
[GNUnet-SVN] r7414 - in gnunet-qt/src: common core |
Date: |
Sat, 12 Jul 2008 10:35:12 -0600 (MDT) |
Author: durner
Date: 2008-07-12 10:35:12 -0600 (Sat, 12 Jul 2008)
New Revision: 7414
Added:
gnunet-qt/src/common/menu.h
Modified:
gnunet-qt/src/common/Makefile.am
gnunet-qt/src/common/pluginInitParams.h
gnunet-qt/src/core/main.cc
gnunet-qt/src/core/main.h
gnunet-qt/src/core/wndMain.cc
gnunet-qt/src/core/wndMain.h
gnunet-qt/src/core/wndMain.ui
Log:
make menu accessible to plugins
Modified: gnunet-qt/src/common/Makefile.am
===================================================================
--- gnunet-qt/src/common/Makefile.am 2008-07-11 22:50:09 UTC (rev 7413)
+++ gnunet-qt/src/common/Makefile.am 2008-07-12 16:35:12 UTC (rev 7414)
@@ -12,6 +12,7 @@
eventDispatcher.cc \
itemModel.h \
itemModel.cc \
+ model.h \
textEditor.cc \
plugin.h \
pluginInitParams.h \
Added: gnunet-qt/src/common/menu.h
===================================================================
--- gnunet-qt/src/common/menu.h (rev 0)
+++ gnunet-qt/src/common/menu.h 2008-07-12 16:35:12 UTC (rev 7414)
@@ -0,0 +1,47 @@
+/*
+ This file is part of gnunet-qt.
+ (C) 2008 Nils Durner (and other contributing authors)
+
+ gnunet-qt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ gnunet-qt is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef MENU_H_
+#define MENU_H_
+
+#include <QMenu>
+#include <QAction>
+#include <QLinkedList>
+
+typedef struct
+{
+ QString name, text, receiverSlot;
+ QIcon icon;
+ enum QAction::MenuRole menuRole;
+ QObject *receiver;
+ QAction **action;
+} GMenuAction;
+
+typedef QLinkedList<GMenuAction> GMenuActionList;
+
+typedef struct
+{
+ QString name, title;
+ GMenuActionList actions;
+} GMenu;
+
+typedef QLinkedList<GMenu> GMenuStruct;
+
+#endif /* MENU_H_ */
Modified: gnunet-qt/src/common/pluginInitParams.h
===================================================================
--- gnunet-qt/src/common/pluginInitParams.h 2008-07-11 22:50:09 UTC (rev
7413)
+++ gnunet-qt/src/common/pluginInitParams.h 2008-07-12 16:35:12 UTC (rev
7414)
@@ -21,10 +21,13 @@
#ifndef PLUGINITPARAMS_H_
#define PLUGINITPARAMS_H_
+#include "menu.h"
+
typedef struct
{
struct GNUNET_GC_Configuration *config;
struct GNUNET_GE_Context *errorContext;
+ GMenu *menu;
} GPluginInitParams;
#endif /* PLUGINITPARAMS_H_ */
Modified: gnunet-qt/src/core/main.cc
===================================================================
--- gnunet-qt/src/core/main.cc 2008-07-11 22:50:09 UTC (rev 7413)
+++ gnunet-qt/src/core/main.cc 2008-07-12 16:35:12 UTC (rev 7414)
@@ -193,6 +193,51 @@
this->ectx = ectx;
}
+void GApplication::setupMenuStruct()
+{
+ GMenuAction action;
+ GMenu menu;
+
+ // File menu
+ menu.name = "gnunet-qt::core::file";
+ menu.title = QApplication::translate("WndMain", "&File", 0,
QApplication::UnicodeUTF8);
+
+ action.name = "gnunet-qt::core::file::exit";
+ action.icon = QIcon(":/pixmaps/exit.png");
+ action.text = QApplication::translate("WndMain", "&Exit", 0,
QApplication::UnicodeUTF8);
+ action.menuRole = QAction::QuitRole;
+ action.receiver = this;
+ action.receiverSlot = SLOT(quit());
+ action.action = &wnd.actionExit;
+ menu.actions.push_back(action);
+
+ menuStruct.push_back(menu);
+
+ //Help menu
+ menu.name = "gnunet-qt::core::help";
+ menu.title = QApplication::translate("WndMain", "&Help", 0,
QApplication::UnicodeUTF8);
+ menu.actions.clear();
+
+ action.name = "gnunet-qt::core::help::contextHelp";
+ action.icon = QIcon(":/pixmaps/whatsthis.png");
+ action.text = QApplication::translate("WndMain", "&Context help", 0,
QApplication::UnicodeUTF8);
+ action.receiver = &wnd;
+ action.receiverSlot = SLOT(contextHelp());
+ action.action = &wnd.action_Context_help;
+ menu.actions.push_back(action);
+
+ action.name = "gnunet-qt::core::help::about";
+ action.icon = QIcon(":/pixmaps/gnunet-logo-small.png");
+ action.text = QApplication::translate("WndMain", "About", 0,
QApplication::UnicodeUTF8);
+ action.menuRole = QAction::AboutRole;
+ action.receiver = &wnd;
+ action.receiverSlot = SLOT(about());
+ action.action = &wnd.actionAbout;
+ menu.actions.push_back(action);
+
+ menuStruct.push_back(menu);
+}
+
void GApplication::loadPlugins()
{
int count;
@@ -223,6 +268,7 @@
void GApplication::showWindow()
{
+ wnd.loadMenuStruct(menuStruct);
wnd.show();
}
@@ -282,8 +328,9 @@
app->addLibraryPath(app->applicationDirPath() + "/../lib/GNUnet/");
+ app->setupMenuStruct();
app->loadPlugins();
- app->showWindow();
+ app->showWindow();
#if defined(Q_OS_WIN)
if (!debug_mode)
Modified: gnunet-qt/src/core/main.h
===================================================================
--- gnunet-qt/src/core/main.h 2008-07-11 22:50:09 UTC (rev 7413)
+++ gnunet-qt/src/core/main.h 2008-07-12 16:35:12 UTC (rev 7414)
@@ -34,23 +34,26 @@
class GApplication: public QApplication
{
Q_OBJECT
-
+
public:
GApplication(int &argc, char **argv,
struct GNUNET_GC_Configuration *cfg);
void loadPlugins();
+ void setupMenuStruct();
void showWindow();
void setErrorContext(struct GNUNET_GE_Context *ectx);
GMainWindow *getWindow();
-
+
protected:
#if defined(Q_OS_WIN)
virtual bool winEventFilter(MSG *msg, long *result);
#endif
-
+
GMainWindow wnd;
GPluginLoader loader;
QString strCfgFile;
+
+ GMenuStruct menuStruct;
struct GNUNET_GE_Context *ectx;
struct GNUNET_GC_Configuration *cfg;
};
Modified: gnunet-qt/src/core/wndMain.cc
===================================================================
--- gnunet-qt/src/core/wndMain.cc 2008-07-11 22:50:09 UTC (rev 7413)
+++ gnunet-qt/src/core/wndMain.cc 2008-07-12 16:35:12 UTC (rev 7414)
@@ -86,10 +86,42 @@
networkIcon.setToolTip(tr("Number of connected peers"));
networkText.setToolTip(tr("Number of connected peers"));
}
+}
- connect(action_Context_help, SIGNAL(triggered()), this, SLOT(contextHelp()));
- connect(actionAbout, SIGNAL(triggered()), this, SLOT(about()));
- connect(actionExit, SIGNAL(triggered()), qApp, SLOT(quit()));
+void GMainWindow::loadMenuStruct(GMenuStruct &menuStruct)
+{
+ GMenuStruct::iterator itMenu;
+ GMenuActionList::iterator itItem;
+
+ for (itMenu = menuStruct.begin(); itMenu != menuStruct.end(); itMenu++)
+ {
+ QMenu *menu;
+
+ menu = new QMenu(menu_Bar);
+ menu->setObjectName(itMenu->name);
+ menu->setTitle(itMenu->title);
+ menu_Bar->addAction(menu->menuAction());
+
+ for (itItem = itMenu->actions.begin(); itItem != itMenu->actions.end();
itItem++)
+ {
+ QAction *action;
+
+ action = new QAction(menu);
+ action->setObjectName(itItem->name);
+ action->setIcon(itItem->icon);
+ action->setText(itItem->text);
+ action->setMenuRole(itItem->menuRole);
+ menu->addAction(action);
+
+ if (itItem->action)
+ *itItem->action = action;
+
+ connect(action, SIGNAL(triggered()), itItem->receiver,
+ qPrintable(itItem->receiverSlot));
+ }
+ }
+
+ menuStruct.clear();
}
void GMainWindow::contextHelp()
@@ -195,12 +227,4 @@
return QMainWindow::event(event);
}
-QMenu *GMainWindow::menu(menuType menu)
-{
- if (menu == FILE)
- return menu_File;
- else
- return menuHelp;
-}
-
/* end of wndMain.cc */
Modified: gnunet-qt/src/core/wndMain.h
===================================================================
--- gnunet-qt/src/core/wndMain.h 2008-07-11 22:50:09 UTC (rev 7413)
+++ gnunet-qt/src/core/wndMain.h 2008-07-12 16:35:12 UTC (rev 7414)
@@ -32,6 +32,7 @@
#include <QLabel>
#include <QSystemTrayIcon>
+#include "gnunet_qt_common.h"
#include "ui_wndMain.h"
#include "aboutDlg.h"
@@ -47,11 +48,12 @@
public:
QLabel statusIcon, statusText, networkIcon, networkText;
QSystemTrayIcon *trayIcon;
+ QAction *action_Context_help, *actionAbout, *actionExit;
- typedef enum {FILE, HELP} menuType;
- QMenu *menu(menuType menu);
+ void loadMenuStruct(GMenuStruct &menuStruct);
protected:
virtual bool event(QEvent *event);
+
public slots:
void setStatusText(const QPixmap &icon, const QString strText);
void setNetworkStatus(const QPixmap &icon, const QString strText);
Modified: gnunet-qt/src/core/wndMain.ui
===================================================================
--- gnunet-qt/src/core/wndMain.ui 2008-07-11 22:50:09 UTC (rev 7413)
+++ gnunet-qt/src/core/wndMain.ui 2008-07-12 16:35:12 UTC (rev 7414)
@@ -10,9 +10,7 @@
</rect>
</property>
<property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>4</hsizetype>
- <vsizetype>4</vsizetype>
+ <sizepolicy vsizetype="Maximum" hsizetype="Maximum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -21,22 +19,39 @@
<string>GNUnet, GNU's Peer-To-Peer Network</string>
</property>
<property name="windowIcon" >
- <iconset resource="../../pixmaps/pixmaps.qrc"
>:/pixmaps/gnunet-logo-small.png</iconset>
+ <iconset resource="../../pixmaps/pixmaps.qrc" >
+
<normaloff>:/pixmaps/gnunet-logo-small.png</normaloff>:/pixmaps/gnunet-logo-small.png</iconset>
</property>
<widget class="QWidget" name="centralwidget" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>22</y>
+ <width>800</width>
+ <height>557</height>
+ </rect>
+ </property>
<layout class="QVBoxLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
<property name="spacing" >
<number>6</number>
</property>
+ <property name="margin" >
+ <number>9</number>
+ </property>
<item>
<widget class="QTabWidget" name="tabWidget" >
<property name="currentIndex" >
<number>0</number>
</property>
<widget class="QWidget" name="tabRoot" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>776</width>
+ <height>512</height>
+ </rect>
+ </property>
<attribute name="title" >
<string>gnunet-qt</string>
</attribute>
@@ -45,70 +60,26 @@
</item>
</layout>
</widget>
- <widget class="QStatusBar" name="statusbar" />
- <widget class="QMenuBar" name="menu_Bar" >
+ <widget class="QStatusBar" name="statusbar" >
<property name="geometry" >
<rect>
<x>0</x>
- <y>0</y>
+ <y>579</y>
<width>800</width>
<height>21</height>
</rect>
</property>
- <widget class="QMenu" name="menu_File" >
- <property name="title" >
- <string>&File</string>
- </property>
- <addaction name="actionExit" />
- </widget>
- <widget class="QMenu" name="menuHelp" >
- <property name="title" >
- <string>&Help</string>
- </property>
- <addaction name="action_Context_help" />
- <addaction name="separator" />
- <addaction name="actionAbout" />
- </widget>
- <addaction name="menu_File" />
- <addaction name="menuHelp" />
</widget>
- <action name="actionExit" >
- <property name="icon" >
- <iconset resource="../../pixmaps/pixmaps.qrc" >
- <normaloff>:/pixmaps/exit.png</normaloff>:/pixmaps/exit.png</iconset>
+ <widget class="QMenuBar" name="menu_Bar" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>22</height>
+ </rect>
</property>
- <property name="text" >
- <string>E&xit</string>
- </property>
- </action>
- <action name="action_Context_help" >
- <property name="icon" >
- <iconset resource="../../pixmaps/pixmaps.qrc"
>:/pixmaps/whatsthis.png</iconset>
- </property>
- <property name="text" >
- <string>&Context help</string>
- </property>
- <property name="menuRole" >
- <enum>QAction::QuitRole</enum>
- </property>
- </action>
- <action name="actionAbout" >
- <property name="icon" >
- <iconset resource="../../pixmaps/pixmaps.qrc"
>:/pixmaps/gnunet-logo-small.png</iconset>
- </property>
- <property name="text" >
- <string>About</string>
- </property>
- <property name="shortcut" >
- <string/>
- </property>
- <property name="shortcutContext" >
- <enum>Qt::ApplicationShortcut</enum>
- </property>
- <property name="menuRole" >
- <enum>QAction::AboutRole</enum>
- </property>
- </action>
+ </widget>
</widget>
<resources>
<include location="../../pixmaps/pixmaps.qrc" />
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r7414 - in gnunet-qt/src: common core,
gnunet <=