Skip to content

Commit d4d30f7

Browse files
committedFeb 27, 2018
Gui: disable preview and display waring when preview is unavailable
1 parent 98d8e69 commit d4d30f7

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed
 

‎gui/QT/ultragrid_window.cpp

+47-1
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,52 @@ UltragridWindow::UltragridWindow(QWidget *parent): QMainWindow(parent){
6060

6161
queryOpts();
6262

63+
checkPreview();
64+
6365
startPreview();
6466
}
6567

68+
void UltragridWindow::checkPreview(){
69+
QStringList out;
70+
71+
QProcess process;
72+
73+
QString command = ultragridExecutable;
74+
75+
command += " -d help";
76+
77+
process.start(command);
78+
79+
process.waitForFinished();
80+
QByteArray output = process.readAllStandardOutput();
81+
QList<QByteArray> lines = output.split('\n');
82+
83+
foreach ( const QByteArray &line, lines ) {
84+
if(line.size() > 0 && QChar(line[0]).isSpace()) {
85+
QString opt = QString(line).trimmed();
86+
if(opt != "none"
87+
&& !opt.startsWith("--")
88+
&& !opt.contains("unavailable"))
89+
out.append(QString(line).trimmed());
90+
}
91+
}
92+
93+
if(!out.contains("multiplier") || !out.contains("preview")){
94+
ui.previewCheckBox->setChecked(false);
95+
ui.previewCheckBox->setEnabled(false);
96+
97+
QMessageBox warningBox(this);
98+
warningBox.setWindowTitle("Preview disabled");
99+
warningBox.setText("Preview is disabled, because UltraGrid was compiled"
100+
" without preview and multiplier displays."
101+
" Please build UltraGrid configured with the --enable-qt flag"
102+
" to enable preview.");
103+
warningBox.setStandardButtons(QMessageBox::Ok);
104+
warningBox.setIcon(QMessageBox::Warning);
105+
warningBox.exec();
106+
}
107+
}
108+
66109
void UltragridWindow::about(){
67110
QMessageBox aboutBox(this);
68111
aboutBox.setWindowTitle("About UltraGrid");
@@ -108,7 +151,10 @@ void UltragridWindow::start(){
108151
}
109152

110153
void UltragridWindow::startPreview(){
111-
if(process.state() != QProcess::NotRunning || !ui.previewCheckBox->isChecked()){
154+
if(!ui.previewCheckBox->isEnabled()
155+
|| process.state() != QProcess::NotRunning
156+
|| !ui.previewCheckBox->isChecked()
157+
){
112158
return;
113159
}
114160

‎gui/QT/ultragrid_window.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class UltragridWindow : public QMainWindow{
1919
void closeEvent(QCloseEvent *);
2020

2121
private:
22+
void checkPreview();
23+
2224
Ui::UltragridWindow ui;
2325

2426
QString ultragridExecutable;

0 commit comments

Comments
 (0)
Please sign in to comment.