📄 qt4.cpp
字号:
} vlc_object_release( p_intf->p_sys->p_playlist ); msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub ); free( p_intf->p_sys );}/***************************************************************************** * Initialize the interface or the dialogs provider *****************************************************************************/static void Run( intf_thread_t *p_intf ){ if( p_intf->pf_show_dialog ) { if( vlc_thread_create( p_intf, "Qt dialogs", Init, 0, true ) ) msg_Err( p_intf, "failed to create Qt dialogs thread" ); } else Init( VLC_OBJECT(p_intf) );}static QMutex windowLock;static QWaitCondition windowWait;static void *Init( vlc_object_t *obj ){ intf_thread_t *p_intf = (intf_thread_t *)obj; vlc_value_t val; char dummy[] = ""; char *argv[] = { dummy }; int argc = 1; Q_INIT_RESOURCE( vlc );#if !defined(WIN32) && !defined(__APPLE__) /* KLUDGE: * disables icon theme use because that makes Cleanlooks style bug * because it asks gconf for some settings that timeout because of threads * see commits 21610 21622 21654 for reference */ /* If you don't have a gconftool-2 binary, you should comment this line */ if( strcmp( qVersion(), "4.4.0" ) < 0 ) /* fixed in Qt 4.4.0 */ QApplication::setDesktopSettingsAware( false );#endif /* Start the QApplication here */ QApplication *app = new QApplication( argc, argv , true ); p_intf->p_sys->p_app = app; p_intf->p_sys->mainSettings = new QSettings(#ifdef WIN32 QSettings::IniFormat,#else QSettings::NativeFormat,#endif QSettings::UserScope, "vlc", "vlc-qt-interface" ); /* Icon setting */ if( QDate::currentDate().dayOfYear() >= 354 ) app->setWindowIcon( QIcon( QPixmap(vlc_christmas_xpm) ) ); else app->setWindowIcon( QIcon( QPixmap(vlc_xpm) ) ); /* Initialize timers and the Dialog Provider */ DialogsProvider::getInstance( p_intf ); QPointer<MainInterface> *miP = NULL;#ifdef UPDATE_CHECK /* Checking for VLC updates */ if( config_GetInt( p_intf, "qt-updates-notif" ) && !config_GetInt( p_intf, "qt-privacy-ask" ) ) { int interval = config_GetInt( p_intf, "qt-updates-days" ); if( QDate::currentDate() > getSettings()->value( "updatedate" ).toDate().addDays( interval ) ) { /* The constructor of the update Dialog will do the 1st request */ UpdateDialog::getInstance( p_intf ); getSettings()->setValue( "updatedate", QDate::currentDate() ); } }#endif /* Create the normal interface in non-DP mode */ if( !p_intf->pf_show_dialog ) { p_intf->p_sys->p_mi = new MainInterface( p_intf ); /* We don't show it because it is done in the MainInterface constructor p_mi->show(); */ p_intf->p_sys->b_isDialogProvider = false; miP = new QPointer<MainInterface> (p_intf->p_sys->p_mi); val.p_address = miP; QMutexLocker locker (&windowLock); var_Set (p_intf, "window_widget", val); windowWait.wakeAll (); } else { vlc_thread_ready( p_intf ); p_intf->p_sys->b_isDialogProvider = true; } /* Explain to the core how to show a dialog :D */ p_intf->pf_show_dialog = ShowDialog;#ifdef ENABLE_NLS // Translation - get locale# if defined (WIN32) || defined (__APPLE__) char* psz_tmp = config_GetPsz( p_intf, "language" ); QString lang = qfu( psz_tmp ); free( psz_tmp); if (lang == "auto") lang = QLocale::system().name();# else QString lang = QLocale::system().name();# endif // Translations for qt's own dialogs QTranslator qtTranslator( 0 ); // Let's find the right path for the translation file#if !defined( WIN32 ) QString path = QString( QT4LOCALEDIR );#else QString path = QString( QString(config_GetDataDir()) + DIR_SEP + "locale" + DIR_SEP + "qt4" + DIR_SEP );#endif // files depending on locale bool b_loaded = qtTranslator.load( path + "qt_" + lang ); if (!b_loaded) msg_Dbg( p_intf, "Error while initializing qt-specific localization" ); app->installTranslator( &qtTranslator );#endif //ENABLE_NLS /* Last settings */ app->setQuitOnLastWindowClosed( false ); /* Retrieve last known path used in file browsing */ char *psz_path = config_GetPsz( p_intf, "qt-filedialog-path" ); p_intf->p_sys->psz_filepath = EMPTY_STR( psz_path ) ? psz_path : config_GetHomeDir(); /* Launch */ app->exec(); /* And quit */ msg_Dbg( p_intf, "Quitting the Qt4 Interface" ); if (miP) { QMutexLocker locker (&windowLock); /* We need to warn to detach from any vout before * deleting miP (WindowClose will not be called after it) */ p_intf->p_sys->p_mi->releaseVideo( NULL ); val.p_address = NULL; var_Set (p_intf, "window_widget", val); delete miP; } /* Destroy first the main interface because it is connected to some slots in the MainInputManager */ delete p_intf->p_sys->p_mi; /* Destroy all remaining windows, because some are connected to some slots in the MainInputManager Settings must be destroyed after that. */ DialogsProvider::killInstance(); /* Delete the configuration. Application has to be deleted after that. */ delete p_intf->p_sys->mainSettings; /* Destroy the MainInputManager */ MainInputManager::killInstance(); /* Delete the application */ delete app; /* Save the path */ config_PutPsz( p_intf, "qt-filedialog-path", p_intf->p_sys->psz_filepath ); free( psz_path );}/***************************************************************************** * Callback to show a dialog *****************************************************************************/static void ShowDialog( intf_thread_t *p_intf, int i_dialog_event, int i_arg, intf_dialog_args_t *p_arg ){ DialogEvent *event = new DialogEvent( i_dialog_event, i_arg, p_arg ); QApplication::postEvent( THEDP, static_cast<QEvent*>(event) );}/***************************************************************************** * PopupMenuCB: callback to show the popupmenu. * We don't show the menu directly here because we don't want the * caller to block for a too long time. *****************************************************************************/static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable, vlc_value_t old_val, vlc_value_t new_val, void *param ){ intf_thread_t *p_intf = (intf_thread_t *)param; ShowDialog( p_intf, INTF_DIALOG_POPUPMENU, new_val.b_bool, 0 ); return VLC_SUCCESS;}/** * Video output window provider */#include <vlc_window.h>static int WindowControl (vout_window_t *, int, va_list);static int WindowOpen (vlc_object_t *obj){ vout_window_t *wnd = (vout_window_t *)obj; if (config_GetInt (obj, "embedded-video") <= 0) return VLC_EGENERIC; intf_thread_t *intf = (intf_thread_t *) vlc_object_find_name (obj, "qt4", FIND_ANYWHERE); if (intf == NULL) return VLC_EGENERIC; /* Qt4 not in use */ assert (intf->i_object_type == VLC_OBJECT_INTF); var_Create (intf, "window_widget", VLC_VAR_ADDRESS); vlc_value_t ptrval; windowLock.lock (); msg_Dbg (obj, "waiting for interface..."); for (;;) { var_Get (intf, "window_widget", &ptrval); if (ptrval.p_address != NULL) break; windowWait.wait (&windowLock); } msg_Dbg (obj, "requesting window..."); QPointer<MainInterface> *miP = (QPointer<MainInterface> *)ptrval.p_address; miP = new QPointer<MainInterface> (*miP); /* create our own copy */ vlc_object_release (intf); if (miP->isNull ()) return VLC_EGENERIC; wnd->handle = (*miP)->requestVideo (wnd->vout, &wnd->pos_x, &wnd->pos_y, &wnd->width, &wnd->height); windowLock.unlock (); if (!wnd->handle) return VLC_EGENERIC; wnd->control = WindowControl; wnd->p_private = miP; return VLC_SUCCESS;}static int WindowControl (vout_window_t *wnd, int query, va_list args){ QPointer<MainInterface> *miP = (QPointer<MainInterface> *)wnd->p_private; QMutexLocker locker (&windowLock); if (miP->isNull ()) return VLC_EGENERIC; return (*miP)->controlVideo (wnd->handle, query, args);}static void WindowClose (vlc_object_t *obj){ vout_window_t *wnd = (vout_window_t *)obj; QPointer<MainInterface> *miP = (QPointer<MainInterface> *)wnd->p_private; QMutexLocker locker (&windowLock); if (!miP->isNull ()) (*miP)->releaseVideo( wnd->handle ); delete miP;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -