From 168d0f063e97986f14c867ade88904be60068168 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Tue, 17 Jan 2012 21:19:17 +0100 Subject: [PATCH] Handle file browse buttons. --- frontend/maingui.cpp | 42 ++++++++++++++++++++++++++++++++++++++---- frontend/maingui.h | 1 + 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/frontend/maingui.cpp b/frontend/maingui.cpp index 42a30bf..b558a5d 100644 --- a/frontend/maingui.cpp +++ b/frontend/maingui.cpp @@ -58,12 +58,38 @@ Main_GUI::about() void Main_GUI::browse_input() { + // XXX remember last directory + QString file = QFileDialog::getOpenFileName( + this, + tr("Open Input File"), + QDir::toNativeSeparators(QDir::homePath()), + ""); + if (!file.isEmpty()) + input_line->setText(file); } void Main_GUI::browse_output() { + // XXX remember last directory + QString file = QFileDialog::getOpenFileName( + this, + tr("Open Output File"), + QDir::toNativeSeparators(QDir::homePath()), + ""); + if (!file.isEmpty()) + output_line->setText(file); +} + + +void +Main_GUI::check_run() +{ + if (input_line->text().isEmpty() || output_line->text().isEmpty()) + run_button->setEnabled(false); + else + run_button->setEnabled(true); } @@ -166,10 +192,18 @@ Main_GUI::create_layout() void Main_GUI::create_connections() { - connect(input_button, SIGNAL(clicked()), this, SLOT(browse_input())); - connect(output_button, SIGNAL(clicked()), this, SLOT(browse_output())); - - connect(run_button, SIGNAL(clicked()), this, SLOT(run())); + connect(input_button, SIGNAL(clicked()), this, + SLOT(browse_input())); + connect(output_button, SIGNAL(clicked()), this, + SLOT(browse_output())); + + connect(input_line, SIGNAL(textChanged(QString)), this, + SLOT(check_run())); + connect(output_line, SIGNAL(textChanged(QString)), this, + SLOT(check_run())); + + connect(run_button, SIGNAL(clicked()), this, + SLOT(run())); } diff --git a/frontend/maingui.h b/frontend/maingui.h index 4ff5545..10080bd 100644 --- a/frontend/maingui.h +++ b/frontend/maingui.h @@ -40,6 +40,7 @@ private slots: void about(); void browse_input(); void browse_output(); + void check_run(); void run(); private: -- 2.11.4.GIT