diff --git a/OptionsDialog.ui b/OptionsDialog.ui index b8b4c90..c9297f3 100755 --- a/OptionsDialog.ui +++ b/OptionsDialog.ui @@ -164,13 +164,6 @@ - - - - &Apply - - - diff --git a/SavegameWidget.cpp b/SavegameWidget.cpp index c29e0d6..7e43436 100755 --- a/SavegameWidget.cpp +++ b/SavegameWidget.cpp @@ -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) diff --git a/SavegameWidget.h b/SavegameWidget.h index bc931a7..b3003fb 100755 --- a/SavegameWidget.h +++ b/SavegameWidget.h @@ -25,6 +25,7 @@ #include #include #include +#include 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; diff --git a/SnapmaticWidget.cpp b/SnapmaticWidget.cpp index 0adee1d..0175562 100755 --- a/SnapmaticWidget.cpp +++ b/SnapmaticWidget.cpp @@ -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) diff --git a/SnapmaticWidget.h b/SnapmaticWidget.h index b628de3..a469ccd 100755 --- a/SnapmaticWidget.h +++ b/SnapmaticWidget.h @@ -27,6 +27,7 @@ #include #include #include +#include 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;