From 00f8cbff05c3f548baba59b0cb525205cc1d80e3 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Mon, 20 May 2019 17:38:17 -0400 Subject: expandable sections in the conflict tab --- src/modinfodialog.cpp | 65 ++++++++++++++- src/modinfodialog.h | 21 +++++ src/modinfodialog.ui | 218 +++++++++++++++++++++++++++++++++++--------------- 3 files changed, 237 insertions(+), 67 deletions(-) (limited to 'src') diff --git a/src/modinfodialog.cpp b/src/modinfodialog.cpp index 3c68f4e8..3f8b58a9 100644 --- a/src/modinfodialog.cpp +++ b/src/modinfodialog.cpp @@ -265,6 +265,61 @@ bool FileRenamer::renameFailed(const QString& oldName, const QString& newName) } +ExpanderWidget::ExpanderWidget() + : m_button(nullptr), m_content(nullptr) +{ +} + +ExpanderWidget::ExpanderWidget(QToolButton* button, QWidget* content) + : ExpanderWidget() +{ + set(button, content); +} + +void ExpanderWidget::set(QToolButton* button, QWidget* content, bool o) +{ + m_button = button; + m_content = content; + + m_button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + m_button->setCheckable(true); + + if (o) + open(); + else + close(); + + QObject::connect(m_button, &QToolButton::clicked, [&]{ toggle(); }); +} + +void ExpanderWidget::open() +{ + m_button->setArrowType(Qt::DownArrow); + m_button->setChecked(false); + m_content->show(); +} + +void ExpanderWidget::close() +{ + m_button->setArrowType(Qt::RightArrow); + m_button->setChecked(false); + m_content->hide(); +} + +void ExpanderWidget::toggle() +{ + if (opened()) + close(); + else + open(); +} + +bool ExpanderWidget::opened() const +{ + return m_content->isVisible(); +} + + ModInfoDialog::ModInfoDialog(ModInfo::Ptr modInfo, const DirectoryEntry *directory, bool unmanaged, OrganizerCore *organizerCore, PluginContainer *pluginContainer, QWidget *parent) : TutorableDialog("ModInfoDialog", parent), ui(new Ui::ModInfoDialog), m_ModInfo(modInfo), m_ThumbnailMapper(this), m_RequestStarted(false), @@ -378,6 +433,10 @@ ModInfoDialog::ModInfoDialog(ModInfo::Ptr modInfo, const DirectoryEntry *directo if (ui->tabWidget->currentIndex() == TAB_NEXUS) { activateNexusTab(); } + + m_overwriteExpander.set(ui->overwriteExpander, ui->overwriteTree, true); + m_overwrittenExpander.set(ui->overwrittenExpander, ui->overwrittenTree, true); + m_nonconflictExpander.set(ui->noConflictExpander, ui->noConflictTree); } @@ -501,7 +560,7 @@ void ModInfoDialog::refreshLists() ui->overwriteTree->clear(); ui->overwrittenTree->clear(); - ui->noconflictTree->clear(); + ui->noConflictTree->clear(); if (m_Origin != nullptr) { std::vector files = m_Origin->getFiles(); @@ -520,7 +579,7 @@ void ModInfoDialog::refreshLists() } altString << m_Directory->getOriginByID(altIter->first).getName(); } - QStringList fields(relativeName.prepend("...")); + QStringList fields(relativeName); fields.append(ToQString(altString.str())); QTreeWidgetItem *item = new QTreeWidgetItem(fields); @@ -544,7 +603,7 @@ void ModInfoDialog::refreshLists() font.setItalic(true); item->setFont(0, font); } - ui->noconflictTree->addTopLevelItem(item); + ui->noConflictTree->addTopLevelItem(item); ++numNonConflicting; } } else { diff --git a/src/modinfodialog.h b/src/modinfodialog.h index 66c50be5..731611d2 100644 --- a/src/modinfodialog.h +++ b/src/modinfodialog.h @@ -183,6 +183,25 @@ private: }; +class ExpanderWidget +{ +public: + ExpanderWidget(); + ExpanderWidget(QToolButton* button, QWidget* content); + + void set(QToolButton* button, QWidget* content, bool opened=false); + + void open(); + void close(); + void toggle(); + bool opened() const; + +private: + QToolButton* m_button; + QWidget* m_content; +}; + + /** * this is a larger dialog used to visualise information abount the mod. * @todo this would probably a good place for a plugin-system @@ -383,6 +402,8 @@ private: std::map m_RealTabPos; + ExpanderWidget m_overwriteExpander, m_overwrittenExpander, m_nonconflictExpander; + bool canHideConflictItem(const QTreeWidgetItem* item) const; bool canUnhideConflictItem(const QTreeWidgetItem* item) const; bool canPreviewConflictItem(const QTreeWidgetItem* item) const; diff --git a/src/modinfodialog.ui b/src/modinfodialog.ui index 25fce40c..0d96f621 100644 --- a/src/modinfodialog.ui +++ b/src/modinfodialog.ui @@ -400,28 +400,57 @@ Most mods do not have optional esps, so chances are good you are looking at an e Conflicts - + + + 0 + - + - - - The following conflicted files are provided by this mod - - - - - - - QFrame::Sunken - - - 1 - - - QLCDNumber::Flat - - + + + + + + 0 + 0 + + + + border: none + + + The following conflicted files are provided by this mod + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QFrame::Sunken + + + 1 + + + QLCDNumber::Flat + + + + @@ -470,23 +499,49 @@ Most mods do not have optional esps, so chances are good you are looking at an e - - - - - The following conflicted files are provided by other mods - - - + - - - QFrame::Sunken - - - QLCDNumber::Flat - - + + + + + + 0 + 0 + + + + border: none + + + The following conflicted files are provided by other mods + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QFrame::Sunken + + + QLCDNumber::Flat + + + + @@ -526,16 +581,38 @@ Most mods do not have optional esps, so chances are good you are looking at an e - + - + - + + + + 0 + 0 + + + + border: none; + - <html><head/><body><p>The following files have no conflicts</p></body></html> + The following files have no conflicts + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -548,32 +625,45 @@ Most mods do not have optional esps, so chances are good you are looking at an e - - - - Qt::CustomContextMenu - - - Qt::ElideLeft - - - true - - - true - - - 1 - - - - File - - - - + + + + Qt::CustomContextMenu + + + Qt::ElideLeft + + + true + + + true + + + 1 + + + + File + + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + -- cgit v1.3.1