mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 00:42:14 -07:00
Open Decks on double click, not single click.
This commit is contained in:
parent
a0a7ca6a7b
commit
49bd825196
3 changed files with 23 additions and 2 deletions
|
|
@ -24,6 +24,7 @@
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QMouseEvent>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
|
|
@ -110,7 +111,6 @@ QStringList TabDeckStorageVisual::getBannerCardsForDecks()
|
||||||
|
|
||||||
void TabDeckStorageVisual::actOpenLocalDeck(QMouseEvent *event, DeckPreviewCardPictureWidget *instance)
|
void TabDeckStorageVisual::actOpenLocalDeck(QMouseEvent *event, DeckPreviewCardPictureWidget *instance)
|
||||||
{
|
{
|
||||||
qDebug() << event;
|
|
||||||
DeckLoader deckLoader;
|
DeckLoader deckLoader;
|
||||||
if (!deckLoader.loadFromFile(instance->filePath, DeckLoader::CockatriceFormat))
|
if (!deckLoader.loadFromFile(instance->filePath, DeckLoader::CockatriceFormat))
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#include "deck_preview_card_picture_widget.h"
|
#include "deck_preview_card_picture_widget.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
|
#include <QMouseEvent>
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
#include <QStylePainter>
|
#include <QStylePainter>
|
||||||
#include <QTextOption>
|
#include <QTextOption>
|
||||||
|
|
@ -24,11 +26,25 @@ DeckPreviewCardPictureWidget::DeckPreviewCardPictureWidget(QWidget *parent,
|
||||||
const Qt::Alignment alignment)
|
const Qt::Alignment alignment)
|
||||||
: CardInfoPictureWithTextOverlayWidget(parent, hoverToZoomEnabled, textColor, outlineColor, fontSize, alignment)
|
: CardInfoPictureWithTextOverlayWidget(parent, hoverToZoomEnabled, textColor, outlineColor, fontSize, alignment)
|
||||||
{
|
{
|
||||||
|
singleClickTimer = new QTimer(this);
|
||||||
|
singleClickTimer->setSingleShot(true);
|
||||||
|
connect(singleClickTimer, &QTimer::timeout, this, [this]() { qDebug() << "Clicked some stuff"; });
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckPreviewCardPictureWidget::mousePressEvent(QMouseEvent *event)
|
void DeckPreviewCardPictureWidget::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
emit imageClicked(event, this);
|
if (event->button() == Qt::LeftButton) {
|
||||||
|
lastMouseEvent = event;
|
||||||
|
singleClickTimer->start(QApplication::doubleClickInterval());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeckPreviewCardPictureWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (event->button() == Qt::LeftButton) {
|
||||||
|
singleClickTimer->stop(); // Prevent single-click logic
|
||||||
|
emit imageClicked(lastMouseEvent, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckPreviewCardPictureWidget::setFilePath(const QString &_filePath)
|
void DeckPreviewCardPictureWidget::setFilePath(const QString &_filePath)
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,13 @@ signals:
|
||||||
public slots:
|
public slots:
|
||||||
void setFilePath(const QString &filePath);
|
void setFilePath(const QString &filePath);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QTimer *singleClickTimer;
|
||||||
|
QMouseEvent *lastMouseEvent = nullptr; // Store the last mouse event
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent *event) override;
|
void mousePressEvent(QMouseEvent *event) override;
|
||||||
|
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DECK_PREVIEW_CARD_PICTURE_WIDGET_H
|
#endif // DECK_PREVIEW_CARD_PICTURE_WIDGET_H
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue