diff --git a/src/drivers/Qt/TasEditor/TasEditorWindow.cpp b/src/drivers/Qt/TasEditor/TasEditorWindow.cpp index 807d0130..38634856 100644 --- a/src/drivers/Qt/TasEditor/TasEditorWindow.cpp +++ b/src/drivers/Qt/TasEditor/TasEditorWindow.cpp @@ -6484,7 +6484,6 @@ bookmarkPreviewPopup::bookmarkPreviewPopup( int index, QWidget *parent ) int p; QPoint pos; QVBoxLayout *vbox; - QLabel *imgLbl, *descLbl; uint32_t *pixBuf; uint32_t pixel; QPixmap pixmap; @@ -6632,6 +6631,11 @@ void bookmarkPreviewPopup::periodicUpdate(void) } } //---------------------------------------------------------------------------- +bookmarkPreviewPopup *bookmarkPreviewPopup::currentInstance(void) +{ + return instance; +} +//---------------------------------------------------------------------------- int bookmarkPreviewPopup::currentIndex(void) { if ( instance ) @@ -6645,12 +6649,12 @@ void bookmarkPreviewPopup::imageIndexChanged(int newIndex) { //printf("newIndex:%i\n", newIndex ); - actv = false; + actv = ( newIndex >= 0 ); - if ( instance == this ) - { - instance = NULL; - } + //if ( instance == this ) + //{ + // instance = NULL; + //} } //---------------------------------------------------------------------------- int bookmarkPreviewPopup::loadImage(int index) @@ -6670,6 +6674,54 @@ int bookmarkPreviewPopup::loadImage(int index) return ret; } //---------------------------------------------------------------------------- +int bookmarkPreviewPopup::reloadImage(int index) +{ + int p, ret = 0; + uint32_t *pixBuf; + uint32_t pixel; + QPixmap pixmap; + + actv = true; + imageIndex = index; + + // retrieve info from the pointed bookmark's Markers + int frame = bookmarks->bookmarksArray[index].snapshot.keyFrame; + int markerID = markersManager->getMarkerAboveFrame(bookmarks->bookmarksArray[index].snapshot.markers, frame); + + pixBuf = (uint32_t *)malloc( SCREENSHOT_SIZE * sizeof(uint32_t) ); + + loadImage(index); + + p=0; + for (int h=0; h> 16; + pixBuf[p] |= (pixel & 0x0000FF00); + p++; + } + } + QImage img( (unsigned char*)pixBuf, SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT, SCREENSHOT_WIDTH*4, QImage::Format_RGBA8888 ); + pixmap.convertFromImage( img ); + + if ( pixBuf ) + { + free( pixBuf ); pixBuf = NULL; + } + + imgLbl->setPixmap( pixmap ); + + descLbl->setText( tr(markersManager->getNoteCopy(bookmarks->bookmarksArray[index].snapshot.markers, markerID).c_str()) ); + + update(); + + return ret; +} +//---------------------------------------------------------------------------- //---- TAS Find Note Window //---------------------------------------------------------------------------- TasFindNoteWindow::TasFindNoteWindow( QWidget *parent ) diff --git a/src/drivers/Qt/TasEditor/TasEditorWindow.h b/src/drivers/Qt/TasEditor/TasEditorWindow.h index 652fdb2f..2f4886c4 100644 --- a/src/drivers/Qt/TasEditor/TasEditorWindow.h +++ b/src/drivers/Qt/TasEditor/TasEditorWindow.h @@ -121,16 +121,21 @@ class bookmarkPreviewPopup : public QDialog bookmarkPreviewPopup( int index, QWidget *parent = nullptr ); ~bookmarkPreviewPopup(void); + int reloadImage(int index); + static int currentIndex(void); + static bookmarkPreviewPopup *currentInstance(void); + private: - int loadImage(int index); + int loadImage(int index); int alpha; int imageIndex; bool actv; unsigned char *screenShotRaster; QTimer *timer; + QLabel *imgLbl, *descLbl; static bookmarkPreviewPopup *instance; diff --git a/src/drivers/Qt/TasEditor/bookmarks.cpp b/src/drivers/Qt/TasEditor/bookmarks.cpp index 721cb658..1e4510d0 100644 --- a/src/drivers/Qt/TasEditor/bookmarks.cpp +++ b/src/drivers/Qt/TasEditor/bookmarks.cpp @@ -811,11 +811,20 @@ void BOOKMARKS::showImage(void) if ( item_valid && (imageItem != bookmarkPreviewPopup::currentIndex()) ) { - bookmarkPreviewPopup *popup = new bookmarkPreviewPopup(imageItem, this); + bookmarkPreviewPopup *popup = bookmarkPreviewPopup::currentInstance(); - connect( this, SIGNAL(imageIndexChanged(int)), popup, SLOT(imageIndexChanged(int)) ); + if ( popup == NULL ) + { + popup = new bookmarkPreviewPopup(imageItem, this); - popup->show(); + connect( this, SIGNAL(imageIndexChanged(int)), popup, SLOT(imageIndexChanged(int)) ); + + popup->show(); + } + else + { + popup->reloadImage(imageItem); + } } } diff --git a/src/drivers/Qt/TasEditor/branches.cpp b/src/drivers/Qt/TasEditor/branches.cpp index 14691767..7989f876 100644 --- a/src/drivers/Qt/TasEditor/branches.cpp +++ b/src/drivers/Qt/TasEditor/branches.cpp @@ -597,11 +597,20 @@ void BRANCHES::showImage(void) if ( item_valid && (imageItem != bookmarkPreviewPopup::currentIndex()) ) { - bookmarkPreviewPopup *popup = new bookmarkPreviewPopup(imageItem, this); + bookmarkPreviewPopup *popup = bookmarkPreviewPopup::currentInstance(); - connect( this, SIGNAL(imageIndexChanged(int)), popup, SLOT(imageIndexChanged(int)) ); + if ( popup == NULL ) + { + popup = new bookmarkPreviewPopup(imageItem, this); - popup->show(); + connect( this, SIGNAL(imageIndexChanged(int)), popup, SLOT(imageIndexChanged(int)) ); + + popup->show(); + } + else + { + popup->reloadImage(imageItem); + } } }