From 44c6d38d9cb6a1f9d5b8e54dc26ad6168018c9a7 Mon Sep 17 00:00:00 2001 From: Rafael Date: Thu, 27 Oct 2016 08:59:08 +0200 Subject: [PATCH] Fixed export bug for hidden snapmatic when you have opened the file through the Explorer as example --- PictureDialog.cpp | 2 ++ SnapmaticPicture.cpp | 45 ++++++++++++++++++++++++++++++++++++++++---- SnapmaticPicture.h | 5 +++++ SnapmaticWidget.cpp | 38 ++++++++++++------------------------- SnapmaticWidget.h | 4 ++-- 5 files changed, 62 insertions(+), 32 deletions(-) diff --git a/PictureDialog.cpp b/PictureDialog.cpp index 02d481e..3cd6f10 100755 --- a/PictureDialog.cpp +++ b/PictureDialog.cpp @@ -301,10 +301,12 @@ void PictureDialog::copySnapmaticPicture() { if (rqfullscreen && fullscreenWidget) { + QMessageBox::information(fullscreenWidget, picPath, picPath); PictureCopy::copyPicture(fullscreenWidget, picPath); } else { + QMessageBox::information(this, picPath, picPath); PictureCopy::copyPicture(this, picPath); } } diff --git a/SnapmaticPicture.cpp b/SnapmaticPicture.cpp index 3fcd246..f444abe 100755 --- a/SnapmaticPicture.cpp +++ b/SnapmaticPicture.cpp @@ -79,10 +79,6 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_) QFile *picFile = new QFile(picFileName); QIODevice *picStream; - if (picFileName.right(7) == ".hidden") // for the hidden file system - { - picFileName.remove(picFileName.length() - 7, 7); - } if (!picFile->open(QFile::ReadOnly)) { @@ -484,3 +480,44 @@ QDateTime SnapmaticPicture::getCreatedDateTime() { return jsonCreatedDateTime; } + +// VISIBILITY + +bool SnapmaticPicture::isHidden() +{ + if (picFileName.right(7) == ".hidden") + { + return true; + } + return false; +} + +bool SnapmaticPicture::setPictureHidden() +{ + if (!isHidden()) + { + QString newPicFileName = QString(picFileName + ".hidden"); + if (QFile::rename(picFileName, newPicFileName)) + { + picFileName = newPicFileName; + return true; + } + return false; + } + return true; +} + +bool SnapmaticPicture::setPictureVisible() +{ + if (isHidden()) + { + QString newPicFileName = QString(picFileName).remove(picFileName.length() - 7, 7); + if (QFile::rename(picFileName, newPicFileName)) + { + picFileName = newPicFileName; + return true; + } + return false; + } + return true; +} diff --git a/SnapmaticPicture.h b/SnapmaticPicture.h index 41decd9..d64ac1e 100755 --- a/SnapmaticPicture.h +++ b/SnapmaticPicture.h @@ -57,6 +57,11 @@ public: double getLocationZ(); QStringList getPlayers(); + // VISIBILITY + bool isHidden(); + bool setPictureHidden(); + bool setPictureVisible(); + private: QString getSnapmaticPictureString(const QByteArray &snapmaticHeader); QString getSnapmaticJSONString(const QByteArray &jsonBytes); diff --git a/SnapmaticWidget.cpp b/SnapmaticWidget.cpp index e5858e4..a456325 100755 --- a/SnapmaticWidget.cpp +++ b/SnapmaticWidget.cpp @@ -261,48 +261,34 @@ void SnapmaticWidget::adjustTextColor() } } -bool SnapmaticWidget::makePictureVisible() +void SnapmaticWidget::makePictureHidden() { - if (isHidden()) - { - QString newPicPath = QString(picPath).remove(picPath.length() - 7, 7); - if (QFile::rename(picPath, newPicPath)) - { - picPath = newPicPath; - return true; - } - return false; - } - return true; + QString newPicPath = QString(picPath + ".hidden"); + picPath = newPicPath; } -bool SnapmaticWidget::makePictureHidden() +void SnapmaticWidget::makePictureVisible() { - if (!isHidden()) - { - QString newPicPath = QString(picPath + ".hidden"); - if (QFile::rename(picPath, newPicPath)) - { - picPath = newPicPath; - return true; - } - return false; - } - return true; + QString newPicPath = QString(picPath).remove(picPath.length() - 7, 7); + picPath = newPicPath; } void SnapmaticWidget::makePictureHiddenSlot() { - if (makePictureHidden()) + SnapmaticPicture *picture = (SnapmaticPicture*)smpic; + if (picture->setPictureHidden()) { + makePictureHidden(); adjustTextColor(); } } void SnapmaticWidget::makePictureVisibleSlot() { - if (makePictureVisible()) + SnapmaticPicture *picture = (SnapmaticPicture*)smpic; + if (picture->setPictureVisible()) { + makePictureVisible(); adjustTextColor(); } } diff --git a/SnapmaticWidget.h b/SnapmaticWidget.h index 7676a2b..728ea13 100755 --- a/SnapmaticWidget.h +++ b/SnapmaticWidget.h @@ -44,8 +44,6 @@ public: void setSnapmaticPicture(SnapmaticPicture *picture); void setSelectionMode(bool selectionMode); void setSelected(bool isSelected); - bool makePictureVisible(); - bool makePictureHidden(); SnapmaticPicture *getPicture(); QString getPicturePath(); QString getWidgetType(); @@ -74,6 +72,8 @@ protected: void mouseReleaseEvent(QMouseEvent *ev); void mousePressEvent(QMouseEvent *ev); void contextMenuEvent(QContextMenuEvent *ev); + void makePictureVisible(); + void makePictureHidden(); private: ProfileDatabase *profileDB;