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
...@@ -73,31 +73,29 @@ SearchThread::SearchThread( SearchProgress* pProgress, ...@@ -73,31 +73,29 @@ SearchThread::SearchThread( SearchProgress* pProgress,
{ {
} }
SearchThread::~SearchThread() SearchThread::~SearchThread()
{ {
} }
void SearchThread::execute() void SearchThread::execute()
{ {
const OUString aFileType( mpBrowser->m_pCbbFileType->GetText() ); const OUString aFileType(mpBrowser->m_xCbbFileType->get_active_text());
if( !aFileType.isEmpty() ) if (!aFileType.isEmpty())
{ {
const sal_Int32 nFileNumber = mpBrowser->m_pCbbFileType->GetEntryPos( aFileType ); const int nFileNumber = mpBrowser->m_xCbbFileType->find_text(aFileType);
sal_Int32 nBeginFormat, nEndFormat; sal_Int32 nBeginFormat, nEndFormat;
std::vector< OUString > aFormats; std::vector< OUString > aFormats;
if( !nFileNumber || ( nFileNumber >= mpBrowser->m_pCbbFileType->GetEntryCount() ) ) if( !nFileNumber || nFileNumber == -1)
{ {
nBeginFormat = 1; nBeginFormat = 1;
nEndFormat = mpBrowser->m_pCbbFileType->GetEntryCount() - 1; nEndFormat = mpBrowser->m_xCbbFileType->get_count() - 1;
} }
else else
nBeginFormat = nEndFormat = nFileNumber; nBeginFormat = nEndFormat = nFileNumber;
for( sal_Int32 i = nBeginFormat; i <= nEndFormat; ++i ) for (sal_Int32 i = nBeginFormat; i <= nEndFormat; ++i)
aFormats.push_back( mpBrowser->aFilterEntryList[ i ]->aFilterName.toAsciiLowerCase() ); aFormats.push_back( mpBrowser->aFilterEntryList[ i ]->aFilterName.toAsciiLowerCase() );
ImplSearch( maStartURL, aFormats, mpBrowser->bSearchRecursive ); ImplSearch( maStartURL, aFormats, mpBrowser->bSearchRecursive );
...@@ -171,9 +169,9 @@ void SearchThread::ImplSearch( const INetURLObject& rStartURL, ...@@ -171,9 +169,9 @@ void SearchThread::ImplSearch( const INetURLObject& rStartURL,
mpBrowser->aFoundList.push_back( mpBrowser->aFoundList.push_back(
aFoundURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) aFoundURL.GetMainURL( INetURLObject::DecodeMechanism::NONE )
); );
mpBrowser->m_pLbxFound->InsertEntry( mpBrowser->m_xLbxFound->insert_text(
GetReducedString( aFoundURL, 50 ), mpBrowser->aFoundList.size() - 1,
static_cast<sal_uInt16>(mpBrowser->aFoundList.size()) - 1 ); GetReducedString(aFoundURL, 50));
} }
} }
} }
...@@ -279,16 +277,24 @@ void TakeThread::execute() ...@@ -279,16 +277,24 @@ void TakeThread::execute()
GalleryTheme* pThm = mpBrowser->GetXChgData()->pTheme; GalleryTheme* pThm = mpBrowser->GetXChgData()->pTheme;
std::unique_ptr<GalleryProgress> pStatusProgress; std::unique_ptr<GalleryProgress> pStatusProgress;
std::vector<int> aSelectedRows;
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
pStatusProgress.reset(new GalleryProgress); pStatusProgress.reset(new GalleryProgress);
nEntries = mpBrowser->bTakeAll ? mpBrowser->m_pLbxFound->GetEntryCount() : mpBrowser->m_pLbxFound->GetSelectedEntryCount(); if (mpBrowser->bTakeAll)
nEntries = mpBrowser->m_xLbxFound->n_children();
else
{
aSelectedRows = mpBrowser->m_xLbxFound->get_selected_rows();
nEntries = aSelectedRows.size();
}
pThm->LockBroadcaster(); pThm->LockBroadcaster();
} }
for( sal_Int32 i = 0; i < nEntries && schedule(); ++i ) for( sal_Int32 i = 0; i < nEntries && schedule(); ++i )
{ {
const sal_Int32 nPos = mpBrowser->bTakeAll ? i : mpBrowser->m_pLbxFound->GetSelectedEntryPos( i ); const sal_Int32 nPos = mpBrowser->bTakeAll ? i : aSelectedRows[i];
const INetURLObject aURL( mpBrowser->aFoundList[ nPos ]); const INetURLObject aURL( mpBrowser->aFoundList[ nPos ]);
mrTakenList.push_back( static_cast<sal_uLong>(nPos) ); mrTakenList.push_back( static_cast<sal_uLong>(nPos) );
...@@ -359,8 +365,8 @@ IMPL_LINK_NOARG(TakeProgress, CleanUpHdl, void*, void) ...@@ -359,8 +365,8 @@ IMPL_LINK_NOARG(TakeProgress, CleanUpHdl, void*, void)
sal_uInt32 i, nCount; sal_uInt32 i, nCount;
GetParent()->EnterWait(); GetParent()->EnterWait();
pBrowser->m_pLbxFound->SetUpdateMode( false ); pBrowser->m_xLbxFound->select(-1);
pBrowser->m_pLbxFound->SetNoSelection(); pBrowser->m_xLbxFound->freeze();
// mark all taken positions in aRemoveEntries // mark all taken positions in aRemoveEntries
for( i = 0, nCount = maTakenList.size(); i < nCount; ++i ) for( i = 0, nCount = maTakenList.size(); i < nCount; ++i )
...@@ -382,17 +388,17 @@ IMPL_LINK_NOARG(TakeProgress, CleanUpHdl, void*, void) ...@@ -382,17 +388,17 @@ IMPL_LINK_NOARG(TakeProgress, CleanUpHdl, void*, void)
// refill list box // refill list box
for( i = 0, nCount = aRemoveEntries.size(); i < nCount; ++i ) for( i = 0, nCount = aRemoveEntries.size(); i < nCount; ++i )
if( !aRemoveEntries[ i ] ) if( !aRemoveEntries[ i ] )
aRemainingVector.push_back( pBrowser->m_pLbxFound->GetEntry( static_cast<sal_uInt16>(i) ) ); aRemainingVector.push_back(pBrowser->m_xLbxFound->get_text(i));
pBrowser->m_pLbxFound->Clear(); pBrowser->m_xLbxFound->clear();
for( i = 0, nCount = aRemainingVector.size(); i < nCount; ++i ) for( i = 0, nCount = aRemainingVector.size(); i < nCount; ++i )
pBrowser->m_pLbxFound->InsertEntry( aRemainingVector[ i ] ); pBrowser->m_xLbxFound->append_text(aRemainingVector[i]);
aRemainingVector.clear(); aRemainingVector.clear();
pBrowser->m_pLbxFound->SetUpdateMode( true ); pBrowser->m_xLbxFound->thaw();
pBrowser->SelectFoundHdl( *pBrowser->m_pLbxFound ); pBrowser->SelectFoundHdl( *pBrowser->m_xLbxFound );
GetParent()->LeaveWait(); GetParent()->LeaveWait();
EndDialog( RET_OK ); EndDialog( RET_OK );
...@@ -653,57 +659,51 @@ VclPtr<SfxTabPage> TPGalleryThemeGeneral::Create(TabPageParent pParent, const Sf ...@@ -653,57 +659,51 @@ VclPtr<SfxTabPage> TPGalleryThemeGeneral::Create(TabPageParent pParent, const Sf
return VclPtr<TPGalleryThemeGeneral>::Create(pParent, *rSet); return VclPtr<TPGalleryThemeGeneral>::Create(pParent, *rSet);
} }
TPGalleryThemeProperties::TPGalleryThemeProperties( vcl::Window* pWindow, const SfxItemSet& rSet ) TPGalleryThemeProperties::TPGalleryThemeProperties(TabPageParent pWindow, const SfxItemSet& rSet)
: SfxTabPage(pWindow, "GalleryFilesPage", "cui/ui/galleryfilespage.ui", &rSet) : SfxTabPage(pWindow, "cui/ui/galleryfilespage.ui", "GalleryFilesPage", &rSet)
, pData(nullptr) , pData(nullptr)
, nFirstExtFilterPos(0)
, bEntriesFound(false) , bEntriesFound(false)
, bInputAllowed(true) , bInputAllowed(true)
, bTakeAll(false) , bTakeAll(false)
, bSearchRecursive(false) , bSearchRecursive(false)
, xDialogListener(new ::svt::DialogClosedListener()) , xDialogListener(new ::svt::DialogClosedListener())
, m_xCbbFileType(m_xBuilder->weld_combo_box("filetype"))
, m_xLbxFound(m_xBuilder->weld_tree_view("files"))
, m_xBtnSearch(m_xBuilder->weld_button("findfiles"))
, m_xBtnTake(m_xBuilder->weld_button("add"))
, m_xBtnTakeAll(m_xBuilder->weld_button("addall"))
, m_xCbxPreview(m_xBuilder->weld_check_button("preview"))
, m_xWndPreview(new weld::CustomWeld(*m_xBuilder, "image", m_aWndPreview))
{ {
get(m_pCbbFileType, "filetype"); m_xLbxFound->set_size_request(m_xLbxFound->get_approximate_digit_width() * 35,
get(m_pLbxFound, "files"); m_xLbxFound->get_height_rows(15));
Size aSize(LogicToPixel(Size(172, 156), MapMode(MapUnit::MapAppFont))); m_xLbxFound->set_selection_mode(true);
m_pLbxFound->set_width_request(aSize.Width());
m_pLbxFound->set_height_request(aSize.Height());
m_pLbxFound->EnableMultiSelection(true);
get(m_pBtnSearch, "findfiles");
get(m_pBtnTake, "add");
get(m_pBtnTakeAll, "addall");
get(m_pCbxPreview, "preview");
get(m_pWndPreview, "image");
xDialogListener->SetDialogClosedLink( LINK( this, TPGalleryThemeProperties, DialogClosedHdl ) ); xDialogListener->SetDialogClosedLink( LINK( this, TPGalleryThemeProperties, DialogClosedHdl ) );
} }
void TPGalleryThemeProperties::SetXChgData( ExchangeData* _pData ) void TPGalleryThemeProperties::SetXChgData( ExchangeData* _pData )
{ {
pData = _pData; pData = _pData;
aPreviewTimer.SetInvokeHandler( LINK( this, TPGalleryThemeProperties, PreviewTimerHdl ) ); aPreviewTimer.SetInvokeHandler( LINK( this, TPGalleryThemeProperties, PreviewTimerHdl ) );
aPreviewTimer.SetTimeout( 500 ); aPreviewTimer.SetTimeout( 500 );
m_pBtnSearch->SetClickHdl(LINK(this, TPGalleryThemeProperties, ClickSearchHdl)); m_xBtnSearch->connect_clicked(LINK(this, TPGalleryThemeProperties, ClickSearchHdl));
m_pBtnTake->SetClickHdl(LINK(this, TPGalleryThemeProperties, ClickTakeHdl)); m_xBtnTake->connect_clicked(LINK(this, TPGalleryThemeProperties, ClickTakeHdl));
m_pBtnTakeAll->SetClickHdl(LINK(this, TPGalleryThemeProperties, ClickTakeAllHdl)); m_xBtnTakeAll->connect_clicked(LINK(this, TPGalleryThemeProperties, ClickTakeAllHdl));
m_pCbxPreview->SetClickHdl(LINK(this, TPGalleryThemeProperties, ClickPreviewHdl)); m_xCbxPreview->connect_toggled(LINK(this, TPGalleryThemeProperties, ClickPreviewHdl));
m_pCbbFileType->SetSelectHdl(LINK(this, TPGalleryThemeProperties, SelectFileTypeHdl)); m_xCbbFileType->connect_changed(LINK(this, TPGalleryThemeProperties, SelectFileTypeHdl));
m_pCbbFileType->EnableDDAutoWidth( false ); m_xLbxFound->connect_row_activated(LINK(this, TPGalleryThemeProperties, DClickFoundHdl));
m_pLbxFound->SetDoubleClickHdl(LINK(this, TPGalleryThemeProperties, DClickFoundHdl)); m_xLbxFound->connect_changed(LINK(this, TPGalleryThemeProperties, SelectFoundHdl));
m_pLbxFound->SetSelectHdl(LINK(this, TPGalleryThemeProperties, SelectFoundHdl)); m_xLbxFound->append_text(CuiResId(RID_SVXSTR_GALLERY_NOFILES));
m_pLbxFound->InsertEntry(CuiResId(RID_SVXSTR_GALLERY_NOFILES)); m_xLbxFound->show();
m_pLbxFound->Show();
FillFilterList(); FillFilterList();
m_pBtnTake->Enable(); m_xBtnTake->set_sensitive(true);
m_pBtnTakeAll->Disable(); m_xBtnTakeAll->set_sensitive(false);
m_pCbxPreview->Disable(); m_xCbxPreview->set_sensitive(false);
} }
void TPGalleryThemeProperties::StartSearchFiles( const OUString& _rFolderURL, short _nDlgResult ) void TPGalleryThemeProperties::StartSearchFiles( const OUString& _rFolderURL, short _nDlgResult )
{ {
if ( RET_OK == _nDlgResult ) if ( RET_OK == _nDlgResult )
...@@ -714,37 +714,24 @@ void TPGalleryThemeProperties::StartSearchFiles( const OUString& _rFolderURL, sh ...@@ -714,37 +714,24 @@ void TPGalleryThemeProperties::StartSearchFiles( const OUString& _rFolderURL, sh
} }
} }
TPGalleryThemeProperties::~TPGalleryThemeProperties() TPGalleryThemeProperties::~TPGalleryThemeProperties()
{ {
disposeOnce(); disposeOnce();
} }
void TPGalleryThemeProperties::dispose() void TPGalleryThemeProperties::dispose()
{ {
xMediaPlayer.clear(); xMediaPlayer.clear();
xDialogListener.clear(); xDialogListener.clear();
aFilterEntryList.clear(); aFilterEntryList.clear();
m_pCbbFileType.clear();
m_pLbxFound.clear();
m_pBtnSearch.clear();
m_pBtnTake.clear();
m_pBtnTakeAll.clear();
m_pCbxPreview.clear();
m_pWndPreview.clear();
SfxTabPage::dispose(); SfxTabPage::dispose();
} }
VclPtr<SfxTabPage> TPGalleryThemeProperties::Create(TabPageParent pParent, const SfxItemSet* rSet)
VclPtr<SfxTabPage> TPGalleryThemeProperties::Create( TabPageParent pParent, const SfxItemSet* rSet )
{ {
return VclPtr<TPGalleryThemeProperties>::Create( pParent.pParent, *rSet ); return VclPtr<TPGalleryThemeProperties>::Create(pParent, *rSet);
} }
OUString TPGalleryThemeProperties::addExtension( const OUString& _rDisplayText, const OUString& _rExtension ) OUString TPGalleryThemeProperties::addExtension( const OUString& _rDisplayText, const OUString& _rExtension )
{ {
OUString sRet = _rDisplayText; OUString sRet = _rDisplayText;
...@@ -755,7 +742,6 @@ OUString TPGalleryThemeProperties::addExtension( const OUString& _rDisplayText, ...@@ -755,7 +742,6 @@ OUString TPGalleryThemeProperties::addExtension( const OUString& _rDisplayText,
return sRet; return sRet;
} }
void TPGalleryThemeProperties::FillFilterList() void TPGalleryThemeProperties::FillFilterList()
{ {
GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter(); GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter();
...@@ -803,12 +789,8 @@ void TPGalleryThemeProperties::FillFilterList() ...@@ -803,12 +789,8 @@ void TPGalleryThemeProperties::FillFilterList()
{ {
std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry); std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry);
pFilterEntry->aFilterName = aExt; pFilterEntry->aFilterName = aExt;
size_t pos = m_pCbbFileType->InsertEntry( aName ); m_xCbbFileType->append_text(aName);
if ( pos < aFilterEntryList.size() ) { aFilterEntryList.push_back(std::move(pFilterEntry));
aFilterEntryList.insert( aFilterEntryList.begin() + pos, std::move(pFilterEntry) );
} else {
aFilterEntryList.push_back( std::move(pFilterEntry) );
}
} }
} }
...@@ -827,21 +809,10 @@ void TPGalleryThemeProperties::FillFilterList() ...@@ -827,21 +809,10 @@ void TPGalleryThemeProperties::FillFilterList()
std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry); std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry);
pFilterEntry->aFilterName = aFilter.second.getToken( 0, ';', nIndex ); pFilterEntry->aFilterName = aFilter.second.getToken( 0, ';', nIndex );
aFilterWildcard += pFilterEntry->aFilterName; aFilterWildcard += pFilterEntry->aFilterName;
nFirstExtFilterPos = m_pCbbFileType->InsertEntry( m_xCbbFileType->append_text(addExtension(aFilter.first, aFilterWildcard));
addExtension( aFilter.first, aFilterWildcard ) aFilterEntryList.push_back( std::move(pFilterEntry) );
);
if ( nFirstExtFilterPos < aFilterEntryList.size() ) {
aFilterEntryList.insert(
aFilterEntryList.begin() + nFirstExtFilterPos,
std::move(pFilterEntry)
);
} else {
aFilterEntryList.push_back( std::move(pFilterEntry) );
}
} }
} }
#else
(void) nFirstExtFilterPos;
#endif #endif
// 'All' filters // 'All' filters
...@@ -887,19 +858,15 @@ void TPGalleryThemeProperties::FillFilterList() ...@@ -887,19 +858,15 @@ void TPGalleryThemeProperties::FillFilterList()
std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry); std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry);
pFilterEntry->aFilterName = CuiResId(RID_SVXSTR_GALLERY_ALLFILES); pFilterEntry->aFilterName = CuiResId(RID_SVXSTR_GALLERY_ALLFILES);
pFilterEntry->aFilterName = addExtension( pFilterEntry->aFilterName, aExtensions ); pFilterEntry->aFilterName = addExtension(pFilterEntry->aFilterName, aExtensions);
size_t pos = m_pCbbFileType->InsertEntry( pFilterEntry->aFilterName, 0 ); m_xCbbFileType->insert_text(0, pFilterEntry->aFilterName);
m_pCbbFileType->SetText( pFilterEntry->aFilterName ); m_xCbbFileType->set_active(0);
if ( pos < aFilterEntryList.size() ) { aFilterEntryList.insert(aFilterEntryList.begin(), std::move(pFilterEntry));
aFilterEntryList.insert( aFilterEntryList.begin() + pos, std::move(pFilterEntry) );
} else {
aFilterEntryList.push_back( std::move(pFilterEntry) );
}
} }
IMPL_LINK_NOARG(TPGalleryThemeProperties, SelectFileTypeHdl, ComboBox&, void) IMPL_LINK_NOARG(TPGalleryThemeProperties, SelectFileTypeHdl, weld::ComboBox&, void)
{ {
OUString aText( m_pCbbFileType->GetText() ); OUString aText(m_xCbbFileType->get_active_text());
if( bInputAllowed && ( aLastFilterName != aText ) ) if( bInputAllowed && ( aLastFilterName != aText ) )
{ {
...@@ -917,9 +884,9 @@ void TPGalleryThemeProperties::SearchFiles() ...@@ -917,9 +884,9 @@ void TPGalleryThemeProperties::SearchFiles()
VclPtrInstance<SearchProgress> pProgress( this, aURL ); VclPtrInstance<SearchProgress> pProgress( this, aURL );
aFoundList.clear(); aFoundList.clear();
m_pLbxFound->Clear(); m_xLbxFound->clear();
pProgress->SetFileType( m_pCbbFileType->GetText() ); pProgress->SetFileType( m_xCbbFileType->get_active_text() );
pProgress->SetDirectory( INetURLObject() ); pProgress->SetDirectory( INetURLObject() );
pProgress->Update(); pProgress->Update();
...@@ -928,8 +895,7 @@ void TPGalleryThemeProperties::SearchFiles() ...@@ -928,8 +895,7 @@ void TPGalleryThemeProperties::SearchFiles()
}); });
} }
IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickSearchHdl, weld::Button&, void)
IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickSearchHdl, Button*, void)
{ {
if( bInputAllowed ) if( bInputAllowed )
{ {
...@@ -966,7 +932,7 @@ IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickSearchHdl, Button*, void) ...@@ -966,7 +932,7 @@ IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickSearchHdl, Button*, void)
void TPGalleryThemeProperties::TakeFiles() void TPGalleryThemeProperties::TakeFiles()
{ {
if( m_pLbxFound->GetSelectedEntryCount() || ( bTakeAll && bEntriesFound ) ) if (m_xLbxFound->count_selected_rows() || (bTakeAll && bEntriesFound))
{ {
VclPtrInstance<TakeProgress> pTakeProgress( this ); VclPtrInstance<TakeProgress> pTakeProgress( this );
pTakeProgress->Update(); pTakeProgress->Update();
...@@ -978,39 +944,38 @@ void TPGalleryThemeProperties::TakeFiles() ...@@ -978,39 +944,38 @@ void TPGalleryThemeProperties::TakeFiles()
} }
} }
IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickPreviewHdl, weld::ToggleButton&, void)
IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickPreviewHdl, Button*, void)
{ {
if ( bInputAllowed ) if ( bInputAllowed )
{ {
aPreviewTimer.Stop(); aPreviewTimer.Stop();
aPreviewString.clear(); aPreviewString.clear();
if( !m_pCbxPreview->IsChecked() ) if (!m_xCbxPreview->get_active())
{ {
xMediaPlayer.clear(); xMediaPlayer.clear();
m_pWndPreview->SetGraphic( Graphic() ); m_aWndPreview.SetGraphic(Graphic());
m_pWndPreview->Invalidate(); m_aWndPreview.Invalidate();
} }
else else
DoPreview(); DoPreview();
} }
} }
void TPGalleryThemeProperties::DoPreview() void TPGalleryThemeProperties::DoPreview()
{ {
OUString aString( m_pLbxFound->GetSelectedEntry() ); int nIndex = m_xLbxFound->get_selected_index();
OUString aString(m_xLbxFound->get_text(nIndex));
if( aString != aPreviewString ) if (aString != aPreviewString)
{ {
INetURLObject _aURL( aFoundList[ m_pLbxFound->GetEntryPos( aString ) ] ); INetURLObject _aURL(aFoundList[nIndex]);
bInputAllowed = false; bInputAllowed = false;
if ( !m_pWndPreview->SetGraphic( _aURL ) ) if (!m_aWndPreview.SetGraphic(_aURL))
{ {
GetParent()->LeaveWait(); GetParent()->LeaveWait();
ErrorHandler::HandleError( ERRCODE_IO_NOTEXISTSPATH ); ErrorHandler::HandleError(ERRCODE_IO_NOTEXISTSPATH, GetDialogFrameWeld());
GetParent()->EnterWait(); GetParent()->EnterWait();
} }
#if HAVE_FEATURE_AVMEDIA #if HAVE_FEATURE_AVMEDIA
...@@ -1026,14 +991,13 @@ void TPGalleryThemeProperties::DoPreview() ...@@ -1026,14 +991,13 @@ void TPGalleryThemeProperties::DoPreview()
} }
} }
IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickTakeHdl, weld::Button&, void)
IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickTakeHdl, Button*, void)
{ {
if( bInputAllowed ) if( bInputAllowed )
{ {
aPreviewTimer.Stop(); aPreviewTimer.Stop();
if( !m_pLbxFound->GetSelectedEntryCount() || !bEntriesFound ) if (!m_xLbxFound->count_selected_rows() || !bEntriesFound)
{ {
SvxOpenGraphicDialog aDlg("Gallery", GetFrameWeld()); SvxOpenGraphicDialog aDlg("Gallery", GetFrameWeld());
aDlg.EnableLink(false); aDlg.EnableLink(false);
...@@ -1050,8 +1014,7 @@ IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickTakeHdl, Button*, void) ...@@ -1050,8 +1014,7 @@ IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickTakeHdl, Button*, void)
} }
} }
IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickTakeAllHdl, weld::Button&, void)
IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickTakeAllHdl, Button*, void)
{ {
if( bInputAllowed ) if( bInputAllowed )
{ {
...@@ -1061,10 +1024,9 @@ IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickTakeAllHdl, Button*, void) ...@@ -1061,10 +1024,9 @@ IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickTakeAllHdl, Button*, void)
} }
} }
IMPL_LINK_NOARG(TPGalleryThemeProperties, SelectFoundHdl, weld::TreeView&, void)
IMPL_LINK_NOARG(TPGalleryThemeProperties, SelectFoundHdl, ListBox&, void)
{ {
if( bInputAllowed ) if (bInputAllowed)
{ {
bool bPreviewPossible = false; bool bPreviewPossible = false;
...@@ -1072,38 +1034,36 @@ IMPL_LINK_NOARG(TPGalleryThemeProperties, SelectFoundHdl, ListBox&, void) ...@@ -1072,38 +1034,36 @@ IMPL_LINK_NOARG(TPGalleryThemeProperties, SelectFoundHdl, ListBox&, void)
if( bEntriesFound ) if( bEntriesFound )
{ {
if( m_pLbxFound->GetSelectedEntryCount() == 1 ) if (m_xLbxFound->count_selected_rows() == 1)
{ {
m_pCbxPreview->Enable(); m_xCbxPreview->set_sensitive(true);
bPreviewPossible = true; bPreviewPossible = true;
} }
else else
m_pCbxPreview->Disable(); m_xCbxPreview->set_sensitive(false);
if( !aFoundList.empty() ) if( !aFoundList.empty() )
m_pBtnTakeAll->Enable(); m_xBtnTakeAll->set_sensitive(true);
else else
m_pBtnTakeAll->Disable(); m_xBtnTakeAll->set_sensitive(false);
} }
if( bPreviewPossible && m_pCbxPreview->IsChecked() ) if (bPreviewPossible && m_xCbxPreview->get_active())
aPreviewTimer.Start(); aPreviewTimer.Start();
} }
} }
IMPL_LINK_NOARG(TPGalleryThemeProperties, DClickFoundHdl, weld::TreeView&, void)
IMPL_LINK_NOARG(TPGalleryThemeProperties, DClickFoundHdl, ListBox&, void)
{ {
if( bInputAllowed ) if( bInputAllowed )
{ {
aPreviewTimer.Stop(); aPreviewTimer.Stop();
if (m_pLbxFound->GetSelectedEntryCount() == 1 && bEntriesFound) if (m_xLbxFound->count_selected_rows() == 1 && bEntriesFound)
ClickTakeHdl(nullptr); ClickTakeHdl(*m_xBtnTake);
} }
} }
IMPL_LINK_NOARG(TPGalleryThemeProperties, PreviewTimerHdl, Timer *, void) IMPL_LINK_NOARG(TPGalleryThemeProperties, PreviewTimerHdl, Timer *, void)
{ {
aPreviewTimer.Stop(); aPreviewTimer.Stop();
...@@ -1114,16 +1074,16 @@ void TPGalleryThemeProperties::EndSearchProgressHdl(sal_Int32 /*nResult*/) ...@@ -1114,16 +1074,16 @@ void TPGalleryThemeProperties::EndSearchProgressHdl(sal_Int32 /*nResult*/)
{ {
if( !aFoundList.empty() ) if( !aFoundList.empty() )
{ {
m_pLbxFound->SelectEntryPos( 0 ); m_xLbxFound->select(0);
m_pBtnTakeAll->Enable(); m_xBtnTakeAll->set_sensitive(true);
m_pCbxPreview->Enable(); m_xCbxPreview->set_sensitive(true);
bEntriesFound = true; bEntriesFound = true;
} }
else else
{ {
m_pLbxFound->InsertEntry( CuiResId( RID_SVXSTR_GALLERY_NOFILES ) ); m_xLbxFound->append_text(CuiResId(RID_SVXSTR_GALLERY_NOFILES));
m_pBtnTakeAll->Disable(); m_xBtnTakeAll->set_sensitive(false);
m_pCbxPreview->Disable(); m_xCbxPreview->set_sensitive(false);
bEntriesFound = false; bEntriesFound = false;
} }
} }
......
...@@ -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"/>
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,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>
...@@ -75,6 +76,26 @@ public: ...@@ -75,6 +76,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