GUI upgrade incoming
This commit is contained in:
parent
a613b35caa
commit
58d369b018
@ -2,6 +2,7 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ircbot.h"
|
#include "ircbot.h"
|
||||||
#include "socketirc.h"
|
#include "socketirc.h"
|
||||||
|
#include "console.h"
|
||||||
|
|
||||||
BotApp::BotApp(int argc, char** argv) : nogui(false)
|
BotApp::BotApp(int argc, char** argv) : nogui(false)
|
||||||
{
|
{
|
||||||
@ -58,11 +59,15 @@ int BotApp::exec()
|
|||||||
{
|
{
|
||||||
if(!nogui)
|
if(!nogui)
|
||||||
{
|
{
|
||||||
window = new MainWindow();
|
window = new MainWindow(bot->getChan());
|
||||||
QObject::connect(sock, SIGNAL(receivedMsg(QString)), (QObject*)window->getConsole(), SLOT(append(QString)));
|
QObject::connect(sock, SIGNAL(receivedMsg(QString)), window->getAdvancedConsole(), SLOT(appendAdvancedMsg(QString)));
|
||||||
QObject::connect(bot, SIGNAL(sendMsg(QString)), (QObject*)window->getConsole(), SLOT(append(QString)));
|
QObject::connect(bot, SIGNAL(sendMsg(QString)), window->getAdvancedConsole(), SLOT(appendAdvancedMsg(QString)));
|
||||||
QObject::connect((QObject*)window->getPrompt(), SIGNAL(sendMsg(QString)), sock, SLOT(sendMsg(QString)));
|
QObject::connect(sock, SIGNAL(receivedMsg(QString)), window->getSimpleConsole(), SLOT(appendSimpleMsg(QString)));
|
||||||
QObject::connect((QObject*)window->getPrompt(), SIGNAL(returnPressed()), (QObject*)window->getPrompt(), SLOT(confirmationPerformed()));
|
QObject::connect(bot, SIGNAL(sendMsg(QString)), window->getSimpleConsole(), SLOT(appendSimpleMsg(QString)));
|
||||||
|
QObject::connect((QObject*)window->getAdvancedPrompt(), SIGNAL(sendMsg(QString)), sock, SLOT(sendMsg(QString)));
|
||||||
|
QObject::connect((QObject*)window->getAdvancedPrompt(), SIGNAL(returnPressed()), (QObject*)window->getAdvancedPrompt(), SLOT(advancedConfirmationPerformed()));
|
||||||
|
QObject::connect((QObject*)window->getSimplePrompt(), SIGNAL(sendMsg(QString)), sock, SLOT(sendMsg(QString)));
|
||||||
|
QObject::connect((QObject*)window->getSimplePrompt(), SIGNAL(returnPressed()), (QObject*)window->getSimplePrompt(), SLOT(simpleConfirmationPerformed()));
|
||||||
window->show();
|
window->show();
|
||||||
}
|
}
|
||||||
return sock->connectToServer(coreApp);
|
return sock->connectToServer(coreApp);
|
||||||
|
12
ircbot/console.cpp
Normal file
12
ircbot/console.cpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include "console.h"
|
||||||
|
|
||||||
|
void Console::appendAdvancedMsg(const QString& msg)
|
||||||
|
{
|
||||||
|
append(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Console::appendSimpleMsg(const QString& msg)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
append(msg);
|
||||||
|
}
|
17
ircbot/console.h
Normal file
17
ircbot/console.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef CONSOLE_H
|
||||||
|
#define CONSOLE_H
|
||||||
|
|
||||||
|
#include <QTextBrowser>
|
||||||
|
|
||||||
|
class Console : public QTextBrowser
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
Console(QWidget*& w) : QTextBrowser(w) {}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void appendAdvancedMsg(const QString& msg);
|
||||||
|
void appendSimpleMsg(const QString& msg);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CONSOLE_H
|
@ -18,6 +18,11 @@ void IRCBot::receiveMsg(QString str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString IRCBot::getChan()
|
||||||
|
{
|
||||||
|
return chan;
|
||||||
|
}
|
||||||
|
|
||||||
void IRCBot::addModule(Module* module)
|
void IRCBot::addModule(Module* module)
|
||||||
{
|
{
|
||||||
modules.push_back(module);
|
modules.push_back(module);
|
||||||
|
@ -23,6 +23,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
void addModule(Module* module);
|
void addModule(Module* module);
|
||||||
BaseModule* getBaseModule();
|
BaseModule* getBaseModule();
|
||||||
|
QString getChan();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void receiveMsg(QString msg);
|
void receiveMsg(QString msg);
|
||||||
|
@ -15,7 +15,8 @@ SOURCES += mainwindow.cpp \
|
|||||||
ircbot.cpp \
|
ircbot.cpp \
|
||||||
botapp.cpp \
|
botapp.cpp \
|
||||||
module.cpp \
|
module.cpp \
|
||||||
basemodule.cpp
|
basemodule.cpp \
|
||||||
|
console.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
socketirc.h \
|
socketirc.h \
|
||||||
@ -25,6 +26,7 @@ HEADERS += mainwindow.h \
|
|||||||
ircbot.h \
|
ircbot.h \
|
||||||
botapp.h \
|
botapp.h \
|
||||||
module.h \
|
module.h \
|
||||||
basemodule.h
|
basemodule.h \
|
||||||
|
console.h
|
||||||
|
|
||||||
FORMS += mainwindow.ui
|
FORMS += mainwindow.ui
|
||||||
|
@ -3,21 +3,32 @@
|
|||||||
#include <QTextBrowser>
|
#include <QTextBrowser>
|
||||||
#include "prompt.h"
|
#include "prompt.h"
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(const QString &myChan, QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::MainWindow)
|
ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
ui->simplePrompt->setChan(myChan);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextBrowser* MainWindow::getConsole()
|
Console* MainWindow::getAdvancedConsole()
|
||||||
{
|
{
|
||||||
return this->ui->monitoringConsole;
|
return this->ui->advancedConsole;
|
||||||
}
|
}
|
||||||
|
|
||||||
Prompt* MainWindow::getPrompt()
|
Prompt* MainWindow::getAdvancedPrompt()
|
||||||
{
|
{
|
||||||
return this->ui->prompt;
|
return this->ui->advancedPrompt;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console* MainWindow::getSimpleConsole()
|
||||||
|
{
|
||||||
|
return this->ui->simpleConsole;
|
||||||
|
}
|
||||||
|
|
||||||
|
Prompt* MainWindow::getSimplePrompt()
|
||||||
|
{
|
||||||
|
return this->ui->simplePrompt;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
|
||||||
class Prompt;
|
class Prompt;
|
||||||
|
class Console;
|
||||||
class QTextBrowser;
|
class QTextBrowser;
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
@ -14,11 +15,13 @@ class MainWindow : public QMainWindow
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget *parent = 0);
|
explicit MainWindow(const QString &myChan, QWidget *parent = 0);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
QTextBrowser* getConsole();
|
Console* getAdvancedConsole();
|
||||||
Prompt* getPrompt();
|
Prompt* getAdvancedPrompt();
|
||||||
|
Console* getSimpleConsole();
|
||||||
|
Prompt* getSimplePrompt();
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
};
|
};
|
||||||
|
@ -15,11 +15,68 @@
|
|||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralWidget">
|
<widget class="QWidget" name="centralWidget">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="1" column="0" colspan="2">
|
<item row="0" column="0">
|
||||||
<widget class="QTextBrowser" name="monitoringConsole"/>
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
</item>
|
<property name="currentIndex">
|
||||||
<item row="0" column="0" colspan="2">
|
<number>1</number>
|
||||||
<widget class="Prompt" name="prompt"/>
|
</property>
|
||||||
|
<widget class="QWidget" name="advancedTab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Advanced</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="Console" name="advancedConsole"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Prompt" name="advancedPrompt"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="simpleTab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Simple</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="Console" name="simpleConsole"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Prompt" name="simplePrompt"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@ -31,6 +88,11 @@
|
|||||||
<extends>QLineEdit</extends>
|
<extends>QLineEdit</extends>
|
||||||
<header>prompt.h</header>
|
<header>prompt.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>Console</class>
|
||||||
|
<extends>QTextBrowser</extends>
|
||||||
|
<header>console.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
@ -1,8 +1,20 @@
|
|||||||
#include "prompt.h"
|
#include "prompt.h"
|
||||||
|
|
||||||
void Prompt::confirmationPerformed()
|
Prompt::setChan(const QString& myChan)
|
||||||
|
{
|
||||||
|
chan = myChan;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Prompt::advancedConfirmationPerformed()
|
||||||
{
|
{
|
||||||
QString str = text();
|
QString str = text();
|
||||||
clear();
|
clear();
|
||||||
emit sendMsg(str.append("\r\n"));
|
emit sendMsg(str.append("\r\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Prompt::simpleConfirmationPerformed()
|
||||||
|
{
|
||||||
|
QString str = QString("PRIVMSG #%1 :%2\r\n").arg(chan).arg(text());
|
||||||
|
clear();
|
||||||
|
emit sendMsg(str);
|
||||||
|
}
|
||||||
|
@ -6,11 +6,16 @@
|
|||||||
class Prompt : public QLineEdit
|
class Prompt : public QLineEdit
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
QString chan;
|
||||||
public:
|
public:
|
||||||
Prompt(QWidget*& w) : QLineEdit(w) {}
|
Prompt(QWidget*& w) : QLineEdit(w), chan("epicsparrow") {}
|
||||||
|
|
||||||
|
setChan(const QString& myChan);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void confirmationPerformed();
|
void advancedConfirmationPerformed();
|
||||||
|
void simpleConfirmationPerformed();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sendMsg(QString);
|
void sendMsg(QString);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user