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
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>
30
31#include <atomic>
32
33class AdditionsDialog;
35class AdditionsItem;
36
38{
39 OUString sExtensionID;
40 OUString sName;
41 OUString sAuthorName;
42 OUString sExtensionURL;
44 OUString sIntroduction;
45 OUString sDescription;
48 OUString sLicense;
50 OUString sCommentURL;
51 OUString sRating;
53 OUString sDownloadURL;
54};
55
57{
58private:
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
67public:
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{
105public:
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;
138};
139
141{
142private:
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
154public:
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{
164public:
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: */
i18nutil::SearchOptions2 m_searchOptions
std::unique_ptr< weld::MenuButton > m_xGearBtn
std::vector< std::shared_ptr< AdditionsItem > > m_aAdditionsItems
std::vector< AdditionInfo > m_aAllExtensionsVector
DECL_LINK(SearchUpdateHdl, weld::Entry &, void)
void SetProgress(const OUString &rProgress)
static bool sortByComment(const AdditionInfo &a, const AdditionInfo &b)
std::unique_ptr< weld::MenuButton > m_xMenuButtonSettings
std::unique_ptr< weld::Button > m_xButtonClose
DECL_LINK(CloseButtonHdl, weld::Button &, void)
std::unique_ptr< weld::ScrolledWindow > m_xContentWindow
AdditionsDialog(weld::Window *pParent, const OUString &sAdditionsTag)
std::unique_ptr< weld::Container > m_xContentGrid
std::unique_ptr< weld::Entry > m_xEntrySearch
css::uno::Reference< css::deployment::XExtensionManager > m_xExtensionManager
static bool sortByRating(const AdditionInfo &a, const AdditionInfo &b)
DECL_LINK(FocusOut_Impl, weld::Widget &, void)
~AdditionsDialog() override
static bool sortByDownload(const AdditionInfo &a, const AdditionInfo &b)
DECL_LINK(ImplUpdateDataHdl, Timer *, void)
size_t m_nCurrentListItemCount
::rtl::Reference< SearchAndParseThread > m_pSearchThread
std::unique_ptr< weld::Label > m_xLabelProgress
css::uno::Sequence< css::uno::Sequence< css::uno::Reference< css::deployment::XPackage > > > getInstalledExtensions()
DECL_LINK(GearHdl, const OString &, void)
std::unique_ptr< weld::Image > m_xImageVoting5
std::unique_ptr< weld::Button > m_xButtonInstall
std::unique_ptr< weld::Label > m_xLabelName
std::unique_ptr< weld::Image > m_xImageVoting4
std::unique_ptr< weld::Builder > m_xBuilder
std::unique_ptr< weld::Image > m_xImageVoting3
std::unique_ptr< weld::Label > m_xLabelDownloadNumber
bool getExtensionFile(OUString &sExtensionFile)
std::unique_ptr< weld::Label > m_xLabelNoVoting
std::unique_ptr< weld::Image > m_xImageVoting1
std::unique_ptr< weld::Image > m_xImageScreenshot
OUString m_sDownloadURL
AdditionsDialog * m_pParentDialog
AdditionsItem(weld::Widget *pParent, AdditionsDialog *pParentDialog, const AdditionInfo &additionInfo)
std::unique_ptr< weld::LinkButton > m_xLinkButtonWebsite
std::unique_ptr< weld::Label > m_xLabelDesc
DECL_LINK(ShowMoreHdl, weld::Button &, void)
std::unique_ptr< weld::Label > m_xLabelLicense
std::unique_ptr< weld::Image > m_xImageDownloadNumber
OUString m_sExtensionID
std::unique_ptr< weld::Label > m_xLabelAuthor
std::unique_ptr< weld::Widget > m_xContainer
std::unique_ptr< weld::LinkButton > m_xLinkButtonComments
std::unique_ptr< weld::Label > m_xLabelVersion
std::unique_ptr< weld::Label > m_xLabelComments
DECL_LINK(InstallHdl, weld::Button &, void)
std::unique_ptr< weld::Label > m_xLabelDescription
std::unique_ptr< weld::Button > m_xButtonShowMore
std::unique_ptr< weld::Image > m_xImageVoting2
virtual void execute() override
virtual ~SearchAndParseThread() override
SearchAndParseThread(AdditionsDialog *pDialog, bool bIsFirstLoading)
AdditionsDialog * m_pAdditionsDialog
void Append(AdditionInfo &additionInfo)
std::atomic< bool > m_bExecute
virtual void SAL_CALL push(css::uno::Any const &Status) override
virtual void SAL_CALL handle(css::uno::Reference< css::task::XInteractionRequest > const &xRequest) override
virtual css::uno::Reference< css::task::XInteractionHandler > SAL_CALL getInteractionHandler() override
virtual void SAL_CALL pop() override
virtual ~TmpRepositoryCommandEnv() override
virtual void SAL_CALL update(css::uno::Any const &Status) override
virtual css::uno::Reference< css::ucb::XProgressHandler > SAL_CALL getProgressHandler() override
Status
OUString sExtensionID
OUString sDownloadURL
OUString sAuthorName
OUString sScreenshotURL
OUString sDownloadNumber
OUString sDescription
OUString sCommentNumber
OUString sCommentURL
OUString sCompatibleVersion
OUString sReleaseVersion
OUString sExtensionURL
OUString sIntroduction