diff --git a/PictureDialog.cpp b/PictureDialog.cpp index c42b42f..865a86c 100755 --- a/PictureDialog.cpp +++ b/PictureDialog.cpp @@ -52,6 +52,8 @@ PictureDialog::PictureDialog(ProfileDatabase *profileDB, QWidget *parent) : jsonDrawString = ui->labJSON->text(); ui->cmdExport->setEnabled(0); plyrsList = QStringList(); + fullscreenWidget = 0; + rqfullscreen = 0; indexed = 0; picArea = ""; picTitl = ""; @@ -110,7 +112,7 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev) break; #endif case Qt::Key_Enter: case Qt::Key_Return: - on_labPicture_mouseDoubleClicked(); + on_labPicture_mouseDoubleClicked(Qt::LeftButton); returnValue = true; break; } @@ -119,9 +121,20 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev) return returnValue; } +void PictureDialog::exportCustomContextMenuRequestedPrivate(const QPoint &pos, bool fullscreen) +{ + rqfullscreen = fullscreen; + exportMenu->exec(pos); +} + +void PictureDialog::exportCustomContextMenuRequested(const QPoint &pos) +{ + exportCustomContextMenuRequestedPrivate(pos, true); +} + void PictureDialog::mousePressEvent(QMouseEvent *ev) { - ev->accept(); + QDialog::mousePressEvent(ev); } void PictureDialog::dialogNextPictureRequested() @@ -264,33 +277,56 @@ void PictureDialog::playerNameUpdated() void PictureDialog::exportSnapmaticPicture() { - PictureExport::exportPicture(this, smpic); + if (rqfullscreen && fullscreenWidget != 0) + { + PictureExport::exportPicture(fullscreenWidget, smpic); + } + else + { + PictureExport::exportPicture(this, smpic); + } } void PictureDialog::copySnapmaticPicture() { - PictureCopy::copyPicture(this, picPath); + if (rqfullscreen && fullscreenWidget != 0) + { + PictureCopy::copyPicture(fullscreenWidget, picPath); + } + else + { + PictureCopy::copyPicture(this, picPath); + } } -void PictureDialog::on_labPicture_mouseDoubleClicked() +void PictureDialog::on_labPicture_mouseDoubleClicked(Qt::MouseButton button) { - QRect desktopRect = QApplication::desktop()->screenGeometry(); - PictureWidget *pictureWidget = new PictureWidget(this); - pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::WindowContextHelpButtonHint); - pictureWidget->setWindowTitle(this->windowTitle()); - pictureWidget->setStyleSheet("background-color: black;"); - pictureWidget->setImage(snapmaticPicture, desktopRect); - pictureWidget->setModal(true); + if (button == Qt::LeftButton) + { + QRect desktopRect = QApplication::desktop()->screenGeometry(); + PictureWidget *pictureWidget = new PictureWidget(this); + pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::WindowContextHelpButtonHint); + pictureWidget->setWindowTitle(this->windowTitle()); + pictureWidget->setStyleSheet("QLabel#pictureLabel{background-color: black;}"); + pictureWidget->setImage(snapmaticPicture, desktopRect); + pictureWidget->setModal(true); - QObject::connect(this, SIGNAL(newPictureCommited(QImage)), pictureWidget, SLOT(setImage(QImage))); - QObject::connect(pictureWidget, SIGNAL(nextPictureRequested()), this, SLOT(dialogNextPictureRequested())); - QObject::connect(pictureWidget, SIGNAL(previousPictureRequested()), this, SLOT(dialogPreviousPictureRequested())); + fullscreenWidget = pictureWidget; + QObject::connect(this, SIGNAL(newPictureCommited(QImage)), pictureWidget, SLOT(setImage(QImage))); + QObject::connect(pictureWidget, SIGNAL(nextPictureRequested()), this, SLOT(dialogNextPictureRequested())); + QObject::connect(pictureWidget, SIGNAL(previousPictureRequested()), this, SLOT(dialogPreviousPictureRequested())); - pictureWidget->showFullScreen(); - pictureWidget->setFocus(); - pictureWidget->exec(); + pictureWidget->showFullScreen(); + pictureWidget->setFocus(); + pictureWidget->exec(); - delete pictureWidget; + delete pictureWidget; + } +} + +void PictureDialog::on_labPicture_customContextMenuRequested(const QPoint &pos) +{ + exportCustomContextMenuRequestedPrivate(ui->labPicture->mapToGlobal(pos), false); } bool PictureDialog::isIndexed() diff --git a/PictureDialog.h b/PictureDialog.h index 313f655..faa4ace 100755 --- a/PictureDialog.h +++ b/PictureDialog.h @@ -50,11 +50,14 @@ public slots: void playerNameUpdated(); void dialogNextPictureRequested(); void dialogPreviousPictureRequested(); + void exportCustomContextMenuRequested(const QPoint &pos); private slots: void copySnapmaticPicture(); void exportSnapmaticPicture(); - void on_labPicture_mouseDoubleClicked(); + void on_labPicture_mouseDoubleClicked(Qt::MouseButton button); + void on_labPicture_customContextMenuRequested(const QPoint &pos); + void exportCustomContextMenuRequestedPrivate(const QPoint &pos, bool fullscreen); signals: void nextPictureRequested(); @@ -70,6 +73,7 @@ private: Ui::PictureDialog *ui; QMap globalMap; SnapmaticPicture *smpic; + QWidget *fullscreenWidget; QImage snapmaticPicture; QString jsonDrawString; QString windowTitleStr; @@ -82,6 +86,7 @@ private: QString locX; QString locY; QString locZ; + bool rqfullscreen; bool indexed; int index; QMenu *exportMenu; diff --git a/PictureDialog.ui b/PictureDialog.ui index c30ca27..cfe5345 100755 --- a/PictureDialog.ui +++ b/PictureDialog.ui @@ -34,6 +34,9 @@ 1 + + Qt::CustomContextMenu + diff --git a/PictureWidget.cpp b/PictureWidget.cpp index 04d9ba1..a36045d 100644 --- a/PictureWidget.cpp +++ b/PictureWidget.cpp @@ -16,6 +16,7 @@ * along with this program. If not, see . *****************************************************************************/ +#include "PictureDialog.h" #include "PictureWidget.h" #include "UiModLabel.h" #include @@ -32,11 +33,14 @@ PictureWidget::PictureWidget(QWidget *parent) : QDialog(parent) widgetLayout->setContentsMargins(0, 0, 0, 0); pictureLabel = new UiModLabel(this); + pictureLabel->setObjectName("pictureLabel"); pictureLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + pictureLabel->setContextMenuPolicy(Qt::CustomContextMenu); pictureLabel->setAlignment(Qt::AlignCenter); widgetLayout->addWidget(pictureLabel); - QObject::connect(pictureLabel, SIGNAL(mouseDoubleClicked()), this, SLOT(close())); + QObject::connect(pictureLabel, SIGNAL(mouseDoubleClicked(Qt::MouseButton)), this, SLOT(pictureDoubleClicked(Qt::MouseButton))); + QObject::connect(pictureLabel, SIGNAL(customContextMenuRequested(QPoint)), parent, SLOT(exportCustomContextMenuRequested(QPoint))); setLayout(widgetLayout); } @@ -68,6 +72,14 @@ bool PictureWidget::eventFilter(QObject *obj, QEvent *ev) return false; } +void PictureWidget::pictureDoubleClicked(Qt::MouseButton button) +{ + if (button == Qt::LeftButton) + { + close(); + } +} + void PictureWidget::setImage(QImage image, QRect rec) { pictureLabel->setPixmap(QPixmap::fromImage(image.scaled(rec.width(), rec.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation))); diff --git a/PictureWidget.h b/PictureWidget.h index 2fd76b1..3ed3c36 100644 --- a/PictureWidget.h +++ b/PictureWidget.h @@ -43,6 +43,9 @@ private: QHBoxLayout *widgetLayout; UiModLabel *pictureLabel; +private slots: + void pictureDoubleClicked(Qt::MouseButton button); + signals: void nextPictureRequested(); void previousPictureRequested(); diff --git a/uimod/UiModLabel.cpp b/uimod/UiModLabel.cpp index d0fcfd0..15c9975 100755 --- a/uimod/UiModLabel.cpp +++ b/uimod/UiModLabel.cpp @@ -17,6 +17,7 @@ *****************************************************************************/ #include "UiModLabel.h" +#include UiModLabel::UiModLabel(const QString &text, QWidget *parent) : QLabel(parent) { @@ -45,17 +46,17 @@ void UiModLabel::mouseMoveEvent(QMouseEvent *ev) void UiModLabel::mousePressEvent(QMouseEvent *ev) { QLabel::mousePressEvent(ev); - emit mousePressed(); + emit mousePressed(ev->button()); } void UiModLabel::mouseReleaseEvent(QMouseEvent *ev) { QLabel::mouseReleaseEvent(ev); - emit mouseReleased(); + emit mouseReleased(ev->button()); } void UiModLabel::mouseDoubleClickEvent(QMouseEvent *ev) { QLabel::mouseDoubleClickEvent(ev); - emit mouseDoubleClicked(); + emit mouseDoubleClicked(ev->button()); } diff --git a/uimod/UiModLabel.h b/uimod/UiModLabel.h index 03f9fe0..dcbba4d 100755 --- a/uimod/UiModLabel.h +++ b/uimod/UiModLabel.h @@ -20,8 +20,8 @@ #define UIMODLABEL_H #include -#include #include +#include class UiModLabel : public QLabel { @@ -40,9 +40,9 @@ protected: signals: void mouseMoved(); - void mousePressed(); - void mouseReleased(); - void mouseDoubleClicked(); + void mousePressed(Qt::MouseButton button); + void mouseReleased(Qt::MouseButton button); + void mouseDoubleClicked(Qt::MouseButton button); }; #endif // UIMODLABEL_H