diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-02-19 16:33:35 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-02-22 22:07:38 +0100 |
commit | 6a4c464b49dbfa2801818ead1b50bc9580824d00 (patch) | |
tree | 3d6381b6b13576bc536670992b36784436486e95 /desktop | |
parent | f7733528e88a6619f82b54b59e92a9bca72c0a89 (diff) |
weld native message dialogs
just the straight-forward MessageDialog cases first
a) remove border_width from message dialog .ui so as to take
the default border width
b) retain 12 as default message dialog border for vcl widget case
c) remove layour_style from message dialog button boxes so as to
take the default mode (a no-op for vcl widget case)
d) use gtk response ids (vcl builder will converts to vcl ones)
Change-Id: I7de281093a1b64f92f71ca11e7cbba42bb658154
Reviewed-on: https://gerrit.libreoffice.org/50143
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/app/app.cxx | 20 | ||||
-rw-r--r-- | desktop/source/app/lockfile2.cxx | 17 | ||||
-rw-r--r-- | desktop/source/deployment/gui/dp_gui_dialog2.cxx | 60 | ||||
-rw-r--r-- | desktop/source/deployment/gui/dp_gui_dialog2.hxx | 4 | ||||
-rw-r--r-- | desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx | 34 | ||||
-rw-r--r-- | desktop/source/deployment/gui/dp_gui_service.cxx | 9 | ||||
-rw-r--r-- | desktop/uiconfig/ui/installforalldialog.ui | 8 |
7 files changed, 79 insertions, 73 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 936671f07e58..77152718287e 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -103,7 +103,7 @@ #include <svtools/menuoptions.hxx> #include <rtl/bootstrap.hxx> #include <vcl/help.hxx> -#include <vcl/layout.hxx> +#include <vcl/weld.hxx> #include <vcl/settings.hxx> #include <sfx2/sfxsids.hrc> #include <sfx2/app.hxx> @@ -634,9 +634,10 @@ void Desktop::HandleBootstrapPathErrors( ::utl::Bootstrap::Status aBootstrapStat OUString const aMessage(aDiagnosticMessage + "\n"); - ScopedVclPtrInstance< MessageDialog > aBootstrapFailedBox(nullptr, aMessage); - aBootstrapFailedBox->SetText( aProductKey ); - aBootstrapFailedBox->Execute(); + std::unique_ptr<weld::MessageDialog> xBootstrapFailedBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Warning, VclButtonsType::Ok, aMessage)); + xBootstrapFailedBox->set_title(aProductKey); + xBootstrapFailedBox->run(); } } @@ -1049,8 +1050,9 @@ void restartOnMac(bool passArguments) { (void) passArguments; // avoid warnings OUString aMessage = DpResId(STR_LO_MUST_BE_RESTARTED); - MessageDialog aRestartBox(NULL, aMessage); - aRestartBox.Execute(); + std::unique_ptr<weld::MessageDialog> xRestartBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Warning, VclButtonsType::Ok, aMessage)); + xRestartBox->Execute(); #else OUString execUrl; OSL_VERIFY(osl_getExecutableFile(&execUrl.pData) == osl_Process_E_None); @@ -2153,8 +2155,10 @@ void Desktop::OpenClients() { aRequest.aPrintList.clear(); aRequest.aPrintToList.clear(); - ScopedVclPtrInstance< MessageDialog > aBox(nullptr, DpResId(STR_ERR_PRINTDISABLED)); - aBox->Execute(); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Warning, VclButtonsType::Ok, + DpResId(STR_ERR_PRINTDISABLED))); + xBox->run(); } // Process request diff --git a/desktop/source/app/lockfile2.cxx b/desktop/source/app/lockfile2.cxx index 31911f561719..44447927f63b 100644 --- a/desktop/source/app/lockfile2.cxx +++ b/desktop/source/app/lockfile2.cxx @@ -17,14 +17,13 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - -#include <vcl/layout.hxx> +#include <vcl/svapp.hxx> +#include <vcl/weld.hxx> #include <dp_shared.hxx> #include <strings.hrc> #include <tools/config.hxx> #include <lockfile.hxx> - namespace desktop { bool Lockfile_execWarning( Lockfile const * that ) @@ -38,22 +37,22 @@ bool Lockfile_execWarning( Lockfile const * that ) OString aTime = aConfig.ReadKey( LOCKFILE_TIMEKEY ); // display warning and return response - ScopedVclPtrInstance<MessageDialog> aBox(nullptr, DpResId(STR_QUERY_USERDATALOCKED), - VclMessageType::Question, VclButtonsType::YesNo); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr, + VclMessageType::Question, VclButtonsType::YesNo, DpResId(STR_QUERY_USERDATALOCKED))); // set box title OUString aTitle = DpResId(STR_TITLE_USERDATALOCKED); - aBox->SetText( aTitle ); + xBox->set_title( aTitle ); // insert values... - OUString aMsgText = aBox->get_primary_text(); + OUString aMsgText = xBox->get_primary_text(); aMsgText = aMsgText.replaceFirst( "$u", OStringToOUString( aUser, RTL_TEXTENCODING_ASCII_US) ); aMsgText = aMsgText.replaceFirst( "$h", OStringToOUString( aHost, RTL_TEXTENCODING_ASCII_US) ); aMsgText = aMsgText.replaceFirst( "$t", OStringToOUString( aTime, RTL_TEXTENCODING_ASCII_US) ); - aBox->set_primary_text(aMsgText); + xBox->set_primary_text(aMsgText); // do it - return aBox->Execute( ) == RET_YES; + return xBox->run() == RET_YES; } } diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index f477e4245d31..9888958807b0 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -358,26 +358,24 @@ bool DialogHelper::IsSharedPkgMgr( const uno::Reference< deployment::XPackage > return xPackage->getRepositoryName() == SHARED_PACKAGE_MANAGER; } - bool DialogHelper::continueOnSharedExtension( const uno::Reference< deployment::XPackage > &xPackage, - vcl::Window *pParent, + weld::Widget* pParent, const char* pResID, bool &bHadWarning ) { if ( !bHadWarning && IsSharedPkgMgr( xPackage ) ) { const SolarMutexGuard guard; - ScopedVclPtrInstance<MessageDialog> aInfoBox(pParent, DpResId(pResID), - VclMessageType::Warning, VclButtonsType::OkCancel); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent, + VclMessageType::Warning, VclButtonsType::OkCancel, DpResId(pResID))); bHadWarning = true; - return RET_OK == aInfoBox->Execute(); + return RET_OK == xBox->run(); } else return true; } - void DialogHelper::openWebBrowser( const OUString & sURL, const OUString &sTitle ) const { if ( sURL.isEmpty() ) // Nothing to do, when the URL is empty @@ -395,9 +393,10 @@ void DialogHelper::openWebBrowser( const OUString & sURL, const OUString &sTitle uno::Any exc( ::cppu::getCaughtException() ); OUString msg( ::comphelper::anyToString( exc ) ); const SolarMutexGuard guard; - ScopedVclPtrInstance< MessageDialog > aErrorBox(nullptr, msg); - aErrorBox->SetText( sTitle ); - aErrorBox->Execute(); + std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(getFrameWeld(), + VclMessageType::Warning, VclButtonsType::Ok, msg)); + xErrorBox->set_title(sTitle); + xErrorBox->run(); } } @@ -409,30 +408,30 @@ bool DialogHelper::installExtensionWarn( const OUString &rExtensionName ) const // Check if extension installation is disabled in the expert configurations if (officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionInstallation::get()) { - ScopedVclPtrInstance<MessageDialog> aWarn(m_pVCLWindow, DpResId(RID_STR_WARNING_INSTALL_EXTENSION_DISABLED), - VclMessageType::Warning, VclButtonsType::Ok); - aWarn->Execute(); + std::unique_ptr<weld::MessageDialog> xWarnBox(Application::CreateMessageDialog(getFrameWeld(), + VclMessageType::Warning, VclButtonsType::Ok, + DpResId(RID_STR_WARNING_INSTALL_EXTENSION_DISABLED))); + xWarnBox->run(); return false; } - ScopedVclPtrInstance<MessageDialog> aInfo(m_pVCLWindow, DpResId(RID_STR_WARNING_INSTALL_EXTENSION), - VclMessageType::Warning, VclButtonsType::OkCancel); - - OUString sText(aInfo->get_primary_text()); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(getFrameWeld(), + VclMessageType::Warning, VclButtonsType::OkCancel, + DpResId(RID_STR_WARNING_INSTALL_EXTENSION))); + OUString sText(xInfoBox->get_primary_text()); sText = sText.replaceAll("%NAME", rExtensionName); - aInfo->set_primary_text(sText); + xInfoBox->set_primary_text(sText); - return ( RET_OK == aInfo->Execute() ); + return (RET_OK == xInfoBox->run()); } bool DialogHelper::installForAllUsers( bool &bInstallForAll ) const { const SolarMutexGuard guard; - ScopedVclPtrInstance<MessageDialog> aQuery(m_pVCLWindow, "InstallForAllDialog", - "desktop/ui/installforalldialog.ui"); - - short nRet = aQuery->Execute(); + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(getFrameWeld(), "desktop/ui/installforalldialog.ui")); + std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("InstallForAllDialog")); + short nRet = xQuery->run(); if (nRet == RET_CANCEL) return false; @@ -592,14 +591,15 @@ void ExtMgrDialog::checkEntries() bool ExtMgrDialog::removeExtensionWarn( const OUString &rExtensionName ) const { const SolarMutexGuard guard; - ScopedVclPtrInstance<MessageDialog> aInfo(const_cast<ExtMgrDialog*>(this), DpResId(RID_STR_WARNING_REMOVE_EXTENSION), - VclMessageType::Warning, VclButtonsType::OkCancel); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Warning, VclButtonsType::OkCancel, + DpResId(RID_STR_WARNING_REMOVE_EXTENSION))); - OUString sText(aInfo->get_primary_text()); + OUString sText(xInfoBox->get_primary_text()); sText = sText.replaceAll("%NAME", rExtensionName); - aInfo->set_primary_text(sText); + xInfoBox->set_primary_text(sText); - return ( RET_OK == aInfo->Execute() ); + return (RET_OK == xInfoBox->run()); } void ExtMgrDialog::enablePackage( const uno::Reference< deployment::XPackage > &xPackage, @@ -610,12 +610,12 @@ void ExtMgrDialog::enablePackage( const uno::Reference< deployment::XPackage > & if ( bEnable ) { - if ( ! continueOnSharedExtension( xPackage, this, RID_STR_WARNING_ENABLE_SHARED_EXTENSION, m_bEnableWarning ) ) + if (!continueOnSharedExtension(xPackage, GetFrameWeld(), RID_STR_WARNING_ENABLE_SHARED_EXTENSION, m_bEnableWarning)) return; } else { - if ( ! continueOnSharedExtension( xPackage, this, RID_STR_WARNING_DISABLE_SHARED_EXTENSION, m_bDisableWarning ) ) + if (!continueOnSharedExtension(xPackage, GetFrameWeld(), RID_STR_WARNING_DISABLE_SHARED_EXTENSION, m_bDisableWarning)) return; } @@ -634,7 +634,7 @@ void ExtMgrDialog::removePackage( const uno::Reference< deployment::XPackage > & return; } - if ( ! continueOnSharedExtension( xPackage, this, RID_STR_WARNING_REMOVE_SHARED_EXTENSION, m_bDeleteWarning ) ) + if (!continueOnSharedExtension(xPackage, GetFrameWeld(), RID_STR_WARNING_REMOVE_SHARED_EXTENSION, m_bDeleteWarning)) return; m_pManager->getCmdQueue()->removeExtension( xPackage ); diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.hxx b/desktop/source/deployment/gui/dp_gui_dialog2.hxx index 29cf6b47722e..ed00106535e8 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.hxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.hxx @@ -29,6 +29,7 @@ #include <vcl/prgsbar.hxx> #include <vcl/timer.hxx> #include <vcl/idle.hxx> +#include <vcl/weld.hxx> #include <svtools/svmedit.hxx> @@ -68,6 +69,7 @@ public: void openWebBrowser( const OUString & sURL, const OUString & sTitle ) const; Dialog* getWindow() const { return m_pVCLWindow; }; + weld::Window* getFrameWeld() const { return m_pVCLWindow ? m_pVCLWindow->GetFrameWeld() : nullptr; } void PostUserEvent( const Link<void*,void>& rLink, void* pCaller ); void clearEventID() { m_nEventID = nullptr; } @@ -85,7 +87,7 @@ public: static bool IsSharedPkgMgr( const css::uno::Reference< css::deployment::XPackage > &); static bool continueOnSharedExtension( const css::uno::Reference< css::deployment::XPackage > &, - vcl::Window *pParent, + weld::Widget* pParent, const char* pResID, bool &bHadWarning ); diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index 84246cd046db..331acea1e170 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -62,7 +62,7 @@ #include <cppuhelper/exc_hlp.hxx> #include <cppuhelper/implbase.hxx> #include <comphelper/anytostring.hxx> -#include <vcl/layout.hxx> +#include <vcl/weld.hxx> #include <toolkit/helper/vclunohelper.hxx> #include "dp_gui.h" @@ -145,7 +145,7 @@ public: , m_nCurrentProgress(0) {} - Dialog * activeDialog() { return m_pDialogHelper ? m_pDialogHelper->getWindow() : nullptr; } + weld::Window* activeDialog() { return m_pDialogHelper ? m_pDialogHelper->getFrameWeld() : nullptr; } void startProgress(); void stopProgress(); @@ -421,12 +421,12 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const & verExc.Deployed->getDisplayName(); { SolarMutexGuard guard; - ScopedVclPtrInstance<MessageDialog> box(m_pDialogHelper? m_pDialogHelper->getWindow() : nullptr, - DpResId(id), VclMessageType::Warning, VclButtonsType::OkCancel); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_pDialogHelper ? m_pDialogHelper->getFrameWeld() : nullptr, + VclMessageType::Warning, VclButtonsType::Ok, DpResId(id))); OUString s; if (bEqualNames) { - s = box->get_primary_text(); + s = xBox->get_primary_text(); } else if (!strcmp(id, RID_STR_WARNING_VERSION_EQUAL)) { @@ -447,8 +447,8 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const & s = s.replaceAll("$OLDNAME", verExc.Deployed->getDisplayName()); s = s.replaceAll("$NEW", getVersion(verExc.NewVersion)); s = s.replaceAll("$DEPLOYED", getVersion(verExc.Deployed)); - box->set_primary_text(s); - approve = box->Execute() == RET_OK; + xBox->set_primary_text(s); + approve = xBox->run() == RET_OK; abort = !approve; } } @@ -476,8 +476,9 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const & SolarMutexGuard guard; OUString sMsg(DpResId(RID_STR_UNSUPPORTED_PLATFORM)); sMsg = sMsg.replaceAll("%Name", platExc.package->getDisplayName()); - ScopedVclPtrInstance< MessageDialog > box(m_pDialogHelper? m_pDialogHelper->getWindow() : nullptr, sMsg); - box->Execute(); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_pDialogHelper ? m_pDialogHelper->getFrameWeld() : nullptr, + VclMessageType::Warning, VclButtonsType::Ok, sMsg)); + xBox->run(); approve = true; } @@ -539,8 +540,9 @@ void ProgressCmdEnv::update_( uno::Any const & rStatus ) text = ::comphelper::anyToString( rStatus ); // fallback const SolarMutexGuard aGuard; - ScopedVclPtrInstance< MessageDialog > aBox(m_pDialogHelper? m_pDialogHelper->getWindow() : nullptr, text); - aBox->Execute(); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_pDialogHelper ? m_pDialogHelper->getFrameWeld() : nullptr, + VclMessageType::Warning, VclButtonsType::Ok, text)); + xBox->run(); } ++m_nCurrentProgress; updateProgress(); @@ -781,11 +783,11 @@ void ExtensionCmdQueue::Thread::execute() msg = ::comphelper::anyToString(exc); const SolarMutexGuard guard; - ScopedVclPtr<MessageDialog> box( - VclPtr<MessageDialog>::Create(currentCmdEnv->activeDialog(), msg)); - if ( m_pDialogHelper ) - box->SetText( m_pDialogHelper->getWindow()->GetText() ); - box->Execute(); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(currentCmdEnv->activeDialog(), + VclMessageType::Warning, VclButtonsType::Ok, msg)); + if (m_pDialogHelper) + xBox->set_title(m_pDialogHelper->getWindow()->GetText()); + xBox->run(); //Continue with installation of the remaining extensions } { diff --git a/desktop/source/deployment/gui/dp_gui_service.cxx b/desktop/source/deployment/gui/dp_gui_service.cxx index c3d7638c00fa..1f93cdd49fb7 100644 --- a/desktop/source/deployment/gui/dp_gui_service.cxx +++ b/desktop/source/deployment/gui/dp_gui_service.cxx @@ -28,7 +28,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/servicedecl.hxx> #include <comphelper/unwrapargs.hxx> -#include <vcl/layout.hxx> +#include <vcl/weld.hxx> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -214,9 +214,10 @@ void ServiceImpl::startExecuteModal( catch (const Exception & exc) { if (bAppUp) { const SolarMutexGuard guard; - ScopedVclPtrInstance<MessageDialog> box( - Application::GetActiveTopWindow(), exc.Message); - box->Execute(); + vcl::Window* pWin = Application::GetActiveTopWindow(); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + VclMessageType::Warning, VclButtonsType::Ok, exc.Message)); + xBox->run(); } throw; } diff --git a/desktop/uiconfig/ui/installforalldialog.ui b/desktop/uiconfig/ui/installforalldialog.ui index c3d3576db024..220bc6f6b4ff 100644 --- a/desktop/uiconfig/ui/installforalldialog.ui +++ b/desktop/uiconfig/ui/installforalldialog.ui @@ -4,7 +4,6 @@ <requires lib="gtk+" version="3.0"/> <object class="GtkMessageDialog" id="InstallForAllDialog"> <property name="can_focus">False</property> - <property name="border_width">6</property> <property name="resizable">False</property> <property name="type_hint">dialog</property> <property name="skip_taskbar_hint">True</property> @@ -19,7 +18,6 @@ <child internal-child="action_area"> <object class="GtkButtonBox" id="messagedialog-action_area"> <property name="can_focus">False</property> - <property name="layout_style">end</property> <child> <object class="GtkButton" id="no"> <property name="label" translatable="yes" context="installforalldialog|no">_For all users</property> @@ -75,9 +73,9 @@ </object> </child> <action-widgets> - <action-widget response="3">no</action-widget> - <action-widget response="2">yes</action-widget> - <action-widget response="0">cancel</action-widget> + <action-widget response="-9">no</action-widget> + <action-widget response="-8">yes</action-widget> + <action-widget response="-6">cancel</action-widget> </action-widgets> </object> </interface> |