[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdenlive] src: Fix signal/slot. Make sure to delete dialog. Clean up
From:       Montel Laurent <montel () kde ! org>
Date:       2016-12-08 12:38:06
Message-ID: E1cExxe-0004pX-U0 () code ! kde ! org
[Download RAW message or body]

Git commit 1ac705b47940e859dde2cbccd24dabc8bb181ff3 by Montel Laurent.
Committed on 08/12/2016 at 12:29.
Pushed by mlaurent into branch 'master'.

Fix signal/slot. Make sure to delete dialog. Clean up

M  +14   -19   src/qt-oauth-lib/logindialog.cpp
M  +7    -5    src/qt-oauth-lib/logindialog.h
M  +2    -2    src/qt-oauth-lib/oauth2.cpp
M  +2    -1    src/utils/resourcewidget.cpp

https://commits.kde.org/kdenlive/1ac705b47940e859dde2cbccd24dabc8bb181ff3

diff --git a/src/qt-oauth-lib/logindialog.cpp b/src/qt-oauth-lib/logindialog.cpp
index e6f2660cf..8222fbb63 100644
--- a/src/qt-oauth-lib/logindialog.cpp
+++ b/src/qt-oauth-lib/logindialog.cpp
@@ -40,14 +40,16 @@
 #include "kdenlive_debug.h"
 #include <QWebView>
 
-LoginDialog::LoginDialog(QWidget *parent) :
-    QDialog(parent),
-    ui(new Ui::LoginDialog)
+LoginDialog::LoginDialog(QWidget *parent)
+    : QDialog(parent),
+      ui(new Ui::LoginDialog)
 {
     ui->setupUi(this);
+    setAttribute(Qt::WA_DeleteOnClose);
+    setWindowTitle(i18n("Freesound Login"));
+
     connect(ui->CancelButton, &QPushButton::clicked, this, \
                &LoginDialog::slotRejected);
     connect(ui->GetHQpreview, &QPushButton::clicked, this, \
                &LoginDialog::slotGetHQPreview);
-    setWindowTitle(i18n("Freesound Login"));
     ui->FreeSoundLoginLabel->setText(i18n("Enter your freesound account details to \
download the highest quality version of this file. Or use the High Quality preview \
file instead (no freesound account required)."));  // ui->textBrowser
     connect(ui->webView, &QWebView::urlChanged, this, &LoginDialog::urlChanged);
@@ -60,7 +62,7 @@ LoginDialog::~LoginDialog()
 
 void LoginDialog::slotGetHQPreview()
 {
-    emit UseHQPreview();
+    emit useHQPreview();
     QDialog::accept();
 }
 
@@ -79,40 +81,33 @@ void LoginDialog::slotRejected()
 void LoginDialog::urlChanged(const QUrl &url)
 {
     //qCDebug(KDENLIVE_LOG) << "URL =" << url;
-    QString str = url.toString();
-    int posCode = str.indexOf(QLatin1String("&code="));
-    int posErr = str.indexOf(QLatin1String("&error="));
+    const QString str = url.toString();
+    const int posCode = str.indexOf(QLatin1String("&code="));
+    const int posErr = str.indexOf(QLatin1String("&error="));
     if(posCode != -1)
     {
-
-        m_strAuthCode =str.mid(posCode+6) ;
-        emit AuthCodeObtained();
+        m_strAuthCode =str.mid(posCode+6);
+        emit authCodeObtained();
         QDialog::accept();
-
-    }
-    if(posErr != -1)
+    } else if(posErr != -1)
     {
-
         QString sError =str.mid(posErr+7) ;
         if (sError==QLatin1String("access_denied") )
         {
             emit accessDenied();
         }
         QDialog::accept();
-
     }
 }
 
 
 
-QString LoginDialog::authCode()
+QString LoginDialog::authCode() const
 {
     return m_strAuthCode;
 }
 
-
 void LoginDialog::setLoginUrl(const QUrl& url)
 {
    ui->webView->setUrl(url);
-
 }
diff --git a/src/qt-oauth-lib/logindialog.h b/src/qt-oauth-lib/logindialog.h
index b936bdbb9..2e4e410d8 100644
--- a/src/qt-oauth-lib/logindialog.h
+++ b/src/qt-oauth-lib/logindialog.h
@@ -60,14 +60,15 @@ public:
     explicit LoginDialog(QWidget *parent = Q_NULLPTR);
     ~LoginDialog();
     void setLoginUrl(const QUrl& url);
-    QString authCode();
+
+    QString authCode() const;
 
 signals:
     /**
-     * @brief AuthCodeObtained - emited when freesound gives us an Authorisation \
code \n +     * @brief authCodeObtained - emited when freesound gives us an \
                Authorisation code \n
      * Authorisation codes last 10mins and must be exchanged for an access token in \
                that time
      */
-    void AuthCodeObtained();
+    void authCodeObtained();
     /**
      * @brief accessDenied -signal emmited if freesound denies acess - eg bad \
                password or user has denied access to Kdenlive app.
      */
@@ -77,15 +78,16 @@ signals:
      */
     void canceled();
     /**
-     * @brief UseHQPreview - signal emmited when user clicks the "use HQ preview" \
button in the logon dialog +     * @brief useHQPreview - signal emmited when user \
                clicks the "use HQ preview" button in the logon dialog
      */
-    void UseHQPreview();
+    void useHQPreview();
 
 private slots:
     void urlChanged(const QUrl& url);
 
     void slotGetHQPreview();
     void slotRejected();
+
 private:
     Ui::LoginDialog *ui;
     QString m_strAuthCode;
diff --git a/src/qt-oauth-lib/oauth2.cpp b/src/qt-oauth-lib/oauth2.cpp
index 84417d0a5..82353003e 100644
--- a/src/qt-oauth-lib/oauth2.cpp
+++ b/src/qt-oauth-lib/oauth2.cpp
@@ -78,11 +78,11 @@ OAuth2::OAuth2(QWidget* parent)
        m_bAccessTokenRec=true;
        m_strAccessToken=strAccessTokenFromSettings;
     }
-    connect(m_pLoginDialog, &LoginDialog::AuthCodeObtained, this, \
&OAuth2::SlotAuthCodeObtained); +    connect(m_pLoginDialog, \
&LoginDialog::authCodeObtained, this, &OAuth2::SlotAuthCodeObtained);  
     connect(m_pLoginDialog, &LoginDialog::accessDenied, this, \
                &OAuth2::SlotAccessDenied);
     connect(m_pLoginDialog, &LoginDialog::canceled, this, &OAuth2::SlotCanceled);
-    connect(m_pLoginDialog, &LoginDialog::UseHQPreview, this, \
&OAuth2::SlotDownloadHQPreview); +    connect(m_pLoginDialog, \
                &LoginDialog::useHQPreview, this, &OAuth2::SlotDownloadHQPreview);
     connect(this, &OAuth2::AuthCodeObtained, this, &OAuth2::SlotAuthCodeObtained);
 }
 /**
diff --git a/src/utils/resourcewidget.cpp b/src/utils/resourcewidget.cpp
index ffcfec794..35cea8aba 100644
--- a/src/utils/resourcewidget.cpp
+++ b/src/utils/resourcewidget.cpp
@@ -56,6 +56,7 @@
 
 ResourceWidget::ResourceWidget(const QString &folder, QWidget *parent) :
     QDialog(parent),
+    m_pOAuth2(Q_NULLPTR),
     m_folder(folder),
     m_currentService(Q_NULLPTR),
     m_movie(Q_NULLPTR)
@@ -805,7 +806,7 @@ QString ResourceWidget::GetSaveFileNameAndPathS(const QString \
                &path, const QStri
                                        QMessageBox::Yes | QMessageBox::No,
                                        QMessageBox::No);
         if (ret == QMessageBox::No) {
-            return QLatin1String("");
+            return QString();
         }
     }
     return saveUrlstring;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic