void FileConfigControl::updateField() { QString file; if (p_item->i_type == CONFIG_ITEM_SAVEFILE) file = QFileDialog::getSaveFileName( NULL, qtr( "Save File" ), QVLCUserDir( VLC_HOME_DIR ) ); else file = QFileDialog::getOpenFileName( NULL, qtr( "Select File" ), QVLCUserDir( VLC_HOME_DIR ) ); if( file.isNull() ) return; text->setText( toNativeSeparators( file ) ); }
bool VLMDialog::importVLMConf() { QString openVLMConfFileName = toNativeSeparators( QFileDialog::getOpenFileName( this, qtr( "Open VLM configuration..." ), QVLCUserDir( VLC_DOCUMENTS_DIR ), qtr( "VLM conf (*.vlm);;All (*)" ) ) ); if( !openVLMConfFileName.isEmpty() ) { vlm_message_t *message; int status; QString command = "load \"" + openVLMConfFileName + "\""; status = vlm_ExecuteCommand( p_vlm, qtu( command ) , &message ); vlm_MessageDelete( message ); if( status == 0 ) { mediasPopulator(); } else { msg_Warn( p_intf, "Failed to import vlm configuration file : %s", qtu( command ) ); return false; } return true; } return false; }
bool MessagesDialog::save() { QString saveLogFileName = QFileDialog::getSaveFileName( this, qtr( "Save log file as..." ), QVLCUserDir( VLC_DOCUMENTS_DIR ), qtr( "Texts / Logs (*.log *.txt);; All (*.*) ") ); if( !saveLogFileName.isNull() ) { QFile file( saveLogFileName ); if ( !file.open( QFile::WriteOnly | QFile::Text ) ) { QMessageBox::warning( this, qtr( "Application" ), qtr( "Cannot write to file %1:\n%2." ) .arg( saveLogFileName ) .arg( file.errorString() ) ); return false; } QTextStream out( &file ); QTextBlock block = ui.messages->document()->firstBlock(); while( block.isValid() ) { if( block.isVisible() ) out << block.text() << "\n"; block = block.next(); } return true; } return false; }
void DirectoryConfigControl::updateField() { QString dir = QFileDialog::getExistingDirectory( NULL, qtr( I_OP_SEL_DIR ), text->text().isEmpty() ? QVLCUserDir( VLC_HOME_DIR ) : text->text(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks ); if( dir.isNull() ) return; text->setText( toNativeSepNoSlash( dir ) ); }
/* TODO : VOD are not exported to the file */ bool VLMDialog::exportVLMConf() { QString saveVLMConfFileName = QFileDialog::getSaveFileName( this, qtr( "Save VLM configuration as..." ), QVLCUserDir( VLC_DOCUMENTS_DIR ), qtr( "VLM conf (*.vlm);;All (*)" ) ); if( !saveVLMConfFileName.isEmpty() ) { vlm_message_t *message; QString command = "save \"" + saveVLMConfFileName + "\""; vlm_ExecuteCommand( p_vlm , qtu( command ) , &message ); vlm_MessageDelete( message ); return true; } return false; }
static void *Thread( void *obj ) { intf_thread_t *p_intf = (intf_thread_t *)obj; MainInterface *p_mi; char vlc_name[] = "vlc"; /* for WM_CLASS */ #ifdef QT5_HAS_X11 char platform_parm[] = "-platform"; char platform_value[] = "xcb"; #endif char *argv[] = { vlc_name, #ifdef QT5_HAS_X11 platform_parm, platform_value, #endif NULL, }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; Q_INIT_RESOURCE( vlc ); /* Start the QApplication here */ QVLCApp app( argc, argv ); p_intf->p_sys->p_app = &app; /* All the settings are in the .conf/.ini style */ p_intf->p_sys->mainSettings = new QSettings( #ifdef _WIN32 QSettings::IniFormat, #else QSettings::NativeFormat, #endif QSettings::UserScope, "vlc", "vlc-qt-interface" ); /* Icon setting, Mac uses icon from .icns */ #ifndef Q_OS_MAC if( QDate::currentDate().dayOfYear() >= QT_XMAS_JOKE_DAY && var_InheritBool( p_intf, "qt-icon-change" ) ) app.setWindowIcon( QIcon::fromTheme( "vlc-xmas", QIcon( ":/logo/vlc128-xmas.png" ) ) ); else app.setWindowIcon( QIcon::fromTheme( "vlc", QIcon( ":/logo/vlc256.png" ) ) ); #endif /* Initialize the Dialog Provider and the Main Input Manager */ DialogsProvider::getInstance( p_intf ); MainInputManager::getInstance( p_intf ); #ifdef UPDATE_CHECK /* Checking for VLC updates */ if( var_InheritBool( p_intf, "qt-updates-notif" ) && !var_InheritBool( p_intf, "qt-privacy-ask" ) ) { int interval = var_InheritInteger( 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->p_sys->b_isDialogProvider ) { p_mi = new MainInterface( p_intf ); p_intf->p_sys->p_mi = p_mi; } else p_mi = NULL; /* Explain how to show a dialog :D */ p_intf->pf_show_dialog = ShowDialog; /* Check window type from the Qt platform back-end */ p_intf->p_sys->voutWindowType = VOUT_WINDOW_TYPE_INVALID; #if HAS_QT5 || defined (Q_WS_QPA) QString platform = app.platformName(); if( platform == qfu("xcb") ) p_intf->p_sys->voutWindowType = VOUT_WINDOW_TYPE_XID; else if( platform == qfu("windows") ) p_intf->p_sys->voutWindowType = VOUT_WINDOW_TYPE_HWND; else if( platform == qfu("cocoa" ) ) p_intf->p_sys->voutWindowType = VOUT_WINDOW_TYPE_NSOBJECT; else msg_Err( p_intf, "unknown Qt platform: %s", qtu(platform) ); #elif defined (Q_WS_X11) p_intf->p_sys->voutWindowType = VOUT_WINDOW_TYPE_XID; #elif defined (Q_WS_WIN) || defined (Q_WS_PM) p_intf->p_sys->voutWindowType = VOUT_WINDOW_TYPE_HWND; #elif defined (Q_WS_MAC) p_intf->p_sys->voutWindowType = VOUT_WINDOW_TYPE_NSOBJECT; #endif /* Tell the main LibVLC thread we are ready */ vlc_sem_post (&ready); #ifdef Q_OS_MAC /* We took over main thread, register and start here */ if( !p_intf->p_sys->b_isDialogProvider ) { RegisterIntf( p_intf ); playlist_Play( THEPL ); } #endif /* Last settings */ app.setQuitOnLastWindowClosed( false ); /* Retrieve last known path used in file browsing */ p_intf->p_sys->filepath = getSettings()->value( "filedialog-path", QVLCUserDir( VLC_HOME_DIR ) ).toString(); /* Loads and tries to apply the preferred QStyle */ QString s_style = getSettings()->value( "MainWindow/QtStyle", "" ).toString(); if( s_style.compare("") != 0 ) QApplication::setStyle( s_style ); /* Launch */ app.exec(); msg_Dbg( p_intf, "QApp exec() finished" ); if (p_mi != NULL) { QMutexLocker locker (&lock); active = false; p_intf->p_sys->p_mi = NULL; /* Destroy first the main interface because it is connected to some slots in the MainInputManager */ delete p_mi; } /* */ ExtensionsManager::killInstance(); AddonsManager::killInstance(); /* Destroy all remaining windows, because some are connected to some slots in the MainInputManager Settings must be destroyed after that. */ DialogsProvider::killInstance(); /* Delete the recentsMRL object before the configuration */ RecentsMRL::killInstance(); /* Save the path or delete if recent play are disabled */ if( var_InheritBool( p_intf, "qt-recentplay" ) ) getSettings()->setValue( "filedialog-path", p_intf->p_sys->filepath ); else getSettings()->remove( "filedialog-path" ); /* */ delete p_intf->p_sys->pl_model; /* Delete the configuration. Application has to be deleted after that. */ delete p_intf->p_sys->mainSettings; /* Destroy the MainInputManager */ MainInputManager::killInstance(); /* Delete the application automatically */ return NULL; }
static void *Thread( void *obj ) { intf_thread_t *p_intf = (intf_thread_t *)obj; MainInterface *p_mi; char dummy[] = "vlc"; /* for WM_CLASS */ char *argv[4] = { dummy, NULL, }; int argc = 1; Q_INIT_RESOURCE( vlc ); /* Start the QApplication here */ #ifdef Q_WS_X11 if( x11_display != NULL ) { argv[argc++] = const_cast<char *>("-display"); argv[argc++] = x11_display; argv[argc] = NULL; } #endif QVLCApp app( argc, argv ); p_intf->p_sys->p_app = &app; /* All the settings are in the .conf/.ini style */ 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() >= 352 ) /* One Week before Xmas */ app.setWindowIcon( QIcon(vlc_christmas_xpm) ); else app.setWindowIcon( QIcon(vlc_xpm) ); /* Initialize timers and the Dialog Provider */ DialogsProvider::getInstance( p_intf ); /* Detect screensize for small screens like TV or EEEpc*/ p_intf->p_sys->i_screenHeight = app.QApplication::desktop()->availableGeometry().height(); #ifdef UPDATE_CHECK /* Checking for VLC updates */ if( var_InheritBool( p_intf, "qt-updates-notif" ) && !var_InheritBool( p_intf, "qt-privacy-ask" ) ) { int interval = var_InheritInteger( 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->p_sys->b_isDialogProvider ) p_mi = new MainInterface( p_intf ); else p_mi = NULL; p_intf->p_sys->p_mi = p_mi; /* Explain how to show a dialog :D */ p_intf->pf_show_dialog = ShowDialog; /* */ vlc_sem_post (&ready); /* Last settings */ app.setQuitOnLastWindowClosed( false ); /* Retrieve last known path used in file browsing */ p_intf->p_sys->filepath = getSettings()->value( "filedialog-path", QVLCUserDir( VLC_HOME_DIR ) ).toString(); /* Loads and tries to apply the preferred QStyle */ QString s_style = getSettings()->value( "MainWindow/QtStyle", "" ).toString(); if( s_style.compare("") != 0 ) QApplication::setStyle( s_style ); /* Launch */ app.exec(); /* And quit */ QApplication::closeAllWindows(); if (p_mi != NULL) { #warning BUG! /* FIXME: the video window may still be registerd at this point */ /* See LP#448082 as an example. */ p_intf->p_sys->p_mi = NULL; /* Destroy first the main interface because it is connected to some slots in the MainInputManager */ delete 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 recentsMRL object before the configuration */ RecentsMRL::killInstance(); /* Save the path */ getSettings()->setValue( "filedialog-path", p_intf->p_sys->filepath ); /* Delete the configuration. Application has to be deleted after that. */ delete p_intf->p_sys->mainSettings; /* Destroy the MainInputManager */ MainInputManager::killInstance(); /* Delete the application automatically */ return NULL; }