[vlc-devel] [RFC 37/82] qt: remove external dialogs
Pierre Lamot
pierre at videolabs.io
Fri Feb 1 14:01:41 CET 2019
---
modules/gui/qt/Makefile.am | 2 -
modules/gui/qt/dialogs/external.cpp | 402 ----------------------------
modules/gui/qt/dialogs/external.hpp | 157 -----------
modules/gui/qt/dialogs_provider.cpp | 1 -
4 files changed, 562 deletions(-)
delete mode 100644 modules/gui/qt/dialogs/external.cpp
delete mode 100644 modules/gui/qt/dialogs/external.hpp
diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 9be31dc368..144f5cf987 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -60,7 +60,6 @@ libqt_plugin_la_SOURCES = \
gui/qt/dialogs/extended.cpp gui/qt/dialogs/extended.hpp \
gui/qt/dialogs/messages.cpp gui/qt/dialogs/messages.hpp \
gui/qt/dialogs/errors.cpp gui/qt/dialogs/errors.hpp \
- gui/qt/dialogs/external.cpp gui/qt/dialogs/external.hpp \
gui/qt/dialogs/plugins.cpp gui/qt/dialogs/plugins.hpp \
gui/qt/dialogs/sout.cpp gui/qt/dialogs/sout.hpp \
gui/qt/dialogs/convert.cpp gui/qt/dialogs/convert.hpp \
@@ -185,7 +184,6 @@ nodist_libqt_plugin_la_SOURCES = \
gui/qt/dialogs/messages.moc.cpp \
gui/qt/dialogs/epg.moc.cpp \
gui/qt/dialogs/errors.moc.cpp \
- gui/qt/dialogs/external.moc.cpp \
gui/qt/dialogs/plugins.moc.cpp \
gui/qt/dialogs/preferences.moc.cpp \
gui/qt/dialogs/sout.moc.cpp \
diff --git a/modules/gui/qt/dialogs/external.cpp b/modules/gui/qt/dialogs/external.cpp
deleted file mode 100644
index 4c78c6193b..0000000000
--- a/modules/gui/qt/dialogs/external.cpp
+++ /dev/null
@@ -1,402 +0,0 @@
-/*****************************************************************************
- * external.cpp : Dialogs from other LibVLC core and other plugins
- ****************************************************************************
- * Copyright (C) 2009 Rémi Denis-Courmont
- * Copyright (C) 2006 the VideoLAN team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "external.hpp"
-#include "errors.hpp"
-
-#include <assert.h>
-
-#include <QCheckBox>
-#include <QDialogButtonBox>
-#include <QLabel>
-#include <QLineEdit>
-#include <QMessageBox>
-#include <QProgressDialog>
-#include <QPushButton>
-
-DialogHandler::DialogHandler (intf_thread_t *p_intf, QObject *_parent)
- : QObject( _parent ), p_intf (p_intf)
-{
- const vlc_dialog_cbs cbs = {
- displayErrorCb,
- displayLoginCb,
- displayQuestionCb,
- displayProgressCb,
- cancelCb,
- updateProgressCb
- };
- vlc_dialog_provider_set_callbacks(p_intf, &cbs, this);
-
- CONNECT(this, errorDisplayed(const QString &, const QString &),
- this, displayError(const QString &, const QString &));
-
- CONNECT(this, loginDisplayed(vlc_dialog_id *, const QString &,
- const QString &, const QString &, bool),
- this, displayLogin(vlc_dialog_id *, const QString &, const QString &,
- const QString &, bool));
-
- CONNECT(this, questionDisplayed(vlc_dialog_id *, const QString &,
- const QString &, int, const QString &,
- const QString &, const QString &),
- this, displayQuestion(vlc_dialog_id *, const QString &, const QString &,
- int, const QString &, const QString &,
- const QString &));
-
- CONNECT(this, progressDisplayed(vlc_dialog_id *, const QString &, const QString &,
- bool, float, const QString &),
- this, displayProgress(vlc_dialog_id *, const QString &, const QString &,
- bool, float, const QString &));
-
- CONNECT(this, cancelled(vlc_dialog_id *), this, cancel(vlc_dialog_id *));
-
- CONNECT(this, progressUpdated(vlc_dialog_id *, float, const QString &),
- this, updateProgress(vlc_dialog_id *, float, const QString &));
-}
-
-DialogHandler::~DialogHandler()
-{
- vlc_dialog_provider_set_callbacks(p_intf, NULL, NULL);
-}
-
-void
-DialogHandler::displayErrorCb(void *p_data, const char *psz_title,
- const char *psz_text)
-{
- DialogHandler *self = static_cast<DialogHandler *>(p_data);
- const QString title = qfu(psz_title);
- const QString text = qfu(psz_text);
-
- emit self->errorDisplayed(title, text);
-}
-
-
-void
-DialogHandler::displayLoginCb(void *p_data, vlc_dialog_id *p_id,
- const char *psz_title, const char *psz_text,
- const char *psz_default_username,
- bool b_ask_store)
-{
- DialogHandler *self = static_cast<DialogHandler *>(p_data);
- const QString title = qfu(psz_title);
- const QString text = qfu(psz_text);
-
- const QString defaultUsername =
- psz_default_username != NULL ? qfu(psz_default_username) : QString();
-
- emit self->loginDisplayed(p_id, title, text, defaultUsername,
- b_ask_store);
-}
-
-void
-DialogHandler::displayQuestionCb(void *p_data, vlc_dialog_id *p_id,
- const char *psz_title, const char *psz_text,
- vlc_dialog_question_type i_type,
- const char *psz_cancel, const char *psz_action1,
- const char *psz_action2)
-{
- DialogHandler *self = static_cast<DialogHandler *>(p_data);
- const QString title = qfu(psz_title);
- const QString text = qfu(psz_text);
-
- const QString cancel = qfu(psz_cancel);
- const QString action1 = psz_action1 != NULL ? qfu(psz_action1) : QString();
- const QString action2 = psz_action2 != NULL ? qfu(psz_action2) : QString();
-
- emit self->questionDisplayed(p_id, title, text, i_type, cancel,
- action1, action2);
-}
-
-void
-DialogHandler::displayProgressCb(void *p_data, vlc_dialog_id *p_id,
- const char *psz_title, const char *psz_text,
- bool b_indeterminate, float f_position,
- const char *psz_cancel)
-{
- DialogHandler *self = static_cast<DialogHandler *>(p_data);
- const QString title = qfu(psz_title);
- const QString text = qfu(psz_text);
-
- const QString cancel = psz_cancel != NULL ? qfu(psz_cancel) : QString();
- emit self->progressDisplayed(p_id, title, text, b_indeterminate,
- f_position, cancel);
-}
-
-void DialogHandler::cancelCb(void *p_data, vlc_dialog_id *p_id)
-{
- DialogHandler *self = static_cast<DialogHandler *>(p_data);
- emit self->cancelled(p_id);
-}
-
-void DialogHandler::updateProgressCb(void *p_data, vlc_dialog_id *p_id,
- float f_value, const char *psz_text)
-{
- DialogHandler *self = static_cast<DialogHandler *>(p_data);
- emit self->progressUpdated(p_id, f_value, qfu(psz_text));
-}
-
-void DialogHandler::cancel(vlc_dialog_id *p_id)
-{
- DialogWrapper *p_wrapper =
- static_cast<DialogWrapper *>(vlc_dialog_id_get_context(p_id));
- if (p_wrapper != NULL)
- p_wrapper->finish(QDialog::Rejected);
-}
-
-void DialogHandler::updateProgress(vlc_dialog_id *p_id, float f_value,
- const QString &text)
-{
- ProgressDialogWrapper *p_wrapper =
- static_cast<ProgressDialogWrapper *>(vlc_dialog_id_get_context(p_id));
-
- if (p_wrapper != NULL)
- p_wrapper->updateProgress(f_value, text);
-}
-
-void DialogHandler::displayError(const QString &title, const QString &text)
-{
- ErrorsDialog::getInstance (p_intf)->addError(title, text);
-}
-
-void DialogHandler::displayLogin(vlc_dialog_id *p_id, const QString &title,
- const QString &text,
- const QString &defaultUsername,
- bool b_ask_store)
-{
- QDialog *dialog = new QDialog();
- QLayout *layout = new QVBoxLayout (dialog);
-
- dialog->setWindowTitle (title);
- dialog->setWindowRole ("vlc-login");
- dialog->setModal(true);
- layout->setMargin (2);
-
- /* Username and password fields */
- QWidget *panel = new QWidget (dialog);
- QGridLayout *grid = new QGridLayout;
- grid->addWidget (new QLabel (text), 0, 0, 1, 2);
-
- QLineEdit *userLine = new QLineEdit;
- if (!defaultUsername.isEmpty())
- userLine->setText(defaultUsername);
- grid->addWidget (new QLabel (qtr("Username")), 1, 0);
- grid->addWidget (userLine, 1, 1);
-
- QLineEdit *passLine = new QLineEdit;
- passLine->setEchoMode (QLineEdit::Password);
- grid->addWidget (new QLabel (qtr("Password")), 2, 0);
- grid->addWidget (passLine, 2, 1);
-
- QCheckBox *checkbox = NULL;
- if (b_ask_store)
- {
- checkbox = new QCheckBox;
- checkbox->setChecked (getSettings()->value ("store_password", true).toBool ());
- grid->addWidget (new QLabel (qtr("Store the Password")), 3, 0);
- grid->addWidget (checkbox, 3, 1);
- }
-
- panel->setLayout (grid);
- layout->addWidget (panel);
-
- /* focus on passLine if the username is already set */
- if (!defaultUsername.isEmpty())
- passLine->setFocus();
-
- /* OK, Cancel buttons */
- QDialogButtonBox *buttonBox = new QDialogButtonBox;
- QPushButton *okButton = new QPushButton( "&Ok" );
- QPushButton *cancelButton = new QPushButton( "&Cancel" );
- buttonBox->addButton( okButton, QDialogButtonBox::AcceptRole );
- buttonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
-
- CONNECT( buttonBox, accepted(), dialog, accept() );
- CONNECT( buttonBox, rejected(), dialog, reject() );
- layout->addWidget (buttonBox);
-
- dialog->setLayout (layout);
- vlc_dialog_id_set_context(p_id,
- new LoginDialogWrapper(this, p_intf, p_id, dialog, userLine, passLine,
- checkbox));
- dialog->show();
-}
-
-void
-DialogHandler::displayQuestion(vlc_dialog_id *p_id, const QString &title,
- const QString &text, int i_type,
- const QString &cancel, const QString &action1,
- const QString &action2)
-{
- enum QMessageBox::Icon icon;
- switch (i_type)
- {
- case VLC_DIALOG_QUESTION_WARNING:
- icon = QMessageBox::Warning;
- break;
- case VLC_DIALOG_QUESTION_CRITICAL:
- icon = QMessageBox::Critical;
- break;
- default:
- case VLC_DIALOG_QUESTION_NORMAL:
- icon = action1.isEmpty() && action2.isEmpty() ?
- QMessageBox::Information : QMessageBox::Question;
- break;
- }
- QMessageBox *box = new QMessageBox (icon, title, text);
- box->addButton ("&" + cancel, QMessageBox::RejectRole);
- box->setModal(true);
- QAbstractButton *action1Button = NULL;
- if (!action1.isEmpty())
- action1Button = box->addButton("&" + action1, QMessageBox::AcceptRole);
- QAbstractButton *action2Button = NULL;
- if (!action2.isEmpty())
- action2Button = box->addButton("&" + action2, QMessageBox::AcceptRole);
-
- vlc_dialog_id_set_context(p_id,
- new QuestionDialogWrapper(this, p_intf, p_id, box, action1Button,
- action2Button));
- box->show();
-}
-
-void DialogHandler::displayProgress(vlc_dialog_id *p_id, const QString &title,
- const QString &text, bool b_indeterminate,
- float f_position, const QString &cancel)
-{
- QProgressDialog *progress =
- new QProgressDialog(text, cancel.isEmpty() ? QString() : "&" + cancel,
- 0, b_indeterminate ? 0 : 1000);
- progress->setWindowTitle(title);
- if (cancel.isEmpty())
- {
- /* not cancellable: remove close button */
- progress->setWindowFlags(Qt::Window | Qt::WindowTitleHint |
- Qt::CustomizeWindowHint);
- }
- progress->setWindowRole ("vlc-progress");
- progress->setValue(b_indeterminate ? 0 : f_position * 1000);
-
- vlc_dialog_id_set_context(p_id,
- new ProgressDialogWrapper(this, p_intf, p_id, progress, b_indeterminate));
-
- progress->show();
-}
-
-DialogWrapper::DialogWrapper(DialogHandler *p_handler, intf_thread_t *p_intf,
- vlc_dialog_id *p_id, QDialog *p_dialog)
- : QObject()
- , p_handler(p_handler)
- , p_intf(p_intf)
- , p_id(p_id)
- , p_dialog(p_dialog)
-{
- CONNECT(p_dialog, finished(int), this, finish(int));
-}
-
-DialogWrapper::~DialogWrapper()
-{
- p_dialog->hide();
- delete p_dialog;
-}
-
-void DialogWrapper::finish(int result)
-{
- if (result == QDialog::Rejected && p_id != NULL)
- {
- vlc_dialog_id_dismiss(p_id);
- p_id = NULL;
- }
- deleteLater();
-}
-
-LoginDialogWrapper::LoginDialogWrapper(DialogHandler *p_handler,
- intf_thread_t *p_intf, vlc_dialog_id *p_id,
- QDialog *p_dialog, QLineEdit *userLine,
- QLineEdit *passLine, QCheckBox *checkbox)
- : DialogWrapper(p_handler, p_intf, p_id, p_dialog)
- , userLine(userLine)
- , passLine(passLine)
- , checkbox(checkbox)
-{
- CONNECT(p_dialog, accepted(), this, accept());
-}
-
-void LoginDialogWrapper::accept()
-{
- if (p_id != NULL)
- {
- vlc_dialog_id_post_login(p_id, qtu(userLine->text ()),
- qtu(passLine->text ()),
- checkbox != NULL ? checkbox->isChecked () : false);
- p_id = NULL;
- if (checkbox != NULL)
- getSettings()->setValue ("store_password", checkbox->isChecked ());
- }
-}
-
-QuestionDialogWrapper::QuestionDialogWrapper(DialogHandler *p_handler,
- intf_thread_t *p_intf,
- vlc_dialog_id *p_id,
- QMessageBox *p_box,
- QAbstractButton *action1,
- QAbstractButton *action2)
- : DialogWrapper(p_handler, p_intf, p_id, p_box)
- , action1(action1)
- , action2(action2)
-{
- CONNECT(p_box, buttonClicked(QAbstractButton *),
- this, buttonClicked(QAbstractButton *));
-}
-
-void QuestionDialogWrapper::buttonClicked(QAbstractButton *button)
-{
- if (p_id != NULL)
- {
- if (button == action1)
- vlc_dialog_id_post_action(p_id, 1);
- else if (button == action2)
- vlc_dialog_id_post_action(p_id, 2);
- else
- vlc_dialog_id_dismiss(p_id);
- p_id = NULL;
- }
-}
-
-ProgressDialogWrapper::ProgressDialogWrapper(DialogHandler *p_handler,
- intf_thread_t *p_intf,
- vlc_dialog_id *p_id,
- QProgressDialog *p_progress,
- bool b_indeterminate)
- : DialogWrapper(p_handler, p_intf, p_id, p_progress)
- , b_indeterminate(b_indeterminate)
-{
- CONNECT(p_progress, canceled(void), this, finish(void));
-}
-
-void ProgressDialogWrapper::updateProgress(float f_position, const QString &text)
-{
- QProgressDialog *progress = static_cast<QProgressDialog *>(p_dialog);
- progress->setLabelText(text);
- if (!b_indeterminate)
- progress->setValue(f_position * 1000);
-}
diff --git a/modules/gui/qt/dialogs/external.hpp b/modules/gui/qt/dialogs/external.hpp
deleted file mode 100644
index 64696e4597..0000000000
--- a/modules/gui/qt/dialogs/external.hpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/*****************************************************************************
- * external.hpp : Dialogs from other LibVLC core and other plugins
- ****************************************************************************
- * Copyright (C) 2009 Rémi Denis-Courmont
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#ifndef QVLC_DIALOGS_EXTERNAL_H_
-#define QVLC_DIALOGS_EXTERNAL_H_ 1
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <QObject>
-#include <QDialog>
-#include <QMap>
-#include <vlc_common.h>
-#include <vlc_dialog.h>
-#include "adapters/variables.hpp"
-
-struct intf_thread_t;
-class QProgressDialog;
-class DialogWrapper;
-
-class DialogHandler : public QObject
-{
- Q_OBJECT
-
-public:
- DialogHandler (intf_thread_t *, QObject *parent);
- virtual ~DialogHandler();
- void removeDialogId(vlc_dialog_id *p_id);
-
-signals:
- void errorDisplayed(const QString &title, const QString &text);
- void loginDisplayed(vlc_dialog_id *p_id, const QString &title,
- const QString &text, const QString &defaultUsername,
- bool b_ask_store);
- void questionDisplayed(vlc_dialog_id *p_id, const QString &title,
- const QString &text, int i_type,
- const QString &cancel, const QString &action1,
- const QString &action2);
- void progressDisplayed(vlc_dialog_id *p_id, const QString &title,
- const QString &text, bool b_indeterminate,
- float f_position, const QString &cancel);
- void cancelled(vlc_dialog_id *p_id);
- void progressUpdated(vlc_dialog_id *p_id, float f_value, const QString &text);
-
-private slots:
- void displayError(const QString &title, const QString &text);
- void displayLogin(vlc_dialog_id *p_id, const QString &title,
- const QString &text, const QString &defaultUsername,
- bool b_ask_store);
- void displayQuestion(vlc_dialog_id *p_id, const QString &title,
- const QString &text, int i_type,
- const QString &cancel, const QString &action1,
- const QString &action2);
- void displayProgress(vlc_dialog_id *p_id, const QString &title,
- const QString &text, bool b_indeterminate,
- float f_position, const QString &cancel);
- void cancel(vlc_dialog_id *p_id);
- void updateProgress(vlc_dialog_id *p_id, float f_value, const QString &text);
-
-private:
- intf_thread_t *p_intf;
-
- static void displayErrorCb(void *, const char *, const char *);
- static void displayLoginCb(void *, vlc_dialog_id *, const char *,
- const char *, const char *, bool);
- static void displayQuestionCb(void *, vlc_dialog_id *, const char *,
- const char *, vlc_dialog_question_type,
- const char *, const char *, const char *);
- static void displayProgressCb(void *, vlc_dialog_id *, const char *,
- const char *, bool, float, const char *);
- static void cancelCb(void *, vlc_dialog_id *);
- static void updateProgressCb(void *, vlc_dialog_id *, float, const char *);
-};
-
-class DialogWrapper : public QObject
-{
- Q_OBJECT
-
- friend class DialogHandler;
-public:
- DialogWrapper(DialogHandler *p_handler, intf_thread_t *p_intf,
- vlc_dialog_id *p_id, QDialog *p_dialog);
- virtual ~DialogWrapper();
-protected slots:
- virtual void finish(int result = QDialog::Rejected);
-protected:
- DialogHandler *p_handler;
- intf_thread_t *p_intf;
- vlc_dialog_id *p_id;
- QDialog *p_dialog;
-};
-
-class QLineEdit;
-class QCheckBox;
-class LoginDialogWrapper : public DialogWrapper
-{
- Q_OBJECT
-public:
- LoginDialogWrapper(DialogHandler *p_handler, intf_thread_t *p_intf,
- vlc_dialog_id *p_id, QDialog *p_dialog,
- QLineEdit *userLine, QLineEdit *passLine,
- QCheckBox *checkbox);
-private slots:
- virtual void accept();
-private:
- QLineEdit *userLine;
- QLineEdit *passLine;
- QCheckBox *checkbox;
-};
-
-class QAbstractButton;
-class QMessageBox;
-class QuestionDialogWrapper : public DialogWrapper
-{
- Q_OBJECT
-public:
- QuestionDialogWrapper(DialogHandler *p_handler, intf_thread_t *p_intf,
- vlc_dialog_id *p_id, QMessageBox *p_box,
- QAbstractButton *action1, QAbstractButton *action2);
-private slots:
- virtual void buttonClicked(QAbstractButton *);
-private:
- QAbstractButton *action1;
- QAbstractButton *action2;
-};
-
-class ProgressDialogWrapper : public DialogWrapper
-{
- Q_OBJECT
-public:
- ProgressDialogWrapper(DialogHandler *p_handler, intf_thread_t *p_intf,
- vlc_dialog_id *p_id, QProgressDialog *p_progress,
- bool b_indeterminate);
- void updateProgress(float f_position, const QString &text);
-private:
- bool b_indeterminate;
-};
-
-#endif
diff --git a/modules/gui/qt/dialogs_provider.cpp b/modules/gui/qt/dialogs_provider.cpp
index ccaef54124..a7bd4ed339 100644
--- a/modules/gui/qt/dialogs_provider.cpp
+++ b/modules/gui/qt/dialogs_provider.cpp
@@ -53,7 +53,6 @@
#include "dialogs/podcast_configuration.hpp"
#include "dialogs/toolbar.hpp"
#include "dialogs/plugins.hpp"
-#include "dialogs/external.hpp"
#include "dialogs/epg.hpp"
#include "dialogs/errors.hpp"
--
2.19.1
More information about the vlc-devel
mailing list