📄 complete_preferences.cpp
字号:
} break; } } if( !b_found ) continue; PrefsItemData *module_data = new PrefsItemData(); module_data->i_type = TYPE_MODULE; module_data->psz_name = strdup( module_GetObjName( p_module ) ); module_data->help.clear(); QTreeWidgetItem *module_item = new QTreeWidgetItem(); module_item->setText( 0, qtr( module_GetName( p_module, false ) ) ); module_item->setData( 0, Qt::UserRole, QVariant::fromValue( module_data) ); module_item->setSizeHint( 0, QSize( -1, ITEM_HEIGHT ) ); subcat_item->addChild( module_item ); } /* We got everything, just sort a bit */ sortItems( 0, Qt::AscendingOrder ); vlc_list_release( p_list );}PrefsTree::~PrefsTree() {}void PrefsTree::applyAll(){ doAll( false );}void PrefsTree::cleanAll(){ doAll( true );}void PrefsTree::doAll( bool doclean ){ for( int i_cat_index = 0 ; i_cat_index < topLevelItemCount(); i_cat_index++ ) { QTreeWidgetItem *cat_item = topLevelItem( i_cat_index ); for( int i_sc_index = 0; i_sc_index < cat_item->childCount(); i_sc_index++ ) { QTreeWidgetItem *sc_item = cat_item->child( i_sc_index ); for( int i_module = 0 ; i_module < sc_item->childCount(); i_module++ ) { PrefsItemData *data = sc_item->child( i_module )-> data( 0, Qt::UserRole).value<PrefsItemData *>(); if( data->panel && doclean ) { delete data->panel; data->panel = NULL; } else if( data->panel ) data->panel->apply(); } PrefsItemData *data = sc_item->data( 0, Qt::UserRole). value<PrefsItemData *>(); if( data->panel && doclean ) { delete data->panel; data->panel = NULL; } else if( data->panel ) data->panel->apply(); } PrefsItemData *data = cat_item->data( 0, Qt::UserRole). value<PrefsItemData *>(); if( data->panel && doclean ) { delete data->panel; data->panel = NULL; } else if( data->panel ) data->panel->apply(); }}/********************************************************************* * The Panel *********************************************************************/AdvPrefsPanel::AdvPrefsPanel( QWidget *_parent ) : QWidget( _parent ){}AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, PrefsItemData * data ) : QWidget( _parent ), p_intf( _p_intf ){ /* Find our module */ module_t *p_module = NULL; if( data->i_type == TYPE_CATEGORY ) return; else if( data->i_type == TYPE_MODULE ) p_module = module_Find( p_intf, data->psz_name ); else { p_module = module_GetMainModule( p_intf ); assert( p_module ); } unsigned confsize; module_config_t *const p_config = module_GetConfig (p_module, &confsize), *p_item = p_config, *p_end = p_config + confsize; if( data->i_type == TYPE_SUBCATEGORY || data->i_type == TYPE_CATSUBCAT ) { while (p_item < p_end) { if( p_item->i_type == CONFIG_SUBCATEGORY && ( data->i_type == TYPE_SUBCATEGORY && p_item->value.i == data->i_object_id ) || ( data->i_type == TYPE_CATSUBCAT && p_item->value.i == data->i_subcat_id ) ) break; p_item++; } } /* Widgets now */ global_layout = new QVBoxLayout(); global_layout->setMargin( 2 ); QString head; QString help; help = QString( data->help ); if( data->i_type == TYPE_SUBCATEGORY || data->i_type == TYPE_CATSUBCAT ) { head = QString( data->name ); p_item++; // Why that ? } else { const char *psz_help = module_GetHelp (p_module); head = QString( qtr( module_GetLongName( p_module ) ) ); if( psz_help ) { help.append( "\n" ); help.append( qtr( psz_help ) ); } } QLabel *titleLabel = new QLabel( head ); QFont titleFont = QApplication::font( static_cast<QWidget*>(0) ); titleFont.setPointSize( titleFont.pointSize() + 6 ); titleFont.setFamily( "Verdana" ); titleLabel->setFont( titleFont ); // Title <hr> QFrame *title_line = new QFrame; title_line->setFrameShape(QFrame::HLine); title_line->setFrameShadow(QFrame::Sunken); QLabel *helpLabel = new QLabel( help, this ); helpLabel->setWordWrap( true ); global_layout->addWidget( titleLabel ); global_layout->addWidget( title_line ); global_layout->addWidget( helpLabel ); QGroupBox *box = NULL; QGridLayout *boxlayout = NULL; QScrollArea *scroller= new QScrollArea; scroller->setFrameStyle( QFrame::NoFrame ); QWidget *scrolled_area = new QWidget; QGridLayout *layout = new QGridLayout(); int i_line = 0, i_boxline = 0; bool has_hotkey = false; if( p_item ) do { if( ( ( data->i_type == TYPE_SUBCATEGORY && p_item->value.i != data->i_object_id ) || ( data->i_type == TYPE_CATSUBCAT && p_item->value.i != data->i_subcat_id ) ) && ( p_item->i_type == CONFIG_CATEGORY || p_item->i_type == CONFIG_SUBCATEGORY ) ) break; if( p_item->b_internal == true ) continue; if( p_item->i_type == CONFIG_SECTION ) { if( box ) { box->setLayout( boxlayout ); box->show(); layout->addWidget( box, i_line, 0, 1, -1 ); i_line++; } box = new QGroupBox( qtr( p_item->psz_text ) ); box->hide(); boxlayout = new QGridLayout(); } /* Only one hotkey control */ if( has_hotkey && p_item->i_type & CONFIG_ITEM && p_item->psz_name && strstr( p_item->psz_name, "key-" ) ) continue; if( p_item->i_type & CONFIG_ITEM && p_item->psz_name && strstr( p_item->psz_name, "key-" ) ) has_hotkey = true; ConfigControl *control; if( ! box ) control = ConfigControl::createControl( VLC_OBJECT( p_intf ), p_item, NULL, layout, i_line ); else control = ConfigControl::createControl( VLC_OBJECT( p_intf ), p_item, NULL, boxlayout, i_boxline ); if( !control ) continue; if( box ) i_boxline++; else i_line++; controls.append( control ); } while( !( ( data->i_type == TYPE_SUBCATEGORY || data->i_type == TYPE_CATSUBCAT ) && ( p_item->i_type == CONFIG_CATEGORY || p_item->i_type == CONFIG_SUBCATEGORY ) ) && ( ++p_item < p_end ) ); if( box ) { box->setLayout( boxlayout ); box->show(); layout->addWidget( box, i_line, 0, 1, -1 ); } module_Put( p_module ); scrolled_area->setSizePolicy( QSizePolicy::Preferred,QSizePolicy::Fixed ); scrolled_area->setLayout( layout ); scroller->setWidget( scrolled_area ); scroller->setWidgetResizable( true ); global_layout->addWidget( scroller ); setLayout( global_layout );}void AdvPrefsPanel::apply(){ QList<ConfigControl *>::Iterator i; for( i = controls.begin() ; i != controls.end() ; i++ ) { ConfigControl *c = qobject_cast<ConfigControl *>(*i); c->doApply( p_intf ); }}void AdvPrefsPanel::clean(){}AdvPrefsPanel::~AdvPrefsPanel(){ qDeleteAll( controls ); controls.clear();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -