From 6a4e52f9dc9e929f3404145702e8279eb19beae0 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Wed, 26 Dec 2018 10:59:18 -0600 Subject: Display counter tooltips when clicked --- src/CMakeLists.txt | 2 ++ src/lcdnumber.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/lcdnumber.h | 35 +++++++++++++++++++++++++++++++++++ src/mainwindow.ui | 9 +++++++-- src/organizer.pro | 6 ++++-- 5 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 src/lcdnumber.cpp create mode 100644 src/lcdnumber.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3f004ddc..a084bae0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -92,6 +92,7 @@ SET(organizer_SRCS eventfilter.cpp moshortcut.cpp listdialog.cpp + lcdnumber.cpp shared/windows_error.cpp shared/error_report.cpp @@ -187,6 +188,7 @@ SET(organizer_HDRS descriptionpage.h moshortcut.h listdialog.h + lcdnumber.h shared/windows_error.h shared/error_report.h diff --git a/src/lcdnumber.cpp b/src/lcdnumber.cpp new file mode 100644 index 00000000..3191b434 --- /dev/null +++ b/src/lcdnumber.cpp @@ -0,0 +1,37 @@ +/* +This file is part of Mod Organizer. + +Mod Organizer is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Mod Organizer is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Mod Organizer. If not, see . +*/ + +#include "lcdnumber.h" + +#include +#include + +LCDNumber::LCDNumber(QWidget *parent) + : QLCDNumber(parent) +{ +} + +void LCDNumber::mousePressEvent(QMouseEvent *event) +{ + m_toolTipPosition = mapToGlobal(event->pos()); + QTimer::singleShot(100, this, SLOT(showToolTip())); +} + +void LCDNumber::showToolTip() +{ + QToolTip::showText(m_toolTipPosition, toolTip()); +} diff --git a/src/lcdnumber.h b/src/lcdnumber.h new file mode 100644 index 00000000..2f8e0454 --- /dev/null +++ b/src/lcdnumber.h @@ -0,0 +1,35 @@ +/* +This file is part of Mod Organizer. + +Mod Organizer is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Mod Organizer is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Mod Organizer. If not, see . +*/ + +#include +#include +#include + +class LCDNumber : public QLCDNumber +{ + Q_OBJECT + +public: + LCDNumber(QWidget *parent = nullptr); + void mousePressEvent(QMouseEvent *event); + +public slots: + void showToolTip(); + +private: + QPoint m_toolTipPosition; +}; diff --git a/src/mainwindow.ui b/src/mainwindow.ui index f2b12037..b1ed8e5a 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -303,7 +303,7 @@ p, li { white-space: pre-wrap; } - + 0 @@ -924,7 +924,7 @@ p, li { white-space: pre-wrap; } - + 0 @@ -1678,6 +1678,11 @@ Right now this has very limited functionality QTreeView
pluginlistview.h
+ + LCDNumber + QLCDNumber +
lcdnumber.h
+
diff --git a/src/organizer.pro b/src/organizer.pro index 582fde9f..df42db40 100644 --- a/src/organizer.pro +++ b/src/organizer.pro @@ -92,7 +92,8 @@ SOURCES += \ modinfobackup.cpp \ modinfooverwrite.cpp \ modinfoforeign.cpp \ - listdialog.cpp + listdialog.cpp \ + lcdnumber.cpp HEADERS += \ @@ -169,7 +170,8 @@ HEADERS += \ modinfobackup.h \ modinfooverwrite.h \ modinfoforeign.h \ - listdialog.h + listdialog.h \ + lcdnumber.h FORMS += \ transfersavesdialog.ui \ -- cgit v1.3.1