Added option to download document from the context menu

This commit is contained in:
Manuel Cortez 2019-03-05 17:43:19 -06:00
parent 95fe0c9516
commit 98c5c052de
3 changed files with 18 additions and 1 deletions

View File

@ -2,6 +2,7 @@
## changes in this version
* Added a new buffer called documents. When loading the buffer, it will contain all documents owned by the current user. The context menu of any item will allow you to download the document to your computer or remove it from VK.
* A new buffer, called online, has been added in the friends section. It contains friends currently connected to VK. Items in this buffer will be added as soon as new friends are online in the social network, and will be removed when friends are offline. This buffer needs a lot of testing. Please report any possible inconsistency on this method.
* Added new options to open the config and logs folder, these options are located in the help menu and may be useful during error reporting.
* Added experimental support to "subscribers" buffer, inside frienship requests. This shows friend requests that have been declined by the current user.
@ -36,7 +37,7 @@
* For the home buffer, only a limited amount of items (around 700) can be loaded, supposedly due to VK API limits.
* For walls, all posts should be possible to be loaded, however, testing with walls containing more than 2000 posts are not performed yet.
* Added improvements to groups:
* It is possible to load topics, audios and videos for a group. In order to do so, you need to go to the group buffer and press the menu key, or right mouse click, in the tree item representing the group. New buffers will be created inside the current group's buffer.
* It is possible to load topics, audios, videos and documents for a group. In order to do so, you need to go to the group buffer and press the menu key, or right mouse click, in the tree item representing the group. New buffers will be created inside the current group's buffer.
* You can create or delete all buffers for groups by pressing the menu key or right mouse click in the "communities" buffer.
* There is support for group topics. When opening them, they will be displayed as a list of posts. You can like or reply to such posts, as well as adding new posts in the topic.
* Authentication errors should be handled gracefully by the application:

View File

@ -544,6 +544,7 @@ class documentBuffer(feedBuffer):
added = False
m = menus.documentMenu(added)
widgetUtils.connect_event(m, widgetUtils.MENU, self.add_remove_document, menuitem=m.action)
widgetUtils.connect_event(m, widgetUtils.MENU, self.download, menuitem=m.download)
return m
def add_remove_document(self, *args, **kwargs):
@ -560,6 +561,16 @@ class documentBuffer(feedBuffer):
result = self.session.vk.client.docs.add(owner_id=p["owner_id"], doc_id=p["id"])
output.speak(_("The document has been successfully added."))
def download(self, *args, **kwargs):
post = self.get_post()
filename = post["title"]
# If document does not end in .extension we must fix it so the file dialog will save it properly later.
if filename.endswith(post["ext"]) == False:
filename = filename+ "."+post["ext"]
filepath = self.tab.get_download_path(filename)
if filepath != None:
pub.sendMessage("download-file", url=post["url"], filename=filepath)
class documentCommunityBuffer(documentBuffer):
can_get_items = True

View File

@ -165,6 +165,11 @@ class documentCommunityTab(homeTab):
self.list.set_size()
self.list.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnKeyDown)
def get_download_path(self, filename):
saveFileDialog = wx.FileDialog(self, _("Save document as"), "", filename, _("All files (*.*)|*.*"), wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
if saveFileDialog.ShowModal() == widgetUtils.OK:
return saveFileDialog.GetPath()
class documentTab(documentCommunityTab):
def create_post_buttons(self):
self.postBox = wx.StaticBoxSizer(parent=self, orient=wx.HORIZONTAL, label=_("Actions"))