Commit b80cfdd9 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Don't load images if the reference images docker isn't visible

parent e0240f74
...@@ -48,6 +48,7 @@ void ImageLoader::run() ...@@ -48,6 +48,7 @@ void ImageLoader::run()
if (!img.isNull()) { if (!img.isNull()) {
data->image = img.scaled(m_size, m_size, Qt::KeepAspectRatio, Qt::SmoothTransformation); data->image = img.scaled(m_size, m_size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
} }
//qDebug() << "Loaded" << data->path;
data->isLoaded = true; data->isLoaded = true;
emit sigItemContentChanged(data.key()); emit sigItemContentChanged(data.key());
} }
...@@ -122,6 +123,7 @@ ImageStripScene::~ImageStripScene() ...@@ -122,6 +123,7 @@ ImageStripScene::~ImageStripScene()
bool ImageStripScene::setCurrentDirectory(const QString& path) bool ImageStripScene::setCurrentDirectory(const QString& path)
{ {
m_path = path;
QMutexLocker locker(&m_mutex); QMutexLocker locker(&m_mutex);
QDir directory(path); QDir directory(path);
QImageReader reader; QImageReader reader;
......
...@@ -102,7 +102,7 @@ public: ...@@ -102,7 +102,7 @@ public:
ImageStripScene(); ImageStripScene();
~ImageStripScene(); ~ImageStripScene();
bool setCurrentDirectory(const QString& path); bool setCurrentDirectory(const QString& path);
QString currentPath() { return m_path; }
Q_SIGNALS: Q_SIGNALS:
void sigImageActivated(const QString& path); void sigImageActivated(const QString& path);
...@@ -117,6 +117,7 @@ private: ...@@ -117,6 +117,7 @@ private:
quint32 m_numItems; quint32 m_numItems;
ImageLoader* m_loader; ImageLoader* m_loader;
QMutex m_mutex; QMutex m_mutex;
QString m_path;
}; };
#endif // H_IMAGE_STRIP_SCENE_H_ #endif // H_IMAGE_STRIP_SCENE_H_
...@@ -183,7 +183,7 @@ ImageDockerDock::ImageDockerDock(): ...@@ -183,7 +183,7 @@ ImageDockerDock::ImageDockerDock():
m_popupUi = new PopupWidgetUI(); m_popupUi = new PopupWidgetUI();
m_zoomButtons = new QButtonGroup(); m_zoomButtons = new QButtonGroup();
m_imgListModel = new ImageListModel(); m_imgListModel = new ImageListModel();
m_thumbModel = new ImageStripScene(); m_imageStripScene = new ImageStripScene();
m_model = new QFileSystemModel(); m_model = new QFileSystemModel();
m_proxyModel = new ImageFilter(); m_proxyModel = new ImageFilter();
m_proxyModel->setSourceModel(m_model); m_proxyModel->setSourceModel(m_model);
...@@ -195,7 +195,7 @@ ImageDockerDock::ImageDockerDock(): ...@@ -195,7 +195,7 @@ ImageDockerDock::ImageDockerDock():
m_ui->bnImgPrev->setIcon(koIcon("go-previous")); m_ui->bnImgPrev->setIcon(koIcon("go-previous"));
m_ui->bnImgNext->setIcon(koIcon("go-next")); m_ui->bnImgNext->setIcon(koIcon("go-next"));
m_ui->bnImgClose->setIcon(koIcon("window-close")); m_ui->bnImgClose->setIcon(koIcon("window-close"));
m_ui->thumbView->setScene(m_thumbModel); m_ui->thumbView->setScene(m_imageStripScene);
m_ui->treeView->setModel(m_proxyModel); m_ui->treeView->setModel(m_proxyModel);
m_ui->cmbImg->setModel(m_imgListModel); m_ui->cmbImg->setModel(m_imgListModel);
m_ui->bnPopup->setIcon(koIcon("zoom-original")); m_ui->bnPopup->setIcon(koIcon("zoom-original"));
...@@ -225,13 +225,12 @@ ImageDockerDock::ImageDockerDock(): ...@@ -225,13 +225,12 @@ ImageDockerDock::ImageDockerDock():
m_model->setRootPath(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation)); m_model->setRootPath(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation));
m_ui->treeView->setRootIndex(m_proxyModel->mapFromSource(m_model->index(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation)))); m_ui->treeView->setRootIndex(m_proxyModel->mapFromSource(m_model->index(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation))));
updatePath(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation));
connect(m_ui->treeView , SIGNAL(doubleClicked(const QModelIndex&)) , SLOT(slotItemDoubleClicked(const QModelIndex&))); connect(m_ui->treeView , SIGNAL(doubleClicked(const QModelIndex&)) , SLOT(slotItemDoubleClicked(const QModelIndex&)));
connect(m_ui->bnBack , SIGNAL(clicked(bool)) , SLOT(slotBackButtonClicked())); connect(m_ui->bnBack , SIGNAL(clicked(bool)) , SLOT(slotBackButtonClicked()));
connect(m_ui->bnHome , SIGNAL(clicked(bool)) , SLOT(slotHomeButtonClicked())); connect(m_ui->bnHome , SIGNAL(clicked(bool)) , SLOT(slotHomeButtonClicked()));
connect(m_ui->bnUp , SIGNAL(clicked(bool)) , SLOT(slotUpButtonClicked())); connect(m_ui->bnUp , SIGNAL(clicked(bool)) , SLOT(slotUpButtonClicked()));
connect(m_thumbModel , SIGNAL(sigImageActivated(const QString&)) , SLOT(slotOpenImage(QString))); connect(m_imageStripScene , SIGNAL(sigImageActivated(const QString&)) , SLOT(slotOpenImage(QString)));
connect(m_ui->bnImgNext , SIGNAL(clicked(bool)) , SLOT(slotNextImage())); connect(m_ui->bnImgNext , SIGNAL(clicked(bool)) , SLOT(slotNextImage()));
connect(m_ui->bnImgPrev , SIGNAL(clicked(bool)) , SLOT(slotPrevImage())); connect(m_ui->bnImgPrev , SIGNAL(clicked(bool)) , SLOT(slotPrevImage()));
connect(m_ui->bnImgClose , SIGNAL(clicked(bool)) , SLOT(slotCloseCurrentImage())); connect(m_ui->bnImgClose , SIGNAL(clicked(bool)) , SLOT(slotCloseCurrentImage()));
...@@ -251,7 +250,7 @@ ImageDockerDock::~ImageDockerDock() ...@@ -251,7 +250,7 @@ ImageDockerDock::~ImageDockerDock()
{ {
delete m_proxyModel; delete m_proxyModel;
delete m_model; delete m_model;
delete m_thumbModel; delete m_imageStripScene;
delete m_imgListModel; delete m_imgListModel;
delete m_zoomButtons; delete m_zoomButtons;
...@@ -298,6 +297,13 @@ void ImageDockerDock::dropEvent(QDropEvent *event) ...@@ -298,6 +297,13 @@ void ImageDockerDock::dropEvent(QDropEvent *event)
} }
} }
void ImageDockerDock::showEvent(QShowEvent *)
{
if (m_imageStripScene->currentPath().isNull()) {
updatePath(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation));
}
}
void ImageDockerDock::setCanvas(KoCanvasBase* canvas) void ImageDockerDock::setCanvas(KoCanvasBase* canvas)
{ {
// Intentionally not disabled if there's no canvas // Intentionally not disabled if there's no canvas
...@@ -317,7 +323,7 @@ void ImageDockerDock::addCurrentPathToHistory() ...@@ -317,7 +323,7 @@ void ImageDockerDock::addCurrentPathToHistory()
void ImageDockerDock::updatePath(const QString& path) void ImageDockerDock::updatePath(const QString& path)
{ {
m_ui->bnBack->setDisabled(m_history.empty()); m_ui->bnBack->setDisabled(m_history.empty());
m_thumbModel->setCurrentDirectory(path); m_imageStripScene->setCurrentDirectory(path);
} }
qint64 ImageDockerDock::generateImageID() const qint64 ImageDockerDock::generateImageID() const
......
...@@ -82,6 +82,7 @@ protected: ...@@ -82,6 +82,7 @@ protected:
void dragEnterEvent(QDragEnterEvent *event); void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event); void dropEvent(QDropEvent *event);
void showEvent(QShowEvent *);
private: private:
void addCurrentPathToHistory(); void addCurrentPathToHistory();
void updatePath(const QString& path); void updatePath(const QString& path);
...@@ -97,7 +98,7 @@ private: ...@@ -97,7 +98,7 @@ private:
ImageFilter* m_proxyModel; ImageFilter* m_proxyModel;
ImageListModel* m_imgListModel; ImageListModel* m_imgListModel;
QStringList m_history; QStringList m_history;
ImageStripScene* m_thumbModel; ImageStripScene* m_imageStripScene;
ImageDockerUI* m_ui; ImageDockerUI* m_ui;
PopupWidgetUI* m_popupUi; PopupWidgetUI* m_popupUi;
QMap<qint64,ImageInfo> m_imgInfoMap; QMap<qint64,ImageInfo> m_imgInfoMap;
......
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