mirror of
https://github.com/ra3xdh/qucs_s
synced 2025-03-28 21:13:26 +00:00
Add possibility to view/hide text output console
The text output console showing the detailed results of the filter calculation can be now hidden/shown using a dedicated menu item. Visibility of the output console is remembered across sessions using the QucsSettings. A status bar has also been added to show the status of the last calculation
This commit is contained in:
parent
9029bc7879
commit
8b9b2277af
@ -36,6 +36,7 @@ bool loadSettings()
|
||||
settings.beginGroup("QucsActiveFilter");
|
||||
if(settings.contains("x"))QucsSettings.x=settings.value("x").toInt();
|
||||
if(settings.contains("y"))QucsSettings.y=settings.value("y").toInt();
|
||||
if(settings.contains("showConsole")) QucsSettings.showConsole=settings.value("showConsole").toBool();
|
||||
settings.endGroup();
|
||||
|
||||
if(settings.contains("font"))QucsSettings.font.fromString(settings.value("font").toString());
|
||||
@ -53,6 +54,7 @@ bool saveApplSettings(QucsActiveFilter *qucs)
|
||||
settings.beginGroup("QucsActiveFilter");
|
||||
settings.setValue("x", qucs->x());
|
||||
settings.setValue("y", qucs->y());
|
||||
settings.setValue("showConsole", QucsSettings.showConsole);
|
||||
settings.endGroup();
|
||||
return true;
|
||||
|
||||
@ -66,6 +68,7 @@ int main(int argc, char *argv[])
|
||||
QucsSettings.x = 200;
|
||||
QucsSettings.y = 100;
|
||||
QucsSettings.font = QFont("Helvetica", 12);
|
||||
QucsSettings.showConsole = true;
|
||||
|
||||
// is application relocated?
|
||||
char * var = getenv ("QUCSDIR");
|
||||
|
@ -52,6 +52,17 @@ QucsActiveFilter::QucsActiveFilter(QWidget *parent)
|
||||
|
||||
fileMenu->addAction(fileQuit);
|
||||
|
||||
// View menu
|
||||
QMenu *viewMenu = new QMenu(tr("&View"));
|
||||
viewConsole = new QAction(tr("&Console"), this);
|
||||
viewConsole->setCheckable(true);
|
||||
viewConsole->setChecked(QucsSettings.showConsole);
|
||||
viewConsole->setStatusTip(tr("Enables/disables the filter calculation console"));
|
||||
viewConsole->setWhatsThis(tr("Console\n\nEnables/disables the filter calculation console"));
|
||||
connect(viewConsole, SIGNAL(toggled(bool)), SLOT(slotViewConsole(bool)));
|
||||
viewMenu->addAction(viewConsole);
|
||||
|
||||
// Help menu
|
||||
QMenu *helpMenu = new QMenu(tr("&Help"), this);
|
||||
QAction * helpHelp = new QAction(tr("Help..."), this);
|
||||
helpHelp->setShortcut(Qt::Key_F1);
|
||||
@ -71,6 +82,7 @@ QucsActiveFilter::QucsActiveFilter(QWidget *parent)
|
||||
helpMenu->addAction(helpAboutQt);
|
||||
|
||||
menuBar()->addMenu(fileMenu);
|
||||
menuBar()->addMenu(viewMenu);
|
||||
menuBar()->addSeparator();
|
||||
menuBar()->addMenu(helpMenu);
|
||||
|
||||
@ -83,7 +95,6 @@ QucsActiveFilter::QucsActiveFilter(QWidget *parent)
|
||||
//lblRpl2 = new QLabel(tr("Stopband ripple (dB)"));
|
||||
lblKv = new QLabel(tr("Passband gain, Kv (dB)"));
|
||||
|
||||
|
||||
edtA1 = new QLineEdit("3");
|
||||
QDoubleValidator *val1 = new QDoubleValidator(0,100000,3);
|
||||
edtA1->setValidator(val1);
|
||||
@ -123,7 +134,6 @@ QucsActiveFilter::QucsActiveFilter(QWidget *parent)
|
||||
btnCalcSchematic = new QPushButton(tr("Calculate and copy to clipboard"));
|
||||
connect(btnCalcSchematic,SIGNAL(clicked()),SLOT(slotCalcSchematic()));
|
||||
|
||||
lblResult = new QLabel(tr("Calculation console"));
|
||||
txtResult = new QPlainTextEdit;
|
||||
txtResult->setReadOnly(true);
|
||||
txtResult->setWordWrapMode(QTextOption::NoWrap);
|
||||
@ -172,7 +182,10 @@ QucsActiveFilter::QucsActiveFilter(QWidget *parent)
|
||||
vl3->addWidget(lblOrder,6,0);
|
||||
vl3->addWidget(edtOrder,6,1);
|
||||
gpbPar->setLayout(vl3);
|
||||
gpbPar->show(); // show now since we need its actual size later
|
||||
// do not actually show on screen (yet)
|
||||
gpbPar->setAttribute(Qt::WA_DontShowOnScreen);
|
||||
// call show() now since we need its actual size later
|
||||
gpbPar->show();
|
||||
|
||||
// second parameters group, below the previous one
|
||||
QGroupBox *gpbFunc = new QGroupBox(tr("Transfer function and Topology"));
|
||||
@ -196,7 +209,10 @@ QucsActiveFilter::QucsActiveFilter(QWidget *parent)
|
||||
vl4->addWidget(btnCalcSchematic);
|
||||
|
||||
gpbFunc->setLayout(vl4);
|
||||
gpbFunc->show(); // show now since we need its actual size later
|
||||
// do not actually show on screen (yet)
|
||||
gpbFunc->setAttribute(Qt::WA_DontShowOnScreen);
|
||||
// call show() now since we need its actual size later
|
||||
gpbFunc->show();
|
||||
|
||||
// filter response box, top-right
|
||||
QGroupBox *gpbAFR = new QGroupBox(tr("General filter amplitude-frequency response"));
|
||||
@ -237,17 +253,19 @@ QucsActiveFilter::QucsActiveFilter(QWidget *parent)
|
||||
|
||||
top1 = new QVBoxLayout;
|
||||
top1->addLayout(layout);
|
||||
QSplitter *sp1 = new QSplitter;
|
||||
top1->addWidget(sp1);
|
||||
|
||||
QGroupBox *gpbCons = new QGroupBox(tr("Filter calculation console"));
|
||||
gpbCons = new QGroupBox(tr("Filter calculation console"));
|
||||
QVBoxLayout *vl5 = new QVBoxLayout;
|
||||
vl5->addWidget(txtResult);
|
||||
gpbCons->setLayout(vl5);
|
||||
slotViewConsole(QucsSettings.showConsole);
|
||||
|
||||
top1->addWidget(gpbCons);
|
||||
txtResult->setMinimumHeight(180);
|
||||
|
||||
// init status bar
|
||||
statusBar()->showMessage(tr("Ready."));
|
||||
|
||||
zenter = new QWidget;
|
||||
this->setCentralWidget(zenter);
|
||||
zenter->setLayout(top1);
|
||||
@ -258,7 +276,6 @@ QucsActiveFilter::~QucsActiveFilter()
|
||||
|
||||
}
|
||||
|
||||
|
||||
void QucsActiveFilter::slotCalcSchematic()
|
||||
{
|
||||
txtResult->clear();
|
||||
@ -392,10 +409,12 @@ void QucsActiveFilter::slotCalcSchematic()
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
statusBar()->showMessage(tr("Filter calculation was successful"), 2000);
|
||||
txtResult->appendHtml("<pre>\r\n" +
|
||||
tr("Filter calculation was successful") +
|
||||
"</pre>");
|
||||
} else {
|
||||
statusBar()->showMessage(tr("Filter calculation terminated with error!"), 2000);
|
||||
txtResult->appendHtml("<pre>\r\n" +
|
||||
tr("Filter calculation terminated with error") +
|
||||
"</pre>");
|
||||
@ -551,6 +570,7 @@ void QucsActiveFilter::slotDefineTransferFunc()
|
||||
|
||||
void QucsActiveFilter::errorMessage(QString str)
|
||||
{
|
||||
statusBar()->showMessage(tr("Error!"));
|
||||
QMessageBox* msg = new QMessageBox(QMessageBox::Critical,tr("Active filter design"),
|
||||
str,
|
||||
QMessageBox::Ok);
|
||||
@ -558,13 +578,29 @@ void QucsActiveFilter::errorMessage(QString str)
|
||||
delete msg;
|
||||
}
|
||||
|
||||
void QucsActiveFilter::fixSize()
|
||||
{
|
||||
// make main window fit widgets height
|
||||
resize(width(), 1);
|
||||
statusBar()->showMessage(tr("Ready."));
|
||||
}
|
||||
|
||||
void QucsActiveFilter::slotViewConsole(bool toggle) {
|
||||
gpbCons->setVisible(toggle);
|
||||
QucsSettings.showConsole = toggle;
|
||||
|
||||
// a QMainWindow does not automatically resize when a child widget is hidden
|
||||
// only way seems to force a resize after all the events have been processed
|
||||
QApplication::processEvents();
|
||||
QTimer::singleShot(0, this, SLOT(fixSize()));
|
||||
}
|
||||
|
||||
void QucsActiveFilter::slotHelpAbout()
|
||||
{
|
||||
QMessageBox::about(this, tr("About..."),
|
||||
"QucsActiveFilter Version " PACKAGE_VERSION+
|
||||
tr("\nActive Filter synthesis program\n")+
|
||||
tr("Copyright (C) 2014 by")+
|
||||
tr("Copyright (C) 2014, 2015 by")+
|
||||
"\nVadim Kuznetsov\n"
|
||||
"\nThis is free software; see the source for copying conditions."
|
||||
"\nThere is NO warranty; not even for MERCHANTABILITY or "
|
||||
|
@ -29,6 +29,7 @@ struct tQucsSettings {
|
||||
QFont font;
|
||||
QString LangDir;
|
||||
QString Language;
|
||||
bool showConsole;
|
||||
};
|
||||
|
||||
extern struct tQucsSettings QucsSettings;
|
||||
@ -72,7 +73,8 @@ private:
|
||||
QPushButton *btnCalcSchematic;
|
||||
QPushButton *btnDefineTransferFunc;
|
||||
|
||||
QLabel *lblResult;
|
||||
QGroupBox *gpbCons;
|
||||
QAction *viewConsole;
|
||||
QPlainTextEdit *txtResult;
|
||||
|
||||
QSvgWidget *imgAFR;
|
||||
@ -118,6 +120,8 @@ private slots:
|
||||
void slotHelpAbout();
|
||||
void slotHelpAboutQt();
|
||||
void slotHelpIntro();
|
||||
void slotViewConsole(bool toggle);
|
||||
void fixSize();
|
||||
|
||||
public:
|
||||
QucsActiveFilter(QWidget *parent = 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user