Merge branch 'master' into hostdev

This commit is contained in:
Srivats P 2019-04-11 18:56:49 +05:30
commit cd9758f165
10 changed files with 117 additions and 9 deletions

86
client/applymsg.h Normal file
View File

@ -0,0 +1,86 @@
/*
Copyright (C) 2019 Srivats P.
This file is part of "Ostinato"
This 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef _APPLY_MESSAGE_H
#define _APPLY_MESSAGE_H
#include <QDialog>
#include <QMainWindow>
#include <QProgressBar>
#include <QTimer>
extern QMainWindow *mainWindow;
class ApplyMessage: public QDialog
{
public:
ApplyMessage(QWidget *parent = Q_NULLPTR);
public slots:
void show();
virtual void done(int r);
private:
QLabel *help_;
QTimer *helpTimer_;
};
ApplyMessage::ApplyMessage(QWidget *parent)
: QDialog(parent)
{
auto layout = new QVBoxLayout(this);
auto message = new QLabel(tr("Pushing configuration changes to agent "
"and re-building packets ..."), this);
auto progress = new QProgressBar(this);
progress->setRange(0, 0);
progress->setTextVisible(false);
help_ = new QLabel(tr("<b>This may take some time</b>"), this);
help_->setAlignment(Qt::AlignCenter);
layout->addWidget(message);
layout->addWidget(progress);
layout->addWidget(help_);
helpTimer_ = new QTimer(this);
helpTimer_->setSingleShot(true);
helpTimer_->setInterval(4000);
connect(helpTimer_, SIGNAL(timeout()), help_, SLOT(show()));
}
void ApplyMessage::show()
{
help_->hide(); // shown when helpTimer_ expires
QWidget *parent = parentWidget();
if (!parent)
parent = mainWindow;
move(parent->frameGeometry().center() - rect().center());
setModal(true);
QDialog::show();
helpTimer_->start();
}
void ApplyMessage::done(int r)
{
helpTimer_->stop();
QDialog::done(r);
}
#endif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -153,10 +153,16 @@ MainWindow::MainWindow(QWidget *parent)
this, SLOT(onNewVersion(QString))); this, SLOT(onNewVersion(QString)));
updater->checkForNewVersion(); updater->checkForNewVersion();
// Add the "Local" Port Group
if (appParams.optLocalDrone()) {
PortGroup *pg = new PortGroup;
pgl->addPortGroup(*pg);
}
if (appParams.argumentCount()) { if (appParams.argumentCount()) {
QString fileName = appParams.argument(0); QString fileName = appParams.argument(0);
if (QFile::exists(fileName)) if (QFile::exists(fileName))
on_actionOpenSession_triggered(fileName); openSession(fileName);
else else
QMessageBox::information(NULL, qApp->applicationName(), QMessageBox::information(NULL, qApp->applicationName(),
QString("File not found: " + fileName)); QString("File not found: " + fileName));
@ -201,7 +207,7 @@ MainWindow::~MainWindow()
} }
} }
void MainWindow::on_actionOpenSession_triggered(QString fileName) void MainWindow::openSession(QString fileName)
{ {
qDebug("Open Session Action (%s)", qPrintable(fileName)); qDebug("Open Session Action (%s)", qPrintable(fileName));
@ -253,6 +259,11 @@ _exit:
return; return;
} }
void MainWindow::on_actionOpenSession_triggered()
{
openSession();
}
void MainWindow::on_actionSaveSession_triggered() void MainWindow::on_actionSaveSession_triggered()
{ {
qDebug("Save Session Action"); qDebug("Save Session Action");

View File

@ -36,6 +36,7 @@ class MainWindow : public QMainWindow, private Ui::MainWindow
Q_OBJECT Q_OBJECT
private: private:
void openSession(QString fileName = QString());
bool openSession(QString fileName, QString &error); bool openSession(QString fileName, QString &error);
bool saveSession(QString fileName, QString fileType, QString &error); bool saveSession(QString fileName, QString fileType, QString &error);
@ -55,7 +56,7 @@ public:
~MainWindow(); ~MainWindow();
public slots: public slots:
void on_actionOpenSession_triggered(QString fileName = QString()); void on_actionOpenSession_triggered();
void on_actionSaveSession_triggered(); void on_actionSaveSession_triggered();
void on_actionPreferences_triggered(); void on_actionPreferences_triggered();
void on_actionViewRestoreDefaults_triggered(); void on_actionViewRestoreDefaults_triggered();

View File

@ -770,6 +770,8 @@ void PortGroup::processModifyStreamAck(int portIndex,
_error_exit: _error_exit:
mPorts[portIndex]->when_syncComplete(); mPorts[portIndex]->when_syncComplete();
emit applyFinished();
mainWindow->setEnabled(true); mainWindow->setEnabled(true);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
delete controller; delete controller;

View File

@ -171,6 +171,7 @@ public:
void processStreamStatsList(PbRpcController *controller); void processStreamStatsList(PbRpcController *controller);
signals: signals:
void applyFinished();
void portGroupDataChanged(int portGroupId, int portId = 0xFFFF); void portGroupDataChanged(int portGroupId, int portId = 0xFFFF);
void portListAboutToBeChanged(quint32 portGroupId); void portListAboutToBeChanged(quint32 portGroupId);
void portListChanged(quint32 portGroupId); void portListChanged(quint32 portGroupId);

View File

@ -43,12 +43,6 @@ PortGroupList::PortGroupList()
deviceGroupModelTester_ = new ModelTest(getDeviceGroupModel()); deviceGroupModelTester_ = new ModelTest(getDeviceGroupModel());
deviceModelTester_ = new ModelTest(getDeviceModel()); deviceModelTester_ = new ModelTest(getDeviceModel());
#endif #endif
// Add the "Local" Port Group
if (appParams.optLocalDrone()) {
PortGroup *pg = new PortGroup;
addPortGroup(*pg);
}
} }
PortGroupList::~PortGroupList() PortGroupList::~PortGroupList()

View File

@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "portswindow.h" #include "portswindow.h"
#include "applymsg.h"
#include "deviceswidget.h" #include "deviceswidget.h"
#include "portconfigdialog.h" #include "portconfigdialog.h"
#include "settings.h" #include "settings.h"
@ -52,6 +53,7 @@ PortsWindow::PortsWindow(PortGroupList *pgl, QWidget *parent)
plm = pgl; plm = pgl;
setupUi(this); setupUi(this);
applyMsg_ = new ApplyMessage();
devicesWidget->setPortGroupList(plm); devicesWidget->setPortGroupList(plm);
tvPortList->header()->hide(); tvPortList->header()->hide();
@ -173,6 +175,7 @@ PortsWindow::~PortsWindow()
{ {
delete delegate; delete delegate;
delete proxyPortModel; delete proxyPortModel;
delete applyMsg_;
} }
int PortsWindow::portGroupCount() int PortsWindow::portGroupCount()
@ -647,6 +650,11 @@ void PortsWindow::on_pbApply_clicked()
goto _exit; goto _exit;
} }
disconnect(applyMsg_);
connect(&(plm->portGroup(curPortGroup)), SIGNAL(applyFinished()),
applyMsg_, SLOT(hide()));
applyMsg_->show();
// FIXME(HI): shd this be a signal? // FIXME(HI): shd this be a signal?
//portGroup.when_configApply(port); //portGroup.when_configApply(port);
// FIXME(MED): mixing port id and index!!! // FIXME(MED): mixing port id and index!!!

View File

@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "ui_portswindow.h" #include "ui_portswindow.h"
#include "portgrouplist.h" #include "portgrouplist.h"
class ApplyMessage;
class QAbstractItemDelegate; class QAbstractItemDelegate;
class QProgressDialog; class QProgressDialog;
class QSortFilterProxyModel; class QSortFilterProxyModel;
@ -61,6 +62,7 @@ private:
QString lastNewPortGroup; QString lastNewPortGroup;
QAbstractItemDelegate *delegate; QAbstractItemDelegate *delegate;
QSortFilterProxyModel *proxyPortModel; QSortFilterProxyModel *proxyPortModel;
ApplyMessage *applyMsg_;
public slots: public slots:
void showMyReservedPortsOnly(bool enabled); void showMyReservedPortsOnly(bool enabled);

View File

@ -49,6 +49,9 @@ int main(int argc, char *argv[])
int exitCode = 0; int exitCode = 0;
QCoreApplication app(argc, argv); QCoreApplication app(argc, argv);
qDebug("Version: %s", version);
qDebug("Revision: %s", revision);
// TODO: command line options // TODO: command line options
// -v (--version) // -v (--version)
// -h (--help) // -h (--help)