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

List:       kde-commits
Subject:    [juk/frameworks] /: Port the tag guesser code away from KDialog.
From:       Michael Pyne <null () kde ! org>
Date:       2017-09-30 21:33:50
Message-ID: E1dyPOQ-0007iK-7C () code ! kde ! org
[Download RAW message or body]

Git commit b9bd44b939eb3d7227c69bb0b06d3ce3ce40a39b by Michael Pyne.
Committed on 30/09/2017 at 21:08.
Pushed by mpyne into branch 'frameworks'.

Port the tag guesser code away from KDialog.

M  +13   -12   tagguesserconfigdlg.cpp
M  +31   -26   tagguesserconfigdlg.h
M  +7    -0    tagguesserconfigdlgwidget.ui

https://commits.kde.org/juk/b9bd44b939eb3d7227c69bb0b06d3ce3ce40a39b

diff --git a/tagguesserconfigdlg.cpp b/tagguesserconfigdlg.cpp
index 1dd4d74..d39d73b 100644
--- a/tagguesserconfigdlg.cpp
+++ b/tagguesserconfigdlg.cpp
@@ -17,34 +17,33 @@
 #include "tagguesserconfigdlg.h"
 #include "tagguesser.h"
 
-#include <QIcon>
 #include <klocale.h>
 #include <klineedit.h>
 
+#include <QIcon>
 #include <QKeyEvent>
 #include <QStringListModel>
+#include <QVBoxLayout>
 #include <QPushButton>
+#include <QDialogButtonBox>
 
 TagGuesserConfigDlg::TagGuesserConfigDlg(QWidget *parent, const char *name)
-    : KDialog(parent)
+  : QDialog(parent)
+  , m_child(new TagGuesserConfigDlgWidget(this))
+  , m_tagSchemeModel(new QStringListModel(TagGuesser::schemeStrings(), \
m_child->lvSchemes))  {
-    setObjectName( QLatin1String( name ) );
+    setObjectName(QLatin1String(name));
     setModal(true);
-    setCaption(i18n("Tag Guesser Configuration"));
-    setButtons(Ok | Cancel);
-    setDefaultButton(Ok);
-    showButtonSeparator(true);
+    setWindowTitle(i18n("Tag Guesser Configuration"));
 
-    m_child = new TagGuesserConfigDlgWidget(this);
-    setMainWidget(m_child);
+    auto vboxLayout = new QVBoxLayout(this);
+    vboxLayout->addWidget(m_child);
 
     m_child->bMoveUp->setIcon(QIcon::fromTheme( QLatin1String( "arrow-up" )));
     m_child->bMoveDown->setIcon(QIcon::fromTheme( QLatin1String( "arrow-down" )));
 
-    m_tagSchemeModel = new QStringListModel(m_child->lvSchemes);
     m_child->lvSchemes->setModel(m_tagSchemeModel);
     m_child->lvSchemes->setHeaderHidden(true);
-    m_tagSchemeModel->setStringList(TagGuesser::schemeStrings());
 
     connect(m_child->lvSchemes, SIGNAL(clicked(QModelIndex)), this, \
                SLOT(slotCurrentChanged(QModelIndex)));
     connect(m_child->bMoveUp, SIGNAL(clicked()), this, SLOT(slotMoveUpClicked()));
@@ -52,6 +51,8 @@ TagGuesserConfigDlg::TagGuesserConfigDlg(QWidget *parent, const \
                char *name)
     connect(m_child->bAdd, SIGNAL(clicked()), this, SLOT(slotAddClicked()));
     connect(m_child->bModify, SIGNAL(clicked()), this, SLOT(slotModifyClicked()));
     connect(m_child->bRemove, SIGNAL(clicked()), this, SLOT(slotRemoveClicked()));
+    connect(m_child->dlgButtonBox, &QDialogButtonBox::accepted, this, \
&QDialog::accept); +    connect(m_child->dlgButtonBox, &QDialogButtonBox::rejected, \
this, &QDialog::reject);  
     resize( 400, 300 );
 }
@@ -133,7 +134,7 @@ void TagGuesserConfigDlg::slotRemoveClicked()
 void TagGuesserConfigDlg::accept()
 {
     TagGuesser::setSchemeStrings(m_tagSchemeModel->stringList());
-    KDialog::accept();
+    QDialog::accept();
 }
 
 // vim: set et sw=4 tw=0 sta:
diff --git a/tagguesserconfigdlg.h b/tagguesserconfigdlg.h
index 93ebd16..37564a9 100644
--- a/tagguesserconfigdlg.h
+++ b/tagguesserconfigdlg.h
@@ -14,45 +14,50 @@
  * this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef TAGGUESSERCONFIGDLG_H
-#define TAGGUESSERCONFIGDLG_H
+#ifndef JUK_TAGGUESSERCONFIGDLG_H
+#define JUK_TAGGUESSERCONFIGDLG_H
+
+#include <QDialog>
 
-#include <kdialog.h>
 #include "ui_tagguesserconfigdlgwidget.h"
 
 class QStringListModel;
 
-
 class TagGuesserConfigDlgWidget : public QWidget, public \
Ui::TagGuesserConfigDlgWidget  {
+    Q_OBJECT
+
 public:
-  TagGuesserConfigDlgWidget( QWidget *parent ) : QWidget( parent ) {
-    setupUi( this );
-  }
+    TagGuesserConfigDlgWidget(QWidget *parent)
+      : QWidget(parent)
+    {
+        setupUi(this);
+    }
 };
 
-class TagGuesserConfigDlg : public KDialog
+class TagGuesserConfigDlg : public QDialog
 {
     Q_OBJECT
-    public:
-        explicit TagGuesserConfigDlg(QWidget *parent, const char *name = 0);
-
-    protected slots:
-        virtual void accept();
-
-    private slots:
-        void slotCurrentChanged(QModelIndex item);
-        void slotMoveUpClicked();
-        void slotMoveDownClicked();
-        void slotAddClicked();
-        void slotModifyClicked();
-        void slotRemoveClicked();
-
-    private:
-        TagGuesserConfigDlgWidget *m_child;
-        QStringListModel *m_tagSchemeModel;
+
+public:
+    explicit TagGuesserConfigDlg(QWidget *parent, const char *name = nullptr);
+
+protected slots:
+    virtual void accept();
+
+private slots:
+    void slotCurrentChanged(QModelIndex item);
+    void slotMoveUpClicked();
+    void slotMoveDownClicked();
+    void slotAddClicked();
+    void slotModifyClicked();
+    void slotRemoveClicked();
+
+private:
+    TagGuesserConfigDlgWidget *m_child;
+    QStringListModel *m_tagSchemeModel;
 };
 
-#endif // TAGGUESSERCONFIGDLG_H
+#endif // JUK_TAGGUESSERCONFIGDLG_H
 
 // vim: set et sw=4 tw=0 sta:
diff --git a/tagguesserconfigdlgwidget.ui b/tagguesserconfigdlgwidget.ui
index 21c44a0..1c68417 100644
--- a/tagguesserconfigdlgwidget.ui
+++ b/tagguesserconfigdlgwidget.ui
@@ -129,6 +129,13 @@ Note that the order in which the schemes appear in the list is \
relevant, since t  </property>
     </widget>
    </item>
+   <item>
+    <widget class="QDialogButtonBox" name="dlgButtonBox">
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <resources/>


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

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