Example #1
0
ApplicationControl::ApplicationControl(GuiControl *guiControl)
    : server(new LogAppServer("local", "localhost", DEBUG_PORT))
    , state(ApplicationState::NORMAL)
    , connectionState(ApplicationConnectionState::JUST_STARTED)
    , currentDocument(nullptr)
    , guiControl(guiControl)
{
    connect(server, SIGNAL(connected()), this, SLOT(onServerConnected()));
    connect(server, SIGNAL(disconnected(QString)), this, SLOT(onServerDisconnected(QString)));
    connect(server, SIGNAL(docListReceived(std::vector<std::pair<uint64_t,QString> >)), this, SLOT(onDocListReceived(std::vector<std::pair<uint64_t,QString> >)));
    connect(server, SIGNAL(docCreatedOnServer(uint64_t,QString)), this, SLOT(onNewDocumentOnServer(uint64_t,QString)));

    connectionTimer.setInterval(5000);
    connectionTimer.setSingleShot(true);
    connect(&connectionTimer, SIGNAL(timeout()), this, SLOT(serverPooling()));

    server->connectToServer();
    serverPooling();
}
Example #2
0
CMainWindow::CMainWindow(int argc, char *argv[], QWidget *parent)
    : QMainWindow(parent)
{
    //======================================================================================================================================
    QStringList arguments;

    for (int i = 0; i < argc; i++)
    {
        arguments.append(argv[i]);

        arguments[i].remove("-");
    }
    //======================================================================================================================================
    qSetMessagePattern("[%{time h:mm:ss:zzz} %{if-category}%{category}%{endif} %{type}] %{function}: - %{message}");
    //======================================================================================================================================
    ui.setupUi(this);
    QSettings settings;
    m_EventFilter = CEventFilter::Signleton();
    m_Data = new CData;
    //======================================================================================================================================
    if (arguments.contains("ip"))
    {
        m_WebSocketClient = new CWebSocketClient(QUrl(QString("ws://%1").arg((arguments.at(arguments.indexOf("ip") + 1)))), m_Data);
        settings.setValue("IPAdress", arguments.at(arguments.indexOf("ip") + 1).split(":").first());
        settings.setValue("Port", arguments.at(arguments.indexOf("ip") + 1).split(":").last());
    }
    else
        m_WebSocketClient = new CWebSocketClient(QUrl(QString("ws://%1:%2").arg(settings.value("IPAdress").toString()).arg(settings.value("Port").toString())), m_Data);
    //======================================================================================================================================
    ////Actions
    //QAction *action_Close = new QAction(QIcon(QString::fromUtf8(":/Resources/cancel.png")), "Close", this);
    //QAction *action_FullScreen = new QAction(QIcon(QString::fromUtf8(":/Resources/slideshow_full_screen.png")), "Fullsreen", this);
    //QAction *action_HomePage = new QAction(QIcon(QString::fromUtf8(":/Resources/home_page.png")), "Home Page", this);
    //QAction *action_Plotter = new QAction(QIcon(QString::fromUtf8(":/Resources/chart_curve.png")), "Plotter", this);
    ////======================================================================================================================================
    ////Toolbar
    //ui.toolBar->addAction(action_Close);
    //ui.toolBar->addAction(action_FullScreen);
    //ui.toolBar->addSeparator();
    //ui.toolBar->setIconSize(QSize(20, 20));
    //ui.toolBar->addAction(action_HomePage);
    //ui.toolBar->addAction(action_Plotter);
    //======================================================================================================================================
    //StartPage
    m_StartPage = new CStartPage(this);
    ui.stackedWidget->addWidget(m_StartPage->getView());
    //======================================================================================================================================
    //Plotter
    m_Plotter = new CPlotter(this);
    ui.stackedWidget->addWidget(m_Plotter->getView());
    //======================================================================================================================================
    //Settings
    m_Settings = new CSettings(this);
    ui.stackedWidget->addWidget(m_Settings);
    //======================================================================================================================================
    //======================================================================================================================================
    connect(m_EventFilter,		SIGNAL(reciveClick()),							this,		SLOT(showNextPage()));
    connect(m_EventFilter,		SIGNAL(reciveDoubleClick()),					this,		SLOT(showSettings()));

    connect(m_Data,				SIGNAL(NewDataRecieved()),						this,		SLOT(onNewData()));

    connect(m_Settings,			SIGNAL(reciveNewURL(QString)),					this,		SLOT(onNewURL(QString)));
    connect(m_Settings,			SIGNAL(ready()),								this,		SLOT(showStartpage()));

    connect(m_WebSocketClient,	SIGNAL(serverConnected(QString)),				m_Settings, SLOT(onServerConnected(QString)));
    connect(m_WebSocketClient,	SIGNAL(serverDisconnected()),					m_Settings, SLOT(onServerDisconnected()));

    connect(m_WebSocketClient,	SIGNAL(recievedInitialScript(QJsonObject)),		m_Data,		SLOT(recievedInitialScript(QJsonObject)));
    connect(m_WebSocketClient,	SIGNAL(recievedDataScript(QJsonObject)),		m_Data,		SLOT(recievedDataScript(QJsonObject)));

    //======================================================================================================================================
    //======================================================================================================================================
    resize(480, 320);

    ui.stackedWidget->setCurrentIndex(0);
}