aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/widgets
diff options
context:
space:
mode:
authorTrial97 <alexandru.tripon97@gmail.com>2023-06-25 11:36:37 +0300
committerTrial97 <alexandru.tripon97@gmail.com>2023-06-25 11:36:37 +0300
commit40fbae8ff684b6613ff073ec1992587b38dcdf8c (patch)
tree49566489cc3d0962418d543e050407dbbf4b5c47 /launcher/ui/widgets
parentce4a86fbcd0c891472b842e76066d285de3aef7b (diff)
downloadPrismLauncher-40fbae8ff684b6613ff073ec1992587b38dcdf8c.tar.gz
PrismLauncher-40fbae8ff684b6613ff073ec1992587b38dcdf8c.tar.bz2
PrismLauncher-40fbae8ff684b6613ff073ec1992587b38dcdf8c.zip
Fixed links tooltip
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Diffstat (limited to 'launcher/ui/widgets')
-rw-r--r--launcher/ui/widgets/InfoFrame.cpp36
-rw-r--r--launcher/ui/widgets/InfoFrame.h2
2 files changed, 24 insertions, 14 deletions
diff --git a/launcher/ui/widgets/InfoFrame.cpp b/launcher/ui/widgets/InfoFrame.cpp
index 57562a93..24349014 100644
--- a/launcher/ui/widgets/InfoFrame.cpp
+++ b/launcher/ui/widgets/InfoFrame.cpp
@@ -34,13 +34,24 @@
* limitations under the License.
*/
+#include <QLabel>
#include <QMessageBox>
+#include <QToolTip>
#include "InfoFrame.h"
#include "ui_InfoFrame.h"
#include "ui/dialogs/CustomMessageBox.h"
+void setupLinkTooTip(QLabel* label)
+{
+ QObject::connect(label, &QLabel::linkHovered, [label](const QString& link) {
+ if (!link.isEmpty() && !link.startsWith("http"))
+ return;
+ label->setToolTip(link);
+ });
+}
+
InfoFrame::InfoFrame(QWidget* parent) : QFrame(parent), ui(new Ui::InfoFrame)
{
ui->setupUi(this);
@@ -48,6 +59,12 @@ InfoFrame::InfoFrame(QWidget* parent) : QFrame(parent), ui(new Ui::InfoFrame)
ui->nameLabel->setHidden(true);
ui->licenseLabel->setHidden(true);
ui->issueTrackerLabel->setHidden(true);
+
+ setupLinkTooTip(ui->iconLabel);
+ setupLinkTooTip(ui->descriptionLabel);
+ setupLinkTooTip(ui->nameLabel);
+ setupLinkTooTip(ui->licenseLabel);
+ setupLinkTooTip(ui->issueTrackerLabel);
updateHiddenState();
}
@@ -66,7 +83,6 @@ void InfoFrame::updateWithMod(Mod const& m)
QString text = "";
QString name = "";
QString link = m.metaurl();
- QString toolTip = "";
if (m.name().isEmpty())
name = m.internal_id();
else
@@ -76,12 +92,11 @@ void InfoFrame::updateWithMod(Mod const& m)
text = name;
else {
text = "<a href=\"" + link + "\">" + name + "</a>";
- toolTip = link;
}
if (!m.authors().isEmpty())
text += " by " + m.authors().join(", ");
- setName(text, toolTip);
+ setName(text);
if (m.description().isEmpty()) {
setDescription(QString());
@@ -89,14 +104,14 @@ void InfoFrame::updateWithMod(Mod const& m)
setDescription(m.description());
}
- setImage(m.icon({64,64}));
+ setImage(m.icon({ 64, 64 }));
auto licenses = m.licenses();
QString licenseText = "";
if (!licenses.empty()) {
for (auto l : licenses) {
if (!licenseText.isEmpty()) {
- licenseText += "\n"; // add newline between licenses
+ licenseText += "\n"; // add newline between licenses
}
if (!l.name.isEmpty()) {
if (l.url.isEmpty()) {
@@ -226,29 +241,24 @@ void InfoFrame::updateHiddenState()
}
}
-void InfoFrame::setName(QString text, QString toolTip)
+void InfoFrame::setName(QString text)
{
if (text.isEmpty()) {
ui->nameLabel->setHidden(true);
- ui->nameLabel->setToolTip({});
} else {
ui->nameLabel->setText(text);
ui->nameLabel->setHidden(false);
- ui->nameLabel->setToolTip(toolTip);
}
updateHiddenState();
}
void InfoFrame::setDescription(QString text)
{
- if(text.isEmpty())
- {
+ if (text.isEmpty()) {
ui->descriptionLabel->setHidden(true);
updateHiddenState();
return;
- }
- else
- {
+ } else {
ui->descriptionLabel->setHidden(false);
updateHiddenState();
}
diff --git a/launcher/ui/widgets/InfoFrame.h b/launcher/ui/widgets/InfoFrame.h
index b8c7e9a0..d6764baa 100644
--- a/launcher/ui/widgets/InfoFrame.h
+++ b/launcher/ui/widgets/InfoFrame.h
@@ -52,7 +52,7 @@ class InfoFrame : public QFrame {
InfoFrame(QWidget* parent = nullptr);
~InfoFrame() override;
- void setName(QString text = {}, QString toolTip = {});
+ void setName(QString text = {});
void setDescription(QString text = {});
void setImage(QPixmap img = {});
void setLicense(QString text = {});