Kaydet (Commit) 62623f76 authored tarafından Caolán McNamara's avatar Caolán McNamara

weld GalleryFilesPage

Change-Id: I5fa399144fb12bb19c3b88bf99f99dad6a64e052
Reviewed-on: https://gerrit.libreoffice.org/64188
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 7eaaf96e
......@@ -232,14 +232,6 @@ class TPGalleryThemeProperties : public SfxTabPage
friend class TakeProgress;
friend class TakeThread;
VclPtr<ComboBox> m_pCbbFileType;
VclPtr<ListBox> m_pLbxFound;
VclPtr<PushButton> m_pBtnSearch;
VclPtr<PushButton> m_pBtnTake;
VclPtr<PushButton> m_pBtnTakeAll;
VclPtr<CheckBox> m_pCbxPreview;
VclPtr<GalleryPreview> m_pWndPreview;
ExchangeData* pData;
std::vector<OUString> aFoundList;
std::vector< std::unique_ptr<FilterEntry> >
......@@ -248,7 +240,6 @@ class TPGalleryThemeProperties : public SfxTabPage
OUString aLastFilterName;
OUString aPreviewString;
INetURLObject aURL;
sal_uInt16 nFirstExtFilterPos;
bool bEntriesFound;
bool bInputAllowed;
bool bTakeAll;
......@@ -258,6 +249,15 @@ class TPGalleryThemeProperties : public SfxTabPage
css::uno::Reference< css::media::XPlayer > xMediaPlayer;
css::uno::Reference< css::ui::dialogs::XFolderPicker2 > xFolderPicker;
SvxGalleryPreview m_aWndPreview;
std::unique_ptr<weld::ComboBox> m_xCbbFileType;
std::unique_ptr<weld::TreeView> m_xLbxFound;
std::unique_ptr<weld::Button> m_xBtnSearch;
std::unique_ptr<weld::Button> m_xBtnTake;
std::unique_ptr<weld::Button> m_xBtnTakeAll;
std::unique_ptr<weld::CheckButton> m_xCbxPreview;
std::unique_ptr<weld::CustomWeld> m_xWndPreview;
virtual void Reset( const SfxItemSet* /*rSet*/ ) override {}
virtual bool FillItemSet( SfxItemSet* /*rSet*/ ) override { return true; }
static OUString addExtension( const OUString&, const OUString& );
......@@ -268,19 +268,19 @@ class TPGalleryThemeProperties : public SfxTabPage
void DoPreview();
void EndSearchProgressHdl(sal_Int32 nResult);
DECL_LINK( ClickPreviewHdl, Button*, void );
DECL_LINK( ClickSearchHdl, Button*, void );
DECL_LINK( ClickTakeHdl, Button*, void );
DECL_LINK( ClickTakeAllHdl, Button*, void );
DECL_LINK( SelectFoundHdl, ListBox&, void );
DECL_LINK( SelectFileTypeHdl, ComboBox&, void );
DECL_LINK( DClickFoundHdl, ListBox&, void );
DECL_LINK( PreviewTimerHdl, Timer*, void );
DECL_LINK( DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void );
DECL_LINK(ClickPreviewHdl, weld::ToggleButton&, void);
DECL_LINK(ClickSearchHdl, weld::Button&, void);
DECL_LINK(ClickTakeHdl, weld::Button&, void);
DECL_LINK(ClickTakeAllHdl, weld::Button&, void);
DECL_LINK(SelectFoundHdl, weld::TreeView&, void);
DECL_LINK(SelectFileTypeHdl, weld::ComboBox&, void);
DECL_LINK(DClickFoundHdl, weld::TreeView&, void);
DECL_LINK(PreviewTimerHdl, Timer*, void);
DECL_LINK(DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void);
public:
TPGalleryThemeProperties( vcl::Window* pWindow, const SfxItemSet& rSet );
virtual ~TPGalleryThemeProperties() override;
TPGalleryThemeProperties(TabPageParent pWindow, const SfxItemSet& rSet);
virtual ~TPGalleryThemeProperties() override;
virtual void dispose() override;
void SetXChgData( ExchangeData* pData );
......@@ -288,7 +288,7 @@ public:
void StartSearchFiles( const OUString& _rFolderURL, short _nDlgResult );
static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* rSet );
static VclPtr<SfxTabPage> Create(TabPageParent pParent, const SfxItemSet* rSet);
};
#endif // INCLUDED_CUI_SOURCE_INC_CUIGALDLG_HXX
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="cui">
<requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/>
<object class="GtkTreeStore" id="liststore1">
<columns>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkGrid" id="GalleryFilesPage">
<property name="visible">True</property>
<property name="can_focus">False</property>
......@@ -15,6 +22,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="row_spacing">12</property>
<child>
<object class="GtkGrid" id="grid2">
......@@ -26,10 +34,10 @@
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="galleryfilespage|label1">_File type:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">filetype</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -37,16 +45,16 @@
</packing>
</child>
<child>
<object class="VclComboBoxText" id="filetype">
<object class="GtkComboBoxText" id="filetype">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="has_entry">True</property>
<property name="max_width_chars">30</property>
<property name="width_request">0</property>
<child internal-child="entry">
<object class="GtkEntry" id="comboboxtext-entry">
<property name="can_focus">False</property>
<property name="width_chars">30</property>
<property name="activates_default">True</property>
</object>
</child>
</object>
......@@ -62,20 +70,43 @@
</packing>
</child>
<child>
<object class="GtkTreeView" id="files:border">
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1">
<property name="mode">multiple</property>
</object>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="files:border-atkobject">
<property name="AtkObject::accessible-name" translatable="yes" context="galleryfilespage|files-atkobject">Files Found</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="files">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="model">liststore1</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<property name="search_column">0</property>
<property name="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1">
<property name="mode">multiple</property>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="types-atkobject">
<property name="AtkObject::accessible-name" translatable="yes" context="galleryfilespage|files-atkobject">Files Found</property>
</object>
</child>
</object>
</child>
</object>
......@@ -116,14 +147,27 @@
</packing>
</child>
<child>
<object class="svxcorelo-GalleryPreview" id="image:border">
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child internal-child="accessible">
<object class="AtkObject" id="image:border-atkobject">
<property name="AtkObject::accessible-name" translatable="yes" context="galleryfilespage|image-atkobject">Preview</property>
<property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkDrawingArea" id="image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child internal-child="accessible">
<object class="AtkObject" id="image-atkobject">
<property name="AtkObject::accessible-name" translatable="yes" context="galleryfilespage|image-atkobject">Preview</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
......
......@@ -154,9 +154,6 @@
<glade-widget-class title="Mark Preview" name="swuilo-SwMarkPreview"
generic-name="Mark Preview Window" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Gallery Preview" name="svxcorelo-GalleryPreview"
generic-name="Gallery Preview" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Html Attribute Preview" name="sduilo-SdHtmlAttrPreview"
generic-name="Html Attribute Preview" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
......
......@@ -26,6 +26,7 @@
#include <vcl/menu.hxx>
#include <vcl/edit.hxx>
#include <vcl/combobox.hxx>
#include <vcl/customweld.hxx>
#include <svl/slstitm.hxx>
#include <vcl/transfer.hxx>
#include <svtools/valueset.hxx>
......@@ -75,6 +76,26 @@ public:
static void PreviewMedia( const INetURLObject& rURL );
};
class SVX_DLLPUBLIC SvxGalleryPreview : public weld::CustomWidgetController
{
private:
GraphicObject aGraphicObj;
tools::Rectangle aPreviewRect;
SVX_DLLPRIVATE bool ImplGetGraphicCenterRect( const Graphic& rGraphic, tools::Rectangle& rResultRect ) const;
SVX_DLLPRIVATE void InitSettings();
SVX_DLLPRIVATE virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
public:
SvxGalleryPreview();
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
void SetGraphic( const Graphic& rGraphic ) { aGraphicObj.SetGraphic( rGraphic ); }
bool SetGraphic( const INetURLObject& );
};
class GalleryIconView : public ValueSet, public DropTargetHelper, public DragSourceHelper
{
using ValueSet::StartDrag;
......
......@@ -51,8 +51,6 @@ GalleryPreview::GalleryPreview(vcl::Window* pParent, WinBits nStyle, GalleryThem
InitSettings();
}
VCL_BUILDER_FACTORY_CONSTRUCTOR(GalleryPreview, WB_TABSTOP)
Size GalleryPreview::GetOptimalSize() const
{
return LogicToPixel(Size(70, 88), MapMode(MapUnit::MapAppFont));
......@@ -257,6 +255,90 @@ void GalleryPreview::PreviewMedia( const INetURLObject& rURL )
#endif
}
SvxGalleryPreview::SvxGalleryPreview()
{
}
void SvxGalleryPreview::SetDrawingArea(weld::DrawingArea* pDrawingArea)
{
CustomWidgetController::SetDrawingArea(pDrawingArea);
Size aSize(pDrawingArea->get_ref_device().LogicToPixel(Size(70, 88), MapMode(MapUnit::MapAppFont)));
pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
pDrawingArea->set_help_id(HID_GALLERY_WINDOW);
}
bool SvxGalleryPreview::SetGraphic( const INetURLObject& _aURL )
{
bool bRet = true;
Graphic aGraphic;
#if HAVE_FEATURE_AVMEDIA
if( ::avmedia::MediaWindow::isMediaURL( _aURL.GetMainURL( INetURLObject::DecodeMechanism::Unambiguous ), "" ) )
{
aGraphic = BitmapEx(RID_SVXBMP_GALLERY_MEDIA);
}
else
#endif
{
GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
GalleryProgress aProgress( &rFilter );
if( rFilter.ImportGraphic( aGraphic, _aURL ) )
bRet = false;
}
SetGraphic( aGraphic );
Invalidate();
return bRet;
}
bool SvxGalleryPreview::ImplGetGraphicCenterRect( const Graphic& rGraphic, tools::Rectangle& rResultRect ) const
{
const Size aWinSize(GetOutputSizePixel());
Size aNewSize(GetDrawingArea()->get_ref_device().LogicToPixel(rGraphic.GetPrefSize(), rGraphic.GetPrefMapMode()));
bool bRet = false;
if( aNewSize.Width() && aNewSize.Height() )
{
// scale to fit window
const double fGrfWH = static_cast<double>(aNewSize.Width()) / aNewSize.Height();
const double fWinWH = static_cast<double>(aWinSize.Width()) / aWinSize.Height();
if ( fGrfWH < fWinWH )
{
aNewSize.setWidth( static_cast<long>( aWinSize.Height() * fGrfWH ) );
aNewSize.setHeight( aWinSize.Height() );
}
else
{
aNewSize.setWidth( aWinSize.Width() );
aNewSize.setHeight( static_cast<long>( aWinSize.Width() / fGrfWH) );
}
const Point aNewPos( ( aWinSize.Width() - aNewSize.Width() ) >> 1,
( aWinSize.Height() - aNewSize.Height() ) >> 1 );
rResultRect = tools::Rectangle( aNewPos, aNewSize );
bRet = true;
}
return bRet;
}
void SvxGalleryPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
{
rRenderContext.SetBackground(Wallpaper(GALLERY_BG_COLOR));
if (ImplGetGraphicCenterRect(aGraphicObj.GetGraphic(), aPreviewRect))
{
const Point aPos( aPreviewRect.TopLeft() );
const Size aSize( aPreviewRect.GetSize() );
if( aGraphicObj.IsAnimated() )
aGraphicObj.StartAnimation(&rRenderContext, aPos, aSize);
else
aGraphicObj.Draw(&rRenderContext, aPos, aSize);
}
}
static void drawTransparenceBackground(vcl::RenderContext& rOut, const Point& rPos, const Size& rSize)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment