summaryrefslogtreecommitdiffstats
path: root/clients/tde/src/part
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-07-01 15:46:30 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-07-01 15:46:30 -0500
commite9dafbb9d016a1aa5e90bb12c63c12b8521cf059 (patch)
tree4cf6a0b2ae2fde33df1a8eb8f0d01deb4299caf9 /clients/tde/src/part
parentb6eb80309781bd02b9b66808d29508f23881de66 (diff)
downloadulab-e9dafbb9d016a1aa5e90bb12c63c12b8521cf059.tar.gz
ulab-e9dafbb9d016a1aa5e90bb12c63c12b8521cf059.zip
Add ability for instruments to add menu options to the main window
Diffstat (limited to 'clients/tde/src/part')
-rw-r--r--clients/tde/src/part/fpgaview/part.cpp59
-rw-r--r--clients/tde/src/part/fpgaview/part.h19
2 files changed, 76 insertions, 2 deletions
diff --git a/clients/tde/src/part/fpgaview/part.cpp b/clients/tde/src/part/fpgaview/part.cpp
index 316fd48..6161562 100644
--- a/clients/tde/src/part/fpgaview/part.cpp
+++ b/clients/tde/src/part/fpgaview/part.cpp
@@ -54,7 +54,7 @@ K_EXPORT_COMPONENT_FACTORY(libremotelab_fpgaviewer, RemoteLab::Factory)
FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObject *parent, const char *name, const TQStringList&)
- : RemoteInstrumentPart( parent, name ), m_socket(0), m_base(0), connToServerConnecting(false), connToServerState(-1), connToServerTimeoutTimer(NULL)
+ : RemoteInstrumentPart( parent, name ), m_socket(0), m_base(0), connToServerConnecting(false), connToServerState(-1), connToServerTimeoutTimer(NULL), m_interfaceMode(BasicInterfaceMode)
{
// Initialize mutex
m_connectionMutex = new TQMutex(false);
@@ -69,6 +69,19 @@ FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObj
// Create widgets
m_base = new FPGAViewBase(widget());
+ // Create menu actions
+ // Submenus
+ KActionCollection *const ac = actionCollection();
+ m_modeSubMenu = new KActionMenu(i18n("Mode"), ac, "mode_submenu");
+ m_menuActionList.append(m_modeSubMenu);
+ // Menu items
+ m_modeBasicEnabled = new KToggleAction(i18n("Basic"), KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(switchToBasicMode()), ac, "mode_basic_enabled");
+ m_modeSubMenu->insert(m_modeBasicEnabled);
+ m_modeIntermediateEnabled = new KToggleAction(i18n("Intermediate"), KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(switchToIntermediateMode()), ac, "mode_intermediate_enabled");
+ m_modeSubMenu->insert(m_modeIntermediateEnabled);
+ m_modeAdvancedEnabled = new KToggleAction(i18n("Advanced"), KShortcut(), TQT_TQOBJECT(this), TQT_SLOT(switchToAdvancedMode()), ac, "mode_advanced_enabled");
+ m_modeSubMenu->insert(m_modeAdvancedEnabled);
+
processLockouts();
TQTimer::singleShot(0, this, TQT_SLOT(postInit()));
@@ -86,13 +99,44 @@ FPGAViewPart::~FPGAViewPart() {
void FPGAViewPart::processLockouts() {
TQWidget* mainWidget = widget();
if (mainWidget) {
- if ((m_socket) && (m_socket->state() == TQSocket::Connected)) {
+ if ((m_socket) && (m_socket->state() == TQSocket::Connected) && (connToServerState > 0) && (connToServerConnecting == false)) {
mainWidget->setEnabled(true);
}
else {
mainWidget->setEnabled(false);
}
}
+
+ if (m_interfaceMode == BasicInterfaceMode) {
+ m_modeBasicEnabled->setChecked(true);
+ m_modeIntermediateEnabled->setChecked(false);
+ m_modeAdvancedEnabled->setChecked(false);
+ }
+ if (m_interfaceMode == IntermediateInterfaceMode) {
+ m_modeBasicEnabled->setChecked(false);
+ m_modeIntermediateEnabled->setChecked(true);
+ m_modeAdvancedEnabled->setChecked(false);
+ }
+ if (m_interfaceMode == AdvancedInterfaceMode) {
+ m_modeBasicEnabled->setChecked(false);
+ m_modeIntermediateEnabled->setChecked(false);
+ m_modeAdvancedEnabled->setChecked(true);
+ }
+}
+
+void FPGAViewPart::switchToBasicMode() {
+ m_interfaceMode = BasicInterfaceMode;
+ processLockouts();
+}
+
+void FPGAViewPart::switchToIntermediateMode() {
+ m_interfaceMode = IntermediateInterfaceMode;
+ processLockouts();
+}
+
+void FPGAViewPart::switchToAdvancedMode() {
+ m_interfaceMode = AdvancedInterfaceMode;
+ processLockouts();
}
void FPGAViewPart::connectionClosed() {
@@ -127,6 +171,13 @@ void FPGAViewPart::disconnectFromServer() {
}
void FPGAViewPart::finishConnectingToServer() {
+ if (!m_socket) {
+ connToServerState = -1;
+ connToServerConnecting = false;
+ processLockouts();
+ return;
+ }
+
if (connToServerConnecting) {
switch(connToServerState) {
case 0:
@@ -254,6 +305,10 @@ int FPGAViewPart::connectToServer(TQString server) {
return 0;
}
+TQPtrList<KAction> FPGAViewPart::menuActionList() {
+ return m_menuActionList;
+}
+
void FPGAViewPart::updateDisplay() {
// RAJA FIXME
}
diff --git a/clients/tde/src/part/fpgaview/part.h b/clients/tde/src/part/fpgaview/part.h
index 02797d8..3e8ac07 100644
--- a/clients/tde/src/part/fpgaview/part.h
+++ b/clients/tde/src/part/fpgaview/part.h
@@ -45,6 +45,13 @@ namespace RemoteLab
class FPGAViewPart : public KParts::RemoteInstrumentPart
{
Q_OBJECT
+
+ public:
+ enum InterfaceMode {
+ BasicInterfaceMode,
+ IntermediateInterfaceMode,
+ AdvancedInterfaceMode
+ };
public:
FPGAViewPart(TQWidget *, const char *, TQObject *, const char *, const TQStringList&);
@@ -54,6 +61,7 @@ namespace RemoteLab
virtual bool closeURL();
static KAboutData *createAboutData();
int connectToServer(TQString server);
+ virtual TQPtrList<KAction> menuActionList();
public slots:
virtual bool openURL(const KURL &url);
@@ -65,6 +73,9 @@ namespace RemoteLab
void connectionClosed();
void disconnectFromServer();
void finishConnectingToServer();
+ void switchToBasicMode();
+ void switchToIntermediateMode();
+ void switchToAdvancedMode();
private:
TDEKerberosClientSocket* m_socket;
@@ -75,6 +86,14 @@ namespace RemoteLab
bool connToServerConnecting;
int connToServerState;
TQTimer *connToServerTimeoutTimer;
+
+ TQPtrList<KAction> m_menuActionList;
+ KActionMenu* m_modeSubMenu;
+ KToggleAction* m_modeBasicEnabled;
+ KToggleAction* m_modeIntermediateEnabled;
+ KToggleAction* m_modeAdvancedEnabled;
+
+ InterfaceMode m_interfaceMode;
};
}