multiple hover glitch fix
This commit is contained in:
parent
373cdc1c2d
commit
19ff5b4d7b
5 changed files with 61 additions and 21 deletions
|
@ -164,13 +164,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="cmdApply">
|
|
||||||
<property name="text">
|
|
||||||
<string extracomment="OK, Cancel, Apply">&Apply</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -50,14 +50,15 @@ SavegameWidget::SavegameWidget(QWidget *parent) :
|
||||||
Q_UNUSED(exportSavegameStr)
|
Q_UNUSED(exportSavegameStr)
|
||||||
|
|
||||||
QPalette palette;
|
QPalette palette;
|
||||||
QColor highlightBackColor = palette.highlight().color();
|
highlightBackColor = palette.highlight().color();
|
||||||
QColor highlightTextColor = palette.highlightedText().color();
|
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())));
|
|
||||||
|
|
||||||
clkIssued = 0;
|
clkIssued = 0;
|
||||||
sgdPath = "";
|
sgdPath = "";
|
||||||
sgdStr = "";
|
sgdStr = "";
|
||||||
sgdata = 0;
|
sgdata = 0;
|
||||||
|
|
||||||
|
installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
SavegameWidget::~SavegameWidget()
|
SavegameWidget::~SavegameWidget()
|
||||||
|
@ -65,6 +66,24 @@ SavegameWidget::~SavegameWidget()
|
||||||
delete ui;
|
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)
|
void SavegameWidget::setSavegameData(SavegameData *savegame, QString savegamePath)
|
||||||
{
|
{
|
||||||
ui->labSavegameStr->setText(savegame->getSavegameStr());
|
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"), this, SLOT(savegameSelected()));
|
||||||
contextMenu.addAction(tr("Select &All"), this, SLOT(selectAllWidgets()), QKeySequence::fromString("Ctrl+S"));
|
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());
|
contextMenu.exec(ev->globalPos());
|
||||||
setStyleSheet(styleSheet()); // fix multi highlight bug
|
//ui->SavegameFrame->setStyleSheet("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SavegameWidget::on_cbSelected_stateChanged(int arg1)
|
void SavegameWidget::on_cbSelected_stateChanged(int arg1)
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QColor>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class SavegameWidget;
|
class SavegameWidget;
|
||||||
|
@ -55,6 +56,7 @@ private slots:
|
||||||
void deselectAllWidgets();
|
void deselectAllWidgets();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
bool eventFilter(QObject *obj, QEvent *ev);
|
||||||
void mouseDoubleClickEvent(QMouseEvent *ev);
|
void mouseDoubleClickEvent(QMouseEvent *ev);
|
||||||
void mouseReleaseEvent(QMouseEvent *ev);
|
void mouseReleaseEvent(QMouseEvent *ev);
|
||||||
void mousePressEvent(QMouseEvent *ev);
|
void mousePressEvent(QMouseEvent *ev);
|
||||||
|
@ -63,6 +65,8 @@ protected:
|
||||||
private:
|
private:
|
||||||
Ui::SavegameWidget *ui;
|
Ui::SavegameWidget *ui;
|
||||||
SavegameData *sgdata;
|
SavegameData *sgdata;
|
||||||
|
QColor highlightBackColor;
|
||||||
|
QColor highlightTextColor;
|
||||||
QString sgdPath;
|
QString sgdPath;
|
||||||
QString sgdStr;
|
QString sgdStr;
|
||||||
bool clkIssued;
|
bool clkIssued;
|
||||||
|
|
|
@ -42,14 +42,15 @@ SnapmaticWidget::SnapmaticWidget(ProfileDatabase *profileDB, DatabaseThread *thr
|
||||||
ui->cbSelected->setVisible(false);
|
ui->cbSelected->setVisible(false);
|
||||||
|
|
||||||
QPalette palette;
|
QPalette palette;
|
||||||
QColor highlightBackColor = palette.highlight().color();
|
highlightBackColor = palette.highlight().color();
|
||||||
QColor highlightTextColor = palette.highlightedText().color();
|
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())));
|
|
||||||
|
|
||||||
clkIssued = 0;
|
clkIssued = 0;
|
||||||
picPath = "";
|
picPath = "";
|
||||||
picStr = "";
|
picStr = "";
|
||||||
smpic = 0;
|
smpic = 0;
|
||||||
|
|
||||||
|
installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
SnapmaticWidget::~SnapmaticWidget()
|
SnapmaticWidget::~SnapmaticWidget()
|
||||||
|
@ -57,6 +58,24 @@ SnapmaticWidget::~SnapmaticWidget()
|
||||||
delete ui;
|
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)
|
void SnapmaticWidget::setSnapmaticPicture(SnapmaticPicture *picture, QString picturePath)
|
||||||
{
|
{
|
||||||
smpic = picture;
|
smpic = picture;
|
||||||
|
@ -148,11 +167,11 @@ void SnapmaticWidget::mouseDoubleClickEvent(QMouseEvent *ev)
|
||||||
{
|
{
|
||||||
QWidget::mouseDoubleClickEvent(ev);
|
QWidget::mouseDoubleClickEvent(ev);
|
||||||
|
|
||||||
// if (ev->button() == Qt::LeftButton)
|
// if (ev->button() == Qt::LeftButton)
|
||||||
// {
|
// {
|
||||||
// clkIssued = true;
|
// clkIssued = true;
|
||||||
// on_cmdView_clicked();
|
// on_cmdView_clicked();
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnapmaticWidget::changeCheckedState()
|
void SnapmaticWidget::changeCheckedState()
|
||||||
|
@ -196,8 +215,9 @@ void SnapmaticWidget::contextMenuEvent(QContextMenuEvent *ev)
|
||||||
contextMenu.addAction(tr("&Select"), this, SLOT(pictureSelected()));
|
contextMenu.addAction(tr("&Select"), this, SLOT(pictureSelected()));
|
||||||
contextMenu.addAction(tr("Select &All"), this, SLOT(selectAllWidgets()), QKeySequence::fromString("Ctrl+S"));
|
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());
|
contextMenu.exec(ev->globalPos());
|
||||||
setStyleSheet(styleSheet()); // fix multi highlight bug
|
//ui->SnapmaticFrame->setStyleSheet("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnapmaticWidget::on_cbSelected_stateChanged(int arg1)
|
void SnapmaticWidget::on_cbSelected_stateChanged(int arg1)
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QColor>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class SnapmaticWidget;
|
class SnapmaticWidget;
|
||||||
|
@ -58,6 +59,7 @@ private slots:
|
||||||
void deselectAllWidgets();
|
void deselectAllWidgets();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
bool eventFilter(QObject *obj, QEvent *ev);
|
||||||
void mouseDoubleClickEvent(QMouseEvent *ev);
|
void mouseDoubleClickEvent(QMouseEvent *ev);
|
||||||
void mouseReleaseEvent(QMouseEvent *ev);
|
void mouseReleaseEvent(QMouseEvent *ev);
|
||||||
void mousePressEvent(QMouseEvent *ev);
|
void mousePressEvent(QMouseEvent *ev);
|
||||||
|
@ -68,7 +70,8 @@ private:
|
||||||
DatabaseThread *threadDB;
|
DatabaseThread *threadDB;
|
||||||
Ui::SnapmaticWidget *ui;
|
Ui::SnapmaticWidget *ui;
|
||||||
SnapmaticPicture *smpic;
|
SnapmaticPicture *smpic;
|
||||||
QAction *actSelectPic;
|
QColor highlightBackColor;
|
||||||
|
QColor highlightTextColor;
|
||||||
QString picPath;
|
QString picPath;
|
||||||
QString picTitl;
|
QString picTitl;
|
||||||
QString picStr;
|
QString picStr;
|
||||||
|
|
Loading…
Reference in a new issue