Commit 5897ca4d authored by Pierre Lamot's avatar Pierre Lamot Committed by Pierre Lamot
Browse files

qt: move dialog file path variable from module to maininterface

  the variable was no longer initialized properly as it was stored
  in a "C" structure and there was no reason to store this variable in
  the module
parent 537d41a4
......@@ -424,7 +424,7 @@ void DialogsProvider::openFileGenericDialog( intf_dialog_args_t *p_arg )
{
QString file = getSaveFileName( NULL,
qfu( p_arg->psz_title ),
p_intf->filepath, extensions );
p_intf->p_mi->getDialogFilePath(), extensions );
if( !file.isEmpty() )
{
p_arg->i_results = 1;
......@@ -437,14 +437,14 @@ void DialogsProvider::openFileGenericDialog( intf_dialog_args_t *p_arg )
else /* non-save mode */
{
QList<QUrl> urls = QFileDialog::getOpenFileUrls( NULL, qfu( p_arg->psz_title ),
p_intf->filepath, extensions );
p_intf->p_mi->getDialogFilePath(), extensions );
p_arg->i_results = urls.count();
p_arg->psz_results = (char **)vlc_alloc( p_arg->i_results, sizeof( char * ) );
i = 0;
foreach( const QUrl &uri, urls )
p_arg->psz_results[i++] = strdup( uri.toEncoded().constData() );
if( !urls.isEmpty() )
p_intf->filepath = urls.last();
p_intf->p_mi->setDialogFilePath(urls.last());
}
/* Callback */
......@@ -528,11 +528,11 @@ QStringList DialogsProvider::showSimpleOpen( const QString& help,
QList<QUrl> urls = QFileDialog::getOpenFileUrls( NULL,
help.isEmpty() ? qfut(I_OP_SEL_FILES ) : help,
path.isEmpty() ? p_intf->filepath : path,
path.isEmpty() ? p_intf->p_mi->getDialogFilePath() : path,
fileTypes );
if( !urls.isEmpty() )
p_intf->filepath = urls.last();
p_intf->p_mi->setDialogFilePath(urls.last());
QStringList res;
foreach( const QUrl &url, urls )
......@@ -600,12 +600,12 @@ QString DialogsProvider::getDirectoryDialog( qt_intf_t *p_intf )
{
const QStringList schemes = QStringList(QStringLiteral("file"));
QUrl dirurl = QFileDialog::getExistingDirectoryUrl( NULL,
qfut( I_OP_DIR_WINTITLE ), p_intf->filepath,
qfut( I_OP_DIR_WINTITLE ), p_intf->p_mi->getDialogFilePath(),
QFileDialog::ShowDirsOnly, schemes );
if( dirurl.isEmpty() ) return QString();
p_intf->filepath = dirurl;
p_intf->p_mi->setDialogFilePath(dirurl);
QString dir = dirurl.toLocalFile();
const char *scheme = "directory";
......@@ -669,7 +669,7 @@ void DialogsProvider::savePlayingToPlaylist()
QString selected;
QString file = getSaveFileName( NULL,
qtr( "Save playlist as..." ),
p_intf->filepath, filters.join( ";;" ),
p_intf->p_mi->getDialogFilePath(), filters.join( ";;" ),
&selected );
const char *psz_selected_module = NULL;
const char *psz_last_playlist_ext = NULL;
......
......@@ -47,6 +47,7 @@
#include "extended_panels.hpp"
#include "dialogs/preferences/preferences.hpp"
#include "qt.hpp"
#include "maininterface/main_interface.hpp"
#include "player/player_controller.hpp"
#include "util/qt_dirs.hpp"
#include "widgets/native/customwidgets.hpp"
......@@ -369,7 +370,7 @@ void ExtVideo::browseLogo()
.arg( TITLE_EXTENSIONS_IMAGE )
.arg( TITLE_EXTENSIONS_ALL );
QString file = QFileDialog::getOpenFileUrl( NULL, qtr( "Logo filenames" ),
p_intf->filepath, filter,
p_intf->p_mi->getDialogFilePath(), filter,
NULL, QFileDialog::Options(), schemes ).toLocalFile();
UPDATE_AND_APPLY_TEXT( logoFileText, file );
......@@ -382,7 +383,7 @@ void ExtVideo::browseEraseFile()
.arg( TITLE_EXTENSIONS_IMAGE )
.arg( TITLE_EXTENSIONS_ALL );
QString file = QFileDialog::getOpenFileUrl( NULL, qtr( "Image mask" ),
p_intf->filepath, filter,
p_intf->p_mi->getDialogFilePath(), filter,
NULL, QFileDialog::Options(), schemes ).toLocalFile();
UPDATE_AND_APPLY_TEXT( eraseMaskText, file );
......
......@@ -30,6 +30,7 @@
#endif
#include "qt.hpp"
#include "maininterface/main_interface.hpp"
#include "open_panels.hpp"
#include "dialogs/open/open.hpp"
#include "dialogs/dialogs_provider.hpp" /* Open Subtitle file */
......@@ -130,7 +131,7 @@ inline void FileOpenPanel::BuildOldPanel()
/* Make this QFileDialog a child of tempWidget from the ui. */
dialogBox = new FileOpenBox( ui.tempWidget, NULL,
p_intf->filepath, "" );
p_intf->p_mi->getDialogFilePath(), "" );
dialogBox->setFileMode( QFileDialog::ExistingFiles );
dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
......@@ -245,7 +246,7 @@ void FileOpenPanel::browseFile()
);
item->setFlags( Qt::ItemIsEnabled );
ui.fileListWidg->addItem( item );
p_intf->filepath = url;
p_intf->p_mi->setDialogFilePath(url);
}
updateButtons();
updateMRL();
......@@ -269,7 +270,7 @@ void FileOpenPanel::removeFile()
void FileOpenPanel::browseFileSub()
{
QStringList urls = THEDP->showSimpleOpen( qtr("Open subtitle file"),
EXT_FILTER_SUBTITLE, p_intf->filepath );
EXT_FILTER_SUBTITLE, p_intf->p_mi->getDialogFilePath() );
if( urls.isEmpty() ) {
return;
......@@ -310,7 +311,7 @@ void FileOpenPanel::updateMRL()
void FileOpenPanel::accept()
{
if( dialogBox )
p_intf->filepath = dialogBox->directory().absolutePath();
p_intf->p_mi->setDialogFilePath(dialogBox->directory().absolutePath());
ui.fileListWidg->clear();
urlList.clear();
}
......@@ -649,7 +650,7 @@ void DiscOpenPanel::browseDevice()
{
const QStringList schemes = QStringList(QStringLiteral("file"));
QString dir = QFileDialog::getExistingDirectoryUrl( this,
qfut( I_DEVICE_TOOLTIP ), p_intf->filepath,
qfut( I_DEVICE_TOOLTIP ), p_intf->p_mi->getDialogFilePath(),
QFileDialog::ShowDirsOnly, schemes ).toLocalFile();
if( !dir.isEmpty() )
{
......
......@@ -27,6 +27,7 @@
#include "dialogs/sout/sout.hpp"
#include "dialogs/sout/convert.hpp"
#include "dialogs/sout/sout_widgets.hpp"
#include "maininterface/main_interface.hpp"
#include "util/qt_dirs.hpp"
......@@ -158,7 +159,7 @@ void ConvertDialog::fileBrowse()
QString fileExtension = ( ! profile->isEnabled() ) ? ".*" : "." + profile->getMux();
outgoingMRL = QFileDialog::getSaveFileUrl( this, qtr( "Save file..." ),
p_intf->filepath,
p_intf->p_mi->getDialogFilePath(),
QString( "%1 (*%2);;%3 (*.*)" ).arg( qtr( "Containers" ) )
.arg( fileExtension ).arg( qtr("All") ), 0, QFileDialog::DontConfirmOverwrite );
fileLine->setText( urlToDisplayString( outgoingMRL ) );
......
......@@ -25,6 +25,7 @@
#include "dialogs/sout/sout_widgets.hpp"
#include "dialogs/sout/sout.hpp"
#include "maininterface/main_interface.hpp"
#include "util/soutchain.hpp"
#include "util/qt_dirs.hpp"
#include <vlc_intf_strings.h>
......@@ -171,7 +172,7 @@ void FileDestBox::fileBrowse()
{
const QStringList schemes = QStringList(QStringLiteral("file"));
QString fileName = QFileDialog::getSaveFileUrl( this, qtr( "Save file..." ),
p_intf->filepath, qtr( "Containers (*.ps *.ts *.mpg *.ogg *.asf *.mp4 *.mov *.wav *.raw *.flv *.webm)" ),
p_intf->p_mi->getDialogFilePath(), qtr( "Containers (*.ps *.ts *.mpg *.ogg *.asf *.mp4 *.mov *.wav *.raw *.flv *.webm)" ),
nullptr, QFileDialog::Options(), schemes).toLocalFile();
fileEdit->setText( toNativeSeparators( fileName ) );
emit mrlUpdated();
......
......@@ -168,6 +168,8 @@ MainInterface::MainInterface(qt_intf_t *_p_intf , QWidget* parent, Qt::WindowFla
#endif
m_hasToolbarMenu = var_InheritBool( p_intf, "qt-menubar" );
m_dialogFilepath = getSettings()->value( "filedialog-path", QVLCUserDir( VLC_HOME_DIR ) ).toString();
QString platformName = QGuiApplication::platformName();
#ifdef QT5_HAS_WAYLAND
......@@ -255,6 +257,11 @@ MainInterface::~MainInterface()
/* Save the stackCentralW sizes */
settings->endGroup();
if( var_InheritBool( p_intf, "qt-recentplay" ) )
getSettings()->setValue( "filedialog-path", m_dialogFilepath );
else
getSettings()->remove( "filedialog-path" );
/* Save this size */
QVLCTools::saveWidgetPosition(settings, this);
......
......@@ -162,7 +162,6 @@ class MainInterface : public QVLCMW
Q_PROPERTY(bool pinVideoControls READ pinVideoControls WRITE setPinVideoControls NOTIFY pinVideoControlsChanged)
Q_PROPERTY(ControlbarProfileModel* controlbarProfileModel READ controlbarProfileModel CONSTANT)
public:
/* tors */
MainInterface( qt_intf_t *, QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
......@@ -211,6 +210,8 @@ public:
inline void setCanShowVideoPIP(bool canShowVideoPIP) { m_canShowVideoPIP = canShowVideoPIP; }
inline bool pinVideoControls() const { return m_pinVideoControls; }
inline ControlbarProfileModel* controlbarProfileModel() const { return m_controlbarProfileModel; }
inline QUrl getDialogFilePath() const { return m_dialogFilepath; }
inline void setDialogFilePath(const QUrl& filepath ){ m_dialogFilepath = filepath; }
bool hasEmbededVideo() const;
VideoSurfaceProvider* getVideoSurfaceProvider() const;
......@@ -282,6 +283,7 @@ protected:
bool m_hasToolbarMenu = false;
bool m_canShowVideoPIP = false;
bool m_pinVideoControls = false;
QUrl m_dialogFilepath; /* Last path used in dialogs */
/* States */
bool playlistVisible; ///< Is the playlist visible ?
......
......@@ -757,10 +757,6 @@ static void *Thread( void *obj )
/* Last settings */
app.setQuitOnLastWindowClosed( false );
/* Retrieve last known path used in file browsing */
p_intf->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 )
......@@ -817,12 +813,6 @@ static void *ThreadCleanup( qt_intf_t *p_intf, bool error )
*/
DialogsProvider::killInstance();
/* Save the path or delete if recent play are disabled */
if( var_InheritBool( p_intf, "qt-recentplay" ) )
getSettings()->setValue( "filedialog-path", p_intf->filepath );
else
getSettings()->remove( "filedialog-path" );
/* Destroy the main playlist controller */
delete p_intf->p_mainPlaylistController;
/* Destroy the main InputManager */
......
......@@ -93,8 +93,6 @@ struct qt_intf_t
class MainInterface *p_mi; /* Main Interface, NULL if DialogProvider Mode */
class QSettings *mainSettings; /* Qt State settings not messing main VLC ones */
QUrl filepath; /* Last path used in dialogs */
unsigned voutWindowType; /* Type of vout_window_t provided */
bool b_isDialogProvider; /* Qt mode or Skins mode */
......
......@@ -478,7 +478,7 @@ void CoverArtLabel::setArtFromFile()
return;
QUrl fileUrl = QFileDialog::getOpenFileUrl( this, qtr( "Choose Cover Art" ),
p_intf->filepath, qtr( "Image Files (*.gif *.jpg *.jpeg *.png)" ) );
p_intf->p_mi->getDialogFilePath(), qtr( "Image Files (*.gif *.jpg *.jpeg *.png)" ) );
if( fileUrl.isEmpty() )
return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment