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> <item>
<widget class="QTabWidget" name="mode_tab"> <widget class="QTabWidget" name="mode_tab">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="tab_2"> <widget class="QWidget" name="tab_2">
<attribute name="title"> <attribute name="title">
@ -217,6 +217,12 @@
</property> </property>
<item> <item>
<widget class="QLabel" name="label_6"> <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"> <property name="font">
<font> <font>
<bold>true</bold> <bold>true</bold>
@ -227,6 +233,19 @@
</property> </property>
</widget> </widget>
</item> </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> <item>
<widget class="QToolButton" name="toolButton"> <widget class="QToolButton" name="toolButton">
<property name="enabled"> <property name="enabled">
@ -515,6 +534,12 @@
</property> </property>
<item> <item>
<widget class="QLabel" name="label_9"> <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"> <property name="font">
<font> <font>
<bold>true</bold> <bold>true</bold>
@ -525,6 +550,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="detailed_view2">
<property name="text">
<string>More details</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QToolButton" name="toolButton_2"> <widget class="QToolButton" name="toolButton_2">
<property name="enabled"> <property name="enabled">
@ -935,8 +967,21 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </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"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font"> <property name="font">
<font> <font>
<bold>true</bold> <bold>true</bold>
@ -947,7 +992,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="2">
<widget class="QToolButton" name="edit_button"> <widget class="QToolButton" name="edit_button">
<property name="toolTip"> <property name="toolTip">
<string>Edit Package Details</string> <string>Edit Package Details</string>
@ -964,10 +1009,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="2"> <item row="0" column="1">
<widget class="lay::SaltGrainDetailsTextWidget" name="details_text"> <widget class="QCheckBox" name="detailed_view3">
<property name="openExternalLinks"> <property name="text">
<bool>true</bool> <string>More details</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -1157,20 +1202,33 @@
<class>lay::SaltGrainDetailsTextWidget</class> <class>lay::SaltGrainDetailsTextWidget</class>
<extends>QTextBrowser</extends> <extends>QTextBrowser</extends>
<header>laySaltGrainDetailsTextWidget.h</header> <header>laySaltGrainDetailsTextWidget.h</header>
<slots>
<slot>show_detailed_view(bool)</slot>
</slots>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>mode_tab</tabstop> <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>search_installed_edit</tabstop>
<tabstop>salt_view</tabstop> <tabstop>salt_view</tabstop>
<tabstop>details_text</tabstop> <tabstop>detailed_view3</tabstop>
<tabstop>edit_button</tabstop> <tabstop>edit_button</tabstop>
<tabstop>search_new_edit</tabstop> <tabstop>details_text</tabstop>
<tabstop>mark_new_button</tabstop> <tabstop>create_button</tabstop>
<tabstop>salt_mine_view_new</tabstop>
<tabstop>details_new_text</tabstop>
<tabstop>toolButton</tabstop>
<tabstop>apply_new_button</tabstop> <tabstop>apply_new_button</tabstop>
<tabstop>apply_update_button</tabstop>
<tabstop>scrollArea</tabstop> <tabstop>scrollArea</tabstop>
</tabstops> </tabstops>
<resources> <resources>
@ -1193,5 +1251,53 @@
</hint> </hint>
</hints> </hints>
</connection> </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> </connections>
</ui> </ui>

View File

@ -36,14 +36,15 @@ namespace lay
{ {
SaltGrainDetailsTextWidget::SaltGrainDetailsTextWidget (QWidget *w) SaltGrainDetailsTextWidget::SaltGrainDetailsTextWidget (QWidget *w)
: QTextBrowser (w), mp_grain () : QTextBrowser (w), mp_grain (), m_detailed_view (false)
{ {
setOpenLinks (false); setOpenLinks (false);
setOpenExternalLinks (false); setOpenExternalLinks (false);
connect (this, SIGNAL (anchorClicked (const QUrl &)), this, SLOT (open_link (const QUrl &))); 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) { if (g) {
mp_grain.reset (new SaltGrain (*g)); mp_grain.reset (new SaltGrain (*g));
@ -53,6 +54,15 @@ void SaltGrainDetailsTextWidget::set_grain (const SaltGrain *g)
setHtml (details_text ()); setHtml (details_text ());
} }
void
SaltGrainDetailsTextWidget::show_detailed_view (bool f)
{
if (m_detailed_view != f) {
m_detailed_view = f;
setHtml (details_text ());
}
}
void void
SaltGrainDetailsTextWidget::open_link (const QUrl &url) 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 << "<h3>" << QObject::tr ("Screenshot") << "</h3><p><img src=\":/screenshot\"/></p>";
} }
stream << "<br/>"; if (m_detailed_view) {
stream << "<h3>" << QObject::tr ("Installation") << "</h3>";
if (! g->url ().empty ()) { stream << "<br/>";
stream << "<p><b>" << QObject::tr ("Download URL: ") << "</b>" << tl::to_qstring (tl::escaped_to_html (g->url ())) << "</p>"; stream << "<h3>" << QObject::tr ("Installation") << "</h3>";
}
if (! g->path ().empty () && ! g->installed_time ().isNull ()) { if (! g->url ().empty ()) {
stream << "<p><b>" << QObject::tr ("Installed: ") << "</b>" << g->installed_time ().toString () << "</p>"; stream << "<p><b>" << QObject::tr ("Download URL: ") << "</b>" << tl::to_qstring (tl::escaped_to_html (g->url ())) << "</p>";
} }
if (! g->dependencies ().empty ()) { if (! g->path ().empty () && ! g->installed_time ().isNull ()) {
stream << "<p><b>" << QObject::tr ("Depends on: ") << "</b><br/>"; stream << "<p><b>" << QObject::tr ("Installed: ") << "</b>" << g->installed_time ().toString () << "</p>";
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)) << " "; if (! g->dependencies ().empty ()) {
stream << tl::to_qstring (tl::escaped_to_html (d->version)); stream << "<p><b>" << QObject::tr ("Depends on: ") << "</b><br/>";
if (! d->url.empty ()) { for (std::vector<lay::SaltGrainDependency>::const_iterator d = g->dependencies ().begin (); d != g->dependencies ().end (); ++d) {
stream << " - "; stream << "&nbsp;&nbsp;&nbsp;&nbsp;" << tl::to_qstring (tl::escaped_to_html (d->name)) << " ";
stream << "[" << tl::to_qstring (tl::escaped_to_html (d->url)) << "]<br/>"; 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>"; stream << "</td></tr></table>";

View File

@ -55,6 +55,9 @@ public:
protected: protected:
virtual QVariant loadResource (int type, const QUrl &url); virtual QVariant loadResource (int type, const QUrl &url);
public slots:
void show_detailed_view (bool f);
private slots: private slots:
void open_link (const QUrl &url); void open_link (const QUrl &url);
@ -62,6 +65,7 @@ private:
std::unique_ptr<lay::SaltGrain> mp_grain; std::unique_ptr<lay::SaltGrain> mp_grain;
QString details_text (); QString details_text ();
bool m_detailed_view;
}; };
} }