minor stuff
This commit is contained in:
parent
763e707139
commit
806ae4d2b7
|
@ -113,7 +113,7 @@ namespace
|
||||||
{
|
{
|
||||||
case FileDialog:
|
case FileDialog:
|
||||||
{
|
{
|
||||||
auto file = qskDialog->selectFile( "select file", "." );
|
auto file = qskDialog->selectFile( "select file", QDir::currentPath() );
|
||||||
qDebug() << "selected file" << file;
|
qDebug() << "selected file" << file;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <qguiapplication.h>
|
#include <qguiapplication.h>
|
||||||
#include <qpointer.h>
|
#include <qpointer.h>
|
||||||
#include <qquickwindow.h>
|
#include <qquickwindow.h>
|
||||||
|
#include <qtimer.h>
|
||||||
|
|
||||||
#include <qpa/qplatformdialoghelper.h>
|
#include <qpa/qplatformdialoghelper.h>
|
||||||
|
|
||||||
|
@ -195,7 +196,7 @@ namespace
|
||||||
using Inherited = QskListView;
|
using Inherited = QskListView;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FileSystemView( const QString& directory, QDir::Filters filter, QQuickItem* parent = nullptr )
|
FileSystemView( const QString& directory, QDir::Filters filters, QQuickItem* parent = nullptr )
|
||||||
: QskListView( parent )
|
: QskListView( parent )
|
||||||
, m_model( new QFileSystemModel( this ) )
|
, m_model( new QFileSystemModel( this ) )
|
||||||
{
|
{
|
||||||
|
@ -208,7 +209,8 @@ namespace
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
|
|
||||||
m_model->setFilter( filter );
|
m_model->setFilter( filters );
|
||||||
|
m_model->setRootPath( {} ); // invalidate to make sure to get an update
|
||||||
m_model->setRootPath( directory );
|
m_model->setRootPath( directory );
|
||||||
|
|
||||||
m_columnWidths.fill( 0, m_model->columnCount() );
|
m_columnWidths.fill( 0, m_model->columnCount() );
|
||||||
|
@ -313,9 +315,10 @@ namespace
|
||||||
using Inherited = WindowOrSubWindow< W >;
|
using Inherited = WindowOrSubWindow< W >;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FileSelectionWindow( QObject* parent, const QString& title,
|
FileSelectionWindow( QObject* parent, const QString& title,
|
||||||
QskDialog::Actions actions, QskDialog::Action defaultAction,
|
QskDialog::Actions actions, QskDialog::Action defaultAction,
|
||||||
const QString& directory, QDir::Filters filter )
|
const QString& directory, QDir::Filters filters )
|
||||||
: WindowOrSubWindow< W >( parent, title, actions, defaultAction )
|
: WindowOrSubWindow< W >( parent, title, actions, defaultAction )
|
||||||
{
|
{
|
||||||
auto* outerBox = new QskLinearBox( Qt::Vertical );
|
auto* outerBox = new QskLinearBox( Qt::Vertical );
|
||||||
|
@ -325,7 +328,7 @@ namespace
|
||||||
outerBox->setFixedSize( 700, 500 );
|
outerBox->setFixedSize( 700, 500 );
|
||||||
#endif
|
#endif
|
||||||
setupHeader( outerBox );
|
setupHeader( outerBox );
|
||||||
setupFileSystemView( directory, filter, outerBox );
|
setupFileSystemView( directory, filters, outerBox );
|
||||||
|
|
||||||
updateHeader( directory );
|
updateHeader( directory );
|
||||||
|
|
||||||
|
@ -411,15 +414,33 @@ namespace
|
||||||
|
|
||||||
m_breadcrumbsButtons.remove( dirPaths.count(), m_breadcrumbsButtons.count() - dirPaths.count() );
|
m_breadcrumbsButtons.remove( dirPaths.count(), m_breadcrumbsButtons.count() - dirPaths.count() );
|
||||||
|
|
||||||
m_headerScrollArea->ensureItemVisible( m_breadcrumbsButtons.last() );
|
if( !m_breadcrumbsButtons.isEmpty() )
|
||||||
|
{
|
||||||
|
auto* b = m_breadcrumbsButtons.last();
|
||||||
|
|
||||||
|
// button might just have been created and not be layed out yet:
|
||||||
|
QObject::connect( b, &QskPushButton::widthChanged, this, [this, b]()
|
||||||
|
{
|
||||||
|
m_headerScrollArea->ensureItemVisible( b );
|
||||||
|
} );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupFileSystemView( const QString& directory, QDir::Filters filter, QQuickItem* parentItem )
|
void setupFileSystemView( const QString& directory, QDir::Filters filters, QQuickItem* parentItem )
|
||||||
{
|
{
|
||||||
m_fileView = new FileSystemView( directory, filter, parentItem );
|
m_fileView = new FileSystemView( directory, filters, parentItem );
|
||||||
|
|
||||||
QObject::connect( m_fileView->model(), &QFileSystemModel::rootPathChanged,
|
QObject::connect( m_fileView->model(), &QFileSystemModel::rootPathChanged,
|
||||||
this, &FileSelectionWindow< W >::updateHeader );
|
this, &FileSelectionWindow< W >::updateHeader );
|
||||||
|
|
||||||
|
QObject::connect( m_fileView, &QskListView::selectedRowChanged, this, [this]()
|
||||||
|
{
|
||||||
|
if( m_fileView->model()->filter() & QDir::Files )
|
||||||
|
{
|
||||||
|
QFileInfo fi( selectedPath() );
|
||||||
|
W::defaultButton()->setEnabled( !fi.isDir() );
|
||||||
|
}
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskScrollArea* m_headerScrollArea;
|
QskScrollArea* m_headerScrollArea;
|
||||||
|
@ -718,7 +739,7 @@ QString QskDialog::selectFile(
|
||||||
const auto defaultAction = QskDialog::Ok;
|
const auto defaultAction = QskDialog::Ok;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const auto flags = QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs;
|
const auto filters = QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs;
|
||||||
|
|
||||||
if ( m_data->policy == EmbeddedBox )
|
if ( m_data->policy == EmbeddedBox )
|
||||||
{
|
{
|
||||||
|
@ -730,13 +751,13 @@ QString QskDialog::selectFile(
|
||||||
if ( quickWindow )
|
if ( quickWindow )
|
||||||
{
|
{
|
||||||
FileSelectionWindow< QskDialogSubWindow > window( quickWindow, title,
|
FileSelectionWindow< QskDialogSubWindow > window( quickWindow, title,
|
||||||
actions, defaultAction, directory, flags );
|
actions, defaultAction, directory, filters );
|
||||||
return qskSelectPath< QskDialogSubWindow >( window );
|
return qskSelectPath< QskDialogSubWindow >( window );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSelectionWindow< QskDialogWindow > window( m_data->transientParent, title,
|
FileSelectionWindow< QskDialogWindow > window( m_data->transientParent, title,
|
||||||
actions, defaultAction, directory, flags );
|
actions, defaultAction, directory, filters );
|
||||||
return qskSelectPath< QskDialogWindow >( window );
|
return qskSelectPath< QskDialogWindow >( window );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -749,7 +770,7 @@ QString QskDialog::selectDirectory(
|
||||||
const auto defaultAction = QskDialog::Ok;
|
const auto defaultAction = QskDialog::Ok;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const auto flags = QDir::NoDotAndDotDot | QDir::AllDirs;
|
const auto filters = QDir::NoDotAndDotDot | QDir::AllDirs;
|
||||||
|
|
||||||
if ( m_data->policy == EmbeddedBox )
|
if ( m_data->policy == EmbeddedBox )
|
||||||
{
|
{
|
||||||
|
@ -761,13 +782,13 @@ QString QskDialog::selectDirectory(
|
||||||
if ( quickWindow )
|
if ( quickWindow )
|
||||||
{
|
{
|
||||||
FileSelectionWindow< QskDialogSubWindow > window( quickWindow, title,
|
FileSelectionWindow< QskDialogSubWindow > window( quickWindow, title,
|
||||||
actions, defaultAction, directory, flags );
|
actions, defaultAction, directory, filters );
|
||||||
return qskSelectPath< QskDialogSubWindow >( window );
|
return qskSelectPath< QskDialogSubWindow >( window );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSelectionWindow< QskDialogWindow > window( m_data->transientParent, title,
|
FileSelectionWindow< QskDialogWindow > window( m_data->transientParent, title,
|
||||||
actions, defaultAction, directory, flags );
|
actions, defaultAction, directory, filters );
|
||||||
return qskSelectPath< QskDialogWindow >( window );
|
return qskSelectPath< QskDialogWindow >( window );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue