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::vector<std::shared_ptr<AdditionsItem>> m_aAdditionsItems; // UI components
72 std::vector<AdditionInfo> m_aAllExtensionsVector; // Stores the all extensions' info
73
74 std::unique_ptr<weld::ScrolledWindow> m_xContentWindow;
75 std::unique_ptr<weld::Container> m_xContentGrid;
76
77 std::unique_ptr<weld::Label> m_xLabelProgress;
78 std::unique_ptr<weld::MenuButton> m_xGearBtn;
79
81
82 OUString m_sURL;
83 OUString m_sTag;
84 size_t
85 m_nMaxItemCount; // Max number of item which will appear on the list before the press to the show more button.
86 size_t m_nCurrentListItemCount; // Current number of item on the list
88
89 AdditionsDialog(weld::Window* pParent, const OUString& sAdditionsTag);
90 ~AdditionsDialog() override;
91 css::uno::Sequence<css::uno::Sequence<css::uno::Reference<css::deployment::XPackage>>>
93 void SetProgress(const OUString& rProgress);
94 void ClearList();
95 void RefreshUI();
96
97 static bool sortByComment(const AdditionInfo& a, const AdditionInfo& b);
98 static bool sortByRating(const AdditionInfo& a, const AdditionInfo& b);
99 static bool sortByDownload(const AdditionInfo& a, const AdditionInfo& b);
100};
101
103{
104public:
105 AdditionsItem(weld::Widget* pParent, AdditionsDialog* pParentDialog,
106 const AdditionInfo& additionInfo);
107 bool getExtensionFile(OUString& sExtensionFile);
108
109 DECL_LINK(ShowMoreHdl, weld::Button&, void);
110 DECL_LINK(InstallHdl, weld::Button&, void);
111
112 std::unique_ptr<weld::Builder> m_xBuilder;
113 std::unique_ptr<weld::Widget> m_xContainer;
114 std::unique_ptr<weld::Image> m_xImageScreenshot;
115 std::unique_ptr<weld::Button> m_xButtonInstall;
116 std::unique_ptr<weld::LinkButton> m_xLinkButtonWebsite;
117 std::unique_ptr<weld::Label> m_xLabelName;
118 std::unique_ptr<weld::Label> m_xLabelAuthor;
119 std::unique_ptr<weld::Label> m_xLabelDescription;
120 std::unique_ptr<weld::Label> m_xLabelLicense;
121 std::unique_ptr<weld::Label> m_xLabelVersion;
122 std::unique_ptr<weld::LinkButton> m_xLinkButtonComments;
123 std::unique_ptr<weld::Image> m_xImageVoting1;
124 std::unique_ptr<weld::Image> m_xImageVoting2;
125 std::unique_ptr<weld::Image> m_xImageVoting3;
126 std::unique_ptr<weld::Image> m_xImageVoting4;
127 std::unique_ptr<weld::Image> m_xImageVoting5;
128 std::unique_ptr<weld::Label> m_xLabelDownloadNumber;
129 std::unique_ptr<weld::Button> m_xButtonShowMore;
133};
134
136{
137private:
139 std::atomic<bool> m_bExecute;
141
142 void Search();
143 void Append(AdditionInfo& additionInfo);
145
146 virtual ~SearchAndParseThread() override;
147 virtual void execute() override;
148
149public:
150 SearchAndParseThread(AdditionsDialog* pDialog, bool bIsFirstLoading);
151
152 void StopExecution() { m_bExecute = false; }
153};
154
156 : public ::cppu::WeakImplHelper<css::ucb::XCommandEnvironment, css::task::XInteractionHandler,
157 css::ucb::XProgressHandler>
158{
159public:
160 virtual ~TmpRepositoryCommandEnv() override;
162
163 // XCommandEnvironment
164 virtual css::uno::Reference<css::task::XInteractionHandler>
165 SAL_CALL getInteractionHandler() override;
166 virtual css::uno::Reference<css::ucb::XProgressHandler> SAL_CALL getProgressHandler() override;
167
168 // XInteractionHandler
169 virtual void SAL_CALL
170 handle(css::uno::Reference<css::task::XInteractionRequest> const& xRequest) override;
171
172 // XProgressHandler
173 virtual void SAL_CALL push(css::uno::Any const& Status) override;
174 virtual void SAL_CALL update(css::uno::Any const& Status) override;
175 virtual void SAL_CALL pop() override;
176};
177
178/* 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::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::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
DECL_LINK(ShowMoreHdl, weld::Button &, void)
std::unique_ptr< weld::Label > m_xLabelLicense
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
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