[vlc-commits] Qt: better unsetting of keys in preferences

Jean-Baptiste Kempf git at videolan.org
Fri Dec 7 00:46:48 CET 2012


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Fri Dec  7 00:01:35 2012 +0100| [e41e1a7dfe704ec3bb7212e5d9adf53706b861fe] | committer: Jean-Baptiste Kempf

Qt: better unsetting of keys in preferences

Close #6640

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e41e1a7dfe704ec3bb7212e5d9adf53706b861fe
---

 modules/gui/qt4/components/preferences_widgets.cpp |   29 ++++++++++++++------
 modules/gui/qt4/components/preferences_widgets.hpp |    5 +++-
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/modules/gui/qt4/components/preferences_widgets.cpp b/modules/gui/qt4/components/preferences_widgets.cpp
index a10cade..ecebebe 100644
--- a/modules/gui/qt4/components/preferences_widgets.cpp
+++ b/modules/gui/qt4/components/preferences_widgets.cpp
@@ -1202,8 +1202,8 @@ void KeySelectorControl::finish()
 
             QString keys = qfu( p_config_item->value.psz );
             treeItem->setText( 1, keys );
-            treeItem->setToolTip( 1, qtr("Double click to change") );
-            treeItem->setToolTip( 2, qtr("Double click to change") );
+            treeItem->setToolTip( 1, qtr("Double click to change.\nDelete key to remove.") );
+            treeItem->setToolTip( 2, qtr("Double click to change.\nDelete key to remove.") );
             treeItem->setData( 1, Qt::UserRole, QVariant( keys ) );
             table->addTopLevelItem( treeItem );
             continue;
@@ -1285,9 +1285,8 @@ void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem, int column )
                 if( ( keyItem != it ) &&
                     ( it->data( 1 + b_global, Qt::UserRole ).toString() == newKey ) )
                 {
-                    it->setData( 1 + b_global, Qt::UserRole,
-                                 QVariant( qfu( "Unset" ) ) );
-                    it->setText( 1 + b_global, qtr( "Unset" ) );
+                    it->setText( 1 + b_global, NULL );
+                    it->setData( 1 + b_global, Qt::UserRole, QVariant() );
                 }
             }
         }
@@ -1295,6 +1294,12 @@ void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem, int column )
         keyItem->setText( column, newKey );
         keyItem->setData( column, Qt::UserRole, newKey );
     }
+    else if( d->result() == 2 )
+    {
+        keyItem->setText( 1 + b_global, NULL );
+        keyItem->setData( 1 + b_global, Qt::UserRole, QVariant() );
+    }
+
     delete d;
 }
 
@@ -1376,18 +1381,21 @@ KeyInputDialog::KeyInputDialog( QTreeWidget *_table,
     warning->hide();
     vLayout->insertWidget( 1, warning );
 
-    buttonBox = new QDialogButtonBox;
-    QPushButton *ok = new QPushButton( qtr("Assign") );
+    QDialogButtonBox *buttonBox = new QDialogButtonBox;
+    ok = new QPushButton( qtr("Assign") );
     QPushButton *cancel = new QPushButton( qtr("Cancel") );
+    unset = new QPushButton( qtr("Unset") );
     buttonBox->addButton( ok, QDialogButtonBox::AcceptRole );
+    buttonBox->addButton( unset, QDialogButtonBox::ActionRole );
     buttonBox->addButton( cancel, QDialogButtonBox::RejectRole );
     ok->setDefault( true );
 
     vLayout->addWidget( buttonBox );
-    buttonBox->hide();
+    ok->hide();
 
     CONNECT( buttonBox, accepted(), this, accept() );
     CONNECT( buttonBox, rejected(), this, reject() );
+    BUTTONACT( unset, unsetAction() );
 }
 
 void KeyInputDialog::checkForConflicts( int i_vlckey )
@@ -1403,7 +1411,8 @@ void KeyInputDialog::checkForConflicts( int i_vlckey )
         warning->setText( qtr("Warning: this key or combination is already assigned to ") +
                 QString( "\"<b>%1</b>\"" ).arg( conflictList[0]->text( 0 ) ) );
         warning->show();
-        buttonBox->show();
+        ok->show();
+        unset->hide();
 
         conflicts = true;
     }
@@ -1433,3 +1442,5 @@ void KeyInputDialog::wheelEvent( QWheelEvent *e )
     checkForConflicts( i_vlck );
     keyValue = i_vlck;
 }
+
+void KeyInputDialog::unsetAction() { done( 2 ); };
diff --git a/modules/gui/qt4/components/preferences_widgets.hpp b/modules/gui/qt4/components/preferences_widgets.hpp
index 17ec335..1370a73 100644
--- a/modules/gui/qt4/components/preferences_widgets.hpp
+++ b/modules/gui/qt4/components/preferences_widgets.hpp
@@ -512,6 +512,7 @@ private slots:
 
 class KeyInputDialog : public QDialog
 {
+    Q_OBJECT
 public:
     KeyInputDialog( QTreeWidget *, const QString&, QWidget *, bool b_global = false);
     int keyValue;
@@ -520,11 +521,13 @@ public:
 private:
     QTreeWidget *table;
     QLabel *selected, *warning;
-    QDialogButtonBox *buttonBox;
+    QPushButton *ok, *unset;
 
     void checkForConflicts( int i_vlckey );
     void keyPressEvent( QKeyEvent *);
     void wheelEvent( QWheelEvent *);
     bool b_global;
+private slots:
+    void unsetAction();
 };
 #endif



More information about the vlc-commits mailing list