highlight hovered widgets at the ProfileInterface

This commit is contained in:
Rafael 2016-04-03 05:25:54 +02:00
parent 50809e7a7c
commit 466f739b3a
6 changed files with 275 additions and 138 deletions

View File

@ -27,6 +27,10 @@
#include <QMessageBox> #include <QMessageBox>
#include <QSettings> #include <QSettings>
#include <QFileInfo> #include <QFileInfo>
#include <QPalette>
#include <QColor>
#include <QBrush>
#include <QTimer>
#include <QFile> #include <QFile>
#include <QMenu> #include <QMenu>
#include <QUrl> #include <QUrl>
@ -40,6 +44,13 @@ SavegameWidget::SavegameWidget(QWidget *parent) :
ui->cmdView->setVisible(false); ui->cmdView->setVisible(false);
ui->cmdDelete->setVisible(false); ui->cmdDelete->setVisible(false);
ui->cbSelected->setVisible(false); ui->cbSelected->setVisible(false);
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())));
clkIssued = 0;
sgdPath = ""; sgdPath = "";
sgdStr = ""; sgdStr = "";
sgdata = 0; sgdata = 0;
@ -95,15 +106,6 @@ void SavegameWidget::on_cmdView_clicked()
delete savegameDialog; delete savegameDialog;
} }
void SavegameWidget::mouseDoubleClickEvent(QMouseEvent *ev)
{
QWidget::mouseDoubleClickEvent(ev);
if (ev->button() == Qt::LeftButton)
{
on_cmdView_clicked();
}
}
void SavegameWidget::setChecked(bool isChecked) void SavegameWidget::setChecked(bool isChecked)
{ {
@ -115,6 +117,44 @@ void SavegameWidget::on_savegameSelected()
setChecked(true); setChecked(true);
} }
void SavegameWidget::mousePressEvent(QMouseEvent *ev)
{
ProfileWidget::mouseReleaseEvent(ev);
clkIssued = true;
}
void SavegameWidget::mouseReleaseEvent(QMouseEvent *ev)
{
ProfileWidget::mouseReleaseEvent(ev);
if (ui->cbSelected->isVisible())
{
if (rect().contains(ev->pos()) && ev->button() == Qt::LeftButton)
{
clkIssued = false;
QTimer::singleShot(QApplication::doubleClickInterval(), this, SLOT(changeCheckedState()));
}
}
}
void SavegameWidget::mouseDoubleClickEvent(QMouseEvent *ev)
{
QWidget::mouseDoubleClickEvent(ev);
if (ev->button() == Qt::LeftButton)
{
clkIssued = true;
on_cmdView_clicked();
}
}
void SavegameWidget::changeCheckedState()
{
if (!clkIssued)
{
ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
}
}
void SavegameWidget::contextMenuEvent(QContextMenuEvent *ev) void SavegameWidget::contextMenuEvent(QContextMenuEvent *ev)
{ {
QMenu contextMenu(this); QMenu contextMenu(this);

View File

@ -48,9 +48,12 @@ private slots:
void on_cmdDelete_clicked(); void on_cmdDelete_clicked();
void on_savegameSelected(); void on_savegameSelected();
void on_cbSelected_stateChanged(int arg1); void on_cbSelected_stateChanged(int arg1);
void changeCheckedState();
protected: protected:
void mouseDoubleClickEvent(QMouseEvent *ev); void mouseDoubleClickEvent(QMouseEvent *ev);
void mouseReleaseEvent(QMouseEvent *ev);
void mousePressEvent(QMouseEvent *ev);
void contextMenuEvent(QContextMenuEvent *ev); void contextMenuEvent(QContextMenuEvent *ev);
private: private:
@ -58,6 +61,7 @@ private:
SavegameData *sgdata; SavegameData *sgdata;
QString sgdPath; QString sgdPath;
QString sgdStr; QString sgdStr;
bool clkIssued;
signals: signals:
void savegameDeleted(); void savegameDeleted();

View File

@ -14,64 +14,91 @@
<string>Savegame Widget</string> <string>Savegame Widget</string>
</property> </property>
<layout class="QHBoxLayout" name="hlSavegameContent"> <layout class="QHBoxLayout" name="hlSavegameContent">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item> <item>
<widget class="QCheckBox" name="cbSelected"> <widget class="QFrame" name="SavegameFrame">
<property name="text"> <property name="frameShape">
<string/> <enum>QFrame::NoFrame</enum>
</property> </property>
</widget> <property name="frameShadow">
</item> <enum>QFrame::Plain</enum>
<item>
<widget class="QLabel" name="labSavegamePic">
<property name="text">
<string/>
</property> </property>
<property name="pixmap"> <property name="lineWidth">
<pixmap resource="res/app.qrc">:/img/savegame.png</pixmap> <number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labSavegameStr">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>The Third Way (100%) - 00/00/00 00:00:00</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdView">
<property name="text">
<string>View</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdCopy">
<property name="text">
<string>Copy</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdDelete">
<property name="text">
<string>Delete</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property> </property>
<layout class="QHBoxLayout" name="hlSavegame">
<item>
<widget class="QCheckBox" name="cbSelected">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labSavegamePic">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="res/app.qrc">:/img/savegame.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labSavegameStr">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>The Third Way (100%) - 00/00/00 00:00:00</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdView">
<property name="text">
<string>View</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdCopy">
<property name="text">
<string>Copy</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdDelete">
<property name="text">
<string>Delete</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -25,6 +25,7 @@
#include "PictureCopy.h" #include "PictureCopy.h"
#include <QMessageBox> #include <QMessageBox>
#include <QPixmap> #include <QPixmap>
#include <QTimer>
#include <QDebug> #include <QDebug>
#include <QMenu> #include <QMenu>
#include <QFile> #include <QFile>
@ -39,6 +40,13 @@ SnapmaticWidget::SnapmaticWidget(ProfileDatabase *profileDB, DatabaseThread *thr
ui->cmdExport->setVisible(false); ui->cmdExport->setVisible(false);
ui->cmdDelete->setVisible(false); ui->cmdDelete->setVisible(false);
ui->cbSelected->setVisible(false); 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())));
clkIssued = 0;
picPath = ""; picPath = "";
picStr = ""; picStr = "";
smpic = 0; smpic = 0;
@ -108,16 +116,43 @@ void SnapmaticWidget::on_cmdDelete_clicked()
} }
} }
void SnapmaticWidget::mousePressEvent(QMouseEvent *ev)
{
ProfileWidget::mousePressEvent(ev);
}
void SnapmaticWidget::mouseReleaseEvent(QMouseEvent *ev)
{
ProfileWidget::mouseReleaseEvent(ev);
if (ui->cbSelected->isVisible())
{
if (rect().contains(ev->pos()) && ev->button() == Qt::LeftButton)
{
clkIssued = false;
QTimer::singleShot(QApplication::doubleClickInterval(), this, SLOT(changeCheckedState()));
}
}
}
void SnapmaticWidget::mouseDoubleClickEvent(QMouseEvent *ev) void SnapmaticWidget::mouseDoubleClickEvent(QMouseEvent *ev)
{ {
QWidget::mouseDoubleClickEvent(ev); QWidget::mouseDoubleClickEvent(ev);
if (ev->button() == Qt::LeftButton) if (ev->button() == Qt::LeftButton)
{ {
clkIssued = true;
on_cmdView_clicked(); on_cmdView_clicked();
} }
} }
void SnapmaticWidget::changeCheckedState()
{
if (!clkIssued)
{
ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
}
}
void SnapmaticWidget::setChecked(bool isChecked) void SnapmaticWidget::setChecked(bool isChecked)
{ {
ui->cbSelected->setChecked(isChecked); ui->cbSelected->setChecked(isChecked);

View File

@ -51,9 +51,12 @@ private slots:
void on_cmdDelete_clicked(); void on_cmdDelete_clicked();
void on_pictureSelected(); void on_pictureSelected();
void on_cbSelected_stateChanged(int arg1); void on_cbSelected_stateChanged(int arg1);
void changeCheckedState();
protected: protected:
void mouseDoubleClickEvent(QMouseEvent *ev); void mouseDoubleClickEvent(QMouseEvent *ev);
void mouseReleaseEvent(QMouseEvent *ev);
void mousePressEvent(QMouseEvent *ev);
void contextMenuEvent(QContextMenuEvent *ev); void contextMenuEvent(QContextMenuEvent *ev);
private: private:
@ -64,6 +67,7 @@ private:
QAction *actSelectPic; QAction *actSelectPic;
QString picPath; QString picPath;
QString picStr; QString picStr;
bool clkIssued;
signals: signals:
void pictureDeleted(); void pictureDeleted();

View File

@ -13,87 +13,114 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Snapmatic Widget</string> <string>Snapmatic Widget</string>
</property> </property>
<layout class="QHBoxLayout" name="hlSnapmaticWidget"> <layout class="QHBoxLayout" name="hlSnapmaticContent">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item> <item>
<widget class="QCheckBox" name="cbSelected"> <widget class="QFrame" name="SnapmaticFrame">
<property name="text"> <property name="frameShape">
<string/> <enum>QFrame::NoFrame</enum>
</property> </property>
</widget> <property name="frameShadow">
</item> <enum>QFrame::Plain</enum>
<item>
<widget class="QLabel" name="labPicture">
<property name="minimumSize">
<size>
<width>48</width>
<height>27</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>48</width>
<height>27</height>
</size>
</property> </property>
<property name="lineWidth"> <property name="lineWidth">
<number>0</number> <number>0</number>
</property> </property>
<property name="text"> <layout class="QHBoxLayout" name="hlSnapmatic">
<string/> <item>
</property> <widget class="QCheckBox" name="cbSelected">
<property name="scaledContents"> <property name="text">
<bool>true</bool> <string/>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="labPicStr"> <widget class="QLabel" name="labPicture">
<property name="sizePolicy"> <property name="minimumSize">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <size>
<horstretch>0</horstretch> <width>48</width>
<verstretch>0</verstretch> <height>27</height>
</sizepolicy> </size>
</property> </property>
<property name="text"> <property name="maximumSize">
<string>PHOTO - 00/00/00 00:00:00</string> <size>
</property> <width>48</width>
<property name="wordWrap"> <height>27</height>
<bool>true</bool> </size>
</property> </property>
</widget> <property name="lineWidth">
</item> <number>0</number>
<item> </property>
<widget class="QPushButton" name="cmdView"> <property name="text">
<property name="text"> <string/>
<string>View</string> </property>
</property> <property name="scaledContents">
<property name="autoDefault"> <bool>true</bool>
<bool>true</bool> </property>
</property> </widget>
</widget> </item>
</item> <item>
<item> <widget class="QLabel" name="labPicStr">
<widget class="QPushButton" name="cmdCopy"> <property name="sizePolicy">
<property name="text"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<string>Copy</string> <horstretch>0</horstretch>
</property> <verstretch>0</verstretch>
</widget> </sizepolicy>
</item> </property>
<item> <property name="text">
<widget class="QPushButton" name="cmdExport"> <string>PHOTO - 00/00/00 00:00:00</string>
<property name="text"> </property>
<string>Export</string> <property name="wordWrap">
</property> <bool>true</bool>
</widget> </property>
</item> </widget>
<item> </item>
<widget class="QPushButton" name="cmdDelete"> <item>
<property name="text"> <widget class="QPushButton" name="cmdView">
<string>Delete</string> <property name="text">
</property> <string>View</string>
<property name="autoDefault"> </property>
<bool>true</bool> <property name="autoDefault">
</property> <bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdCopy">
<property name="text">
<string>Copy</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdExport">
<property name="text">
<string>Export</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdDelete">
<property name="text">
<string>Delete</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>