fix: should clear gallery when paste image

This commit is contained in:
Gary Wang 2020-02-22 17:09:36 +08:00
parent f49ed645fc
commit 6b0e4b6767
2 changed files with 13 additions and 2 deletions

View File

@ -113,6 +113,10 @@ MainWindow::MainWindow(QWidget *parent) :
connect(quitAppShorucut, &QShortcut::activated,
std::bind(&MainWindow::quitAppAction, this, false));
QShortcut * quitAppShorucut2 = new QShortcut(QKeySequence(Qt::Key_Escape), this);
connect(quitAppShorucut2, &QShortcut::activated,
std::bind(&MainWindow::quitAppAction, this, false));
QShortcut * prevPictureShorucut = new QShortcut(QKeySequence(Qt::Key_PageUp), this);
connect(prevPictureShorucut, &QShortcut::activated,
this, &MainWindow::galleryPrev);
@ -185,6 +189,12 @@ QUrl MainWindow::currentImageFileUrl() const
return QUrl();
}
void MainWindow::clearGallery()
{
m_currentFileIndex = -1;
m_files.clear();
}
void MainWindow::loadGalleryBySingleLocalFile(const QString &path)
{
QFileInfo info(path);
@ -198,8 +208,7 @@ void MainWindow::loadGalleryBySingleLocalFile(const QString &path)
std::sort(entryList.begin(), entryList.end(), collator);
m_currentFileIndex = -1;
m_files.clear();
clearGallery();
for (int i = 0; i < entryList.count(); i++) {
const QString & oneEntry = entryList.at(i);
@ -357,6 +366,7 @@ void MainWindow::contextMenuEvent(QContextMenuEvent *event)
QAction * pasteImage = new QAction(tr("&Paste Image"));
connect(pasteImage, &QAction::triggered, this, [ = ](){
clearGallery();
m_graphicsView->showImage(clipboardImage);
});

View File

@ -27,6 +27,7 @@ public:
void adjustWindowSizeBySceneRect();
QUrl currentImageFileUrl() const;
void clearGallery();
void loadGalleryBySingleLocalFile(const QString &path);
void galleryPrev();
void galleryNext();