Modified: freeswitch/trunk/contrib/jmesquita/fsgui/resources/fs_gui.ui (14253 => 14254)
--- freeswitch/trunk/contrib/jmesquita/fsgui/resources/fs_gui.ui 2009-07-14 20:56:09 UTC (rev 14253)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/resources/fs_gui.ui 2009-07-14 22:55:48 UTC (rev 14254)
@@ -14,43 +14,75 @@
<string>FSGui - The console for humans</string>
</property>
<widget class="QWidget" name="centralWidget">
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0" colspan="2">
- <widget class="QTextEdit" name="textConsole">
- <property name="undoRedoEnabled">
- <bool>false</bool>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="currentIndex">
+ <number>1</number>
</property>
- <property name="readOnly">
+ <property name="tabsClosable">
<bool>true</bool>
</property>
- <property name="textInteractionFlags">
- <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
- </property>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Console</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QTextEdit" name="textConsole">
+ <property name="undoRedoEnabled">
+ <bool>false</bool>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_2">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <attribute name="title">
+ <string>Tab 2</string>
+ </attribute>
+ </widget>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QLineEdit" name="lineCmd">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLineEdit" name="lineCmd">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="btnSend">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Send</string>
+ </property>
+ <property name="shortcut">
+ <string>Return</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
- <item row="1" column="1">
- <widget class="QPushButton" name="btnSend">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Send</string>
- </property>
- <property name="autoDefault">
- <bool>false</bool>
- </property>
- <property name="default">
- <bool>true</bool>
- </property>
- </widget>
- </item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
@@ -59,7 +91,7 @@
<x>0</x>
<y>0</y>
<width>600</width>
- <height>26</height>
+ <height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@@ -118,9 +150,25 @@
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>lineCmd</tabstop>
- <tabstop>textConsole</tabstop>
<tabstop>btnSend</tabstop>
</tabstops>
<resources/>
- <connections/>
+ <connections>
+ <connection>
+ <sender>actionQuit</sender>
+ <signal>triggered()</signal>
+ <receiver>Cfsgui</receiver>
+ <slot>close()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>299</x>
+ <y>199</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
</ui>
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/fs_gui.cpp (14253 => 14254)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/fs_gui.cpp 2009-07-14 20:56:09 UTC (rev 14253)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/fs_gui.cpp 2009-07-14 22:55:48 UTC (rev 14254)
@@ -41,10 +41,11 @@
#include "esl_connection.h"
#include "esl.h"
+CserverManager *Cfsgui::serverDialog = NULL;
+
Cfsgui::Cfsgui(QWidget *parent) :
QMainWindow(parent),
- m_ui(new Ui::Cfsgui),
- serverDialog(new CserverManager)
+ m_ui(new Ui::Cfsgui)
{
m_ui->setupUi(this);
@@ -52,36 +53,34 @@
m_ui->statusBar->showMessage(tr("Ready"));
connect(m_ui->actionConnect, SIGNAL(triggered()),
- serverDialog, SLOT(show()));
- connect(serverDialog, SIGNAL(doConnect(QString,QString,QString)),
- this, SLOT(newConnectionFromDialog(QString,QString,QString)));
+ this, SLOT(newConnectionFromDialog()));
connect(m_ui->lineCmd, SIGNAL(textChanged(QString)),
this, SLOT(typedCommand()));
connect(m_ui->btnSend, SIGNAL(clicked()),
this, SLOT(sendCommand()));
+
+ /* Why QtDesigner does not allow me to delete this? */
+ m_ui->tabWidget->removeTab(1);
+ delete m_ui->tab_2;
+
}
-
Cfsgui::~Cfsgui()
{
delete m_ui;
delete serverDialog;
}
-
void Cfsgui::appendConsoleText(const QString text)
{
m_ui->textConsole->append(text);
}
-
void Cfsgui::getDisconnectedSlot()
{
eslConnection->disconnect();
}
-
void Cfsgui::typedCommand()
{
m_ui->btnSend->setDisabled(m_ui->lineCmd->text().isEmpty());
}
-
void Cfsgui::sendCommand()
{
QStringList cmdList = m_ui->lineCmd->text().split(" ");
@@ -96,7 +95,6 @@
gotEventSlot(e);
m_ui->lineCmd->clear();
}
-
void Cfsgui::gotConnectedSlot()
{
m_ui->statusBar->showMessage(tr("Connected"));
@@ -115,7 +113,6 @@
m_ui->lineCmd->setDisabled(true);
delete eslConnection;
}
-
void Cfsgui::connectionFailedSlot(QString msg)
{
qDebug() << msg;
@@ -126,7 +123,6 @@
m_ui->lineCmd->setDisabled(true);
delete eslConnection;
}
-
void Cfsgui::gotEventSlot(ESLevent * event)
{
QString type (event->getHeader("Content-Type"));
@@ -186,7 +182,6 @@
}
delete event;
}
-
void Cfsgui::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
@@ -198,32 +193,41 @@
break;
}
}
-
void Cfsgui::closeEvent(QCloseEvent *e)
{
/* TODO: We have to stop threads and do cleanup */
e->accept();
}
-
-void Cfsgui::newConnectionFromDialog(QString host, QString pass, QString port)
+void Cfsgui::newConnectionFromDialog()
{
- m_ui->statusBar->showMessage("Connecting...");
- eslConnection = new ESLconnection(host.toAscii(),
- port.toAscii(),
- pass.toAscii());
- /* Connect signals from eslConnection */
- connect(eslConnection, SIGNAL(gotConnected(void)),
- this, SLOT(gotConnectedSlot(void)));
- connect(eslConnection, SIGNAL(gotDisconnected(void)),
- this, SLOT(gotDisconnectedSlot(void)));
- connect(eslConnection, SIGNAL(connectionFailed(QString)),
- this, SLOT(connectionFailedSlot(QString)));
- connect(eslConnection, SIGNAL(gotEvent(ESLevent*)),
- this, SLOT(gotEventSlot(ESLevent*)));
+ if (!serverDialog)
+ {
+ serverDialog = new CserverManager();
+ }
+ serverDialog->show();
+ serverDialog->raise();
+ serverDialog->activateWindow();
- /* Connect the disconnect menu */
- connect(m_ui->actionDisconnect, SIGNAL(triggered()),
- this, SLOT(getDisconnectedSlot()));
+ if (serverDialog->exec())
+ {
+ m_ui->statusBar->showMessage("Connecting...");
+ eslConnection = new ESLconnection(serverDialog->getHost().toAscii(),
+ serverDialog->getPort().toAscii(),
+ serverDialog->getPass().toAscii());
+ /* Connect signals from eslConnection */
+ connect(eslConnection, SIGNAL(gotConnected(void)),
+ this, SLOT(gotConnectedSlot(void)));
+ connect(eslConnection, SIGNAL(gotDisconnected(void)),
+ this, SLOT(gotDisconnectedSlot(void)));
+ connect(eslConnection, SIGNAL(connectionFailed(QString)),
+ this, SLOT(connectionFailedSlot(QString)));
+ connect(eslConnection, SIGNAL(gotEvent(ESLevent*)),
+ this, SLOT(gotEventSlot(ESLevent*)));
- eslConnection->doConnect();
+ /* Connect the disconnect menu */
+ connect(m_ui->actionDisconnect, SIGNAL(triggered()),
+ this, SLOT(getDisconnectedSlot()));
+
+ eslConnection->doConnect();
+ }
}
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/include/fs_gui.h (14253 => 14254)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/include/fs_gui.h 2009-07-14 20:56:09 UTC (rev 14253)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/include/fs_gui.h 2009-07-14 22:55:48 UTC (rev 14254)
@@ -63,7 +63,7 @@
void appendConsoleText(const QString);
private slots:
- void newConnectionFromDialog(QString,QString,QString);
+ void newConnectionFromDialog();
void gotConnectedSlot();
void gotDisconnectedSlot();
void connectionFailedSlot(QString);
@@ -74,7 +74,8 @@
private:
Ui::Cfsgui *m_ui;
- CserverManager *serverDialog;
+ /*! Has to be static cos will be used by all server tabs */
+ static CserverManager *serverDialog;
ESLconnection *eslConnection;
};
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/include/server_manager.h (14253 => 14254)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/include/server_manager.h 2009-07-14 20:56:09 UTC (rev 14253)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/include/server_manager.h 2009-07-14 22:55:48 UTC (rev 14254)
@@ -39,7 +39,7 @@
#ifndef SERVER_MANAGER_H
#define SERVER_MANAGER_H
-#include <QtGui/QDialog>
+#include <QtGui>
namespace Ui {
class CserverManager;
@@ -51,12 +51,11 @@
public:
explicit CserverManager(QWidget *parent = 0);
virtual ~CserverManager();
-signals:
- void doConnect(QString, QString, QString);
+ QString getHost();
+ QString getPass();
+ QString getPort();
protected:
virtual void changeEvent(QEvent *e);
-private slots:
- void newConnection();
private:
Ui::CserverManager *m_ui;
};
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/server_manager.cpp (14253 => 14254)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/server_manager.cpp 2009-07-14 20:56:09 UTC (rev 14253)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/server_manager.cpp 2009-07-14 22:55:48 UTC (rev 14254)
@@ -44,8 +44,6 @@
m_ui(new Ui::CserverManager)
{
m_ui->setupUi(this);
- connect(this, SIGNAL(accepted()),
- this, SLOT(newConnection()));
}
CserverManager::~CserverManager()
@@ -65,10 +63,15 @@
}
}
-void CserverManager::newConnection()
+QString CserverManager::getHost()
{
- //TODO: Sanity checking needed.
- emit doConnect(m_ui->host->text(),
- m_ui->pass->text(),
- m_ui->port->text());
+ return m_ui->host->text();
}
+QString CserverManager::getPort()
+{
+ return m_ui->port->text();
+}
+QString CserverManager::getPass()
+{
+ return m_ui->pass->text();
+}