multiple hover glitch fix

This commit is contained in:
Rafael 2016-04-12 18:29:52 +02:00
parent 373cdc1c2d
commit 19ff5b4d7b
5 changed files with 61 additions and 21 deletions

View file

@ -164,13 +164,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdApply">
<property name="text">
<string extracomment="OK, Cancel, Apply">&amp;Apply</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View file

@ -50,14 +50,15 @@ SavegameWidget::SavegameWidget(QWidget *parent) :
Q_UNUSED(exportSavegameStr)
QPalette palette;
QColor highlightBackColor = palette.highlight().color();
QColor highlightTextColor = palette.highlightedText().color();
setStyleSheet(QString("QFrame:hover#SavegameFrame{background-color: rgb(%1, %2, %3); color: rgb(%4, %5, %6)}").arg(QString::number(highlightBackColor.red()), QString::number(highlightBackColor.green()), QString::number(highlightBackColor.blue()), QString::number(highlightTextColor.red()), QString::number(highlightTextColor.green()), QString::number(highlightTextColor.blue())));
highlightBackColor = palette.highlight().color();
highlightTextColor = palette.highlightedText().color();
clkIssued = 0;
sgdPath = "";
sgdStr = "";
sgdata = 0;
installEventFilter(this);
}
SavegameWidget::~SavegameWidget()
@ -65,6 +66,24 @@ SavegameWidget::~SavegameWidget()
delete ui;
}
bool SavegameWidget::eventFilter(QObject *obj, QEvent *ev)
{
if (obj == this)
{
if (ev->type() == QEvent::Enter)
{
setStyleSheet(QString("QFrame#SavegameFrame{background-color: rgb(%1, %2, %3)}QLabel#labSavegameStr{color: rgb(%4, %5, %6)}").arg(QString::number(highlightBackColor.red()), QString::number(highlightBackColor.green()), QString::number(highlightBackColor.blue()), QString::number(highlightTextColor.red()), QString::number(highlightTextColor.green()), QString::number(highlightTextColor.blue())));
return true;
}
else if(ev->type() == QEvent::Leave)
{
setStyleSheet("");
return true;
}
}
return false;
}
void SavegameWidget::setSavegameData(SavegameData *savegame, QString savegamePath)
{
ui->labSavegameStr->setText(savegame->getSavegameStr());
@ -186,8 +205,9 @@ void SavegameWidget::contextMenuEvent(QContextMenuEvent *ev)
contextMenu.addAction(tr("&Select"), this, SLOT(savegameSelected()));
contextMenu.addAction(tr("Select &All"), this, SLOT(selectAllWidgets()), QKeySequence::fromString("Ctrl+S"));
}
//ui->SavegameFrame->setStyleSheet(QString("QFrame#SavegameFrame{background-color: rgb(%1, %2, %3)}QLabel#labSavegameStr{color: rgb(%4, %5, %6)}").arg(QString::number(highlightBackColor.red()), QString::number(highlightBackColor.green()), QString::number(highlightBackColor.blue()), QString::number(highlightTextColor.red()), QString::number(highlightTextColor.green()), QString::number(highlightTextColor.blue())));
contextMenu.exec(ev->globalPos());
setStyleSheet(styleSheet()); // fix multi highlight bug
//ui->SavegameFrame->setStyleSheet("");
}
void SavegameWidget::on_cbSelected_stateChanged(int arg1)

View file

@ -25,6 +25,7 @@
#include <QContextMenuEvent>
#include <QMouseEvent>
#include <QWidget>
#include <QColor>
namespace Ui {
class SavegameWidget;
@ -55,6 +56,7 @@ private slots:
void deselectAllWidgets();
protected:
bool eventFilter(QObject *obj, QEvent *ev);
void mouseDoubleClickEvent(QMouseEvent *ev);
void mouseReleaseEvent(QMouseEvent *ev);
void mousePressEvent(QMouseEvent *ev);
@ -63,6 +65,8 @@ protected:
private:
Ui::SavegameWidget *ui;
SavegameData *sgdata;
QColor highlightBackColor;
QColor highlightTextColor;
QString sgdPath;
QString sgdStr;
bool clkIssued;

View file

@ -42,14 +42,15 @@ SnapmaticWidget::SnapmaticWidget(ProfileDatabase *profileDB, DatabaseThread *thr
ui->cbSelected->setVisible(false);
QPalette palette;
QColor highlightBackColor = palette.highlight().color();
QColor highlightTextColor = palette.highlightedText().color();
setStyleSheet(QString("QFrame:hover#SnapmaticFrame{background-color: rgb(%1, %2, %3); color: rgb(%4, %5, %6)}").arg(QString::number(highlightBackColor.red()), QString::number(highlightBackColor.green()), QString::number(highlightBackColor.blue()), QString::number(highlightTextColor.red()), QString::number(highlightTextColor.green()), QString::number(highlightTextColor.blue())));
highlightBackColor = palette.highlight().color();
highlightTextColor = palette.highlightedText().color();
clkIssued = 0;
picPath = "";
picStr = "";
smpic = 0;
installEventFilter(this);
}
SnapmaticWidget::~SnapmaticWidget()
@ -57,6 +58,24 @@ SnapmaticWidget::~SnapmaticWidget()
delete ui;
}
bool SnapmaticWidget::eventFilter(QObject *obj, QEvent *ev)
{
if (obj == this)
{
if (ev->type() == QEvent::Enter)
{
setStyleSheet(QString("QFrame#SnapmaticFrame{background-color: rgb(%1, %2, %3)}QLabel#labPicStr{color: rgb(%4, %5, %6)}").arg(QString::number(highlightBackColor.red()), QString::number(highlightBackColor.green()), QString::number(highlightBackColor.blue()), QString::number(highlightTextColor.red()), QString::number(highlightTextColor.green()), QString::number(highlightTextColor.blue())));
return true;
}
else if(ev->type() == QEvent::Leave)
{
setStyleSheet("");
return true;
}
}
return false;
}
void SnapmaticWidget::setSnapmaticPicture(SnapmaticPicture *picture, QString picturePath)
{
smpic = picture;
@ -148,11 +167,11 @@ void SnapmaticWidget::mouseDoubleClickEvent(QMouseEvent *ev)
{
QWidget::mouseDoubleClickEvent(ev);
// if (ev->button() == Qt::LeftButton)
// {
// clkIssued = true;
// on_cmdView_clicked();
// }
// if (ev->button() == Qt::LeftButton)
// {
// clkIssued = true;
// on_cmdView_clicked();
// }
}
void SnapmaticWidget::changeCheckedState()
@ -196,8 +215,9 @@ void SnapmaticWidget::contextMenuEvent(QContextMenuEvent *ev)
contextMenu.addAction(tr("&Select"), this, SLOT(pictureSelected()));
contextMenu.addAction(tr("Select &All"), this, SLOT(selectAllWidgets()), QKeySequence::fromString("Ctrl+S"));
}
//ui->SnapmaticFrame->setStyleSheet(QString("QFrame#SnapmaticFrame{background-color: rgb(%1, %2, %3)}QLabel#labPicStr{color: rgb(%4, %5, %6)}").arg(QString::number(highlightBackColor.red()), QString::number(highlightBackColor.green()), QString::number(highlightBackColor.blue()), QString::number(highlightTextColor.red()), QString::number(highlightTextColor.green()), QString::number(highlightTextColor.blue())));
contextMenu.exec(ev->globalPos());
setStyleSheet(styleSheet()); // fix multi highlight bug
//ui->SnapmaticFrame->setStyleSheet("");
}
void SnapmaticWidget::on_cbSelected_stateChanged(int arg1)

View file

@ -27,6 +27,7 @@
#include <QContextMenuEvent>
#include <QMouseEvent>
#include <QWidget>
#include <QColor>
namespace Ui {
class SnapmaticWidget;
@ -58,6 +59,7 @@ private slots:
void deselectAllWidgets();
protected:
bool eventFilter(QObject *obj, QEvent *ev);
void mouseDoubleClickEvent(QMouseEvent *ev);
void mouseReleaseEvent(QMouseEvent *ev);
void mousePressEvent(QMouseEvent *ev);
@ -68,7 +70,8 @@ private:
DatabaseThread *threadDB;
Ui::SnapmaticWidget *ui;
SnapmaticPicture *smpic;
QAction *actSelectPic;
QColor highlightBackColor;
QColor highlightTextColor;
QString picPath;
QString picTitl;
QString picStr;