@@ -128,7 +128,7 @@ static QWidget *createSelectableLineEditOptionHandle(QObject *opt)
128
128
129
129
option->connect (le, &DLineEdit::iconClicked, [=]() {
130
130
QString name = QFileDialog::getExistingDirectory (0 , QObject::tr (" Open folder" ),
131
- QDir::currentPath (),
131
+ MainWindow::lastOpenedPath (),
132
132
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
133
133
if (validate (name, false )) {
134
134
option->setValue (name);
@@ -1447,11 +1447,13 @@ void MainWindow::requestAction(ActionFactory::ActionKind kd, bool fromUI,
1447
1447
1448
1448
case ActionFactory::ActionKind::OpenDirectory: {
1449
1449
QString name = QFileDialog::getExistingDirectory (this , tr (" Open folder" ),
1450
- QDir::currentPath (),
1450
+ lastOpenedPath (),
1451
1451
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
1452
1452
1453
1453
QFileInfo fi (name);
1454
1454
if (fi.isDir () && fi.exists ()) {
1455
+ Settings::get ().setGeneralOption (" last_open_path" , fi.path ());
1456
+
1455
1457
const auto & urls = _engine->addPlayDir (name);
1456
1458
if (urls.size ()) {
1457
1459
_engine->playByName (QUrl (" playlist://0" ));
@@ -1462,12 +1464,17 @@ void MainWindow::requestAction(ActionFactory::ActionKind kd, bool fromUI,
1462
1464
1463
1465
case ActionFactory::ActionKind::OpenFileList: {
1464
1466
QStringList filenames = QFileDialog::getOpenFileNames (this , tr (" Open file" ),
1465
- QDir::currentPath (),
1467
+ lastOpenedPath (),
1466
1468
tr (" All videos (%1)" ).arg (_engine->video_filetypes .join (" " )), 0 ,
1467
1469
QFileDialog::HideNameFilterDetails);
1468
1470
1469
1471
QList<QUrl> urls;
1470
1472
if (filenames.size ()) {
1473
+ QFileInfo fileInfo (filenames[0 ]);
1474
+ if (fileInfo.exists ()) {
1475
+ Settings::get ().setGeneralOption (" last_open_path" , fileInfo.path ());
1476
+ }
1477
+
1471
1478
for (const auto & filename: filenames) {
1472
1479
urls.append (QUrl::fromLocalFile (filename));
1473
1480
}
@@ -1479,10 +1486,13 @@ void MainWindow::requestAction(ActionFactory::ActionKind kd, bool fromUI,
1479
1486
1480
1487
case ActionFactory::ActionKind::OpenFile: {
1481
1488
QString filename = QFileDialog::getOpenFileName (this , tr (" Open file" ),
1482
- QDir::currentPath (),
1489
+ lastOpenedPath (),
1483
1490
tr (" All videos (%1)" ).arg (_engine->video_filetypes .join (" " )), 0 ,
1484
1491
QFileDialog::HideNameFilterDetails);
1485
- if (QFileInfo (filename).exists ()) {
1492
+ QFileInfo fileInfo (filename);
1493
+ if (fileInfo.exists ()) {
1494
+ Settings::get ().setGeneralOption (" last_open_path" , fileInfo.path ());
1495
+
1486
1496
play (QUrl::fromLocalFile (filename));
1487
1497
}
1488
1498
break ;
@@ -1814,7 +1824,7 @@ void MainWindow::requestAction(ActionFactory::ActionKind kd, bool fromUI,
1814
1824
1815
1825
case ActionFactory::ActionKind::LoadSubtitle: {
1816
1826
QString filename = QFileDialog::getOpenFileName (this , tr (" Open file" ),
1817
- QDir::currentPath (),
1827
+ lastOpenedPath (),
1818
1828
tr (" Subtitle (*.ass *.aqt *.jss *.gsub *.ssf *.srt *.sub *.ssa *.smi *.usf *.idx)" ));
1819
1829
if (QFileInfo (filename).exists ()) {
1820
1830
auto success = _engine->loadSubtitle (QFileInfo (filename));
@@ -2568,6 +2578,21 @@ void MainWindow::prepareSplashImages()
2568
2578
bg_light = utils::LoadHiDPIImage (" :/resources/icons/light/init-splash.svg" );
2569
2579
}
2570
2580
2581
+ QString MainWindow::lastOpenedPath ()
2582
+ {
2583
+ QString lastPath = Settings::get ().generalOption (" last_open_path" ).toString ();
2584
+ QDir lastDir (lastPath);
2585
+ if (lastPath.isEmpty () || !lastDir.exists ()) {
2586
+ lastPath = QStandardPaths::writableLocation (QStandardPaths::MoviesLocation);
2587
+ QDir newLastDir (lastPath);
2588
+ if (!newLastDir.exists ()) {
2589
+ lastPath = QDir::currentPath ();
2590
+ }
2591
+ }
2592
+
2593
+ return lastPath;
2594
+ }
2595
+
2571
2596
void MainWindow::paintEvent (QPaintEvent* pe)
2572
2597
{
2573
2598
QPainter p (this );
0 commit comments