highlight hovered widgets at the ProfileInterface

1.3.x
Rafael 7 years ago
parent 50809e7a7c
commit 466f739b3a
  1. 54
      SavegameWidget.cpp
  2. 4
      SavegameWidget.h
  3. 135
      SavegameWidget.ui
  4. 35
      SnapmaticWidget.cpp
  5. 4
      SnapmaticWidget.h
  6. 177
      SnapmaticWidget.ui

@ -27,6 +27,10 @@
#include <QMessageBox>
#include <QSettings>
#include <QFileInfo>
#include <QPalette>
#include <QColor>
#include <QBrush>
#include <QTimer>
#include <QFile>
#include <QMenu>
#include <QUrl>
@ -40,6 +44,13 @@ SavegameWidget::SavegameWidget(QWidget *parent) :
ui->cmdView->setVisible(false);
ui->cmdDelete->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 = "";
sgdStr = "";
sgdata = 0;
@ -95,24 +106,53 @@ void SavegameWidget::on_cmdView_clicked()
delete savegameDialog;
}
void SavegameWidget::setChecked(bool isChecked)
{
ui->cbSelected->setChecked(isChecked);
}
void SavegameWidget::on_savegameSelected()
{
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::setChecked(bool isChecked)
{
ui->cbSelected->setChecked(isChecked);
}
void SavegameWidget::on_savegameSelected()
void SavegameWidget::changeCheckedState()
{
setChecked(true);
if (!clkIssued)
{
ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
}
}
void SavegameWidget::contextMenuEvent(QContextMenuEvent *ev)

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

@ -14,64 +14,91 @@
<string>Savegame Widget</string>
</property>
<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>
<widget class="QCheckBox" name="cbSelected">
<property name="text">
<string/>
<widget class="QFrame" name="SavegameFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</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 name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="autoDefault">
<bool>true</bool>
<property name="lineWidth">
<number>0</number>
</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>
</item>
</layout>

@ -25,6 +25,7 @@
#include "PictureCopy.h"
#include <QMessageBox>
#include <QPixmap>
#include <QTimer>
#include <QDebug>
#include <QMenu>
#include <QFile>
@ -39,6 +40,13 @@ SnapmaticWidget::SnapmaticWidget(ProfileDatabase *profileDB, DatabaseThread *thr
ui->cmdExport->setVisible(false);
ui->cmdDelete->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 = "";
picStr = "";
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)
{
QWidget::mouseDoubleClickEvent(ev);
if (ev->button() == Qt::LeftButton)
{
clkIssued = true;
on_cmdView_clicked();
}
}
void SnapmaticWidget::changeCheckedState()
{
if (!clkIssued)
{
ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
}
}
void SnapmaticWidget::setChecked(bool isChecked)
{
ui->cbSelected->setChecked(isChecked);

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

@ -13,87 +13,114 @@
<property name="windowTitle">
<string>Snapmatic Widget</string>
</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>
<widget class="QCheckBox" name="cbSelected">
<property name="text">
<string/>
<widget class="QFrame" name="SnapmaticFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
</widget>
</item>
<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 name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labPicStr">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>PHOTO - 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>
<property name="autoDefault">
<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>
<layout class="QHBoxLayout" name="hlSnapmatic">
<item>
<widget class="QCheckBox" name="cbSelected">
<property name="text">
<string/>
</property>
</widget>
</item>
<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 name="lineWidth">
<number>0</number>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labPicStr">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>PHOTO - 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>
<property name="autoDefault">
<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>
</item>
</layout>

Loading…
Cancel
Save