suggestions button implemented respecting already installed applications

This commit is contained in:
Vinícius Moreira
2019-12-23 13:04:51 -03:00
parent 4696fc34d4
commit c29b1a0252
13 changed files with 270 additions and 27 deletions

View File

@@ -328,10 +328,10 @@ class GenericSoftwareManager(SoftwareManager):
return warnings
def _fill_suggestions(self, suggestions: list, man: SoftwareManager, limit: int):
def _fill_suggestions(self, suggestions: list, man: SoftwareManager, limit: int, filter_installed: bool):
if self._can_work(man):
mti = time.time()
man_sugs = man.list_suggestions(limit)
man_sugs = man.list_suggestions(limit=limit, filter_installed=filter_installed)
mtf = time.time()
self.logger.info(man.__class__.__name__ + ' took {0:.2f} seconds'.format(mtf - mti))
@@ -346,7 +346,7 @@ class GenericSoftwareManager(SoftwareManager):
if self.managers and internet.is_available(self.context.http_client, self.context.logger):
suggestions, threads = [], []
for man in self.managers:
t = Thread(target=self._fill_suggestions, args=(suggestions, man, int(self.config['suggestions']['by_type'])))
t = Thread(target=self._fill_suggestions, args=(suggestions, man, int(self.config['suggestions']['by_type']), filter_installed))
t.start()
threads.append(t)

View File

@@ -393,9 +393,10 @@ class FindSuggestions(AsyncAction):
def __init__(self, man: SoftwareManager):
super(FindSuggestions, self).__init__()
self.man = man
self.filter_installed = False
def run(self):
sugs = self.man.list_suggestions(limit=-1)
sugs = self.man.list_suggestions(limit=-1, filter_installed=self.filter_installed)
self.notify_finished({'pkgs_found': [s.package for s in sugs] if sugs is not None else [], 'error': None})

View File

@@ -189,6 +189,17 @@ class ManageWindow(QWidget):
self.bt_installed.setStyleSheet(toolbar_button_style('#A94E0A'))
self.ref_bt_installed = self.toolbar.addWidget(self.bt_installed)
if config['suggestions']['enabled']:
self.bt_suggestions = QPushButton()
self.bt_suggestions.setText('Suggestions')
self.bt_suggestions.setIcon(QIcon(resource.get_path('img/suggestions.svg')))
self.bt_suggestions.setStyleSheet(toolbar_button_style('#FF8000'))
self.bt_suggestions.clicked.connect(self.read_suggestions)
self.ref_bt_suggestions = self.toolbar.addWidget(self.bt_suggestions)
else:
self.bt_suggestions = None
self.ref_bt_suggestions = None
self.bt_refresh = QPushButton()
self.bt_refresh.setToolTip(i18n['manage_window.bt.refresh.tooltip'])
self.bt_refresh.setIcon(QIcon(resource.get_path('img/refresh.svg')))
@@ -492,6 +503,15 @@ class ManageWindow(QWidget):
self.thread_refresh.pkg_types = pkg_types
self.thread_refresh.start()
def read_suggestions(self):
self.input_search.clear()
self._handle_console_option(False)
self.ref_checkbox_updates.setVisible(False)
self.ref_checkbox_only_apps.setVisible(False)
self._begin_action('Retrieving suggestions', keep_bt_installed=False, clear_filters=not self.recent_uninstall)
self.thread_suggestions.filter_installed = True
self.thread_suggestions.start()
def _finish_refresh_apps(self, res: dict, as_installed: bool = True):
self.finish_action()
self.ref_checkbox_only_apps.setVisible(bool(res['installed']))
@@ -671,6 +691,7 @@ class ManageWindow(QWidget):
if pkgs_info['apps_count'] == 0:
if self.first_refresh or self.types_changed:
self._begin_search('')
self.thread_suggestions.filter_installed = False
self.thread_suggestions.start()
return
else:
@@ -870,6 +891,10 @@ class ManageWindow(QWidget):
self.label_status.setText(action_label + "...")
self.ref_bt_upgrade.setVisible(False)
self.ref_bt_refresh.setVisible(False)
if self.ref_bt_suggestions:
self.ref_bt_suggestions.setVisible(False)
self.checkbox_only_apps.setEnabled(False)
self.table_apps.setEnabled(False)
self.checkbox_updates.setEnabled(False)
@@ -913,6 +938,9 @@ class ManageWindow(QWidget):
self.checkbox_updates.setEnabled(True)
self.progress_controll_enabled = True
if self.ref_bt_suggestions:
self.ref_bt_suggestions.setVisible(True)
if self.pkgs:
self.ref_input_name_filter.setVisible(True)
self.update_bt_upgrade()
@@ -1113,10 +1141,6 @@ class ManageWindow(QWidget):
def _show_settings_menu(self):
menu_row = QMenu()
# TODO
# action_suggestions = QAction(self.i18n['manage_window.settings.suggestions'])
# action_suggestions.setIcon(QIcon())
if isinstance(self.manager, GenericSoftwareManager):
action_gems = QAction(self.i18n['manage_window.settings.gems'])
action_gems.setIcon(self.icon_app)

View File

@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Capa_1"
x="0px"
y="0px"
viewBox="0 0 48.000001 48.000001"
xml:space="preserve"
sodipodi:docname="suggestions.svg"
inkscape:version="0.92.4 5da689c313, 2019-01-14"
width="48"
height="48"><metadata
id="metadata3871"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs3869" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1360"
inkscape:window-height="703"
id="namedview3867"
showgrid="false"
showborder="false"
inkscape:zoom="1.1933395"
inkscape:cx="193.79578"
inkscape:cy="-23.859998"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="Capa_1"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0" />
<g
id="g3834"
transform="matrix(0.13315982,0,0,0.11100833,-4.7891638,0)"
style="fill:#ffffff">
<g
id="g3832"
style="fill:#ffffff">
<g
id="g3830"
style="fill:#ffffff">
<path
style="fill:#ffffff"
d="m 216.529,93.2 c -61.2,0 -111.2,50 -111.2,111.2 0,32 14,62.8 37.6,83.6 17.6,17.6 16,55.2 15.6,55.6 0,2 0.4,3.6 2,5.2 1.2,1.2 3.2,2 4.8,2 h 102 c 2,0 3.6,-0.8 4.8,-2 1.2,-1.2 2,-3.2 2,-5.2 0,-0.4 -2,-38 15.6,-55.6 0.4,-0.4 0.8,-0.8 1.2,-1.2 23.2,-21.2 36.8,-51.2 36.8,-82.4 0,-61.2 -50,-111.2 -111.2,-111.2 z m 64,184.4 c -0.4,0.4 -1.2,1.2 -1.2,1.6 -15.6,16.8 -18.4,44.4 -18.8,57.6 h -88.4 c -0.4,-13.2 -3.2,-42 -20,-59.2 -21.2,-18.4 -33.6,-45.2 -33.6,-73.6 0,-54 43.6,-97.6 97.6,-97.6 54,0 97.6,43.6 97.6,97.6 0,28.4 -12,55.2 -33.2,73.6 z"
id="path3812"
inkscape:connector-curvature="0" />
<path
style="fill:#ffffff"
d="m 216.129,121.6 c -3.6,0 -6.8,3.2 -6.8,6.8 0,3.6 3.2,6.8 6.8,6.8 40.4,0 72.8,32.8 72.8,72.8 0,3.6 3.2,6.8 6.8,6.8 3.6,0 6.8,-3.2 6.8,-6.8 0.4,-47.6 -38.4,-86.4 -86.4,-86.4 z"
id="path3814"
inkscape:connector-curvature="0" />
<path
style="fill:#ffffff"
d="m 260.529,358.4 h -88.8 c -9.2,0 -16.8,7.6 -16.8,16.8 0,9.2 7.6,16.8 16.8,16.8 h 88.4 c 9.6,-0.4 17.2,-7.6 17.2,-16.8 0,-9.2 -7.6,-16.8 -16.8,-16.8 z m 0,19.6 h -88.8 c -1.6,0 -3.2,-1.2 -3.2,-3.2 0,-2 1.2,-3.2 3.2,-3.2 h 88.4 c 1.6,0 3.2,1.2 3.2,3.2 0,2 -1.2,3.2 -2.8,3.2 z"
id="path3816"
inkscape:connector-curvature="0" />
<path
style="fill:#ffffff"
d="m 247.329,398.8 h -62.4 c -9.2,0 -16.8,7.6 -16.8,16.8 0,9.2 7.6,16.8 16.8,16.8 h 62.4 c 9.2,0 16.8,-7.6 16.8,-16.8 0,-9.6 -7.6,-16.8 -16.8,-16.8 z m 0,19.6 h -62.4 c -1.6,0 -3.2,-1.2 -3.2,-3.2 0,-2 1.2,-3.2 3.2,-3.2 h 62.4 c 1.6,0 3.2,1.2 3.2,3.2 0,2 -1.6,3.2 -3.2,3.2 z"
id="path3818"
inkscape:connector-curvature="0" />
<path
style="fill:#ffffff"
d="m 216.129,60 c 4,0 6.8,-3.2 6.8,-6.8 V 6.8 c 0,-3.6 -3.2,-6.8 -6.8,-6.8 -3.6,0 -6.8,3.2 -6.8,6.8 v 46.4 c 0,3.6 3.2,6.8 6.8,6.8 z"
id="path3820"
inkscape:connector-curvature="0" />
<path
style="fill:#ffffff"
d="m 329.329,34.4 c -3.2,-2.4 -7.2,-1.2 -9.2,1.6 l -25.6,38.4 c -2.4,3.2 -1.6,7.6 1.6,9.6 1.2,0.8 2.4,1.2 3.6,1.2 2.4,0 4.4,-1.2 5.6,-3.2 l 25.6,-38.4 c 2.4,-2.8 1.6,-7.2 -1.6,-9.2 z"
id="path3822"
inkscape:connector-curvature="0" />
<path
style="fill:#ffffff"
d="m 134.929,83.6 c 1.2,0 2.4,-0.4 3.6,-1.2 3.2,-2 4,-6.4 2,-9.6 L 115.729,34 c -2,-3.2 -6.4,-4 -9.6,-2 -3.2,2 -4,6.4 -2,9.6 l 24.8,38.8 c 1.6,2.4 3.6,3.2 6,3.2 z"
id="path3824"
inkscape:connector-curvature="0" />
<path
style="fill:#ffffff"
d="m 86.529,126 -40.4,-22 c -3.2,-1.6 -7.6,-0.4 -9.2,2.8 -2,3.2 -0.8,7.6 2.8,9.2 l 40.4,22 c 1.2,0.4 2,0.8 3.2,0.8 2.4,0 4.8,-1.2 6,-3.6 1.6,-3.2 0.4,-7.6 -2.8,-9.2 z"
id="path3826"
inkscape:connector-curvature="0" />
<path
style="fill:#ffffff"
d="m 395.729,106.8 c -1.6,-3.2 -6,-4.4 -9.2,-2.8 l -40.8,22 c -3.2,1.6 -4.4,6 -2.8,9.2 1.2,2.4 3.6,3.6 6,3.6 1.2,0 2.4,-0.4 3.2,-0.8 l 40.8,-22 c 3.2,-1.6 4.4,-6 2.8,-9.2 z"
id="path3828"
inkscape:connector-curvature="0" />
</g>
</g>
</g>
<g
id="g3836"
transform="translate(-35.965532,-384.4)">
</g>
<g
id="g3838"
transform="translate(-35.965532,-384.4)">
</g>
<g
id="g3840"
transform="translate(-35.965532,-384.4)">
</g>
<g
id="g3842"
transform="translate(-35.965532,-384.4)">
</g>
<g
id="g3844"
transform="translate(-35.965532,-384.4)">
</g>
<g
id="g3846"
transform="translate(-35.965532,-384.4)">
</g>
<g
id="g3848"
transform="translate(-35.965532,-384.4)">
</g>
<g
id="g3850"
transform="translate(-35.965532,-384.4)">
</g>
<g
id="g3852"
transform="translate(-35.965532,-384.4)">
</g>
<g
id="g3854"
transform="translate(-35.965532,-384.4)">
</g>
<g
id="g3856"
transform="translate(-35.965532,-384.4)">
</g>
<g
id="g3858"
transform="translate(-35.965532,-384.4)">
</g>
<g
id="g3860"
transform="translate(-35.965532,-384.4)">
</g>
<g
id="g3862"
transform="translate(-35.965532,-384.4)">
</g>
<g
id="g3864"
transform="translate(-35.965532,-384.4)">
</g>
</svg>

After

Width:  |  Height:  |  Size: 5.7 KiB