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

weld GalleryFilesPage

Change-Id: I5fa399144fb12bb19c3b88bf99f99dad6a64e052
Reviewed-on: https://gerrit.libreoffice.org/64211
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst df2cb062
...@@ -232,14 +232,6 @@ class TPGalleryThemeProperties : public SfxTabPage ...@@ -232,14 +232,6 @@ class TPGalleryThemeProperties : public SfxTabPage
friend class TakeProgress; friend class TakeProgress;
friend class TakeThread; 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; ExchangeData* pData;
std::vector<OUString> aFoundList; std::vector<OUString> aFoundList;
std::vector< std::unique_ptr<FilterEntry> > std::vector< std::unique_ptr<FilterEntry> >
...@@ -248,7 +240,6 @@ class TPGalleryThemeProperties : public SfxTabPage ...@@ -248,7 +240,6 @@ class TPGalleryThemeProperties : public SfxTabPage
OUString aLastFilterName; OUString aLastFilterName;
OUString aPreviewString; OUString aPreviewString;
INetURLObject aURL; INetURLObject aURL;
sal_uInt16 nFirstExtFilterPos;
bool bEntriesFound; bool bEntriesFound;
bool bInputAllowed; bool bInputAllowed;
bool bTakeAll; bool bTakeAll;
...@@ -258,6 +249,15 @@ class TPGalleryThemeProperties : public SfxTabPage ...@@ -258,6 +249,15 @@ class TPGalleryThemeProperties : public SfxTabPage
css::uno::Reference< css::media::XPlayer > xMediaPlayer; css::uno::Reference< css::media::XPlayer > xMediaPlayer;
css::uno::Reference< css::ui::dialogs::XFolderPicker2 > xFolderPicker; 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 void Reset( const SfxItemSet* /*rSet*/ ) override {}
virtual bool FillItemSet( SfxItemSet* /*rSet*/ ) override { return true; } virtual bool FillItemSet( SfxItemSet* /*rSet*/ ) override { return true; }
static OUString addExtension( const OUString&, const OUString& ); static OUString addExtension( const OUString&, const OUString& );
...@@ -268,19 +268,19 @@ class TPGalleryThemeProperties : public SfxTabPage ...@@ -268,19 +268,19 @@ class TPGalleryThemeProperties : public SfxTabPage
void DoPreview(); void DoPreview();
void EndSearchProgressHdl(sal_Int32 nResult); void EndSearchProgressHdl(sal_Int32 nResult);
DECL_LINK( ClickPreviewHdl, Button*, void ); DECL_LINK(ClickPreviewHdl, weld::ToggleButton&, void);
DECL_LINK( ClickSearchHdl, Button*, void ); DECL_LINK(ClickSearchHdl, weld::Button&, void);
DECL_LINK( ClickTakeHdl, Button*, void ); DECL_LINK(ClickTakeHdl, weld::Button&, void);
DECL_LINK( ClickTakeAllHdl, Button*, void ); DECL_LINK(ClickTakeAllHdl, weld::Button&, void);
DECL_LINK( SelectFoundHdl, ListBox&, void ); DECL_LINK(SelectFoundHdl, weld::TreeView&, void);
DECL_LINK( SelectFileTypeHdl, ComboBox&, void ); DECL_LINK(SelectFileTypeHdl, weld::ComboBox&, void);
DECL_LINK( DClickFoundHdl, ListBox&, void ); DECL_LINK(DClickFoundHdl, weld::TreeView&, void);
DECL_LINK( PreviewTimerHdl, Timer*, void ); DECL_LINK(PreviewTimerHdl, Timer*, void);
DECL_LINK( DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void ); DECL_LINK(DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void);
public: public:
TPGalleryThemeProperties( vcl::Window* pWindow, const SfxItemSet& rSet ); TPGalleryThemeProperties(TabPageParent pWindow, const SfxItemSet& rSet);
virtual ~TPGalleryThemeProperties() override; virtual ~TPGalleryThemeProperties() override;
virtual void dispose() override; virtual void dispose() override;
void SetXChgData( ExchangeData* pData ); void SetXChgData( ExchangeData* pData );
...@@ -288,7 +288,7 @@ public: ...@@ -288,7 +288,7 @@ public:
void StartSearchFiles( const OUString& _rFolderURL, short _nDlgResult ); 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 #endif // INCLUDED_CUI_SOURCE_INC_CUIGALDLG_HXX
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 --> <!-- Generated with glade 3.22.1 -->
<interface domain="cui"> <interface domain="cui">
<requires lib="gtk+" version="3.18"/> <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"> <object class="GtkGrid" id="GalleryFilesPage">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
...@@ -15,6 +22,7 @@ ...@@ -15,6 +22,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="row_spacing">12</property> <property name="row_spacing">12</property>
<child> <child>
<object class="GtkGrid" id="grid2"> <object class="GtkGrid" id="grid2">
...@@ -26,10 +34,10 @@ ...@@ -26,10 +34,10 @@
<object class="GtkLabel" id="label1"> <object class="GtkLabel" id="label1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</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="label" translatable="yes" context="galleryfilespage|label1">_File type:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">filetype</property> <property name="mnemonic_widget">filetype</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
...@@ -37,16 +45,16 @@ ...@@ -37,16 +45,16 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="VclComboBoxText" id="filetype"> <object class="GtkComboBoxText" id="filetype">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="has_entry">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"> <child internal-child="entry">
<object class="GtkEntry" id="comboboxtext-entry"> <object class="GtkEntry" id="comboboxtext-entry">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="width_chars">30</property> <property name="activates_default">True</property>
</object> </object>
</child> </child>
</object> </object>
...@@ -62,20 +70,43 @@ ...@@ -62,20 +70,43 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkTreeView" id="files:border"> <object class="GtkScrolledWindow">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="show_expanders">False</property> <property name="shadow_type">in</property>
<child internal-child="selection"> <child>
<object class="GtkTreeSelection" id="treeview-selection1"> <object class="GtkTreeView" id="files">
<property name="mode">multiple</property> <property name="visible">True</property>
</object> <property name="can_focus">True</property>
</child> <property name="hexpand">True</property>
<child internal-child="accessible"> <property name="vexpand">True</property>
<object class="AtkObject" id="files:border-atkobject"> <property name="model">liststore1</property>
<property name="AtkObject::accessible-name" translatable="yes" context="galleryfilespage|files-atkobject">Files Found</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> </object>
</child> </child>
</object> </object>
...@@ -116,14 +147,27 @@ ...@@ -116,14 +147,27 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="svxcorelo-GalleryPreview" id="image:border"> <object class="GtkScrolledWindow">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hscrollbar_policy">never</property>
<property name="vexpand">True</property> <property name="vscrollbar_policy">never</property>
<child internal-child="accessible"> <property name="shadow_type">in</property>
<object class="AtkObject" id="image:border-atkobject"> <child>
<property name="AtkObject::accessible-name" translatable="yes" context="galleryfilespage|image-atkobject">Preview</property> <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> </object>
</child> </child>
</object> </object>
......
...@@ -154,9 +154,6 @@ ...@@ -154,9 +154,6 @@
<glade-widget-class title="Mark Preview" name="swuilo-SwMarkPreview" <glade-widget-class title="Mark Preview" name="swuilo-SwMarkPreview"
generic-name="Mark Preview Window" parent="GtkDrawingArea" generic-name="Mark Preview Window" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/> 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" <glade-widget-class title="Html Attribute Preview" name="sduilo-SdHtmlAttrPreview"
generic-name="Html Attribute Preview" parent="GtkDrawingArea" generic-name="Html Attribute Preview" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/> icon-name="widget-gtk-drawingarea"/>
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <vcl/menu.hxx> #include <vcl/menu.hxx>
#include <vcl/edit.hxx> #include <vcl/edit.hxx>
#include <vcl/combobox.hxx> #include <vcl/combobox.hxx>
#include <vcl/customweld.hxx>
#include <svl/slstitm.hxx> #include <svl/slstitm.hxx>
#include <vcl/transfer.hxx> #include <vcl/transfer.hxx>
#include <svtools/valueset.hxx> #include <svtools/valueset.hxx>
...@@ -76,6 +77,26 @@ public: ...@@ -76,6 +77,26 @@ public:
static void PreviewMedia( const INetURLObject& rURL ); 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 class GalleryIconView : public ValueSet, public DropTargetHelper, public DragSourceHelper
{ {
using ValueSet::StartDrag; using ValueSet::StartDrag;
......
...@@ -51,8 +51,6 @@ GalleryPreview::GalleryPreview(vcl::Window* pParent, WinBits nStyle, GalleryThem ...@@ -51,8 +51,6 @@ GalleryPreview::GalleryPreview(vcl::Window* pParent, WinBits nStyle, GalleryThem
InitSettings(); InitSettings();
} }
VCL_BUILDER_FACTORY_CONSTRUCTOR(GalleryPreview, WB_TABSTOP)
Size GalleryPreview::GetOptimalSize() const Size GalleryPreview::GetOptimalSize() const
{ {
return LogicToPixel(Size(70, 88), MapMode(MapUnit::MapAppFont)); return LogicToPixel(Size(70, 88), MapMode(MapUnit::MapAppFont));
...@@ -257,6 +255,90 @@ void GalleryPreview::PreviewMedia( const INetURLObject& rURL ) ...@@ -257,6 +255,90 @@ void GalleryPreview::PreviewMedia( const INetURLObject& rURL )
#endif #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) 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