Fixed export bug for hidden snapmatic when you have opened the file

through the Explorer as example
This commit is contained in:
Rafael 2016-10-27 08:59:08 +02:00
parent f645863562
commit 44c6d38d9c
5 changed files with 62 additions and 32 deletions

View file

@ -301,10 +301,12 @@ void PictureDialog::copySnapmaticPicture()
{ {
if (rqfullscreen && fullscreenWidget) if (rqfullscreen && fullscreenWidget)
{ {
QMessageBox::information(fullscreenWidget, picPath, picPath);
PictureCopy::copyPicture(fullscreenWidget, picPath); PictureCopy::copyPicture(fullscreenWidget, picPath);
} }
else else
{ {
QMessageBox::information(this, picPath, picPath);
PictureCopy::copyPicture(this, picPath); PictureCopy::copyPicture(this, picPath);
} }
} }

View file

@ -79,10 +79,6 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_)
QFile *picFile = new QFile(picFileName); QFile *picFile = new QFile(picFileName);
QIODevice *picStream; QIODevice *picStream;
if (picFileName.right(7) == ".hidden") // for the hidden file system
{
picFileName.remove(picFileName.length() - 7, 7);
}
if (!picFile->open(QFile::ReadOnly)) if (!picFile->open(QFile::ReadOnly))
{ {
@ -484,3 +480,44 @@ QDateTime SnapmaticPicture::getCreatedDateTime()
{ {
return jsonCreatedDateTime; 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;
}

View file

@ -57,6 +57,11 @@ public:
double getLocationZ(); double getLocationZ();
QStringList getPlayers(); QStringList getPlayers();
// VISIBILITY
bool isHidden();
bool setPictureHidden();
bool setPictureVisible();
private: private:
QString getSnapmaticPictureString(const QByteArray &snapmaticHeader); QString getSnapmaticPictureString(const QByteArray &snapmaticHeader);
QString getSnapmaticJSONString(const QByteArray &jsonBytes); QString getSnapmaticJSONString(const QByteArray &jsonBytes);

View file

@ -261,48 +261,34 @@ void SnapmaticWidget::adjustTextColor()
} }
} }
bool SnapmaticWidget::makePictureVisible() void SnapmaticWidget::makePictureHidden()
{ {
if (isHidden()) QString newPicPath = QString(picPath + ".hidden");
{
QString newPicPath = QString(picPath).remove(picPath.length() - 7, 7);
if (QFile::rename(picPath, newPicPath))
{
picPath = newPicPath; picPath = newPicPath;
return true;
}
return false;
}
return true;
} }
bool SnapmaticWidget::makePictureHidden() void SnapmaticWidget::makePictureVisible()
{ {
if (!isHidden()) QString newPicPath = QString(picPath).remove(picPath.length() - 7, 7);
{
QString newPicPath = QString(picPath + ".hidden");
if (QFile::rename(picPath, newPicPath))
{
picPath = newPicPath; picPath = newPicPath;
return true;
}
return false;
}
return true;
} }
void SnapmaticWidget::makePictureHiddenSlot() void SnapmaticWidget::makePictureHiddenSlot()
{ {
if (makePictureHidden()) SnapmaticPicture *picture = (SnapmaticPicture*)smpic;
if (picture->setPictureHidden())
{ {
makePictureHidden();
adjustTextColor(); adjustTextColor();
} }
} }
void SnapmaticWidget::makePictureVisibleSlot() void SnapmaticWidget::makePictureVisibleSlot()
{ {
if (makePictureVisible()) SnapmaticPicture *picture = (SnapmaticPicture*)smpic;
if (picture->setPictureVisible())
{ {
makePictureVisible();
adjustTextColor(); adjustTextColor();
} }
} }

View file

@ -44,8 +44,6 @@ public:
void setSnapmaticPicture(SnapmaticPicture *picture); void setSnapmaticPicture(SnapmaticPicture *picture);
void setSelectionMode(bool selectionMode); void setSelectionMode(bool selectionMode);
void setSelected(bool isSelected); void setSelected(bool isSelected);
bool makePictureVisible();
bool makePictureHidden();
SnapmaticPicture *getPicture(); SnapmaticPicture *getPicture();
QString getPicturePath(); QString getPicturePath();
QString getWidgetType(); QString getWidgetType();
@ -74,6 +72,8 @@ protected:
void mouseReleaseEvent(QMouseEvent *ev); void mouseReleaseEvent(QMouseEvent *ev);
void mousePressEvent(QMouseEvent *ev); void mousePressEvent(QMouseEvent *ev);
void contextMenuEvent(QContextMenuEvent *ev); void contextMenuEvent(QContextMenuEvent *ev);
void makePictureVisible();
void makePictureHidden();
private: private:
ProfileDatabase *profileDB; ProfileDatabase *profileDB;