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