Skip to content

Commit

Permalink
Start implementing extension info side.
Browse files Browse the repository at this point in the history
  • Loading branch information
Holt59 committed Aug 10, 2024
1 parent a2c6362 commit 29e3ade
Show file tree
Hide file tree
Showing 12 changed files with 397 additions and 267 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ set(MO2_CMAKE_DEPRECATED_UIBASE_INCLUDE ON)

project(organizer)

set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)

# if MO2_INSTALL_IS_BIN is set, this means that we should install directly into the
# installation prefix, without the bin/ subfolder, typically for a standalone build
# to update an existing install
Expand Down
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ mo2_add_filter(NAME src/categories GROUPS

mo2_add_filter(NAME src/core GROUPS
archivefiletree
githubpp
github
inibakery
installationmanager
nexusinterface
Expand Down Expand Up @@ -308,6 +308,7 @@ mo2_add_filter(NAME src/settingsdialog GROUPS
settingsdialogpaths
settingsdialogextensions
settingsdialogextensionrow
settingsdialogextensioninfo
settingsdialogworkarounds
settingsdialogmodlist
settingsdialogtheme
Expand Down
5 changes: 2 additions & 3 deletions src/extensionmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ void ExtensionManager::loadExtensions(fs::path const& directory)
continue;
}

log::debug("extension correctly loaded from '{}': {}, {}",
entry.path().native(), extension->metadata().identifier(),
extension->metadata().type());
log::debug("extension data loaded from '{}': {}, {}", entry.path().native(),
extension->metadata().identifier(), extension->metadata().type());

triggerWatchers(*extension);
m_extensions.push_back(std::move(extension));
Expand Down
211 changes: 112 additions & 99 deletions src/organizer_en.ts

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1345,32 +1345,32 @@ void PluginSettings::registerPlugin(IPlugin* plugin)
m_PluginSettings.insert(plugin->name(), QVariantMap());
m_PluginDescriptions.insert(plugin->name(), QVariantMap());

for (const PluginSetting& setting : plugin->settings()) {
const QString settingName = plugin->name() + "/" + setting.key;
for (const auto& setting : plugin->settings()) {
const auto settingPath = plugin->name() + "/" + setting.name();

QVariant temp = get<QVariant>(m_Settings, "Plugins", settingName, QVariant());
QVariant temp = get<QVariant>(m_Settings, "Plugins", settingPath, QVariant());

// No previous enabled? Skip.
if (setting.key == "enabled" && (!temp.isValid() || !temp.canConvert<bool>())) {
if (setting.name() == "enabled" && (!temp.isValid() || !temp.canConvert<bool>())) {
continue;
}

if (!temp.isValid()) {
temp = setting.defaultValue;
} else if (!temp.convert(setting.defaultValue.type())) {
temp = setting.defaultValue();
} else if (!temp.convert(setting.defaultValue().metaType())) {
log::warn("failed to interpret \"{}\" as correct type for \"{}\" in plugin "
"\"{}\", using default",
temp.toString(), setting.key, plugin->name());
temp.toString(), setting.name(), plugin->name());

temp = setting.defaultValue;
temp = setting.defaultValue();
}

m_PluginSettings[plugin->name()][setting.key] = temp;
m_PluginSettings[plugin->name()][setting.name()] = temp;

m_PluginDescriptions[plugin->name()][setting.key] =
m_PluginDescriptions[plugin->name()][setting.name()] =
QString("%1 (default: %2)")
.arg(setting.description)
.arg(setting.defaultValue.toString());
.arg(setting.description())
.arg(setting.defaultValue().toString());
}

// Handle previous "enabled" settings:
Expand Down
156 changes: 17 additions & 139 deletions src/settingsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>820</width>
<height>592</height>
<height>607</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -17,7 +17,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>5</number>
</property>
<widget class="QWidget" name="generalTab">
<attribute name="title">
Expand All @@ -44,8 +44,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>761</width>
<height>550</height>
<width>766</width>
<height>611</height>
</rect>
</property>
<property name="autoFillBackground">
Expand Down Expand Up @@ -1052,8 +1052,8 @@ If you disable this feature, MO will only display official DLCs this way. Please
<rect>
<x>0</x>
<y>0</y>
<width>761</width>
<height>515</height>
<width>766</width>
<height>548</height>
</rect>
</property>
<property name="autoFillBackground">
Expand Down Expand Up @@ -1537,7 +1537,7 @@ If you disable this feature, MO will only display official DLCs this way. Please
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLineEdit" name="pluginFilterEdit">
<widget class="QLineEdit" name="extensionFilterEdit">
<property name="placeholderText">
<string/>
</property>
Expand All @@ -1547,8 +1547,8 @@ If you disable this feature, MO will only display official DLCs this way. Please
</item>
</layout>
</widget>
<widget class="QWidget" name="pluginWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_7" stretch="0,1,0">
<widget class="ExtensionListInfoWidget" name="infoWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_7" stretch="">
<property name="leftMargin">
<number>0</number>
</property>
Expand All @@ -1561,130 +1561,6 @@ If you disable this feature, MO will only display official DLCs this way. Please
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="pluginDescription" native="true">
<layout class="QFormLayout" name="pluginDescriptionLayout">
<property name="labelAlignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="leftMargin">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Author:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="authorLabel">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Version:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="versionLabel">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Description:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="descriptionLabel">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="enabledCheckbox">
<property name="text">
<string>Enabled</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QTreeWidget" name="pluginSettingsList">
<property name="indentation">
<number>0</number>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="itemsExpandable">
<bool>false</bool>
</property>
<property name="expandsOnDoubleClick">
<bool>false</bool>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>170</number>
</attribute>
<column>
<property name="text">
<string>Key</string>
</property>
</column>
<column>
<property name="text">
<string>Value</string>
</property>
</column>
</widget>
</item>
<item>
<widget class="QLabel" name="noPluginLabel">
<property name="text">
<string>No plugin found.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
Expand Down Expand Up @@ -1736,8 +1612,8 @@ If you disable this feature, MO will only display official DLCs this way. Please
<rect>
<x>0</x>
<y>0</y>
<width>778</width>
<height>475</height>
<width>780</width>
<height>489</height>
</rect>
</property>
<property name="autoFillBackground">
Expand Down Expand Up @@ -2035,9 +1911,6 @@ p, li { white-space: pre-wrap; }
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
Expand Down Expand Up @@ -2330,6 +2203,12 @@ programs you are intentionally running.</string>
<extends>QTableWidget</extends>
<header>colortable.h</header>
</customwidget>
<customwidget>
<class>ExtensionListInfoWidget</class>
<extends>QWidget</extends>
<header>settingsdialogextensioninfo.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>languageBox</tabstop>
Expand All @@ -2348,7 +2227,6 @@ programs you are intentionally running.</string>
<tabstop>browseOverwriteDirBtn</tabstop>
<tabstop>managedGameDirEdit</tabstop>
<tabstop>browseGameDirBtn</tabstop>
<tabstop>pluginSettingsList</tabstop>
<tabstop>lockGUIBox</tabstop>
</tabstops>
<resources>
Expand Down
48 changes: 48 additions & 0 deletions src/settingsdialogextensioninfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include "settingsdialogextensioninfo.h"

#include "ui_settingsdialogextensioninfo.h"

#include <format>

#include <uibase/formatters.h>

using namespace MOBase;

ExtensionListInfoWidget::ExtensionListInfoWidget(QWidget* parent)
: QWidget(parent), ui{new Ui::ExtensionListInfoWidget()}
{
ui->setupUi(this);

ui->authorLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
ui->authorLabel->setOpenExternalLinks(true);
}

void ExtensionListInfoWidget::setExtension(const IExtension& extension)
{
m_extension = &extension;

const auto& metadata = m_extension->metadata();
const auto& author = metadata.author();

if (author.homepage().isEmpty()) {
ui->authorLabel->setText(metadata.author().name());
} else {
ui->authorLabel->setText(QString::fromStdString(
std::format("<a href=\"{}\">{}</a>", author.homepage(), author.name())));
}
ui->descriptionLabel->setText(metadata.description());
ui->versionLabel->setText(metadata.version().string(Version::FormatCondensed));

if (metadata.type() == ExtensionType::THEME ||
metadata.type() == ExtensionType::TRANSLATION) {
ui->enabledCheckbox->setChecked(true);
ui->enabledCheckbox->setEnabled(false);
ui->enabledCheckbox->setToolTip(
tr("Translation and theme extensions cannot be disabled."));
} else {
// TODO:
// ui->enabledCheckbox->setChecked();
ui->enabledCheckbox->setEnabled(true);
ui->enabledCheckbox->setToolTip(QString());
}
}
29 changes: 29 additions & 0 deletions src/settingsdialogextensioninfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef SETTINGSDIALOGEXTENSIONINFO_H
#define SETTINGSDIALOGEXTENSIONINFO_H

#include <QWidget>

#include <uibase/extensions/extension.h>

namespace Ui
{
class ExtensionListInfoWidget;
}

class ExtensionListInfoWidget : public QWidget
{
public:
ExtensionListInfoWidget(QWidget* parent = nullptr);

// set the extension to display
//
void setExtension(const MOBase::IExtension& extension);

private:
Ui::ExtensionListInfoWidget* ui;

// currently displayed extension (default to nullptr)
const MOBase::IExtension* m_extension{nullptr};
};

#endif
Loading

0 comments on commit 29e3ade

Please sign in to comment.