Package manager: show details only when enabling the 'show details' button

This commit is contained in:
Matthias Koefferlein 2022-10-26 21:28:10 +02:00
parent 8da373e9ad
commit 879059f830
3 changed files with 161 additions and 37 deletions

View File

@ -17,7 +17,7 @@
<item>
<widget class="QTabWidget" name="mode_tab">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="tab_2">
<attribute name="title">
@ -217,6 +217,12 @@
</property>
<item>
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<bold>true</bold>
@ -227,6 +233,19 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="detailed_view">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>More details</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton">
<property name="enabled">
@ -515,6 +534,12 @@
</property>
<item>
<widget class="QLabel" name="label_9">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<bold>true</bold>
@ -525,6 +550,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="detailed_view2">
<property name="text">
<string>More details</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_2">
<property name="enabled">
@ -935,8 +967,21 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="1" column="0" colspan="3">
<widget class="lay::SaltGrainDetailsTextWidget" name="details_text">
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<bold>true</bold>
@ -947,7 +992,7 @@
</property>
</widget>
</item>
<item row="0" column="1">
<item row="0" column="2">
<widget class="QToolButton" name="edit_button">
<property name="toolTip">
<string>Edit Package Details</string>
@ -964,10 +1009,10 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="lay::SaltGrainDetailsTextWidget" name="details_text">
<property name="openExternalLinks">
<bool>true</bool>
<item row="0" column="1">
<widget class="QCheckBox" name="detailed_view3">
<property name="text">
<string>More details</string>
</property>
</widget>
</item>
@ -1157,20 +1202,33 @@
<class>lay::SaltGrainDetailsTextWidget</class>
<extends>QTextBrowser</extends>
<header>laySaltGrainDetailsTextWidget.h</header>
<slots>
<slot>show_detailed_view(bool)</slot>
</slots>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>mode_tab</tabstop>
<tabstop>mark_new_button</tabstop>
<tabstop>search_new_edit</tabstop>
<tabstop>salt_mine_view_new</tabstop>
<tabstop>detailed_view</tabstop>
<tabstop>toolButton</tabstop>
<tabstop>details_new_text</tabstop>
<tabstop>mark_update_button</tabstop>
<tabstop>search_update_edit</tabstop>
<tabstop>salt_mine_view_update</tabstop>
<tabstop>detailed_view2</tabstop>
<tabstop>toolButton_2</tabstop>
<tabstop>details_update_text</tabstop>
<tabstop>search_installed_edit</tabstop>
<tabstop>salt_view</tabstop>
<tabstop>details_text</tabstop>
<tabstop>detailed_view3</tabstop>
<tabstop>edit_button</tabstop>
<tabstop>search_new_edit</tabstop>
<tabstop>mark_new_button</tabstop>
<tabstop>salt_mine_view_new</tabstop>
<tabstop>details_new_text</tabstop>
<tabstop>toolButton</tabstop>
<tabstop>details_text</tabstop>
<tabstop>create_button</tabstop>
<tabstop>apply_new_button</tabstop>
<tabstop>apply_update_button</tabstop>
<tabstop>scrollArea</tabstop>
</tabstops>
<resources>
@ -1193,5 +1251,53 @@
</hint>
</hints>
</connection>
<connection>
<sender>detailed_view</sender>
<signal>clicked(bool)</signal>
<receiver>details_new_text</receiver>
<slot>show_detailed_view(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>588</x>
<y>57</y>
</hint>
<hint type="destinationlabel">
<x>578</x>
<y>121</y>
</hint>
</hints>
</connection>
<connection>
<sender>detailed_view2</sender>
<signal>clicked(bool)</signal>
<receiver>details_update_text</receiver>
<slot>show_detailed_view(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>616</x>
<y>58</y>
</hint>
<hint type="destinationlabel">
<x>615</x>
<y>96</y>
</hint>
</hints>
</connection>
<connection>
<sender>detailed_view3</sender>
<signal>clicked(bool)</signal>
<receiver>details_text</receiver>
<slot>show_detailed_view(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>602</x>
<y>58</y>
</hint>
<hint type="destinationlabel">
<x>603</x>
<y>91</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -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 << "<h3>" << QObject::tr ("Screenshot") << "</h3><p><img src=\":/screenshot\"/></p>";
}
stream << "<br/>";
stream << "<h3>" << QObject::tr ("Installation") << "</h3>";
if (m_detailed_view) {
if (! g->url ().empty ()) {
stream << "<p><b>" << QObject::tr ("Download URL: ") << "</b>" << tl::to_qstring (tl::escaped_to_html (g->url ())) << "</p>";
}
if (! g->path ().empty () && ! g->installed_time ().isNull ()) {
stream << "<p><b>" << QObject::tr ("Installed: ") << "</b>" << g->installed_time ().toString () << "</p>";
}
if (! g->dependencies ().empty ()) {
stream << "<p><b>" << QObject::tr ("Depends on: ") << "</b><br/>";
for (std::vector<lay::SaltGrainDependency>::const_iterator d = g->dependencies ().begin (); d != g->dependencies ().end (); ++d) {
stream << "&nbsp;&nbsp;&nbsp;&nbsp;" << 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)) << "]<br/>";
}
stream << "<br/>";
stream << "<h3>" << QObject::tr ("Installation") << "</h3>";
if (! g->url ().empty ()) {
stream << "<p><b>" << QObject::tr ("Download URL: ") << "</b>" << tl::to_qstring (tl::escaped_to_html (g->url ())) << "</p>";
}
if (! g->path ().empty () && ! g->installed_time ().isNull ()) {
stream << "<p><b>" << QObject::tr ("Installed: ") << "</b>" << g->installed_time ().toString () << "</p>";
}
if (! g->dependencies ().empty ()) {
stream << "<p><b>" << QObject::tr ("Depends on: ") << "</b><br/>";
for (std::vector<lay::SaltGrainDependency>::const_iterator d = g->dependencies ().begin (); d != g->dependencies ().end (); ++d) {
stream << "&nbsp;&nbsp;&nbsp;&nbsp;" << 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)) << "]<br/>";
}
}
stream << "</p>";
}
if (! g->path ().empty ()) {
stream << "<p><b>" << QObject::tr ("Installed files: ") << "</b></p><p>";
produce_listing (stream, QDir (tl::to_qstring (g->path ())), 0);
stream << "</p>";
}
stream << "</p>";
}
if (! g->path ().empty ()) {
stream << "<p><b>" << QObject::tr ("Installed files: ") << "</b></p><p>";
produce_listing (stream, QDir (tl::to_qstring (g->path ())), 0);
stream << "</p>";
}
stream << "</td></tr></table>";

View File

@ -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<lay::SaltGrain> mp_grain;
QString details_text ();
bool m_detailed_view;
};
}