"Open" button is disabled not when no URL was entered.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 30 Aug 2017 20:56:31 +0000 (22:56 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 30 Aug 2017 20:56:31 +0000 (22:56 +0200)
src/gui/urlinputdialog.cpp
src/gui/urlinputdialog.h

index 20f138e..c413d15 100644 (file)
@@ -28,10 +28,12 @@ UrlInputDialog::UrlInputDialog(QWidget* parent)
     setupUi(this);
 
     QPushButton* openFile = buttons->addButton("Open File...", QDialogButtonBox::ActionRole);
+    textChanged(urlEntry->text());
 
     connect(openFile, SIGNAL(clicked()), SLOT(openFileClicked()));
     connect(buttons, SIGNAL(accepted()), SLOT(acceptClicked()));
     connect(buttons, SIGNAL(rejected()), SLOT(rejectClicked()));
+    connect(urlEntry, SIGNAL(textChanged(QString)), SLOT(textChanged(QString)));
 }
 
 void UrlInputDialog::openFileClicked()
@@ -46,6 +48,11 @@ void UrlInputDialog::openFileClicked()
     }
 }
 
+void UrlInputDialog::textChanged(const QString& text)
+{
+    buttons->button(QDialogButtonBox::StandardButton::Open)->setEnabled(!text.isEmpty());
+}
+
 void UrlInputDialog::acceptClicked()
 {
     saved_result = urlEntry->text();
index c754e74..9b4b988 100644 (file)
@@ -38,6 +38,7 @@ private slots:
     void acceptClicked();
     void rejectClicked();
     void openFileClicked();
+    void textChanged(const QString& text);
 private:
     QString saved_result;
 };