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

weld FilterDialog

I think this is theoretical and in practice this dialog never appears
anymore

Change-Id: I1c29432ecf0df215c686c228326183d9a3a422d3
Reviewed-on: https://gerrit.libreoffice.org/54489Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 16f784b1
......@@ -44,28 +44,18 @@ namespace uui
@param "pParentWindow" , parent window for dialog
@threadsafe no
*//*-*************************************************************************************************************/
FilterDialog::FilterDialog( vcl::Window* pParentWindow )
: ModalDialog (pParentWindow, "FilterSelectDialog", "uui/ui/filterselect.ui" )
, m_pFilterNames(nullptr)
FilterDialog::FilterDialog(weld::Window* pParentWindow)
: GenericDialogController(pParentWindow, "uui/ui/filterselect.ui", "FilterSelectDialog")
, m_pFilterNames(nullptr)
, m_xFtURL(m_xBuilder->weld_label("url"))
, m_xLbFilters(m_xBuilder->weld_tree_view("filters"))
{
get(m_pFtURL, "url");
get(m_pLbFilters, "filters");
Size aSize(pParentWindow->LogicToPixel(Size(182, 175), MapMode(MapUnit::MapAppFont)));
m_pLbFilters->set_height_request(aSize.Height());
m_pLbFilters->set_width_request(aSize.Width());
m_pFtURL->SetSizePixel(Size(aSize.Width(), m_pFtURL->GetOptimalSize().Height()));
m_xLbFilters->set_size_request(m_xLbFilters->get_approximate_digit_width() * 42,
m_xLbFilters->get_height_rows(15));
}
FilterDialog::~FilterDialog()
{
disposeOnce();
}
void FilterDialog::dispose()
{
m_pFtURL.clear();
m_pLbFilters.clear();
ModalDialog::dispose();
}
/*-************************************************************************************************************
......@@ -77,7 +67,7 @@ void FilterDialog::dispose()
void FilterDialog::SetURL( const OUString& sURL )
{
// convert it and use given pure string as fallback if conversion failed
m_pFtURL->SetText( impl_buildUIFileName(sURL) );
m_xFtURL->set_label(impl_buildUIFileName(sURL));
}
/*-************************************************************************************************************
......@@ -100,14 +90,14 @@ void FilterDialog::SetURL( const OUString& sURL )
void FilterDialog::ChangeFilters( const FilterNameList* pFilterNames )
{
m_pFilterNames = pFilterNames;
m_pLbFilters->Clear();
m_xLbFilters->clear();
if( m_pFilterNames != nullptr )
{
for( FilterNameListPtr pItem = m_pFilterNames->begin();
pItem != m_pFilterNames->end() ;
++pItem )
{
m_pLbFilters->InsertEntry( pItem->sUI );
m_xLbFilters->append_text(pItem->sUI);
}
}
}
......@@ -136,12 +126,12 @@ bool FilterDialog::AskForFilter( FilterNameListPtr& pSelectedItem )
if( m_pFilterNames != nullptr )
{
if( ModalDialog::Execute() == RET_OK )
if (m_xDialog->run() == RET_OK)
{
OUString sEntry = m_pLbFilters->GetSelectedEntry();
OUString sEntry = m_xLbFilters->get_selected_text();
if( !sEntry.isEmpty() )
{
int nPos = m_pLbFilters->GetSelectedEntryPos();
int nPos = m_xLbFilters->get_selected_index();
if( nPos < static_cast<int>(m_pFilterNames->size()) )
{
pSelectedItem = m_pFilterNames->begin();
......@@ -167,18 +157,18 @@ bool FilterDialog::AskForFilter( FilterNameListPtr& pSelectedItem )
class StringCalculator : public ::cppu::WeakImplHelper< css::util::XStringWidth >
{
public:
explicit StringCalculator( const OutputDevice* pDevice )
: m_pDevice( const_cast< OutputDevice * >( pDevice ) )
explicit StringCalculator(weld::Widget* pDevice)
: m_pDevice(pDevice)
{
}
sal_Int32 SAL_CALL queryStringWidth( const OUString& sString ) override
{
return static_cast<sal_Int32>(m_pDevice->GetTextWidth(sString));
return static_cast<sal_Int32>(m_pDevice->get_pixel_size(sString).Width());
}
private:
VclPtr<OutputDevice> m_pDevice;
weld::Widget* m_pDevice;
};
/*-************************************************************************************************************
......@@ -206,11 +196,11 @@ OUString FilterDialog::impl_buildUIFileName( const OUString& sName )
else
{
// otherwise its really a url ... build short name by using INetURLObject
css::uno::Reference< css::util::XStringWidth > xStringCalculator( new StringCalculator(m_pFtURL) );
css::uno::Reference< css::util::XStringWidth > xStringCalculator(new StringCalculator(m_xFtURL.get()));
if( xStringCalculator.is() )
{
INetURLObject aBuilder ( sName );
Size aSize = m_pFtURL->GetOutputSizePixel();
Size aSize = m_xLbFilters->get_preferred_size();
sShortName = aBuilder.getAbbreviated( xStringCalculator, aSize.Width(), INetURLObject::DecodeMechanism::Unambiguous );
}
}
......
......@@ -20,12 +20,7 @@
#ifndef INCLUDED_UUI_SOURCE_FLTDLG_HXX
#define INCLUDED_UUI_SOURCE_FLTDLG_HXX
#include <vcl/dialog.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/button.hxx>
#include <vcl/fixed.hxx>
#include <vcl/weld.hxx>
#include <vector>
......@@ -41,27 +36,24 @@ struct FilterNamePair
typedef ::std::vector< FilterNamePair > FilterNameList ;
typedef FilterNameList::const_iterator FilterNameListPtr;
class FilterDialog : public ModalDialog
class FilterDialog : public weld::GenericDialogController
{
// public interface
public:
explicit FilterDialog(vcl::Window* pParentWindow);
explicit FilterDialog(weld::Window* pParentWindow);
virtual ~FilterDialog() override;
virtual void dispose() override;
void SetURL ( const OUString& sURL );
void ChangeFilters( const FilterNameList* pFilterNames );
bool AskForFilter ( FilterNameListPtr& pSelectedItem );
// helper (or hided functions!)
private:
short Execute() override { return RET_CANCEL; };
OUString impl_buildUIFileName( const OUString& sURL );
// member
private:
VclPtr<FixedText> m_pFtURL ;
VclPtr<ListBox> m_pLbFilters ;
const FilterNameList* m_pFilterNames;
std::unique_ptr<weld::Label> m_xFtURL;
std::unique_ptr<weld::TreeView> m_xLbFilters;
}; // class FilterDialog
......
......@@ -45,20 +45,20 @@ namespace {
void
executeFilterDialog(
vcl::Window * pParent ,
weld::Window* pParent ,
OUString const & rURL ,
uui::FilterNameList const & rFilters,
OUString & rFilter )
{
SolarMutexGuard aGuard;
ScopedVclPtrInstance< uui::FilterDialog > xDialog(pParent);
uui::FilterDialog aDialog(pParent);
xDialog->SetURL(rURL);
xDialog->ChangeFilters(&rFilters);
aDialog.SetURL(rURL);
aDialog.ChangeFilters(&rFilters);
uui::FilterNameListPtr pSelected = rFilters.end();
if( xDialog->AskForFilter( pSelected ) )
if (aDialog.AskForFilter(pSelected))
{
rFilter = pSelected->sInternal;
}
......@@ -66,7 +66,7 @@ executeFilterDialog(
void
handleNoSuchFilterRequest_(
vcl::Window * pParent,
weld::Window* pParent,
uno::Reference< uno::XComponentContext > const & xContext,
document::NoSuchFilterRequest const & rRequest,
uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
......@@ -292,7 +292,8 @@ UUIInteractionHelper::handleNoSuchFilterRequest(
document::NoSuchFilterRequest aNoSuchFilterRequest;
if (aAnyRequest >>= aNoSuchFilterRequest)
{
handleNoSuchFilterRequest_(getParentProperty(),
uno::Reference<awt::XWindow> xParent = getParentXWindow();
handleNoSuchFilterRequest_(Application::GetFrameWeld(xParent),
m_xContext,
aNoSuchFilterRequest,
rRequest->getContinuations());
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface domain="uui">
<!-- interface-requires gtk+ 3.0 -->
<requires lib="gtk+" version="3.18"/>
<object class="GtkListStore" id="liststore1">
<columns>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog" id="FilterSelectDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="filterselect|FilterSelectDialog">Filter Selection</property>
<property name="modal">True</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="layout_style">start</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="ok">
<property name="label">gtk-ok</property>
......@@ -24,7 +39,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
......@@ -40,7 +54,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
......@@ -56,13 +69,13 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="secondary">True</property>
</packing>
</child>
</object>
......@@ -96,13 +109,36 @@
</packing>
</child>
<child>
<object class="GtkTreeView" id="filters: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>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="filters">
<property name="visible">True</property>
<property name="can_focus">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"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
......
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