##// END OF EJS Templates
Progress bar added to the plugin
Progress bar added to the plugin

File last commit:

r35:0ca1c62d8087 default
r57:71cb087f0080 default
Show More
mainwindow.cpp
382 lines | 10.0 KiB | text/x-c | CppLexer
#include "mainwindow.h"
#include <iostream>
using namespace std;
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
wfDisplay = new WFDisplay();
wfPlotV = new WFPlot();
wfPlotE1 = new WFPlot();
wfPlotE2 = new WFPlot();
wfPlotB1 = new WFPlot();
wfPlotB2 = new WFPlot();
wfPlotB3 = new WFPlot();
dockV = NULL;
dockE1 = NULL;
dockE2 = NULL;
dockB1 = NULL;
dockB2 = NULL;
dockB3 = NULL;
createToolBar();
//createDockWindows();
}
MainWindow::~MainWindow()
{
}
void MainWindow::createDockWindows()
{
dockV = new QDockWidget(tr("V"), this);
dockE1 = new QDockWidget(tr("E1"), this);
dockE2 = new QDockWidget(tr("E2"), this);
dockB1 = new QDockWidget(tr("B1"), this);
dockB2 = new QDockWidget(tr("B2"), this);
dockB3 = new QDockWidget(tr("B3"), this);
}
void MainWindow::createToolBar()
{
radio_v = new QRadioButton(tr("v"));
radio_e1 = new QRadioButton(tr("e1"));
radio_e2 = new QRadioButton(tr("e2"));
radio_b1 = new QRadioButton(tr("b1"));
radio_b2 = new QRadioButton(tr("b2"));
radio_b3 = new QRadioButton(tr("b3"));
radio_tabify = new QRadioButton(tr("tabify"));
radio_v->setAutoExclusive(false);
radio_e1->setAutoExclusive(false);
radio_e2->setAutoExclusive(false);
radio_b1->setAutoExclusive(false);
radio_b2->setAutoExclusive(false);
radio_b3->setAutoExclusive(false);
radio_tabify->setAutoExclusive(false);
toolBar = new QToolBar();
toolBar->addWidget(radio_v);
toolBar->addWidget(radio_e1);
toolBar->addWidget(radio_e2);
toolBar->addWidget(radio_b1);
toolBar->addWidget(radio_b2);
toolBar->addWidget(radio_b3);
toolBar->addSeparator();
toolBar->addWidget(radio_tabify);
radio_tabify->setChecked(true);
addToolBar(Qt::LeftToolBarArea, toolBar);
connect(this->radio_v, SIGNAL(clicked(bool)), this, SLOT(actionRadioV(bool)));
connect(this->radio_e1, SIGNAL(clicked(bool)), this, SLOT(actionRadioE1(bool)));
connect(this->radio_e2, SIGNAL(clicked(bool)), this, SLOT(actionRadioE2(bool)));
connect(this->radio_b1, SIGNAL(clicked(bool)), this, SLOT(actionRadioB1(bool)));
connect(this->radio_b2, SIGNAL(clicked(bool)), this, SLOT(actionRadioB2(bool)));
connect(this->radio_b3, SIGNAL(clicked(bool)), this, SLOT(actionRadioB3(bool)));
connect(this->radio_tabify, SIGNAL(clicked(bool)), this, SLOT(organizeDocks()));
}
void MainWindow::actionRadioV(bool state)
{
if (state == true)
{
if (dockV == NULL)
{
dockV = new QDockWidget("V", this);
dockV->setWidget(wfPlotV);
}
}
else
{
this->removeDockWidget(dockV);
}
organizeDocks();
}
void MainWindow::actionRadioE1(bool state)
{
if (state == true)
{
if (dockE1 == NULL)
{
dockE1 = new QDockWidget("E1", this);
dockE1->setWidget(wfPlotE1);
}
addDockWidget(Qt::TopDockWidgetArea, dockE1);
dockE1->show();
}
else
{
this->removeDockWidget(dockE1);
}
organizeDocks();
}
void MainWindow::actionRadioE2(bool state)
{
if (state == true)
{
if (dockE2 == NULL)
{
dockE2 = new QDockWidget("E2", this);
dockE2->setWidget(wfPlotE2);
}
addDockWidget(Qt::TopDockWidgetArea, dockE2);
dockE2->show();
}
else
{
this->removeDockWidget(dockE2);
}
organizeDocks();
}
void MainWindow::actionRadioB1(bool state)
{
if (state == true)
{
if (dockB1 == NULL)
{
dockB1 = new QDockWidget("B1", this);
dockB1->setWidget(wfPlotB1);
}
}
else
{
this->removeDockWidget(dockB1);
}
organizeDocks();
}
void MainWindow::actionRadioB2(bool state)
{
if (state == true)
{
if (dockB2 == NULL)
{
dockB2 = new QDockWidget("B2", this);
dockB2->setWidget(wfPlotB2);
}
}
else
{
this->removeDockWidget(dockB2);
}
organizeDocks();
}
void MainWindow::actionRadioB3(bool state)
{
if (state == true)
{
if (dockB3 == NULL)
{
dockB3 = new QDockWidget("B3", this);
dockB3->setWidget(wfPlotB3);
}
}
else
{
this->removeDockWidget(dockB3);
}
organizeDocks();
}
void MainWindow::buildDockList()
{
dockList.clear();
if (radio_v->isChecked())
{
dockList.append(dockV);
removeDockWidget(dockV);
}
if (radio_e1->isChecked())
{
dockList.append(dockE1);
removeDockWidget(dockE1);
}
if (radio_e2->isChecked())
{
dockList.append(dockE2);
removeDockWidget(dockE2);
}
if (radio_b1->isChecked())
{
dockList.append(dockB1);
removeDockWidget(dockB1);
}
if (radio_b2->isChecked())
{
dockList.append(dockB2);
removeDockWidget(dockB2);
}
if (radio_b3->isChecked())
{
dockList.append(dockB3);
removeDockWidget(dockB3);
}
}
void MainWindow::organizeDocks()
{
if (radio_tabify->isChecked())
{
tabify();
this->resize(1.5*this->minimumSizeHint());
}
else
{
unTabify();
wfPlotV->resize(wfPlotV->minimumSizeHint());
wfPlotE1->resize(wfPlotE1->minimumSizeHint());
wfPlotE2->resize(wfPlotE2->minimumSizeHint());
wfPlotB1->resize(wfPlotB1->minimumSizeHint());
wfPlotB2->resize(wfPlotB2->minimumSizeHint());
wfPlotB3->resize(wfPlotB3->minimumSizeHint());
this->resize(this->minimumSizeHint());
}
}
void MainWindow::unTabify()
{
buildDockList();
switch(dockList.size())
{
case 0:
break;
case 1:
addDockWidget(Qt::TopDockWidgetArea, dockList.at(0));
dockList.at(0)->show();
break;
case 2:
addDockWidget(Qt::TopDockWidgetArea, dockList.at(0));
addDockWidget(Qt::TopDockWidgetArea, dockList.at(1));
dockList.at(0)->show();
dockList.at(1)->show();
break;
case 3:
addDockWidget(Qt::TopDockWidgetArea, dockList.at(0));
addDockWidget(Qt::TopDockWidgetArea, dockList.at(1));
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(2));
dockList.at(0)->show();
dockList.at(1)->show();
dockList.at(2)->show();
break;
case 4:
addDockWidget(Qt::TopDockWidgetArea, dockList.at(0));
addDockWidget(Qt::TopDockWidgetArea, dockList.at(1));
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(2));
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(3));
dockList.at(0)->show();
dockList.at(1)->show();
dockList.at(2)->show();
dockList.at(3)->show();
break;
case 5:
addDockWidget(Qt::TopDockWidgetArea, dockList.at(0));
addDockWidget(Qt::TopDockWidgetArea, dockList.at(1));
addDockWidget(Qt::TopDockWidgetArea, dockList.at(2));
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(3));
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(4));
dockList.at(0)->show();
dockList.at(1)->show();
dockList.at(2)->show();
dockList.at(3)->show();
dockList.at(4)->show();
break;
case 6:
addDockWidget(Qt::TopDockWidgetArea, dockList.at(0));
addDockWidget(Qt::TopDockWidgetArea, dockList.at(1));
addDockWidget(Qt::TopDockWidgetArea, dockList.at(2));
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(3));
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(4));
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(5));
dockList.at(0)->show();
dockList.at(1)->show();
dockList.at(2)->show();
dockList.at(3)->show();
dockList.at(4)->show();
dockList.at(5)->show();
break;
default:
break;
}
}
void MainWindow::tabify()
{
buildDockList();
switch(dockList.size())
{
case 0:
break;
case 1:
addDockWidget(Qt::TopDockWidgetArea, dockList.at(0));
dockList.at(0)->show();
break;
case 2:
addDockWidget(Qt::TopDockWidgetArea, dockList.at(0));
tabifyDockWidget(dockList.at(0), dockList.at(1));
dockList.at(0)->show();
dockList.at(1)->show();
break;
case 3:
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(0));
tabifyDockWidget(dockList.at(0), dockList.at(1));
tabifyDockWidget(dockList.at(1), dockList.at(2));
dockList.at(0)->show();
dockList.at(1)->show();
dockList.at(2)->show();
break;
case 4:
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(0));
tabifyDockWidget(dockList.at(0), dockList.at(1));
tabifyDockWidget(dockList.at(1), dockList.at(2));
tabifyDockWidget(dockList.at(2), dockList.at(3));
dockList.at(0)->show();
dockList.at(1)->show();
dockList.at(2)->show();
dockList.at(3)->show();
break;
case 5:
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(0));
tabifyDockWidget(dockList.at(0), dockList.at(1));
tabifyDockWidget(dockList.at(1), dockList.at(2));
tabifyDockWidget(dockList.at(2), dockList.at(3));
tabifyDockWidget(dockList.at(3), dockList.at(4));
dockList.at(0)->show();
dockList.at(1)->show();
dockList.at(2)->show();
dockList.at(3)->show();
dockList.at(4)->show();
break;
case 6:
addDockWidget(Qt::BottomDockWidgetArea, dockList.at(0));
tabifyDockWidget(dockList.at(0), dockList.at(1));
tabifyDockWidget(dockList.at(1), dockList.at(2));
tabifyDockWidget(dockList.at(2), dockList.at(3));
tabifyDockWidget(dockList.at(3), dockList.at(4));
tabifyDockWidget(dockList.at(4), dockList.at(5));
dockList.at(0)->show();
dockList.at(1)->show();
dockList.at(2)->show();
dockList.at(3)->show();
dockList.at(4)->show();
dockList.at(5)->show();
break;
default:
break;
}
}