LibreOffice Module cui (master)  1
AdditionsDialog.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  */
10 
11 #pragma once
12 
13 #include <salhelper/thread.hxx>
14 #include <rtl/ref.hxx>
15 #include <vcl/weld.hxx>
16 
17 // Detect changes on the UI
18 #include <vcl/timer.hxx>
19 
20 // Search and filter
21 #include <i18nutil/searchopt.hxx>
22 
23 // Extension Manager Connection
24 #include <com/sun/star/deployment/XExtensionManager.hpp>
25 
26 #include <com/sun/star/uno/Reference.hxx>
27 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
28 #include <com/sun/star/ucb/XProgressHandler.hpp>
29 #include <cppuhelper/implbase.hxx>
30 
31 #include <atomic>
32 
33 class AdditionsDialog;
35 class AdditionsItem;
36 
38 {
39  OUString sExtensionID;
40  OUString sName;
41  OUString sAuthorName;
42  OUString sExtensionURL;
43  OUString sScreenshotURL;
44  OUString sIntroduction;
45  OUString sDescription;
47  OUString sReleaseVersion;
48  OUString sLicense;
49  OUString sCommentNumber;
50  OUString sCommentURL;
51  OUString sRating;
52  OUString sDownloadNumber;
53  OUString sDownloadURL;
54 };
55 
57 {
58 private:
60 
61  DECL_LINK(GearHdl, const OString&, void);
62  DECL_LINK(SearchUpdateHdl, weld::Entry&, void);
63  DECL_LINK(ImplUpdateDataHdl, Timer*, void);
64  DECL_LINK(FocusOut_Impl, weld::Widget&, void);
65  DECL_LINK(CloseButtonHdl, weld::Button&, void);
66 
67 public:
68  css::uno::Reference<css::deployment::XExtensionManager> m_xExtensionManager;
69  std::unique_ptr<weld::Entry> m_xEntrySearch;
70  std::unique_ptr<weld::Button> m_xButtonClose;
71  std::unique_ptr<weld::MenuButton> m_xMenuButtonSettings;
72  std::vector<std::shared_ptr<AdditionsItem>> m_aAdditionsItems; // UI components
73  std::vector<AdditionInfo> m_aAllExtensionsVector; // Stores the all extensions' info
74 
75  std::unique_ptr<weld::ScrolledWindow> m_xContentWindow;
76  std::unique_ptr<weld::Container> m_xContentGrid;
77 
78  std::unique_ptr<weld::Label> m_xLabelProgress;
79  std::unique_ptr<weld::MenuButton> m_xGearBtn;
80 
82 
83  OUString m_sURL;
84  OUString m_sTag;
85  size_t
86  m_nMaxItemCount; // Max number of item which will appear on the list before the press to the show more button.
87  size_t m_nCurrentListItemCount; // Current number of item on the list
89 
90  AdditionsDialog(weld::Window* pParent, const OUString& sAdditionsTag);
91  ~AdditionsDialog() override;
92  css::uno::Sequence<css::uno::Sequence<css::uno::Reference<css::deployment::XPackage>>>
94  void SetProgress(const OUString& rProgress);
95  void ClearList();
96  void RefreshUI();
97 
98  static bool sortByComment(const AdditionInfo& a, const AdditionInfo& b);
99  static bool sortByRating(const AdditionInfo& a, const AdditionInfo& b);
100  static bool sortByDownload(const AdditionInfo& a, const AdditionInfo& b);
101 };
102 
104 {
105 public:
106  AdditionsItem(weld::Widget* pParent, AdditionsDialog* pParentDialog,
107  const AdditionInfo& additionInfo);
108  bool getExtensionFile(OUString& sExtensionFile);
109 
110  DECL_LINK(ShowMoreHdl, weld::Button&, void);
111  DECL_LINK(InstallHdl, weld::Button&, void);
112 
113  std::unique_ptr<weld::Builder> m_xBuilder;
114  std::unique_ptr<weld::Widget> m_xContainer;
115  std::unique_ptr<weld::Image> m_xImageScreenshot;
116  std::unique_ptr<weld::Button> m_xButtonInstall;
117  std::unique_ptr<weld::LinkButton> m_xLinkButtonWebsite;
118  std::unique_ptr<weld::Label> m_xLabelName;
119  std::unique_ptr<weld::Label> m_xLabelAuthor;
120  std::unique_ptr<weld::Label> m_xLabelDesc;
121  std::unique_ptr<weld::Label> m_xLabelDescription;
122  std::unique_ptr<weld::Label> m_xLabelLicense;
123  std::unique_ptr<weld::Label> m_xLabelVersion;
124  std::unique_ptr<weld::Label> m_xLabelComments;
125  std::unique_ptr<weld::LinkButton> m_xLinkButtonComments;
126  std::unique_ptr<weld::Image> m_xImageVoting1;
127  std::unique_ptr<weld::Image> m_xImageVoting2;
128  std::unique_ptr<weld::Image> m_xImageVoting3;
129  std::unique_ptr<weld::Image> m_xImageVoting4;
130  std::unique_ptr<weld::Image> m_xImageVoting5;
131  std::unique_ptr<weld::Label> m_xLabelNoVoting;
132  std::unique_ptr<weld::Image> m_xImageDownloadNumber;
133  std::unique_ptr<weld::Label> m_xLabelDownloadNumber;
134  std::unique_ptr<weld::Button> m_xButtonShowMore;
136  OUString m_sDownloadURL;
137  OUString m_sExtensionID;
138 };
139 
141 {
142 private:
144  std::atomic<bool> m_bExecute;
146 
147  void Search();
148  void Append(AdditionInfo& additionInfo);
150 
151  virtual ~SearchAndParseThread() override;
152  virtual void execute() override;
153 
154 public:
155  SearchAndParseThread(AdditionsDialog* pDialog, bool bIsFirstLoading);
156 
157  void StopExecution() { m_bExecute = false; }
158 };
159 
161  : public ::cppu::WeakImplHelper<css::ucb::XCommandEnvironment, css::task::XInteractionHandler,
162  css::ucb::XProgressHandler>
163 {
164 public:
165  virtual ~TmpRepositoryCommandEnv() override;
167 
168  // XCommandEnvironment
169  virtual css::uno::Reference<css::task::XInteractionHandler>
170  SAL_CALL getInteractionHandler() override;
171  virtual css::uno::Reference<css::ucb::XProgressHandler> SAL_CALL getProgressHandler() override;
172 
173  // XInteractionHandler
174  virtual void SAL_CALL
175  handle(css::uno::Reference<css::task::XInteractionRequest> const& xRequest) override;
176 
177  // XProgressHandler
178  virtual void SAL_CALL push(css::uno::Any const& Status) override;
179  virtual void SAL_CALL update(css::uno::Any const& Status) override;
180  virtual void SAL_CALL pop() override;
181 };
182 
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AdditionsDialog * m_pAdditionsDialog
virtual css::uno::Reference< css::ucb::XProgressHandler > SAL_CALL getProgressHandler() override
std::unique_ptr< weld::Label > m_xLabelProgress
std::unique_ptr< weld::Image > m_xImageVoting4
virtual css::uno::Reference< css::task::XInteractionHandler > SAL_CALL getInteractionHandler() override
SearchAndParseThread(AdditionsDialog *pDialog, bool bIsFirstLoading)
std::unique_ptr< weld::MenuButton > m_xGearBtn
bool getExtensionFile(OUString &sExtensionFile)
OUString sCommentURL
virtual void SAL_CALL push(css::uno::Any const &Status) override
DECL_LINK(ShowMoreHdl, weld::Button &, void)
size_t m_nCurrentListItemCount
static bool sortByComment(const AdditionInfo &a, const AdditionInfo &b)
::rtl::Reference< SearchAndParseThread > m_pSearchThread
OUString sScreenshotURL
std::unique_ptr< weld::Image > m_xImageVoting3
std::unique_ptr< weld::Button > m_xButtonClose
std::unique_ptr< weld::Image > m_xImageDownloadNumber
std::unique_ptr< weld::Label > m_xLabelDesc
std::unique_ptr< weld::ScrolledWindow > m_xContentWindow
i18nutil::SearchOptions2 m_searchOptions
static bool sortByRating(const AdditionInfo &a, const AdditionInfo &b)
OUString sIntroduction
std::unique_ptr< weld::Image > m_xImageVoting5
Status
std::unique_ptr< weld::LinkButton > m_xLinkButtonWebsite
std::unique_ptr< weld::Label > m_xLabelComments
OUString sExtensionURL
std::unique_ptr< weld::Button > m_xButtonShowMore
std::atomic< bool > m_bExecute
virtual void SAL_CALL pop() override
std::unique_ptr< weld::Button > m_xButtonInstall
std::unique_ptr< weld::Image > m_xImageScreenshot
std::unique_ptr< weld::Label > m_xLabelAuthor
std::unique_ptr< weld::Entry > m_xEntrySearch
OUString sReleaseVersion
OUString sDownloadNumber
std::vector< std::shared_ptr< AdditionsItem > > m_aAdditionsItems
AdditionsItem(weld::Widget *pParent, AdditionsDialog *pParentDialog, const AdditionInfo &additionInfo)
OUString sExtensionID
~AdditionsDialog() override
std::unique_ptr< weld::Label > m_xLabelVersion
std::unique_ptr< weld::MenuButton > m_xMenuButtonSettings
std::unique_ptr< weld::Label > m_xLabelLicense
std::unique_ptr< weld::Label > m_xLabelNoVoting
std::unique_ptr< weld::Label > m_xLabelDownloadNumber
OUString sCompatibleVersion
OUString m_sDownloadURL
AdditionsDialog * m_pParentDialog
virtual void SAL_CALL handle(css::uno::Reference< css::task::XInteractionRequest > const &xRequest) override
DECL_LINK(GearHdl, const OString &, void)
std::unique_ptr< weld::Widget > m_xContainer
css::uno::Sequence< css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > > getInstalledExtensions()
virtual ~TmpRepositoryCommandEnv() override
virtual void SAL_CALL update(css::uno::Any const &Status) override
std::unique_ptr< weld::Image > m_xImageVoting2
void Append(AdditionInfo &additionInfo)
std::unique_ptr< weld::Builder > m_xBuilder
std::unique_ptr< weld::Container > m_xContentGrid
css::uno::Reference< css::deployment::XExtensionManager > m_xExtensionManager
virtual ~SearchAndParseThread() override
std::unique_ptr< weld::LinkButton > m_xLinkButtonComments
std::unique_ptr< weld::Label > m_xLabelName
OUString sDescription
void SetProgress(const OUString &rProgress)
std::unique_ptr< weld::Image > m_xImageVoting1
std::unique_ptr< weld::Label > m_xLabelDescription
OUString sAuthorName
static bool sortByDownload(const AdditionInfo &a, const AdditionInfo &b)
AdditionsDialog(weld::Window *pParent, const OUString &sAdditionsTag)
OUString sCommentNumber
OUString sDownloadURL
virtual void execute() override
OUString m_sExtensionID
std::vector< AdditionInfo > m_aAllExtensionsVector