cardInfoPopup fix; chatView fix
This commit is contained in:
parent
9f098f2a6d
commit
0120d2a019
13 changed files with 38 additions and 25 deletions
|
@ -26,6 +26,7 @@ AbstractCardItem::AbstractCardItem(const QString &_name, Player *_owner, QGraphi
|
|||
AbstractCardItem::~AbstractCardItem()
|
||||
{
|
||||
qDebug() << "AbstractCardItem destructor:" << name;
|
||||
emit deleteCardInfoPopup(name);
|
||||
}
|
||||
|
||||
QRectF AbstractCardItem::boundingRect() const
|
||||
|
@ -157,6 +158,10 @@ void AbstractCardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
|
|||
|
||||
void AbstractCardItem::setName(const QString &_name)
|
||||
{
|
||||
if (name == _name)
|
||||
return;
|
||||
|
||||
emit deleteCardInfoPopup(name);
|
||||
disconnect(info, 0, this, 0);
|
||||
name = _name;
|
||||
info = db->getCard(name);
|
||||
|
@ -213,7 +218,7 @@ void AbstractCardItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
void AbstractCardItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::MidButton)
|
||||
emit deleteCardInfoPopup();
|
||||
emit deleteCardInfoPopup(name);
|
||||
|
||||
// This function ensures the parent function doesn't mess around with our selection.
|
||||
event->accept();
|
||||
|
|
|
@ -30,7 +30,7 @@ private slots:
|
|||
signals:
|
||||
void hovered(AbstractCardItem *card);
|
||||
void showCardInfoPopup(QPoint pos, QString cardName);
|
||||
void deleteCardInfoPopup();
|
||||
void deleteCardInfoPopup(QString cardName);
|
||||
public:
|
||||
enum { Type = typeCard };
|
||||
int type() const { return Type; }
|
||||
|
@ -50,6 +50,7 @@ public:
|
|||
bool getTapped() const { return tapped; }
|
||||
void setTapped(bool _tapped, bool canAnimate = false);
|
||||
void processHoverEvent();
|
||||
void deleteCardInfoPopup() { emit deleteCardInfoPopup(name); }
|
||||
protected:
|
||||
QSizeF getTranslatedSize(QPainter *painter) const;
|
||||
void transformPainter(QPainter *painter, const QSizeF &translatedSize, int angle);
|
||||
|
|
|
@ -172,8 +172,7 @@ void CardInfoWidget::resizeEvent(QResizeEvent * /*event*/)
|
|||
}
|
||||
}
|
||||
|
||||
void CardInfoWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||
QString CardInfoWidget::getCardName() const
|
||||
{
|
||||
if ((event->button() == Qt::MidButton) && (mode == ModePopUp))
|
||||
emit mouseReleased();
|
||||
}
|
||||
return nameLabel2->text();
|
||||
}
|
|
@ -39,6 +39,7 @@ private:
|
|||
public:
|
||||
CardInfoWidget(ResizeMode _mode, QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||
void retranslateUi();
|
||||
QString getCardName() const;
|
||||
|
||||
public slots:
|
||||
void setCard(CardInfo *card);
|
||||
|
@ -50,12 +51,8 @@ private slots:
|
|||
void updatePixmap();
|
||||
void minimizeClicked(int newMinimized);
|
||||
|
||||
signals:
|
||||
void mouseReleased();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,7 +15,7 @@ ChatView::ChatView(const QString &_ownName, bool _showTimestamps, QWidget *paren
|
|||
connect(this, SIGNAL(anchorClicked(const QUrl &)), this, SLOT(openLink(const QUrl &)));
|
||||
}
|
||||
|
||||
void ChatView::appendMessage(QString sender, QString message)
|
||||
void ChatView::appendMessage(QString sender, QString message, QColor playerColor, bool playerBold)
|
||||
{
|
||||
QTextCursor cursor(document()->lastBlock());
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
|
@ -35,8 +35,14 @@ void ChatView::appendMessage(QString sender, QString message)
|
|||
if (sender == ownName) {
|
||||
senderFormat.setFontWeight(QFont::Bold);
|
||||
senderFormat.setForeground(Qt::red);
|
||||
} else
|
||||
senderFormat.setForeground(QColor(0, 0, 254));
|
||||
} else {
|
||||
if (playerColor == QColor())
|
||||
senderFormat.setForeground(QColor(0, 0, 254));
|
||||
else
|
||||
senderFormat.setForeground(playerColor);
|
||||
if (playerBold)
|
||||
senderFormat.setFontWeight(QFont::Bold);
|
||||
}
|
||||
cursor.setCharFormat(senderFormat);
|
||||
if (!sender.isEmpty())
|
||||
sender.append(": ");
|
||||
|
@ -156,7 +162,7 @@ void ChatView::mousePressEvent(QMouseEvent *event)
|
|||
void ChatView::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::MidButton)
|
||||
emit deleteCardInfoPopup();
|
||||
emit deleteCardInfoPopup(QString("_"));
|
||||
|
||||
QTextBrowser::mouseReleaseEvent(event);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QTextBrowser>
|
||||
#include <QTextFragment>
|
||||
#include <QColor>
|
||||
|
||||
class QTextTable;
|
||||
class QMouseEvent;
|
||||
|
@ -20,7 +21,7 @@ private slots:
|
|||
void openLink(const QUrl &link);
|
||||
public:
|
||||
ChatView(const QString &_ownName, bool _showTimestamps, QWidget *parent = 0);
|
||||
void appendMessage(QString sender, QString message);
|
||||
void appendMessage(QString sender, QString message, QColor playerColor = QColor(), bool playerBold = false);
|
||||
protected:
|
||||
void enterEvent(QEvent *event);
|
||||
void leaveEvent(QEvent *event);
|
||||
|
@ -30,7 +31,7 @@ protected:
|
|||
signals:
|
||||
void cardNameHovered(QString cardName);
|
||||
void showCardInfoPopup(QPoint pos, QString cardName);
|
||||
void deleteCardInfoPopup();
|
||||
void deleteCardInfoPopup(QString cardName);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -139,7 +139,7 @@ void MessageLogWidget::logConnectionStateChanged(Player *player, bool connection
|
|||
|
||||
void MessageLogWidget::logSay(Player *player, QString message)
|
||||
{
|
||||
appendMessage(player->getName(), message);
|
||||
appendMessage(player->getName(), message, QColor(), true);
|
||||
}
|
||||
|
||||
void MessageLogWidget::logSpectatorSay(QString spectatorName, QString message)
|
||||
|
|
|
@ -867,6 +867,8 @@ void Player::eventMoveCard(Event_MoveCard *event, GameEventContext *context)
|
|||
CardItem *card = startZone->takeCard(position, event->getCardId(), startZone != targetZone);
|
||||
if (!card)
|
||||
return;
|
||||
if (startZone != targetZone)
|
||||
card->deleteCardInfoPopup();
|
||||
card->setName(event->getCardName());
|
||||
|
||||
if (card->getAttachedTo() && (startZone != targetZone)) {
|
||||
|
|
|
@ -21,10 +21,12 @@ void Tab::showCardInfoPopup(const QPoint &pos, const QString &cardName)
|
|||
infoPopup->show();
|
||||
}
|
||||
|
||||
void Tab::deleteCardInfoPopup()
|
||||
void Tab::deleteCardInfoPopup(const QString &cardName)
|
||||
{
|
||||
if (infoPopup) {
|
||||
infoPopup->deleteLater();
|
||||
infoPopup = 0;
|
||||
if ((infoPopup->getCardName() == cardName) || (cardName == "_")) {
|
||||
infoPopup->deleteLater();
|
||||
infoPopup = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ protected:
|
|||
TabSupervisor *tabSupervisor;
|
||||
protected slots:
|
||||
void showCardInfoPopup(const QPoint &pos, const QString &cardName);
|
||||
void deleteCardInfoPopup();
|
||||
void deleteCardInfoPopup(const QString &cardName);
|
||||
private:
|
||||
bool contentsChanged;
|
||||
CardInfoWidget *infoPopup;
|
||||
|
|
|
@ -179,7 +179,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
|
|||
messageLog = new MessageLogWidget(_userName);
|
||||
connect(messageLog, SIGNAL(cardNameHovered(QString)), cardInfo, SLOT(setCard(QString)));
|
||||
connect(messageLog, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
|
||||
connect(messageLog, SIGNAL(deleteCardInfoPopup()), this, SLOT(deleteCardInfoPopup()));
|
||||
connect(messageLog, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
||||
sayLabel = new QLabel;
|
||||
sayEdit = new QLineEdit;
|
||||
sayLabel->setBuddy(sayEdit);
|
||||
|
@ -745,7 +745,7 @@ void TabGame::newCardAdded(AbstractCardItem *card)
|
|||
{
|
||||
connect(card, SIGNAL(hovered(AbstractCardItem *)), cardInfo, SLOT(setCard(AbstractCardItem *)));
|
||||
connect(card, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
|
||||
connect(card, SIGNAL(deleteCardInfoPopup()), this, SLOT(deleteCardInfoPopup()));
|
||||
connect(card, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
||||
}
|
||||
|
||||
CardItem *TabGame::getCard(int playerId, const QString &zoneName, int cardId) const
|
||||
|
|
|
@ -13,7 +13,7 @@ TabMessage::TabMessage(TabSupervisor *_tabSupervisor, AbstractClient *_client, c
|
|||
{
|
||||
chatView = new ChatView(_ownName, true);
|
||||
connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
|
||||
connect(chatView, SIGNAL(deleteCardInfoPopup()), this, SLOT(deleteCardInfoPopup()));
|
||||
connect(chatView, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
||||
sayEdit = new QLineEdit;
|
||||
connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(sendMessage()));
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, const Q
|
|||
|
||||
chatView = new ChatView(ownName, true);
|
||||
connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
|
||||
connect(chatView, SIGNAL(deleteCardInfoPopup()), this, SLOT(deleteCardInfoPopup()));
|
||||
connect(chatView, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
||||
sayLabel = new QLabel;
|
||||
sayEdit = new QLineEdit;
|
||||
sayLabel->setBuddy(sayEdit);
|
||||
|
|
Loading…
Reference in a new issue