Added tooltip for name label

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2023-06-15 11:40:39 +03:00
parent fcfb3d2df7
commit be0df38453
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318
4 changed files with 97 additions and 63 deletions

View File

@ -4,6 +4,7 @@
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org> * Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net> * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
* Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me> * Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
* Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

View File

@ -4,6 +4,7 @@
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org> * Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net> * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
* Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me> * Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me>
* Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -60,7 +61,7 @@ class ModFolderPage : public ExternalResourcesPage {
private slots: private slots:
void runningStateChanged(bool running); void runningStateChanged(bool running);
void removeItems(const QItemSelection &selection) override; void removeItems(const QItemSelection& selection) override;
void installMods(); void installMods();
void updateMods(); void updateMods();

View File

@ -1,37 +1,38 @@
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
/* /*
* PolyMC - Minecraft Launcher * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com> * Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
* * Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * This program is free software: you can redistribute it and/or modify
* the Free Software Foundation, version 3. * it under the terms of the GNU General Public License as published by
* * the Free Software Foundation, version 3.
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * This program is distributed in the hope that it will be useful,
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details. * 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 this program. If not, see <https://www.gnu.org/licenses/>. * You should have received a copy of the GNU General Public License
* * along with this program. If not, see <https://www.gnu.org/licenses/>.
* This file incorporates work covered by the following copyright and *
* permission notice: * This file incorporates work covered by the following copyright and
* * permission notice:
* Copyright 2013-2021 MultiMC Contributors *
* * Copyright 2013-2021 MultiMC Contributors
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. * Licensed under the Apache License, Version 2.0 (the "License");
* You may obtain a copy of the License at * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0 *
* * http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, * Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * distributed under the License is distributed on an "AS IS" BASIS,
* See the License for the specific language governing permissions and * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* limitations under the License. * See the License for the specific language governing permissions and
*/ * limitations under the License.
*/
#include <QMessageBox> #include <QMessageBox>
@ -57,34 +58,47 @@ InfoFrame::~InfoFrame()
void InfoFrame::updateWithMod(Mod const& m) void InfoFrame::updateWithMod(Mod const& m)
{ {
if (m.type() == ResourceType::FOLDER) if (m.type() == ResourceType::FOLDER) {
{
clear(); clear();
return; return;
} }
QString text = ""; QString text = "";
QString name = ""; QString name = "";
QString link = "";
QString toolTip = "";
if (m.name().isEmpty()) if (m.name().isEmpty())
name = m.internal_id(); name = m.internal_id();
else else
name = m.name(); name = m.name();
if (m.homeurl().isEmpty()) if (auto meta = m.metadata(); meta != nullptr) {
auto slug = meta->slug.remove(".pw.toml");
switch (meta->provider) {
case ModPlatform::ResourceProvider::MODRINTH:
link = QString("https://modrinth.com/mod/%1").arg(slug);
break;
case ModPlatform::ResourceProvider::FLAME:
link = QString("https://www.curseforge.com/minecraft/mc-mods/%1").arg(slug);
break;
}
} else if (!m.homeurl().isEmpty())
link = m.homeurl();
if (link.isEmpty())
text = name; text = name;
else else {
text = "<a href=\"" + m.homeurl() + "\">" + name + "</a>"; text = "<a href=\"" + link + "\">" + name + "</a>";
toolTip = tr("Go to mod's home page");
}
if (!m.authors().isEmpty()) if (!m.authors().isEmpty())
text += " by " + m.authors().join(", "); text += " by " + m.authors().join(", ");
setName(text); setName(text, toolTip);
if (m.description().isEmpty()) if (m.description().isEmpty()) {
{
setDescription(QString()); setDescription(QString());
} } else {
else
{
setDescription(m.description()); setDescription(m.description());
} }
@ -191,16 +205,15 @@ void InfoFrame::updateHiddenState()
} }
} }
void InfoFrame::setName(QString text) void InfoFrame::setName(QString text, QString toolTip)
{ {
if(text.isEmpty()) if (text.isEmpty()) {
{
ui->nameLabel->setHidden(true); ui->nameLabel->setHidden(true);
} ui->nameLabel->setToolTip({});
else } else {
{
ui->nameLabel->setText(text); ui->nameLabel->setText(text);
ui->nameLabel->setHidden(false); ui->nameLabel->setHidden(false);
ui->nameLabel->setToolTip(toolTip);
} }
updateHiddenState(); updateHiddenState();
} }

View File

@ -1,4 +1,24 @@
/* Copyright 2013-2021 MultiMC Contributors // SPDX-License-Identifier: GPL-3.0-only
/*
* Prism Launcher - Minecraft Launcher
* Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
*
* This program 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, version 3.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*
* This file incorporates work covered by the following copyright and
* permission notice:
*
* Copyright 2013-2021 MultiMC Contributors
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,8 +41,7 @@
#include "minecraft/mod/ResourcePack.h" #include "minecraft/mod/ResourcePack.h"
#include "minecraft/mod/TexturePack.h" #include "minecraft/mod/TexturePack.h"
namespace Ui namespace Ui {
{
class InfoFrame; class InfoFrame;
} }
@ -33,7 +52,7 @@ class InfoFrame : public QFrame {
InfoFrame(QWidget* parent = nullptr); InfoFrame(QWidget* parent = nullptr);
~InfoFrame() override; ~InfoFrame() override;
void setName(QString text = {}); void setName(QString text = {}, QString toolTip = {});
void setDescription(QString text = {}); void setDescription(QString text = {});
void setImage(QPixmap img = {}); void setImage(QPixmap img = {});