diff --git a/sfx2/inc/recentdocsview.hxx b/sfx2/inc/recentdocsview.hxx index 44165afbe38a..119bf6ee7267 100644 --- a/sfx2/inc/recentdocsview.hxx +++ b/sfx2/inc/recentdocsview.hxx @@ -82,6 +82,8 @@ public: void clearUnavailableFiles(); + void setFilter(ApplicationType aFilter); + private: virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override; diff --git a/sfx2/source/control/recentdocsview.cxx b/sfx2/source/control/recentdocsview.cxx index 61b9b55a64a6..c7c9efeb1c16 100644 --- a/sfx2/source/control/recentdocsview.cxx +++ b/sfx2/source/control/recentdocsview.cxx @@ -161,7 +161,8 @@ void RecentDocsView::Reload() OUString aURL = rRecentEntry.sURL; const INetURLObject aURLObj(aURL); - if (!isAcceptedFile(aURLObj)) + if ((mnFileTypes != ApplicationType::TYPE_NONE) && + (!isAcceptedFile(aURLObj))) continue; //Remove extension from url's last segment and use it as title @@ -174,6 +175,12 @@ void RecentDocsView::Reload() Invalidate(); } +void RecentDocsView::setFilter(ApplicationType aFilter) +{ + mnFileTypes = aFilter; + Reload(); +} + void RecentDocsView::clearUnavailableFiles(){ std::vector< SvtHistoryOptions::HistoryItem > aHistoryList = SvtHistoryOptions::GetList( EHistoryType::PickList ); for ( size_t i = 0; i < aHistoryList.size(); i++ ) diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx index 6b68370b0bae..a19529fea4f0 100644 --- a/sfx2/source/dialog/backingwindow.cxx +++ b/sfx2/source/dialog/backingwindow.cxx @@ -143,11 +143,13 @@ float const g_fMultiplier = 1.2f; BackingWindow::BackingWindow(vcl::Window* i_pParent) : InterimItemWindow(i_pParent, "sfx/ui/startcenter.ui", "StartCenter", false) , mxOpenButton(m_xBuilder->weld_button("open_all")) - , mxRecentButton(m_xBuilder->weld_menu_toggle_button("open_recent")) + , mxRecentButton(m_xBuilder->weld_toggle_button("open_recent")) , mxRemoteButton(m_xBuilder->weld_button("open_remote")) - , mxTemplateButton(m_xBuilder->weld_menu_toggle_button("templates_all")) + , mxTemplateButton(m_xBuilder->weld_toggle_button("templates_all")) , mxCreateLabel(m_xBuilder->weld_label("create_label")) , mxAltHelpLabel(m_xBuilder->weld_label("althelplabel")) + , mxFilter(m_xBuilder->weld_combo_box("cbFilter")) + , mxActions(m_xBuilder->weld_menu_button("mbActions")) , mxWriterAllButton(m_xBuilder->weld_button("writer_all")) , mxCalcAllButton(m_xBuilder->weld_button("calc_all")) , mxImpressAllButton(m_xBuilder->weld_button("impress_all")) @@ -174,6 +176,10 @@ BackingWindow::BackingWindow(vcl::Window* i_pParent) SetPaintTransparent(false); SetBackground(svtools::ColorConfig().GetColorValue(::svtools::APPBACKGROUND).nColor); + // square action button + auto nHeight = mxFilter->get_preferred_size().getHeight(); + mxActions->set_size_request(nHeight, nHeight); + //set an alternative help label that doesn't hotkey the H of the Help menu mxHelpButton->set_label(mxAltHelpLabel->get_label()); mxHelpButton->connect_clicked(LINK(this, BackingWindow, ClickHelpHdl)); @@ -227,6 +233,8 @@ void BackingWindow::dispose() mxTemplateButton.reset(); mxCreateLabel.reset(); mxAltHelpLabel.reset(); + mxFilter.reset(); + mxActions.reset(); mxWriterAllButton.reset(); mxCalcAllButton.reset(); mxImpressAllButton.reset(); @@ -278,11 +286,12 @@ void BackingWindow::initControls() mxAllRecentThumbnails->mnFileTypes |= sfx2::ApplicationType::TYPE_OTHER; mxAllRecentThumbnails->Reload(); mxAllRecentThumbnails->ShowTooltips( true ); - mxRecentButton->set_active(true); - mxRecentButton->grab_focus(); + mxAllRecentThumbnails->GrabFocus(); + mxRecentButton->set_highlight_background(); //initialize Template view mxLocalView->Hide(); + mxActions->set_sensitive(true); //set handlers mxLocalView->setCreateContextMenuHdl(LINK(this, BackingWindow, CreateContextMenuHdl)); @@ -296,8 +305,6 @@ void BackingWindow::initControls() mxOpenButton->connect_clicked(LINK(this, BackingWindow, ClickHdl)); mxRemoteButton->connect_clicked(LINK(this, BackingWindow, ClickHdl)); - mxRecentButton->connect_clicked(LINK(this, BackingWindow, ClickHdl)); - mxTemplateButton->connect_clicked(LINK(this, BackingWindow, ClickHdl)); mxWriterAllButton->connect_clicked(LINK(this, BackingWindow, ClickHdl)); mxDrawAllButton->connect_clicked(LINK(this, BackingWindow, ClickHdl)); mxCalcAllButton->connect_clicked(LINK(this, BackingWindow, ClickHdl)); @@ -305,8 +312,11 @@ void BackingWindow::initControls() mxImpressAllButton->connect_clicked(LINK(this, BackingWindow, ClickHdl)); mxMathAllButton->connect_clicked(LINK(this, BackingWindow, ClickHdl)); - mxRecentButton->connect_selected(LINK(this, BackingWindow, MenuSelectHdl)); - mxTemplateButton->connect_selected(LINK(this, BackingWindow, MenuSelectHdl)); + mxRecentButton->connect_toggled(LINK(this, BackingWindow, ToggleHdl)); + mxTemplateButton->connect_toggled(LINK(this, BackingWindow, ToggleHdl)); + + mxFilter->connect_changed(LINK(this, BackingWindow, FilterHdl)); + mxActions->connect_selected(LINK(this, BackingWindow, MenuSelectHdl)); ApplyStyleSettings(); } @@ -547,6 +557,55 @@ IMPL_LINK(BackingWindow, ExtLinkClickHdl, weld::Button&, rButton, void) } } +void BackingWindow::applyFilter() +{ + const int nFilter = mxFilter->get_active(); + if (mxLocalView->IsVisible()) + { + FILTER_APPLICATION aFilter = static_cast(nFilter); + mxLocalView->filterItems(ViewFilter_Application(aFilter)); + } + else + { + sfx2::ApplicationType aFilter; + if (nFilter == 0) + aFilter = sfx2::ApplicationType::TYPE_NONE; + else + aFilter = static_cast(1 << (nFilter - 1)); + mxAllRecentThumbnails->setFilter(aFilter); + } +} + +IMPL_LINK_NOARG( BackingWindow, FilterHdl, weld::ComboBox&, void ) +{ + applyFilter(); +} + +IMPL_LINK( BackingWindow, ToggleHdl, weld::Toggleable&, rButton, void ) +{ + if( &rButton == mxRecentButton.get() ) + { + mxLocalView->Hide(); + mxAllRecentThumbnails->Show(); + mxAllRecentThumbnails->GrabFocus(); + mxRecentButton->set_highlight_background(); + mxTemplateButton->set_stack_background(); + mxActions->set_sensitive(true); + } + else if( &rButton == mxTemplateButton.get() ) + { + mxAllRecentThumbnails->Hide(); + initializeLocalView(); + mxLocalView->Show(); + mxLocalView->reload(); + mxLocalView->GrabFocus(); + mxTemplateButton->set_highlight_background(); + mxRecentButton->set_stack_background(); + mxActions->set_sensitive(false); + } + applyFilter(); +} + IMPL_LINK( BackingWindow, ClickHdl, weld::Button&, rButton, void ) { // dispatch the appropriate URL and end the dialog @@ -574,25 +633,6 @@ IMPL_LINK( BackingWindow, ClickHdl, weld::Button&, rButton, void ) dispatchURL( ".uno:OpenRemote", OUString(), xFrame, {} ); } - else if( &rButton == mxRecentButton.get() ) - { - mxLocalView->Hide(); - mxAllRecentThumbnails->Show(); - mxAllRecentThumbnails->GrabFocus(); - mxRecentButton->set_active(true); - mxTemplateButton->set_active(false); - } - else if( &rButton == mxTemplateButton.get() ) - { - mxAllRecentThumbnails->Hide(); - initializeLocalView(); - mxLocalView->filterItems(ViewFilter_Application(FILTER_APPLICATION::NONE)); - mxLocalView->Show(); - mxLocalView->reload(); - mxLocalView->GrabFocus(); - mxRecentButton->set_active(false); - mxTemplateButton->set_active(true); - } } IMPL_LINK (BackingWindow, MenuSelectHdl, const OString&, rId, void) @@ -603,43 +643,9 @@ IMPL_LINK (BackingWindow, MenuSelectHdl, const OString&, rId, void) mxAllRecentThumbnails->Reload(); return; } - else if(rId == "clear_unavailable"){ - mxAllRecentThumbnails->clearUnavailableFiles(); - } - else if (!rId.isEmpty()) + else if(rId == "clear_unavailable") { - initializeLocalView(); - - if( rId == "filter_writer" ) - { - mxLocalView->filterItems(ViewFilter_Application(FILTER_APPLICATION::WRITER)); - } - else if( rId == "filter_calc" ) - { - mxLocalView->filterItems(ViewFilter_Application(FILTER_APPLICATION::CALC)); - } - else if( rId == "filter_impress" ) - { - mxLocalView->filterItems(ViewFilter_Application(FILTER_APPLICATION::IMPRESS)); - } - else if( rId == "filter_draw" ) - { - mxLocalView->filterItems(ViewFilter_Application(FILTER_APPLICATION::DRAW)); - } - else if( rId == "manage" ) - { - Reference< XDispatchProvider > xFrame( mxFrame, UNO_QUERY ); - - dispatchURL( ".uno:NewDoc", OUString(), xFrame, { comphelper::makePropertyValue("Referer", OUString("private:user")) } ); - return; - } - - mxAllRecentThumbnails->Hide(); - mxLocalView->Show(); - mxLocalView->reload(); - mxLocalView->GrabFocus(); - mxRecentButton->set_active(false); - mxTemplateButton->set_active(true); + mxAllRecentThumbnails->clearUnavailableFiles(); } } diff --git a/sfx2/source/dialog/backingwindow.hxx b/sfx2/source/dialog/backingwindow.hxx index 358055c66aae..2bd2e04e87a1 100644 --- a/sfx2/source/dialog/backingwindow.hxx +++ b/sfx2/source/dialog/backingwindow.hxx @@ -48,12 +48,14 @@ class BackingWindow : public InterimItemWindow css::uno::Reference mxDropTargetListener; std::unique_ptr mxOpenButton; - std::unique_ptr mxRecentButton; + std::unique_ptr mxRecentButton; std::unique_ptr mxRemoteButton; - std::unique_ptr mxTemplateButton; + std::unique_ptr mxTemplateButton; std::unique_ptr mxCreateLabel; std::unique_ptr mxAltHelpLabel; + std::unique_ptr mxFilter; + std::unique_ptr mxActions; std::unique_ptr mxWriterAllButton; std::unique_ptr mxCalcAllButton; @@ -88,6 +90,8 @@ class BackingWindow : public InterimItemWindow const css::uno::Sequence& = css::uno::Sequence< css::beans::PropertyValue>()); + DECL_LINK(ToggleHdl, weld::Toggleable&, void); + DECL_LINK(FilterHdl, weld::ComboBox&, void); DECL_LINK(ClickHdl, weld::Button&, void); DECL_LINK(ClickHelpHdl, weld::Button&, void); DECL_LINK(MenuSelectHdl, const OString&, void); @@ -107,6 +111,9 @@ class BackingWindow : public InterimItemWindow template void setLargerFont(WidgetClass&, const vcl::Font&); void ApplyStyleSettings(); +private: + void applyFilter(); + public: explicit BackingWindow(vcl::Window* pParent); virtual ~BackingWindow() override; diff --git a/sfx2/uiconfig/ui/startcenter.ui b/sfx2/uiconfig/ui/startcenter.ui index 89b4653dffa7..8120556f3d22 100644 --- a/sfx2/uiconfig/ui/startcenter.ui +++ b/sfx2/uiconfig/ui/startcenter.ui @@ -1,5 +1,5 @@ - + @@ -35,50 +35,11 @@ False res/odg_32_8.png - + True False - - - True - False - Writer Templates - - - - - True - False - Calc Templates - - - - - True - False - Impress Templates - - - - - True - False - Draw Templates - - - - - True - False - - - - - True - False - Manage Templates - - + open-menu-symbolic + 3 True @@ -208,9 +169,8 @@ - + _Recent Documents - MenuToggleButton True True True @@ -221,9 +181,6 @@ True 0 True - True - clearmenu - False False @@ -232,9 +189,8 @@ - + T_emplates - MenuToggleButton True True True @@ -245,9 +201,6 @@ True 0 True - True - filtermenu - False False @@ -545,6 +498,78 @@ 1 + + + + True + False + 6 + 6 + 6 + 6 + 3 + + + True + False + start + Filter: + + + + + + 0 + 0 + + + + + True + False + start + 0 + + All Applications + Text Documents + Spreadsheets + Presentations + Drawings + + + + + + + 1 + 0 + + + + + True + True + False + True + Actions + end + True + imActions + True + clearmenu + + + 2 + 0 + + + + + False + True + 2 + + True @@ -573,7 +598,7 @@ False True - 2 + 3 @@ -604,7 +629,7 @@ False True - 3 + 4