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; }
void FileConfigControl::updateField() { QString file = QFileDialog::getOpenFileName( NULL, qtr( "Select File" ), qfu( config_GetHomeDir() ) ); if( file.isNull() ) return; text->setText( toNativeSeparators( file ) ); }
bool OsShell::runExe(const QString& command, const QString& arguments, const QString& workingDir, bool asAdmin) { SHELLEXECUTEINFOW shExecInfo = {0}; shExecInfo.cbSize = sizeof(SHELLEXECUTEINFOW); const QString commandPathUnc = toUncPath(command); const QString workingDirNative = toNativeSeparators(workingDir); shExecInfo.fMask = SEE_MASK_FLAG_NO_UI; shExecInfo.hwnd = nullptr; shExecInfo.lpVerb = asAdmin ? L"runas" : L"open"; shExecInfo.lpFile = (WCHAR*)commandPathUnc.utf16(); shExecInfo.lpParameters = arguments.isEmpty() ? nullptr : (WCHAR*)arguments.utf16(); shExecInfo.lpDirectory = (WCHAR*)workingDirNative.utf16(); shExecInfo.nShow = SW_SHOWNORMAL; shExecInfo.hInstApp = nullptr; if (ShellExecuteExW(&shExecInfo) == 0) { if (GetLastError() != ERROR_CANCELLED) // Operation canceled by the user { const QString errorString = ErrorStringFromLastError(); qInfo() << "ShellExecuteExW failed when trying to run" << commandPathUnc << "in" << workingDirNative; qInfo() << errorString; return false; } } return true; }
void CMainWindow::deleteFiles() { if (!_currentFileList) return; #ifdef _WIN32 auto items = _controller->items(_currentFileList->panelPosition(), _currentFileList->selectedItemsHashes()); std::vector<std::wstring> paths; for (auto& item: items) paths.emplace_back(toNativeSeparators(item.fullAbsolutePath()).toStdWString()); if (paths.empty()) return; _controller->execOnWorkerThread([=]() { if (!CShell::deleteItems(paths, true, (void*) winId())) _controller->execOnUiThread([this]() { QMessageBox::warning(this, tr("Error deleting items"), tr("Failed to delete the selected items")); }); }); #else deleteFilesIrrevocably(); #endif }
void CMainWindow::deleteFilesIrrevocably() { if (!_currentFileList) return; auto items = _controller->items(_currentFileList->panelPosition(), _currentFileList->selectedItemsHashes()); if (items.empty()) return; #ifdef _WIN32 std::vector<std::wstring> paths; for (auto& item: items) paths.emplace_back(toNativeSeparators(item.fullAbsolutePath()).toStdWString()); _controller->execOnWorkerThread([=]() { if (!CShell::deleteItems(paths, false, (void*) winId())) _controller->execOnUiThread([this]() { QMessageBox::warning(this, tr("Error deleting items"), tr("Failed to delete the selected items")); }); }); #else if (QMessageBox::question(this, tr("Are you sure?"), tr("Do you want to delete the selected files and folders completely?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { CDeleteProgressDialog * dialog = new CDeleteProgressDialog(items, _otherFileList->currentDir(), this); connect(this, &CMainWindow::closed, dialog, &CDeleteProgressDialog::deleteLater); dialog->show(); } #endif }
void ConvertDialog::fileBrowse() { QString fileName = QFileDialog::getSaveFileName( this, qtr( "Save file..." ), "", qtr( "Containers (*.ps *.ts *.mpg *.ogg *.asf *.mp4 *.mov *.wav *.raw *.flv *.webm)" ) ); fileLine->setText( toNativeSeparators( fileName ) ); }
void FileDestBox::fileBrowse() { QString fileName = QFileDialog::getSaveFileName( this, qtr( "Save file..." ), "", qtr( "Containers (*.ps *.ts *.mpg *.ogg *.asf *.mp4 *.mov *.wav *.raw *.flv *.webm)" ) ); fileEdit->setText( toNativeSeparators( fileName ) ); emit mrlUpdated(); }
/** * Open a file, * pl helps you to choose from playlist or media library, * go to start or enqueue **/ void DialogsProvider::addFromSimple( bool pl, bool go) { QStringList files = DialogsProvider::showSimpleOpen(); int i = 0; files.sort(); foreach( const QString &file, files ) { playlist_Add( THEPL, qtu( toNativeSeparators( file ) ), NULL, go ? ( PLAYLIST_APPEND | ( i ? 0 : PLAYLIST_GO ) | ( i ? PLAYLIST_PREPARSE : 0 ) ) : ( PLAYLIST_APPEND | PLAYLIST_PREPARSE ), PLAYLIST_END, pl ? true : false, false ); RecentsMRL::getInstance( p_intf )->addRecent( toNativeSeparators( file ) ); i++; }
void ConvertDialog::fileBrowse() { QString fileExtension = ( ! profile->isEnabled() ) ? ".*" : "." + profile->getMux(); QString fileName = QFileDialog::getSaveFileName( this, qtr( "Save file..." ), p_intf->p_sys->filepath, QString( qtr( "Containers (*" ) + fileExtension + ")" ) ); fileLine->setText( toNativeSeparators( fileName ) ); setDestinationFileExtension(); }
void FileOpenPanel::browseFile() { QStringList files = QFileDialog::getOpenFileNames( this ); foreach( const QString &file, files) { QListWidgetItem *item = new QListWidgetItem( toNativeSeparators( file ), ui.fileListWidg ); item->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled ); ui.fileListWidg->addItem( item ); }
void FileOpenPanel::browseFile() { QStringList files = QFileDialog::getOpenFileNames( this, qtr( "Select one or multiple files" ), p_intf->p_sys->filepath) ; foreach( const QString &file, files ) { QListWidgetItem *item = new QListWidgetItem( toNativeSeparators( file ), ui.fileListWidg ); item->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled ); ui.fileListWidg->addItem( item ); savedirpathFromFile( file ); }
/** * Open a file, * pl helps you to choose from playlist or media library, * go to start or enqueue **/ void DialogsProvider::addFromSimple( bool pl, bool go) { QStringList files = DialogsProvider::showSimpleOpen(); bool first = go; files.sort(); foreach( const QString &file, files ) { QString url = toURI( toNativeSeparators( file ) ); Open::openMRL( p_intf, url, first, pl); first = false; }
void ConvertDialog::setDestinationFileExtension() { if( !fileLine->text().isEmpty() && profile->isEnabled() ) { QString newFileExtension = "." + profile->getMux(); if( fileLine->text().lastIndexOf( "." ) == -1 ) { QString newFileName = fileLine->text().append( newFileExtension ); fileLine->setText( toNativeSeparators( newFileName ) ); } } }
/** * Open a file, * pl helps you to choose from playlist or media library, * go to start or enqueue **/ void DialogsProvider::addFromSimple( bool pl, bool go) { QStringList files = DialogsProvider::showSimpleOpen(); int mode = go ? PLAYLIST_GO : PLAYLIST_PREPARSE; files.sort(); foreach( const QString &file, files ) { QString url = toURI( toNativeSeparators( file ) ); playlist_Add( THEPL, qtu( url ), NULL, PLAYLIST_APPEND | mode, PLAYLIST_END, pl, pl_Unlocked ); RecentsMRL::getInstance( p_intf )->addRecent( url ); mode = PLAYLIST_PREPARSE; }
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 ) ); }
void FileOpenPanel::browseFile() { QStringList files = THEDP->showSimpleOpen( qtr( "Select one or multiple files" ) ); foreach( const QString &file, files ) { QUrl url(file); urlList << url; QListWidgetItem *item = nullptr; item = new QListWidgetItem( toNativeSeparators( url.toDisplayString(QUrl::RemovePassword | QUrl::PreferLocalFile | QUrl::NormalizePathSegments) ), ui.fileListWidg ); item->setFlags( Qt::ItemIsEnabled ); ui.fileListWidg->addItem( item ); p_intf->p_sys->filepath = url; }
bool CController::createFile(const QString &parentFolder, const QString &name) { QDir parentDir(parentFolder); if (!parentDir.exists()) return false; const QString newFilePath = parentDir.absolutePath() + "/" + name; if (QFile(newFilePath).open(QFile::WriteOnly)) { if (toNativeSeparators(parentDir.absolutePath()) == activePanel().currentDirPathNative()) { // This is required for the UI to know to set the cursor at the new file setCursorPositionForCurrentFolder(CFileSystemObject(newFilePath).hash()); } return true; } else return false; }
void FileOpenPanel::dropEvent( QDropEvent *event ) { if( event->possibleActions() & Qt::CopyAction ) event->setDropAction( Qt::CopyAction ); else return; const QMimeData *mimeData = event->mimeData(); foreach( const QUrl &url, mimeData->urls() ) { if( url.isValid() ) { QListWidgetItem *item = new QListWidgetItem( toNativeSeparators( url.toLocalFile() ), ui.fileListWidg ); item->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled ); ui.fileListWidg->addItem( item ); } } updateMRL(); updateButtons(); event->accept(); }
bool CMainWindow::copyFiles(const std::vector<CFileSystemObject> & files, const QString & destDir) { if (files.empty() || destDir.isEmpty()) return false; const QString destPath = files.size() == 1 && files.front().isFile() ? cleanPath(destDir % toNativeSeparators("/") % files.front().fullName()) : destDir; CFileOperationConfirmationPrompt prompt(tr("Copy files"), tr("Copy %1 %2 to").arg(files.size()).arg(files.size() > 1 ? "files" : "file"), destPath, this); if (CSettings().value(KEY_OPERATIONS_ASK_FOR_COPY_MOVE_CONFIRMATION, true).toBool()) { if (prompt.exec() != QDialog::Accepted) return false; } CCopyMoveDialog * dialog = new CCopyMoveDialog(operationCopy, files, prompt.text(), this); connect(this, &CMainWindow::closed, dialog, &CCopyMoveDialog::deleteLater); dialog->connect(dialog, &CCopyMoveDialog::closed, this, &CMainWindow::deleteLater); dialog->show(); return true; }
void CMainWindow::moveSelectedFiles() { if (_currentFileList && _otherFileList) // Some algorithms rely on trailing slash for distinguishing between files and folders for non-existent items moveFiles(_controller->items(_currentFileList->panelPosition(), _currentFileList->selectedItemsHashes()), _otherFileList->currentDir() + toNativeSeparators("/")); }