Changeset 3e8d0beb2925c3b2cf6eaa1a45186d5094c40569

Show
Ignore:
Timestamp:
11/06/07 00:01:15 (10 months ago)
Author:
Jean-Baptiste Kempf <jb@videolan.org>
git-committer:
Jean-Baptiste Kempf <jb@videolan.org> 1194303675 +0000
git-parent:

[d5107810595354bd93f6bf65713c039d1bc7cb8b]

git-author:
Jean-Baptiste Kempf <jb@videolan.org> 1194303675 +0000
Message:

Qt4 - Improve the hotkeys preferences.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/gui/qt4/components/preferences_widgets.cpp

    r2088806 r3e8d0be  
    979979    QWidget *keyContainer = new QWidget; 
    980980    QGridLayout *gLayout = new QGridLayout( keyContainer ); 
     981 
     982    label = new QLabel( 
     983            qtr( "Select an action to change the associated hotkey") ); 
    981984     
    982     label = new QLabel( qtr("Select an action to change the associated hotkey") ); 
     985    /* Deactivated for now 
    983986    QLabel *searchLabel = new QLabel( qtr( "Search" ) ); 
     987    QLineEdit *actionSearch = new QLineEdit;*/ 
    984988     
    985989    table = new QTreeWidget; 
     
    987991    table->headerItem()->setText( 0, qtr( "Action" ) ); 
    988992    table->headerItem()->setText( 1, qtr( "Shortcut" ) ); 
    989      
    990     QLineEdit *shortcutValue = new QLineEdit; 
     993 
     994    shortcutValue = new KeyShortcutEdit; 
    991995    shortcutValue->setReadOnly(true); 
    992     QLineEdit *actionSearch = new QLineEdit; 
    993      
     996 
    994997    QPushButton *clearButton = new QPushButton( qtr( "Clear" ) ); 
    995998    QPushButton *setButton = new QPushButton( qtr( "Set" ) ); 
    996999    finish(); 
    997      
     1000 
    9981001    gLayout->addWidget( label, 0, 0, 1, 4 ); 
     1002  /* deactivated for now 
    9991003    gLayout->addWidget( searchLabel, 1, 0, 1, 2 ); 
    1000     gLayout->addWidget( actionSearch, 1, 2, 1, 2 );  
     1004    gLayout->addWidget( actionSearch, 1, 2, 1, 2 ); */ 
    10011005    gLayout->addWidget( table, 2, 0, 1, 4 ); 
    10021006    gLayout->addWidget( clearButton, 3, 0, 1, 1 ); 
    10031007    gLayout->addWidget( shortcutValue, 3, 1, 1, 2 );  
    10041008    gLayout->addWidget( setButton, 3, 3, 1, 1 ); 
    1005      
     1009 
    10061010    if( !l ) /* This shouldn't happen */ 
    10071011    { 
     
    10141018        l->addWidget( keyContainer, 0, 0, 1, 2 ); 
    10151019    } 
     1020    CONNECT( clearButton, clicked(), shortcutValue, clear() ); 
     1021    BUTTONACT( setButton, setTheKey() ); 
    10161022} 
    10171023 
     
    10461052    table->resizeColumnToContents( 0 ); 
    10471053 
     1054    CONNECT( table, itemClicked( QTreeWidgetItem *, int ), 
     1055             this, select1Key( QTreeWidgetItem * ) ); 
    10481056    CONNECT( table, itemDoubleClicked( QTreeWidgetItem *, int ), 
    10491057             this, selectKey( QTreeWidgetItem * ) ); 
     1058    CONNECT( shortcutValue, pressed(), this, selectKey() ); 
     1059} 
     1060 
     1061void KeySelectorControl::select1Key( QTreeWidgetItem *keyItem ) 
     1062{ 
     1063    shortcutValue->setText( keyItem->text( 1 ) ); 
    10501064} 
    10511065 
    10521066void KeySelectorControl::selectKey( QTreeWidgetItem *keyItem ) 
    10531067{ 
    1054    module_config_t *p_keyItem = static_cast<module_config_t*> 
     1068    /* This happens when triggered by ClickEater */ 
     1069    if( keyItem == NULL ) keyItem = table->currentItem(); 
     1070     
     1071    /* This can happen when nothing is selected on the treeView 
     1072       and the shortcutValue is clicked */ 
     1073    if( !keyItem ) return; 
     1074 
     1075    module_config_t *p_keyItem = static_cast<module_config_t*> 
    10551076                          (keyItem->data( 0, Qt::UserRole ).value<void*>()); 
    10561077 
    1057     KeyInputDialog *d = new KeyInputDialog( values, p_keyItem->psz_text ); 
     1078    KeyInputDialog *d = new KeyInputDialog( values, p_keyItem->psz_text, widget ); 
    10581079    d->exec(); 
    10591080    if( d->result() == QDialog::Accepted ) 
     
    10691090                if( p_keyItem != p_item && p_item->value.i == d->keyValue ) 
    10701091                    p_item->value.i = 0; 
    1071                 it->setText( 1, VLCKeyToString( p_item->value.i ) ); 
     1092                shortcutValue->setText( VLCKeyToString( p_item->value.i ) ); 
    10721093            } 
    10731094        } 
    10741095        else 
    1075             keyItem->setText( 1, VLCKeyToString( p_keyItem->value.i ) ); 
     1096            shortcutValue->setText( VLCKeyToString( p_keyItem->value.i ) ); 
    10761097    } 
    10771098    delete d; 
    10781099} 
    10791100 
     1101void KeySelectorControl::setTheKey() 
     1102{ 
     1103    table->currentItem()->setText( 1, shortcutValue->text() ); 
     1104} 
     1105 
    10801106void KeySelectorControl::doApply() 
    10811107{ 
     
    10871113 
    10881114KeyInputDialog::KeyInputDialog( QList<module_config_t*>& _values, 
    1089                                 const char * _keyToChange ) : 
    1090                                                 QDialog(0), keyValue(0) 
     1115                                const char * _keyToChange, 
     1116                                QWidget *_parent ) : 
     1117                                QDialog( _parent ), keyValue(0) 
    10911118{ 
    10921119    setModal( true ); 
     
    11521179    keyValue = i_vlck; 
    11531180} 
     1181 
     1182void KeyShortcutEdit::mousePressEvent( QMouseEvent *) 
     1183{ 
     1184    emit pressed(); 
     1185} 
  • modules/gui/qt4/components/preferences_widgets.hpp

    rcacd39b r3e8d0be  
    413413{ 
    414414public: 
    415     KeyInputDialog( QList<module_config_t *> &, const char * ); 
     415    KeyInputDialog( QList<module_config_t *> &, const char *, QWidget * ); 
    416416    int keyValue; 
    417417    bool conflicts; 
     
    426426}; 
    427427 
     428class KeyShortcutEdit: public QLineEdit 
     429{ 
     430    Q_OBJECT 
     431private: 
     432    virtual void mousePressEvent( QMouseEvent *event ); 
     433signals: 
     434    void pressed(); 
     435}; 
     436 
    428437class KeySelectorControl : public ConfigControl 
    429438{ 
     
    441450    QLabel *label; 
    442451    QTreeWidget *table; 
     452    KeyShortcutEdit *shortcutValue; 
    443453    QList<module_config_t *> values; 
     454    //QWidget *parent; 
    444455private slots: 
    445     void selectKey( QTreeWidgetItem *); 
     456    void setTheKey(); 
     457    void selectKey( QTreeWidgetItem * = NULL ); 
     458    void select1Key( QTreeWidgetItem *); 
    446459}; 
    447460