Q_NULLPTR -> nullptr (already used elsewhere)
use more "auto"
wilder-pre-rebase
Hugo Pereira Da Costa 9 years ago
parent 7db2aa9fcd
commit 2012d71b85
  1. 6
      kstyle/breezeshadowhelper.cpp
  2. 84
      kstyle/breezewindowmanager.cpp

@ -60,8 +60,8 @@ namespace Breeze
_atom( 0 ) _atom( 0 )
#endif #endif
#if BREEZE_HAVE_KWAYLAND #if BREEZE_HAVE_KWAYLAND
, _shadowManager( Q_NULLPTR ) , _shadowManager( nullptr )
, _shmPool( Q_NULLPTR ) , _shmPool( nullptr )
#endif #endif
{ {
// delay till event dispatcher is running as Wayland is highly async // delay till event dispatcher is running as Wayland is highly async
@ -90,7 +90,7 @@ namespace Breeze
if( !connection ) { if( !connection ) {
return; return;
} }
Registry *registry = new Registry( this ); auto registry = new Registry( this );
registry->create( connection ); registry->create( connection );
connect(registry, &Registry::interfacesAnnounced, this, connect(registry, &Registry::interfacesAnnounced, this,
[registry, this] { [registry, this] {

@ -214,8 +214,8 @@ namespace Breeze
_locked( false ), _locked( false ),
_cursorOverride( false ) _cursorOverride( false )
#if BREEZE_HAVE_KWAYLAND #if BREEZE_HAVE_KWAYLAND
, _seat( Q_NULLPTR ) , _seat( nullptr )
, _pointer( Q_NULLPTR ) , _pointer( nullptr )
, _waylandSerial( 0 ) , _waylandSerial( 0 )
#endif #endif
{ {
@ -391,17 +391,17 @@ namespace Breeze
case QEvent::MouseMove: case QEvent::MouseMove:
if ( object == _target.data() if ( object == _target.data()
#if !BREEZE_USE_KDE4 #if !BREEZE_USE_KDE4
|| object == _quickTarget.data() || object == _quickTarget.data()
#endif #endif
) return mouseMoveEvent( object, event ); ) return mouseMoveEvent( object, event );
break; break;
case QEvent::MouseButtonRelease: case QEvent::MouseButtonRelease:
if ( _target if ( _target
#if !BREEZE_USE_KDE4 #if !BREEZE_USE_KDE4
|| _quickTarget || _quickTarget
#endif #endif
) return mouseReleaseEvent( object, event ); ) return mouseReleaseEvent( object, event );
break; break;
@ -422,15 +422,13 @@ namespace Breeze
{ {
_dragTimer.stop(); _dragTimer.stop();
#if BREEZE_USE_KDE4 #if BREEZE_USE_KDE4
if( _target ) if( _target )
{ startDrag( _target.data()->window(), _globalDragPoint ); } { startDrag( _target.data()->window(), _globalDragPoint ); }
#else #else
if( _target ) if( _target ) startDrag( _target.data()->window()->windowHandle(), _globalDragPoint );
{ startDrag( _target.data()->window()->windowHandle(), _globalDragPoint ); } else if( _quickTarget ) startDrag( _quickTarget.data()->window(), _globalDragPoint );
else if( _quickTarget ) #endif
{ startDrag( _quickTarget.data()->window(), _globalDragPoint ); }
#endif
} else { } else {
@ -445,7 +443,7 @@ namespace Breeze
{ {
// cast event and check buttons/modifiers // cast event and check buttons/modifiers
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>( event ); auto mouseEvent = static_cast<QMouseEvent*>( event );
if( !( mouseEvent->modifiers() == Qt::NoModifier && mouseEvent->button() == Qt::LeftButton ) ) if( !( mouseEvent->modifiers() == Qt::NoModifier && mouseEvent->button() == Qt::LeftButton ) )
{ return false; } { return false; }
@ -453,10 +451,11 @@ namespace Breeze
if( isLocked() ) return false; if( isLocked() ) return false;
else setLocked( true ); else setLocked( true );
#if !BREEZE_USE_KDE4 #if !BREEZE_USE_KDE4
// check QQuickItem - we can immediately start drag, because QQuickWindow's contentItem // check QQuickItem - we can immediately start drag, because QQuickWindow's contentItem
// only receives mouse events that weren't handled by children // only receives mouse events that weren't handled by children
if ( QQuickItem *item = qobject_cast<QQuickItem*>( object ) ) { if( auto item = qobject_cast<QQuickItem*>( object ) )
{
_quickTarget = item; _quickTarget = item;
_dragPoint = mouseEvent->pos(); _dragPoint = mouseEvent->pos();
_globalDragPoint = mouseEvent->globalPos(); _globalDragPoint = mouseEvent->globalPos();
@ -466,17 +465,17 @@ namespace Breeze
return true; return true;
} }
#endif #endif
// cast to widget // cast to widget
QWidget *widget = static_cast<QWidget*>( object ); auto widget = static_cast<QWidget*>( object );
// check if widget can be dragged from current position // check if widget can be dragged from current position
if( isBlackListed( widget ) || !canDrag( widget ) ) return false; if( isBlackListed( widget ) || !canDrag( widget ) ) return false;
// retrieve widget's child at event position // retrieve widget's child at event position
QPoint position( mouseEvent->pos() ); auto position( mouseEvent->pos() );
QWidget* child = widget->childAt( position ); auto child = widget->childAt( position );
if( !canDrag( widget, child, position ) ) return false; if( !canDrag( widget, child, position ) ) return false;
// save target and drag point // save target and drag point
@ -508,7 +507,7 @@ namespace Breeze
if( _dragTimer.isActive() ) _dragTimer.stop(); if( _dragTimer.isActive() ) _dragTimer.stop();
// cast event and check drag distance // cast event and check drag distance
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>( event ); auto mouseEvent = static_cast<QMouseEvent*>( event );
if( !_dragInProgress ) if( !_dragInProgress )
{ {
@ -535,7 +534,7 @@ namespace Breeze
// use QWidget::move for the grabbing // use QWidget::move for the grabbing
/* this works only if the sending object and the target are identical */ /* this works only if the sending object and the target are identical */
QWidget* window( _target.data()->window() ); auto window( _target.data()->window() );
window->move( window->pos() + mouseEvent->pos() - _dragPoint ); window->move( window->pos() + mouseEvent->pos() - _dragPoint );
return true; return true;
@ -582,7 +581,7 @@ namespace Breeze
{ return true; } { return true; }
// flat toolbuttons // flat toolbuttons
if( QToolButton* toolButton = qobject_cast<QToolButton*>( widget ) ) if( auto toolButton = qobject_cast<QToolButton*>( widget ) )
{ if( toolButton->autoRaise() ) return true; } { if( toolButton->autoRaise() ) return true; }
// viewports // viewports
@ -592,10 +591,10 @@ namespace Breeze
2/ it matches its parent viewport 2/ it matches its parent viewport
3/ the parent is not blacklisted 3/ the parent is not blacklisted
*/ */
if( QListView* listView = qobject_cast<QListView*>( widget->parentWidget() ) ) if( auto listView = qobject_cast<QListView*>( widget->parentWidget() ) )
{ if( listView->viewport() == widget && !isBlackListed( listView ) ) return true; } { if( listView->viewport() == widget && !isBlackListed( listView ) ) return true; }
if( QTreeView* treeView = qobject_cast<QTreeView*>( widget->parentWidget() ) ) if( auto treeView = qobject_cast<QTreeView*>( widget->parentWidget() ) )
{ if( treeView->viewport() == widget && !isBlackListed( treeView ) ) return true; } { if( treeView->viewport() == widget && !isBlackListed( treeView ) ) return true; }
/* /*
@ -603,7 +602,7 @@ namespace Breeze
this is because of kstatusbar this is because of kstatusbar
who captures buttonPress/release events who captures buttonPress/release events
*/ */
if( QLabel* label = qobject_cast<QLabel*>( widget ) ) if( auto label = qobject_cast<QLabel*>( widget ) )
{ {
if( label->textInteractionFlags().testFlag( Qt::TextSelectableByMouse ) ) return false; if( label->textInteractionFlags().testFlag( Qt::TextSelectableByMouse ) ) return false;
@ -702,14 +701,14 @@ namespace Breeze
{ return false; } { return false; }
// tool buttons // tool buttons
if( QToolButton* toolButton = qobject_cast<QToolButton*>( widget ) ) if( auto toolButton = qobject_cast<QToolButton*>( widget ) )
{ {
if( dragMode() == StyleConfigData::WD_MINIMAL && !qobject_cast<QToolBar*>(widget->parentWidget() ) ) return false; if( dragMode() == StyleConfigData::WD_MINIMAL && !qobject_cast<QToolBar*>(widget->parentWidget() ) ) return false;
return toolButton->autoRaise() && !toolButton->isEnabled(); return toolButton->autoRaise() && !toolButton->isEnabled();
} }
// check menubar // check menubar
if( QMenuBar* menuBar = qobject_cast<QMenuBar*>( widget ) ) if( auto menuBar = qobject_cast<QMenuBar*>( widget ) )
{ {
// do not drag from menubars embedded in Mdi windows // do not drag from menubars embedded in Mdi windows
@ -719,7 +718,7 @@ namespace Breeze
if( menuBar->activeAction() && menuBar->activeAction()->isEnabled() ) return false; if( menuBar->activeAction() && menuBar->activeAction()->isEnabled() ) return false;
// check if action at position exists and is enabled // check if action at position exists and is enabled
if( QAction* action = menuBar->actionAt( position ) ) if( auto action = menuBar->actionAt( position ) )
{ {
if( action->isSeparator() ) return true; if( action->isSeparator() ) return true;
if( action->isEnabled() ) return false; if( action->isEnabled() ) return false;
@ -743,14 +742,14 @@ namespace Breeze
/* following checks are relevant only for WD_FULL mode */ /* following checks are relevant only for WD_FULL mode */
// tabbar. Make sure no tab is under the cursor // tabbar. Make sure no tab is under the cursor
if( QTabBar* tabBar = qobject_cast<QTabBar*>( widget ) ) if( auto tabBar = qobject_cast<QTabBar*>( widget ) )
{ return tabBar->tabAt( position ) == -1; } { return tabBar->tabAt( position ) == -1; }
/* /*
check groupboxes check groupboxes
prevent drag if unchecking grouboxes prevent drag if unchecking grouboxes
*/ */
if( QGroupBox *groupBox = qobject_cast<QGroupBox*>( widget ) ) if( auto groupBox = qobject_cast<QGroupBox*>( widget ) )
{ {
// non checkable group boxes are always ok // non checkable group boxes are always ok
if( !groupBox->isCheckable() ) return true; if( !groupBox->isCheckable() ) return true;
@ -781,7 +780,7 @@ namespace Breeze
} }
// labels // labels
if( QLabel* label = qobject_cast<QLabel*>( widget ) ) if( auto label = qobject_cast<QLabel*>( widget ) )
{ if( label->textInteractionFlags().testFlag( Qt::TextSelectableByMouse ) ) return false; } { if( label->textInteractionFlags().testFlag( Qt::TextSelectableByMouse ) ) return false; }
// abstract item views // abstract item views
@ -811,7 +810,7 @@ namespace Breeze
else if( itemView->indexAt( position ).isValid() ) return false; else if( itemView->indexAt( position ).isValid() ) return false;
} }
} else if( QGraphicsView* graphicsView = qobject_cast<QGraphicsView*>( widget->parentWidget() ) ) { } else if( auto graphicsView = qobject_cast<QGraphicsView*>( widget->parentWidget() ) ) {
if( widget == graphicsView->viewport() ) if( widget == graphicsView->viewport() )
{ {
@ -839,9 +838,9 @@ namespace Breeze
} }
_target.clear(); _target.clear();
#if !BREEZE_USE_KDE4 #if !BREEZE_USE_KDE4
_quickTarget.clear(); _quickTarget.clear();
#endif #endif
if( _dragTimer.isActive() ) _dragTimer.stop(); if( _dragTimer.isActive() ) _dragTimer.stop();
_dragPoint = QPoint(); _dragPoint = QPoint();
_globalDragPoint = QPoint(); _globalDragPoint = QPoint();
@ -861,11 +860,8 @@ namespace Breeze
if( useWMMoveResize() ) if( useWMMoveResize() )
{ {
if( Helper::isX11() ) { if( Helper::isX11() ) startDragX11( window, position );
startDragX11( window, position ); else if( Helper::isWayland() ) startDragWayland( window, position );
} else if( Helper::isWayland() ) {
startDragWayland( window, position );
}
} else if( !_cursorOverride ) { } else if( !_cursorOverride ) {
@ -885,7 +881,7 @@ namespace Breeze
{ {
#if BREEZE_HAVE_X11 #if BREEZE_HAVE_X11
// connection // connection
xcb_connection_t* connection( Helper::connection() ); auto connection( Helper::connection() );
#if QT_VERSION >= 0x050300 #if QT_VERSION >= 0x050300
const qreal dpiRatio = window->devicePixelRatio(); const qreal dpiRatio = window->devicePixelRatio();
@ -894,9 +890,9 @@ namespace Breeze
#endif #endif
#if BREEZE_USE_KDE4 #if BREEZE_USE_KDE4
Display* net_connection = QX11Info::display(); auto net_connection = QX11Info::display();
#else #else
xcb_connection_t* net_connection = connection; auto net_connection = connection;
#endif #endif
xcb_ungrab_pointer( connection, XCB_TIME_CURRENT_TIME ); xcb_ungrab_pointer( connection, XCB_TIME_CURRENT_TIME );
@ -956,7 +952,7 @@ namespace Breeze
{ {
if( !widget ) return false; if( !widget ) return false;
if( const QDockWidget* dockWidget = qobject_cast<const QDockWidget*>( widget->parent() ) ) if( auto dockWidget = qobject_cast<const QDockWidget*>( widget->parent() ) )
{ {
return widget == dockWidget->titleBarWidget(); return widget == dockWidget->titleBarWidget();

Loading…
Cancel
Save