Git commit 128393f1a9f7dfe2394540378e3ba47055a4a562 by Dmitry Kazakov. Committed on 26/07/2017 at 12:54. Pushed by dkazakov into branch 'kazakov/async-saving'. FEATURE: save lastly visited directory in the Reference Images docker Now the docker saves/restores the lastly visited reference folder over Krita restart. ** A question to painters ** Do you also need to restore the open reference images? Please take into account that at the moment the list of reference images is not per-painting, it is global, that is shared between all open images in Krita. CC:kimageshop@kde.org M +31 -2 plugins/dockers/imagedocker/imagedocker_dock.cpp M +4 -0 plugins/dockers/imagedocker/imagedocker_dock.h https://commits.kde.org/krita/128393f1a9f7dfe2394540378e3ba47055a4a562 diff --git a/plugins/dockers/imagedocker/imagedocker_dock.cpp b/plugins/doc= kers/imagedocker/imagedocker_dock.cpp index eebaceebf98..fd846ff51a8 100644 --- a/plugins/dockers/imagedocker/imagedocker_dock.cpp +++ b/plugins/dockers/imagedocker/imagedocker_dock.cpp @@ -15,6 +15,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-13= 01, USA. */ = +#include +#include +#include + #include "imagedocker_dock.h" #include "image_strip_scene.h" #include "image_view.h" @@ -224,8 +228,7 @@ ImageDockerDock::ImageDockerDock(): = connect(m_ui->cmbPath, SIGNAL(activated(const QString&)), SLOT(slotCha= ngeRoot(const QString&))); = - m_model->setRootPath(QDesktopServices::storageLocation(QDesktopService= s::PicturesLocation)); - m_ui->treeView->setRootIndex(m_proxyModel->mapFromSource(m_model->inde= x(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation)))); + loadConfigState(); = connect(m_ui->treeView , SIGNAL(doubleClicked(const QModelIn= dex&)) , SLOT(slotItemDoubleClicked(const QModelIndex&))); connect(m_ui->bnBack , SIGNAL(clicked(bool)) = , SLOT(slotBackButtonClicked())); @@ -249,6 +252,8 @@ ImageDockerDock::ImageDockerDock(): = ImageDockerDock::~ImageDockerDock() { + saveConfigState(); + delete m_proxyModel; delete m_model; delete m_imageStripScene; @@ -374,6 +379,30 @@ void ImageDockerDock::setZoom(const ImageInfo& info) m_popupUi->zoomSlider->blockSignals(false); } = +void ImageDockerDock::saveConfigState() +{ + const QString lastUsedDirectory =3D m_model->filePath(m_proxyModel->ma= pToSource(m_ui->treeView->rootIndex())); + + KConfigGroup cfg =3D KSharedConfig::openConfig()->group("referenceIma= geDocker"); + cfg.writeEntry("lastUsedDirectory", lastUsedDirectory); +} + +void ImageDockerDock::loadConfigState() +{ + const QString defaultLocation =3D QDesktopServices::storageLocation(QD= esktopServices::PicturesLocation); + + KConfigGroup cfg =3D KSharedConfig::openConfig()->group("referenceIma= geDocker"); + QString lastUsedDirectory =3D cfg.readEntry("lastUsedDirectory", defau= ltLocation); + + if (!QFileInfo(lastUsedDirectory).exists()) { + lastUsedDirectory =3D defaultLocation; + } + + m_model->setRootPath(lastUsedDirectory); + m_ui->treeView->setRootIndex(m_proxyModel->mapFromSource(m_model->inde= x(lastUsedDirectory))); + updatePath(lastUsedDirectory); +} + = // ------------ slots ------------------------------------------------- // = diff --git a/plugins/dockers/imagedocker/imagedocker_dock.h b/plugins/docke= rs/imagedocker/imagedocker_dock.h index c5df038db21..c02f7cfd09a 100644 --- a/plugins/dockers/imagedocker/imagedocker_dock.h +++ b/plugins/dockers/imagedocker/imagedocker_dock.h @@ -93,6 +93,10 @@ private: bool isImageLoaded() const { return m_currImageID !=3D -1; } void setZoom(const ImageInfo& info); = + void saveConfigState(); + void loadConfigState(); + + private: QFileSystemModel* m_model; QButtonGroup* m_zoomButtons;