Remember last open directory as start point
This commit is contained in:
+16
-25
@@ -23,9 +23,7 @@
|
||||
|
||||
int MainWindow::socketPair[2] = {0, 0};
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),
|
||||
loading(false),
|
||||
queued(0)
|
||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
||||
{
|
||||
qRegisterMetaType<ImageInfoData>("ImageInfoData");
|
||||
|
||||
@@ -112,6 +110,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),
|
||||
QSettings settings;
|
||||
restoreGeometry(settings.value("mainwindow/geometry").toByteArray());
|
||||
restoreState(settings.value("mainwindow/state").toByteArray());
|
||||
|
||||
QStringList standardLocations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
|
||||
if(standardLocations.size())
|
||||
_lastDir = standardLocations.first();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@@ -120,24 +122,17 @@ MainWindow::~MainWindow()
|
||||
|
||||
void MainWindow::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if(!loading)
|
||||
{
|
||||
switch (event->key())
|
||||
{
|
||||
case Qt::Key_Left:
|
||||
m_ringList->decrement();
|
||||
break;
|
||||
case Qt::Key_Right:
|
||||
m_ringList->increment();
|
||||
break;
|
||||
default:
|
||||
event->ignore();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
switch (event->key())
|
||||
{
|
||||
case Qt::Key_Left:
|
||||
m_ringList->decrement();
|
||||
break;
|
||||
case Qt::Key_Right:
|
||||
m_ringList->increment();
|
||||
break;
|
||||
default:
|
||||
event->ignore();
|
||||
break;
|
||||
}
|
||||
|
||||
if(event->isAccepted())
|
||||
@@ -199,17 +194,13 @@ void MainWindow::pixmapLoaded(QPixmap pix)
|
||||
|
||||
void MainWindow::openFile()
|
||||
{
|
||||
QStringList standardLocations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
|
||||
QString path;
|
||||
if(standardLocations.size())
|
||||
path = standardLocations.first();
|
||||
|
||||
QString file = QFileDialog::getOpenFileName(this, tr("Open file"), path, tr("Images (*.jpg *.png *.cr2 *.fit *.fits *.JPG *.PNG *.CR2 *.FIT *.FITS)"));
|
||||
QString file = QFileDialog::getOpenFileName(this, tr("Open file"), _lastDir, tr("Images (*.jpg *.png *.cr2 *.fit *.fits *.JPG *.PNG *.CR2 *.FIT *.FITS)"));
|
||||
if(!file.isEmpty())
|
||||
{
|
||||
QFileInfo info(file);
|
||||
m_ringList->setFile(info.canonicalFilePath());
|
||||
updateWindowTitle();
|
||||
_lastDir = QFileInfo(file).absoluteDir().absolutePath();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user