From 879059f8306d8d6546b7dd4bf43536b88907d7cd Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 26 Oct 2022 21:28:10 +0200 Subject: [PATCH] Package manager: show details only when enabling the 'show details' button --- src/lay/lay/SaltManagerDialog.ui | 130 +++++++++++++++++-- src/lay/lay/laySaltGrainDetailsTextWidget.cc | 64 +++++---- src/lay/lay/laySaltGrainDetailsTextWidget.h | 4 + 3 files changed, 161 insertions(+), 37 deletions(-) diff --git a/src/lay/lay/SaltManagerDialog.ui b/src/lay/lay/SaltManagerDialog.ui index de9b8baa4..18a5f2ea2 100644 --- a/src/lay/lay/SaltManagerDialog.ui +++ b/src/lay/lay/SaltManagerDialog.ui @@ -17,7 +17,7 @@ - 0 + 2 @@ -217,6 +217,12 @@ + + + 1 + 0 + + true @@ -227,6 +233,19 @@ + + + + + 0 + 0 + + + + More details + + + @@ -515,6 +534,12 @@ + + + 1 + 0 + + true @@ -525,6 +550,13 @@ + + + + More details + + + @@ -935,8 +967,21 @@ 0 + + + + true + + + + + + 1 + 0 + + true @@ -947,7 +992,7 @@ - + Edit Package Details @@ -964,10 +1009,10 @@ - - - - true + + + + More details @@ -1157,20 +1202,33 @@ lay::SaltGrainDetailsTextWidget QTextBrowser
laySaltGrainDetailsTextWidget.h
+ + show_detailed_view(bool) + mode_tab + mark_new_button + search_new_edit + salt_mine_view_new + detailed_view + toolButton + details_new_text + mark_update_button + search_update_edit + salt_mine_view_update + detailed_view2 + toolButton_2 + details_update_text search_installed_edit salt_view - details_text + detailed_view3 edit_button - search_new_edit - mark_new_button - salt_mine_view_new - details_new_text - toolButton + details_text + create_button apply_new_button + apply_update_button scrollArea @@ -1193,5 +1251,53 @@ + + detailed_view + clicked(bool) + details_new_text + show_detailed_view(bool) + + + 588 + 57 + + + 578 + 121 + + + + + detailed_view2 + clicked(bool) + details_update_text + show_detailed_view(bool) + + + 616 + 58 + + + 615 + 96 + + + + + detailed_view3 + clicked(bool) + details_text + show_detailed_view(bool) + + + 602 + 58 + + + 603 + 91 + + + diff --git a/src/lay/lay/laySaltGrainDetailsTextWidget.cc b/src/lay/lay/laySaltGrainDetailsTextWidget.cc index 3bbda18a2..e09b80e82 100644 --- a/src/lay/lay/laySaltGrainDetailsTextWidget.cc +++ b/src/lay/lay/laySaltGrainDetailsTextWidget.cc @@ -36,14 +36,15 @@ namespace lay { SaltGrainDetailsTextWidget::SaltGrainDetailsTextWidget (QWidget *w) - : QTextBrowser (w), mp_grain () + : QTextBrowser (w), mp_grain (), m_detailed_view (false) { setOpenLinks (false); setOpenExternalLinks (false); connect (this, SIGNAL (anchorClicked (const QUrl &)), this, SLOT (open_link (const QUrl &))); } -void SaltGrainDetailsTextWidget::set_grain (const SaltGrain *g) +void +SaltGrainDetailsTextWidget::set_grain (const SaltGrain *g) { if (g) { mp_grain.reset (new SaltGrain (*g)); @@ -53,6 +54,15 @@ void SaltGrainDetailsTextWidget::set_grain (const SaltGrain *g) setHtml (details_text ()); } +void +SaltGrainDetailsTextWidget::show_detailed_view (bool f) +{ + if (m_detailed_view != f) { + m_detailed_view = f; + setHtml (details_text ()); + } +} + void SaltGrainDetailsTextWidget::open_link (const QUrl &url) { @@ -276,32 +286,36 @@ SaltGrainDetailsTextWidget::details_text () stream << "

" << QObject::tr ("Screenshot") << "

"; } - stream << "
"; - stream << "

" << QObject::tr ("Installation") << "

"; + if (m_detailed_view) { - if (! g->url ().empty ()) { - stream << "

" << QObject::tr ("Download URL: ") << "" << tl::to_qstring (tl::escaped_to_html (g->url ())) << "

"; - } - if (! g->path ().empty () && ! g->installed_time ().isNull ()) { - stream << "

" << QObject::tr ("Installed: ") << "" << g->installed_time ().toString () << "

"; - } - if (! g->dependencies ().empty ()) { - stream << "

" << QObject::tr ("Depends on: ") << "
"; - for (std::vector::const_iterator d = g->dependencies ().begin (); d != g->dependencies ().end (); ++d) { - stream << "    " << tl::to_qstring (tl::escaped_to_html (d->name)) << " "; - stream << tl::to_qstring (tl::escaped_to_html (d->version)); - if (! d->url.empty ()) { - stream << " - "; - stream << "[" << tl::to_qstring (tl::escaped_to_html (d->url)) << "]
"; - } + stream << "
"; + stream << "

" << QObject::tr ("Installation") << "

"; + + if (! g->url ().empty ()) { + stream << "

" << QObject::tr ("Download URL: ") << "" << tl::to_qstring (tl::escaped_to_html (g->url ())) << "

"; + } + if (! g->path ().empty () && ! g->installed_time ().isNull ()) { + stream << "

" << QObject::tr ("Installed: ") << "" << g->installed_time ().toString () << "

"; + } + if (! g->dependencies ().empty ()) { + stream << "

" << QObject::tr ("Depends on: ") << "
"; + for (std::vector::const_iterator d = g->dependencies ().begin (); d != g->dependencies ().end (); ++d) { + stream << "    " << tl::to_qstring (tl::escaped_to_html (d->name)) << " "; + stream << tl::to_qstring (tl::escaped_to_html (d->version)); + if (! d->url.empty ()) { + stream << " - "; + stream << "[" << tl::to_qstring (tl::escaped_to_html (d->url)) << "]
"; + } + } + stream << "

"; + } + + if (! g->path ().empty ()) { + stream << "

" << QObject::tr ("Installed files: ") << "

"; + produce_listing (stream, QDir (tl::to_qstring (g->path ())), 0); + stream << "

"; } - stream << "

"; - } - if (! g->path ().empty ()) { - stream << "

" << QObject::tr ("Installed files: ") << "

"; - produce_listing (stream, QDir (tl::to_qstring (g->path ())), 0); - stream << "

"; } stream << ""; diff --git a/src/lay/lay/laySaltGrainDetailsTextWidget.h b/src/lay/lay/laySaltGrainDetailsTextWidget.h index 1e0221235..47dc485ed 100644 --- a/src/lay/lay/laySaltGrainDetailsTextWidget.h +++ b/src/lay/lay/laySaltGrainDetailsTextWidget.h @@ -55,6 +55,9 @@ public: protected: virtual QVariant loadResource (int type, const QUrl &url); +public slots: + void show_detailed_view (bool f); + private slots: void open_link (const QUrl &url); @@ -62,6 +65,7 @@ private: std::unique_ptr mp_grain; QString details_text (); + bool m_detailed_view; }; }