예제 #1
0
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;
}
예제 #2
0
void FileConfigControl::updateField()
{
    QString file = QFileDialog::getOpenFileName( NULL,
                  qtr( "Select File" ), qfu( config_GetHomeDir() ) );
    if( file.isNull() ) return;
    text->setText( toNativeSeparators( file ) );
}
예제 #3
0
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;
}
예제 #4
0
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
}
예제 #5
0
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
}
예제 #6
0
파일: convert.cpp 프로젝트: CSRedRat/vlc
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 ) );
}
예제 #7
0
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();
}
예제 #8
0
/**
 * 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++;
    }
예제 #9
0
파일: convert.cpp 프로젝트: BtbN/vlc
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();
}
예제 #10
0
파일: open_panels.cpp 프로젝트: Kafay/vlc
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 );
    }
예제 #11
0
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 );
    }
예제 #12
0
/**
 * 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;
    }
예제 #13
0
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 ) );
        }
    }
}
예제 #14
0
/**
 * 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;
    }
예제 #15
0
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 ) );
}
예제 #16
0
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;
    }
예제 #17
0
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;
}
예제 #18
0
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();
}
예제 #19
0
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;
}
예제 #20
0
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("/"));
}