diff options
author | Ryan McCoskrie <ryan.mccoskrie@gmail.com> | 2015-08-20 16:42:01 +1200 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2015-09-09 11:24:21 +0200 |
commit | ba8cdfca4d875af0c95622c7b87a8291e130865a (patch) | |
tree | 6b7b39a727549c34203c60b652aea2cd15413bd1 /vcl/unx | |
parent | 773aecc810b1b39c0c3cc78eabf03054c9d113f1 (diff) |
tdf#92649: Converted pointers to unique_ptr's in vcl/unx/kde4
Change-Id: I1bab95a9a3db765d3b3bd34345dc006ccd33caf0
Diffstat (limited to 'vcl/unx')
-rw-r--r-- | vcl/unx/kde4/KDESalFrame.cxx | 75 | ||||
-rw-r--r-- | vcl/unx/kde4/KDESalFrame.hxx | 4 | ||||
-rw-r--r-- | vcl/unx/kde4/KDESalGraphics.cxx | 77 | ||||
-rw-r--r-- | vcl/unx/kde4/KDESalGraphics.hxx | 7 | ||||
-rw-r--r-- | vcl/unx/kde4/KDEXLib.cxx | 5 | ||||
-rw-r--r-- | vcl/unx/kde4/KDEXLib.hxx | 4 |
6 files changed, 78 insertions, 94 deletions
diff --git a/vcl/unx/kde4/KDESalFrame.cxx b/vcl/unx/kde4/KDESalFrame.cxx index 871ee730263b..125e04932b6e 100644 --- a/vcl/unx/kde4/KDESalFrame.cxx +++ b/vcl/unx/kde4/KDESalFrame.cxx @@ -288,48 +288,44 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings ) // Menu style.SetSkipDisabledInMenus( TRUE ); - KMenuBar* pMenuBar = new KMenuBar(); - if ( pMenuBar ) - { - // Color - QPalette qMenuCG = pMenuBar->palette(); - - // Menu text and background color, theme specific - Color aMenuFore = toColor( qMenuCG.color( QPalette::WindowText ) ); - Color aMenuBack = toColor( qMenuCG.color( QPalette::Window ) ); - - style.SetMenuTextColor( aMenuFore ); - style.SetMenuBarTextColor( style.GetPersonaMenuBarTextColor().get_value_or( aMenuFore ) ); - style.SetMenuColor( aMenuBack ); - style.SetMenuBarColor( aMenuBack ); - style.SetMenuHighlightColor( toColor ( qMenuCG.color( QPalette::Highlight ) ) ); - style.SetMenuHighlightTextColor( aMenuFore ); - - // set special menubar higlight text color - if ( QApplication::style()->inherits( "HighContrastStyle" ) ) - ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor = toColor( qMenuCG.color( QPalette::HighlightedText ) ); - else - ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor = aMenuFore; - - // set menubar rollover color - if ( pMenuBar->style()->styleHint( QStyle::SH_MenuBar_MouseTracking ) ) - { - style.SetMenuBarRolloverColor( toColor ( qMenuCG.color( QPalette::Highlight ) ) ); - style.SetMenuBarRolloverTextColor( ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor ); - } - else - { - style.SetMenuBarRolloverColor( aMenuBack ); - style.SetMenuBarRolloverTextColor( aMenuFore ); - } - style.SetMenuBarHighlightTextColor(style.GetMenuHighlightTextColor()); + std::unique_ptr<KMenuBar> pMenuBar = std::unique_ptr<KMenuBar>( new KMenuBar() ); + + // Color + QPalette qMenuCG = pMenuBar->palette(); + + // Menu text and background color, theme specific + Color aMenuFore = toColor( qMenuCG.color( QPalette::WindowText ) ); + Color aMenuBack = toColor( qMenuCG.color( QPalette::Window ) ); + + style.SetMenuTextColor( aMenuFore ); + style.SetMenuBarTextColor( style.GetPersonaMenuBarTextColor().get_value_or( aMenuFore ) ); + style.SetMenuColor( aMenuBack ); + style.SetMenuBarColor( aMenuBack ); + style.SetMenuHighlightColor( toColor ( qMenuCG.color( QPalette::Highlight ) ) ); + style.SetMenuHighlightTextColor( aMenuFore ); - // Font - aFont = toFont( pMenuBar->font(), rSettings.GetUILanguageTag().getLocale() ); - style.SetMenuFont( aFont ); + // set special menubar higlight text color + if ( QApplication::style()->inherits( "HighContrastStyle" ) ) + ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor = toColor( qMenuCG.color( QPalette::HighlightedText ) ); + else + ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor = aMenuFore; + + // set menubar rollover color + if ( pMenuBar->style()->styleHint( QStyle::SH_MenuBar_MouseTracking ) ) + { + style.SetMenuBarRolloverColor( toColor ( qMenuCG.color( QPalette::Highlight ) ) ); + style.SetMenuBarRolloverTextColor( ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor ); } + else + { + style.SetMenuBarRolloverColor( aMenuBack ); + style.SetMenuBarRolloverTextColor( aMenuFore ); + } + style.SetMenuBarHighlightTextColor(style.GetMenuHighlightTextColor()); - delete pMenuBar; + // Font + aFont = toFont( pMenuBar->font(), rSettings.GetUILanguageTag().getLocale() ); + style.SetMenuFont( aFont ); // Scroll bar size style.SetScrollBarSize( QApplication::style()->pixelMetric( QStyle::PM_ScrollBarExtent ) ); @@ -366,7 +362,6 @@ KDESalFrame::~KDESalFrame() KDESalFrame::GraphicsHolder::~GraphicsHolder() { - delete pGraphics; } SalGraphics* KDESalFrame::AcquireGraphics() diff --git a/vcl/unx/kde4/KDESalFrame.hxx b/vcl/unx/kde4/KDESalFrame.hxx index ca45b3463d9e..1346237aaa8e 100644 --- a/vcl/unx/kde4/KDESalFrame.hxx +++ b/vcl/unx/kde4/KDESalFrame.hxx @@ -19,6 +19,8 @@ #pragma once +#include <memory> + #include <unx/saldisp.hxx> #include <unx/salframe.h> @@ -32,7 +34,7 @@ class KDESalFrame : public X11SalFrame X11SalGraphics* pGraphics; bool bInUse; - GraphicsHolder() : pGraphics(0),bInUse( false ) {} + GraphicsHolder() : pGraphics(nullptr),bInUse( false ) {} ~GraphicsHolder(); }; diff --git a/vcl/unx/kde4/KDESalGraphics.cxx b/vcl/unx/kde4/KDESalGraphics.cxx index 87fe4cb1c55b..927c0df9cb79 100644 --- a/vcl/unx/kde4/KDESalGraphics.cxx +++ b/vcl/unx/kde4/KDESalGraphics.cxx @@ -73,16 +73,6 @@ QRect region2QRect( const Rectangle& rControlRegion ) return QRect(rControlRegion.Left(), rControlRegion.Top(), rControlRegion.GetWidth(), rControlRegion.GetHeight()); } -KDESalGraphics::KDESalGraphics() : - m_image(NULL) -{ -} - -KDESalGraphics::~KDESalGraphics() -{ - delete m_image; -} - bool KDESalGraphics::IsNativeControlSupported( ControlType type, ControlPart part ) { switch (type) @@ -241,10 +231,7 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, //if no image, or resized, make a new image if (!m_image || m_image->size() != widgetRect.size()) { - delete m_image; - m_image = new QImage( widgetRect.width(), - widgetRect.height(), - QImage::Format_ARGB32 ); + m_image.reset(new QImage( widgetRect.width(), widgetRect.height(), QImage::Format_ARGB32 ) ); } m_image->fill(KApplication::palette().color(QPalette::Window).rgb()); @@ -254,7 +241,7 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, { m_image->fill( Qt::transparent ); QStyleOptionButton option; - draw( QStyle::CE_PushButton, &option, m_image, + draw( QStyle::CE_PushButton, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); } else if (type == CTRL_MENUBAR) @@ -269,13 +256,13 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, if ( nControlState & ControlState::SELECTED ) // Passing State_Sunken is currently not documented. option.state |= QStyle::State_Sunken; // But some kinds of QStyle interpret it. - draw( QStyle::CE_MenuBarItem, &option, m_image, + draw( QStyle::CE_MenuBarItem, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); } else if (part == PART_ENTIRE_CONTROL) { QStyleOptionMenuItem option; - draw( QStyle::CE_MenuBarEmptyArea, &option, m_image, + draw( QStyle::CE_MenuBarEmptyArea, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); } else @@ -289,7 +276,7 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, if( part == PART_MENU_ITEM ) { QStyleOptionMenuItem option; - draw( QStyle::CE_MenuItem, &option, m_image, + draw( QStyle::CE_MenuItem, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); // HACK: LO core first paints the entire popup and only then it paints menu items, // but QMenu::paintEvent() paints popup frame after all items. That means highlighted @@ -299,7 +286,7 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, QRect framerect( lastPopupRect.topLeft() - widgetRect.topLeft(), widgetRect.size().expandedTo( lastPopupRect.size())); QStyleOptionFrame frame; - draw( QStyle::PE_FrameMenu, &frame, m_image, vclStateValue2StateFlag( nControlState, value ), framerect ); + draw( QStyle::PE_FrameMenu, &frame, m_image.get(), vclStateValue2StateFlag( nControlState, value ), framerect ); } else if( part == PART_MENU_SEPARATOR ) { @@ -317,7 +304,7 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, // don't paint over popup frame border (like the hack above, but here it can be simpler) int fw = QApplication::style()->pixelMetric( QStyle::PM_MenuPanelWidth ); clipRegion = new QRegion( rect.translated( widgetRect.topLeft()).adjusted( fw, 0, -fw, 0 )); - draw( QStyle::CE_MenuItem, &option, m_image, + draw( QStyle::CE_MenuItem, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value), rect ); } else if( part == PART_MENU_ITEM_CHECK_MARK || part == PART_MENU_ITEM_RADIO_MARK ) @@ -336,17 +323,17 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, QRect rect( menuItemRect.topLeft() - widgetRect.topLeft(), widgetRect.size().expandedTo( menuItemRect.size())); m_image->fill( Qt::transparent ); - draw( QStyle::CE_MenuItem, &option, m_image, + draw( QStyle::CE_MenuItem, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value), rect ); } else if( part == PART_ENTIRE_CONTROL ) { QStyleOptionMenuItem option; - draw( QStyle::PE_PanelMenu, &option, m_image, vclStateValue2StateFlag( nControlState, value )); + draw( QStyle::PE_PanelMenu, &option, m_image.get(), vclStateValue2StateFlag( nControlState, value )); // Try hard to get any frame! QStyleOptionFrame frame; - draw( QStyle::PE_FrameMenu, &frame, m_image, vclStateValue2StateFlag( nControlState, value )); - draw( QStyle::PE_FrameWindow, &frame, m_image, vclStateValue2StateFlag( nControlState, value )); + draw( QStyle::PE_FrameMenu, &frame, m_image.get(), vclStateValue2StateFlag( nControlState, value )); + draw( QStyle::PE_FrameWindow, &frame, m_image.get(), vclStateValue2StateFlag( nControlState, value )); lastPopupRect = widgetRect; } else @@ -363,7 +350,7 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, option.state = vclStateValue2StateFlag( nControlState, value ); option.state |= QStyle::State_Raised | QStyle::State_Enabled | QStyle::State_AutoRaise; - draw( QStyle::CC_ToolButton, &option, m_image, + draw( QStyle::CC_ToolButton, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); } else if ( (type == CTRL_TOOLBAR) && (part == PART_ENTIRE_CONTROL) ) @@ -373,7 +360,7 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, option.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); option.state = vclStateValue2StateFlag( nControlState, value ); - draw( QStyle::CE_ToolBar, &option, m_image, + draw( QStyle::CE_ToolBar, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); } else if ( (type == CTRL_TOOLBAR) && (part == PART_THUMB_VERT) ) @@ -385,16 +372,16 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, QStyleOption option; option.state = QStyle::State_Horizontal; - draw( QStyle::PE_IndicatorToolBarHandle, &option, m_image, + draw( QStyle::PE_IndicatorToolBarHandle, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value), rect ); } else if (type == CTRL_EDITBOX) { QStyleOptionFrameV2 option; - draw( QStyle::PE_PanelLineEdit, &option, m_image, + draw( QStyle::PE_PanelLineEdit, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value), m_image->rect().adjusted( 2, 2, -2, -2 )); - draw( QStyle::PE_FrameLineEdit, &option, m_image, + draw( QStyle::PE_FrameLineEdit, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value)); } else if (type == CTRL_COMBOBOX) @@ -402,7 +389,7 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, QStyleOptionComboBox option; option.editable = true; - draw( QStyle::CC_ComboBox, &option, m_image, + draw( QStyle::CC_ComboBox, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); } else if (type == CTRL_LISTBOX) @@ -410,21 +397,21 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, QStyleOptionComboBox option; switch (part) { case PART_WINDOW: - lcl_drawFrame( QStyle::PE_Frame, m_image, + lcl_drawFrame( QStyle::PE_Frame, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); break; case PART_SUB_EDIT: - draw( QStyle::CE_ComboBoxLabel, &option, m_image, + draw( QStyle::CE_ComboBoxLabel, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); break; case PART_ENTIRE_CONTROL: - draw( QStyle::CC_ComboBox, &option, m_image, + draw( QStyle::CC_ComboBox, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); break; case PART_BUTTON_DOWN: m_image->fill( Qt::transparent ); option.subControls = QStyle::SC_ComboBoxArrow; - draw( QStyle::CC_ComboBox, &option, m_image, + draw( QStyle::CC_ComboBox, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); break; } @@ -438,14 +425,14 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, if (value.getTristateVal() == BUTTONVALUE_ON) option.state |= QStyle::State_Open; - draw( QStyle::PE_IndicatorBranch, &option, m_image, + draw( QStyle::PE_IndicatorBranch, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); } else if (type == CTRL_CHECKBOX) { m_image->fill( Qt::transparent ); QStyleOptionButton option; - draw( QStyle::CE_CheckBox, &option, m_image, + draw( QStyle::CE_CheckBox, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); } else if (type == CTRL_SCROLLBAR) @@ -479,7 +466,7 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, if (sbVal->mnThumbState & ControlState::ROLLOVER) option.activeSubControls = QStyle::SC_ScrollBarSlider; - draw( QStyle::CC_ScrollBar, &option, m_image, + draw( QStyle::CC_ScrollBar, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); } else @@ -501,31 +488,31 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, option.activeSubControls |= QStyle::SC_SpinBoxDown; } - draw( QStyle::CC_SpinBox, &option, m_image, + draw( QStyle::CC_SpinBox, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); } else if (type == CTRL_GROUPBOX) { QStyleOptionGroupBox option; - draw( QStyle::CC_GroupBox, &option, m_image, + draw( QStyle::CC_GroupBox, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); } else if (type == CTRL_RADIOBUTTON) { m_image->fill( Qt::transparent ); QStyleOptionButton option; - draw( QStyle::CE_RadioButton, &option, m_image, + draw( QStyle::CE_RadioButton, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); } else if (type == CTRL_TOOLTIP) { QStyleOption option; - draw( QStyle::PE_PanelTipLabel, &option, m_image, + draw( QStyle::PE_PanelTipLabel, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); } else if (type == CTRL_FRAME) { - lcl_drawFrame( QStyle::PE_Frame, m_image, + lcl_drawFrame( QStyle::PE_Frame, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); // draw just the border, see http://qa.openoffice.org/issues/show_bug.cgi?id=107945 @@ -542,7 +529,7 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, option.menuItemType = QStyleOptionMenuItem::Separator; option.state |= QStyle::State_Item; - draw( QStyle::CE_MenuItem, &option, m_image, + draw( QStyle::CE_MenuItem, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); } else if (type == CTRL_SLIDER && (part == PART_TRACK_HORZ_AREA || part == PART_TRACK_VERT_AREA)) @@ -561,7 +548,7 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, if( horizontal ) option.state |= QStyle::State_Horizontal; - draw( QStyle::CC_Slider, &option, m_image, vclStateValue2StateFlag(nControlState, value) ); + draw( QStyle::CC_Slider, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); } else if( type == CTRL_PROGRESS && part == PART_ENTIRE_CONTROL ) { @@ -572,7 +559,7 @@ bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, option.rect = QRect(0, 0, widgetRect.width(), widgetRect.height()); option.state = vclStateValue2StateFlag( nControlState, value ); - draw( QStyle::CE_ProgressBar, &option, m_image, + draw( QStyle::CE_ProgressBar, &option, m_image.get(), vclStateValue2StateFlag(nControlState, value) ); } else diff --git a/vcl/unx/kde4/KDESalGraphics.hxx b/vcl/unx/kde4/KDESalGraphics.hxx index daa911198408..37a96b9f308d 100644 --- a/vcl/unx/kde4/KDESalGraphics.hxx +++ b/vcl/unx/kde4/KDESalGraphics.hxx @@ -19,6 +19,8 @@ #pragma once +#include <memory> + #include <rtl/string.hxx> #include <unx/saldisp.hxx> #include <unx/salgdi.h> @@ -28,13 +30,10 @@ /** handles graphics drawings requests and performs the needed drawing operations */ class KDESalGraphics : public X11SalGraphics { - QImage* m_image; + std::unique_ptr<QImage> m_image; QRect lastPopupRect; public: - KDESalGraphics(); - virtual ~KDESalGraphics(); - /** What widgets can be drawn the native way. @param type Type of the widget. diff --git a/vcl/unx/kde4/KDEXLib.cxx b/vcl/unx/kde4/KDEXLib.cxx index 6040100ba5d8..fd8469a72ba9 100644 --- a/vcl/unx/kde4/KDEXLib.cxx +++ b/vcl/unx/kde4/KDEXLib.cxx @@ -49,7 +49,7 @@ #endif KDEXLib::KDEXLib() : - SalXLib(), m_bStartupDone(false), m_pApplication(0), + SalXLib(), m_bStartupDone(false), m_pFreeCmdLineArgs(0), m_pAppCmdLineArgs(0), m_nFakeCmdLineArgs( 0 ), m_frameWidth( -1 ), m_isGlibEventLoopType(false), m_allowKdeDialogs(false), blockIdleTimeout(false) @@ -86,7 +86,6 @@ KDEXLib::KDEXLib() : KDEXLib::~KDEXLib() { - delete m_pApplication; // free the faked cmdline arguments no longer needed by KApplication for( int i = 0; i < m_nFakeCmdLineArgs; i++ ) @@ -175,7 +174,7 @@ void KDEXLib::Init() session_manager = strdup( getenv( "SESSION_MANAGER" )); unsetenv( "SESSION_MANAGER" ); } - m_pApplication = new VCLKDEApplication(); + m_pApplication.reset( new VCLKDEApplication() ); if( session_manager != NULL ) { // coverity[tainted_string] - trusted source for setenv diff --git a/vcl/unx/kde4/KDEXLib.hxx b/vcl/unx/kde4/KDEXLib.hxx index 0a1aec3f7ea0..0bcc3ec91e87 100644 --- a/vcl/unx/kde4/KDEXLib.hxx +++ b/vcl/unx/kde4/KDEXLib.hxx @@ -19,6 +19,8 @@ #pragma once +#include <memory> + #include <unx/saldisp.hxx> #include <fixx11h.h> @@ -36,7 +38,7 @@ class KDEXLib : public QObject, public SalXLib Q_OBJECT private: bool m_bStartupDone; - VCLKDEApplication* m_pApplication; + std::unique_ptr<VCLKDEApplication> m_pApplication; char** m_pFreeCmdLineArgs; char** m_pAppCmdLineArgs; int m_nFakeCmdLineArgs; |