#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow *w = new MainWindow;
a.setStyleSheet("MainWindow{background-color: rgb(102, 102, 102);}");
w->show();
return a.exec();
}
#include "mainwindow.h"
#include <QtGui>
#include <QFileDialog>
#include "ScdChooseDlg.h"
#include "ScdTreeView.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
setWindowIcon(QIcon(":/IED_Tool/image/app.png"));
//setWindowIcon(QIcon("image/app.png"));
centerWidget = new QWidget;
tipLabel = new QLabel(CHS("此工具可通过IED名称导出关联虚端子\n请选择SCD文件:"));
scdFileLabel = new QLabel(CHS("scd文件:"));
scdDirEdit = new QLineEdit;
butt_scdSelect = new QPushButton(CHS("选择"));
scdOK = new QPushButton(CHS("确 定"));
mainQuit = new QPushButton(CHS("退 出"));
scdFileLabel->setBuddy(scdDirEdit);
connect(butt_scdSelect, SIGNAL(clicked()),
this, SLOT(scdSelect()));
connect(scdOK, SIGNAL(clicked()),
this, SLOT(importScdFile()));
connect(mainQuit, SIGNAL(clicked()), this, SLOT(close()));
mainLayout = new QVBoxLayout;
scdLayout = new QHBoxLayout;
buttLayout = new QHBoxLayout;
scdLayout->addWidget(scdFileLabel);
scdLayout->addWidget(scdDirEdit);
scdLayout->addWidget(butt_scdSelect);
buttLayout->addStretch();
buttLayout->addWidget(scdOK);
buttLayout->addSpacing(100);
buttLayout->addWidget(mainQuit);
buttLayout->addStretch();
mainLayout->addWidget(tipLabel);
mainLayout->addSpacing(20);
mainLayout->addLayout(scdLayout);
mainLayout->addSpacing(35);
mainLayout->addLayout(buttLayout);
mainLayout->addStretch();
centerWidget->setLayout(mainLayout);
// set UI style
butt_scdSelect->setStyleSheet("color: white; \
width: 60px; \
height: 20px; \
border-radius: 10px; \
background-color: rgb(70, 168, 25);");
thisStyleSheet(this);
this->resize(560, 300);
this->setCentralWidget(centerWidget);
}
MainWindow::~MainWindow()
{
}
void MainWindow::scdSelect()
{
QString dir = QFileDialog::getOpenFileName(this,
CHS("请选择scd文件:"), "C:",
tr("ICD file(*.scd *.icd *.cid *.xml)"));
if(!dir.isEmpty())
{
scdDirEdit->setText(dir);
}
}
void MainWindow::importScdFile()
{
QString qsFileName = scdDirEdit->text();
IEDBriefInforList lst;
qsFileName = ScdChooseDlg::getChooseIEDList(qsFileName, lst);
if ( qsFileName.isEmpty() )
return;
QProgressDialog progressDlg( this );
progressDlg.setCancelButtonText(QObject::tr("&Cancel"));
progressDlg.setRange(0, lst.size());
progressDlg.setWindowTitle(QObject::tr("Prase SCD File"));
progressDlg.setWindowModality(Qt::WindowModal);
progressDlg.setMinimumDuration(0);
ServerPtrList lstSrv;
IEDBriefInforList::iterator it = lst.begin();
for( int i = 0; it != lst.end(); ++it, ++i )
{
if (progressDlg.wasCanceled())
break;
progressDlg.setValue(i);
progressDlg.setLabelText(QObject::tr("Prase server number %1 of %2...")
.arg(i).arg(lst.size()));
qApp->processEvents();
execute( (*it).ied_name );
}
}
void MainWindow::execute(QString ied_name)
{
exportVirtualTerminal(ied_name);
}
#include "mainwindow.h"
void MainWindow::thisStyleSheet(QWidget *w)
{
w->setStyleSheet("QLabel{ \
color: lightgray; \
font-size: 12pt;} \
QLineEdit{ \
padding-right: 15px; \
height: 18px; \
border: 2px; \
border-radius: 9px; \
font: 12pt;} \
QPushButton{ \
color: white; \
width: 80px; \
height: 25px; \
border-radius: 12px; \
font-size: 12pt; \
background-color: rgb(70, 168, 25);}");
}
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow *w = new MainWindow;
a.setStyleSheet("MainWindow{background-color: rgb(102, 102, 102);}");
w->show();
return a.exec();
}
#include "mainwindow.h"
#include <QtGui>
#include <QFileDialog>
#include "ScdChooseDlg.h"
#include "ScdTreeView.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
setWindowIcon(QIcon(":/IED_Tool/image/app.png"));
//setWindowIcon(QIcon("image/app.png"));
centerWidget = new QWidget;
tipLabel = new QLabel(CHS("此工具可通过IED名称导出关联虚端子\n请选择SCD文件:"));
scdFileLabel = new QLabel(CHS("scd文件:"));
scdDirEdit = new QLineEdit;
butt_scdSelect = new QPushButton(CHS("选择"));
scdOK = new QPushButton(CHS("确 定"));
mainQuit = new QPushButton(CHS("退 出"));
scdFileLabel->setBuddy(scdDirEdit);
connect(butt_scdSelect, SIGNAL(clicked()),
this, SLOT(scdSelect()));
connect(scdOK, SIGNAL(clicked()),
this, SLOT(importScdFile()));
connect(mainQuit, SIGNAL(clicked()), this, SLOT(close()));
mainLayout = new QVBoxLayout;
scdLayout = new QHBoxLayout;
buttLayout = new QHBoxLayout;
scdLayout->addWidget(scdFileLabel);
scdLayout->addWidget(scdDirEdit);
scdLayout->addWidget(butt_scdSelect);
buttLayout->addStretch();
buttLayout->addWidget(scdOK);
buttLayout->addSpacing(100);
buttLayout->addWidget(mainQuit);
buttLayout->addStretch();
mainLayout->addWidget(tipLabel);
mainLayout->addSpacing(20);
mainLayout->addLayout(scdLayout);
mainLayout->addSpacing(35);
mainLayout->addLayout(buttLayout);
mainLayout->addStretch();
centerWidget->setLayout(mainLayout);
// set UI style
butt_scdSelect->setStyleSheet("color: white; \
width: 60px; \
height: 20px; \
border-radius: 10px; \
background-color: rgb(70, 168, 25);");
thisStyleSheet(this);
this->resize(560, 300);
this->setCentralWidget(centerWidget);
}
MainWindow::~MainWindow()
{
}
void MainWindow::scdSelect()
{
QString dir = QFileDialog::getOpenFileName(this,
CHS("请选择scd文件:"), "C:",
tr("ICD file(*.scd *.icd *.cid *.xml)"));
if(!dir.isEmpty())
{
scdDirEdit->setText(dir);
}
}
void MainWindow::importScdFile()
{
QString qsFileName = scdDirEdit->text();
IEDBriefInforList lst;
qsFileName = ScdChooseDlg::getChooseIEDList(qsFileName, lst);
if ( qsFileName.isEmpty() )
return;
QProgressDialog progressDlg( this );
progressDlg.setCancelButtonText(QObject::tr("&Cancel"));
progressDlg.setRange(0, lst.size());
progressDlg.setWindowTitle(QObject::tr("Prase SCD File"));
progressDlg.setWindowModality(Qt::WindowModal);
progressDlg.setMinimumDuration(0);
ServerPtrList lstSrv;
IEDBriefInforList::iterator it = lst.begin();
for( int i = 0; it != lst.end(); ++it, ++i )
{
if (progressDlg.wasCanceled())
break;
progressDlg.setValue(i);
progressDlg.setLabelText(QObject::tr("Prase server number %1 of %2...")
.arg(i).arg(lst.size()));
qApp->processEvents();
execute( (*it).ied_name );
}
}
void MainWindow::execute(QString ied_name)
{
exportVirtualTerminal(ied_name);
}
#include "mainwindow.h"
void MainWindow::thisStyleSheet(QWidget *w)
{
w->setStyleSheet("QLabel{ \
color: lightgray; \
font-size: 12pt;} \
QLineEdit{ \
padding-right: 15px; \
height: 18px; \
border: 2px; \
border-radius: 9px; \
font: 12pt;} \
QPushButton{ \
color: white; \
width: 80px; \
height: 25px; \
border-radius: 12px; \
font-size: 12pt; \
background-color: rgb(70, 168, 25);}");
}