Reimplement View Homepage
I removed it for some reason, but now it's back for all pages! Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
@@ -74,6 +74,7 @@ ExternalResourcesPage::ExternalResourcesPage(BaseInstance* instance, std::shared
|
||||
connect(ui->actionRemoveItem, &QAction::triggered, this, &ExternalResourcesPage::removeItem);
|
||||
connect(ui->actionEnableItem, &QAction::triggered, this, &ExternalResourcesPage::enableItem);
|
||||
connect(ui->actionDisableItem, &QAction::triggered, this, &ExternalResourcesPage::disableItem);
|
||||
connect(ui->actionViewHomepage, &QAction::triggered, this, &ExternalResourcesPage::viewHomepage);
|
||||
connect(ui->actionViewConfigs, &QAction::triggered, this, &ExternalResourcesPage::viewConfigs);
|
||||
connect(ui->actionViewFolder, &QAction::triggered, this, &ExternalResourcesPage::viewFolder);
|
||||
|
||||
@@ -301,6 +302,27 @@ void ExternalResourcesPage::disableItem()
|
||||
m_model->setResourceEnabled(selection.indexes(), EnableAction::DISABLE);
|
||||
}
|
||||
|
||||
void ExternalResourcesPage::viewHomepage()
|
||||
{
|
||||
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
|
||||
bool openedAny = false;
|
||||
for (auto resource : m_model->selectedResources(selection)) {
|
||||
auto url = resource->homepage();
|
||||
if (!url.isEmpty()) {
|
||||
DesktopServices::openUrl(url);
|
||||
openedAny = true;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: just disable button
|
||||
// just doing this for now to prevent race conditions which may be worse with implementation changes
|
||||
if (!openedAny) {
|
||||
CustomMessageBox::selectable(this, tr("No homepages found"), tr("None of the selected resources had an available homepage."),
|
||||
QMessageBox::Warning, QMessageBox::Ok, QMessageBox::Ok)
|
||||
->exec();
|
||||
}
|
||||
}
|
||||
|
||||
void ExternalResourcesPage::viewConfigs()
|
||||
{
|
||||
DesktopServices::openPath(m_instance->instanceConfigFolder(), true);
|
||||
@@ -314,16 +336,18 @@ void ExternalResourcesPage::viewFolder()
|
||||
void ExternalResourcesPage::updateActions()
|
||||
{
|
||||
const bool hasSelection = ui->treeView->selectionModel()->hasSelection();
|
||||
const QModelIndexList rows = ui->treeView->selectionModel()->selectedRows();
|
||||
|
||||
ui->actionUpdateItem->setEnabled(!m_model->empty());
|
||||
ui->actionResetItemMetadata->setEnabled(hasSelection);
|
||||
|
||||
const QModelIndexList rows = ui->treeView->selectionModel()->selectedRows();
|
||||
ui->actionChangeVersion->setEnabled(rows.count() == 1 && m_model->at(m_filterModel->mapToSource(rows[0]).row()).metadata() != nullptr);
|
||||
|
||||
ui->actionRemoveItem->setEnabled(hasSelection);
|
||||
ui->actionEnableItem->setEnabled(hasSelection);
|
||||
ui->actionDisableItem->setEnabled(hasSelection);
|
||||
|
||||
ui->actionViewHomepage->setEnabled(hasSelection);
|
||||
ui->actionExportMetadata->setEnabled(!m_model->empty());
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,8 @@ class ExternalResourcesPage : public QMainWindow, public BasePage {
|
||||
virtual void enableItem();
|
||||
virtual void disableItem();
|
||||
|
||||
virtual void viewHomepage();
|
||||
|
||||
virtual void viewFolder();
|
||||
virtual void viewConfigs();
|
||||
|
||||
|
||||
@@ -90,6 +90,8 @@
|
||||
<addaction name="actionRemoveItem"/>
|
||||
<addaction name="actionEnableItem"/>
|
||||
<addaction name="actionDisableItem"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionViewHomepage"/>
|
||||
<addaction name="actionViewConfigs"/>
|
||||
<addaction name="actionViewFolder"/>
|
||||
</widget>
|
||||
@@ -213,6 +215,17 @@
|
||||
<enum>QAction::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionViewHomepage">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>View Homepage</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>View the homepages of all selected items.</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
||||
@@ -107,11 +107,11 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel>
|
||||
connect(ui->actionChangeVersion, &QAction::triggered, this, &ModFolderPage::changeModVersion);
|
||||
ui->actionsToolbar->insertActionAfter(ui->actionUpdateItem, ui->actionChangeVersion);
|
||||
|
||||
ui->actionViewHomepage->setToolTip(tr("View the homepages of all selected mods."));
|
||||
|
||||
ui->actionExportMetadata->setToolTip(tr("Export mod's metadata to text."));
|
||||
connect(ui->actionExportMetadata, &QAction::triggered, this, &ModFolderPage::exportModMetadata);
|
||||
ui->actionsToolbar->insertActionAfter(ui->actionDisableItem, ui->actionExportMetadata);
|
||||
|
||||
ui->actionsToolbar->insertSeparator(ui->actionExportMetadata);
|
||||
ui->actionsToolbar->insertActionAfter(ui->actionViewHomepage, ui->actionExportMetadata);
|
||||
}
|
||||
|
||||
bool ModFolderPage::shouldDisplay() const
|
||||
|
||||
@@ -74,6 +74,7 @@ TexturePackPage::TexturePackPage(MinecraftInstance* instance, std::shared_ptr<Te
|
||||
connect(ui->actionChangeVersion, &QAction::triggered, this, &TexturePackPage::changeTexturePackVersion);
|
||||
ui->actionsToolbar->insertActionAfter(ui->actionUpdateItem, ui->actionChangeVersion);
|
||||
|
||||
ui->actionViewHomepage->setToolTip(tr("View the homepages of all selected texture packs."));
|
||||
}
|
||||
|
||||
void TexturePackPage::updateFrame(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
||||
|
||||
Reference in New Issue
Block a user