1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-24 04:36:34 +01:00

[CodeCleanup] Use QMouseEvent::button() in mouse release events

In press/move events, use QMouseEvent::buttons() instead
This commit is contained in:
nowrep 2014-03-01 14:12:50 +01:00
parent 5ad76995a2
commit c7a31c57e0
10 changed files with 22 additions and 39 deletions

View File

@ -240,7 +240,7 @@ void LineEdit::mouseReleaseEvent(QMouseEvent* event)
void LineEdit::mouseDoubleClickEvent(QMouseEvent* event) void LineEdit::mouseDoubleClickEvent(QMouseEvent* event)
{ {
if (event->button() == Qt::LeftButton && qzSettings->selectAllOnDoubleClick) { if (event->buttons() == Qt::LeftButton && qzSettings->selectAllOnDoubleClick) {
selectAll(); selectAll();
return; return;
} }

View File

@ -35,8 +35,6 @@ BookmarksToolbarButton::BookmarksToolbarButton(BookmarkItem* bookmark, QWidget*
: QPushButton(parent) : QPushButton(parent)
, m_bookmark(bookmark) , m_bookmark(bookmark)
, m_window(0) , m_window(0)
, m_buttons(Qt::NoButton)
, m_modifiers(Qt::NoModifier)
, m_showOnlyIcon(false) , m_showOnlyIcon(false)
{ {
init(); init();
@ -225,9 +223,6 @@ QString BookmarksToolbarButton::createTooltip() const
void BookmarksToolbarButton::mousePressEvent(QMouseEvent* event) void BookmarksToolbarButton::mousePressEvent(QMouseEvent* event)
{ {
m_buttons = event->buttons();
m_modifiers = event->modifiers();
if (m_bookmark && m_bookmark->isFolder()) { if (m_bookmark && m_bookmark->isFolder()) {
if (event->buttons() == Qt::LeftButton && event->modifiers() == Qt::ControlModifier) { if (event->buttons() == Qt::LeftButton && event->modifiers() == Qt::ControlModifier) {
openFolder(m_bookmark); openFolder(m_bookmark);
@ -241,25 +236,25 @@ void BookmarksToolbarButton::mousePressEvent(QMouseEvent* event)
void BookmarksToolbarButton::mouseReleaseEvent(QMouseEvent* event) void BookmarksToolbarButton::mouseReleaseEvent(QMouseEvent* event)
{ {
if (m_bookmark && rect().contains(event->pos())) { if (m_bookmark && rect().contains(event->pos())) {
Qt::MouseButton button = event->button();
Qt::KeyboardModifiers modifiers = event->modifiers();
if (m_bookmark->isUrl()) { if (m_bookmark->isUrl()) {
if (m_buttons == Qt::LeftButton && m_modifiers == Qt::NoModifier) { if (button == Qt::LeftButton && modifiers == Qt::NoModifier) {
bookmarkActivated(m_bookmark); bookmarkActivated(m_bookmark);
} }
else if (m_buttons == Qt::LeftButton && m_modifiers == Qt::ShiftModifier) { else if (button == Qt::LeftButton && modifiers == Qt::ShiftModifier) {
bookmarkShiftActivated(m_bookmark); bookmarkShiftActivated(m_bookmark);
} }
else if (m_buttons == Qt::MiddleButton || m_modifiers == Qt::ControlModifier) { else if (button == Qt::MiddleButton || modifiers == Qt::ControlModifier) {
bookmarkCtrlActivated(m_bookmark); bookmarkCtrlActivated(m_bookmark);
} }
} }
else if (m_bookmark->isFolder() && m_buttons == Qt::MiddleButton) { else if (m_bookmark->isFolder() && button == Qt::MiddleButton) {
openFolder(m_bookmark); openFolder(m_bookmark);
} }
} }
m_buttons = Qt::NoButton;
m_modifiers = Qt::NoModifier;
QPushButton::mouseReleaseEvent(event); QPushButton::mouseReleaseEvent(event);
} }

View File

@ -67,10 +67,7 @@ private:
BookmarkItem* m_bookmark; BookmarkItem* m_bookmark;
BrowserWindow* m_window; BrowserWindow* m_window;
Qt::MouseButtons m_buttons;
Qt::KeyboardModifiers m_modifiers;
bool m_showOnlyIcon; bool m_showOnlyIcon;
}; };
#endif // BOOKMARKSTOOLBARBUTTON_H #endif // BOOKMARKSTOOLBARBUTTON_H

View File

@ -79,7 +79,7 @@ void DesktopNotification::mousePressEvent(QMouseEvent* e)
return; return;
} }
if (e->button() == Qt::LeftButton) { if (e->buttons() == Qt::LeftButton) {
m_dragPosition = e->globalPos() - frameGeometry().topLeft(); m_dragPosition = e->globalPos() - frameGeometry().topLeft();
e->accept(); e->accept();
} }

View File

@ -27,7 +27,6 @@
LocationCompleterView::LocationCompleterView() LocationCompleterView::LocationCompleterView()
: QListView(0) : QListView(0)
, m_ignoreNextMouseMove(false) , m_ignoreNextMouseMove(false)
, m_buttons(Qt::NoButton)
{ {
setWindowFlags(Qt::Popup); setWindowFlags(Qt::Popup);
@ -243,29 +242,23 @@ void LocationCompleterView::mouseMoveEvent(QMouseEvent* event)
QListView::mouseMoveEvent(event); QListView::mouseMoveEvent(event);
} }
void LocationCompleterView::mousePressEvent(QMouseEvent* event)
{
m_buttons = event->buttons();
QListView::mousePressEvent(event);
}
void LocationCompleterView::mouseReleaseEvent(QMouseEvent* event) void LocationCompleterView::mouseReleaseEvent(QMouseEvent* event)
{ {
if (m_hoveredIndex.isValid()) { if (m_hoveredIndex.isValid()) {
Qt::MouseButton button = event->button();
Qt::KeyboardModifiers modifiers = event->modifiers(); Qt::KeyboardModifiers modifiers = event->modifiers();
if (m_buttons == Qt::LeftButton && modifiers == Qt::NoModifier) { if (button == Qt::LeftButton && modifiers == Qt::NoModifier) {
emit indexActivated(m_hoveredIndex); emit indexActivated(m_hoveredIndex);
return; return;
} }
if (m_buttons == Qt::MiddleButton || (m_buttons == Qt::LeftButton && modifiers == Qt::ControlModifier)) { if (button == Qt::MiddleButton || (button == Qt::LeftButton && modifiers == Qt::ControlModifier)) {
emit indexCtrlActivated(m_hoveredIndex); emit indexCtrlActivated(m_hoveredIndex);
return; return;
} }
if (m_buttons == Qt::LeftButton && modifiers == Qt::ShiftModifier) { if (button == Qt::LeftButton && modifiers == Qt::ShiftModifier) {
emit indexShiftActivated(m_hoveredIndex); emit indexShiftActivated(m_hoveredIndex);
return; return;
} }

View File

@ -50,7 +50,6 @@ private slots:
protected: protected:
void mouseMoveEvent(QMouseEvent* event); void mouseMoveEvent(QMouseEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event); void mouseReleaseEvent(QMouseEvent* event);
private: private:
@ -58,7 +57,6 @@ private:
LocationCompleterDelegate* m_delegate; LocationCompleterDelegate* m_delegate;
QPersistentModelIndex m_hoveredIndex; QPersistentModelIndex m_hoveredIndex;
Qt::MouseButtons m_buttons;
}; };
#endif // LOCATIONCOMPLETERVIEW_H #endif // LOCATIONCOMPLETERVIEW_H

View File

@ -71,7 +71,7 @@ void SiteIcon::contextMenuEvent(QContextMenuEvent* e)
void SiteIcon::mousePressEvent(QMouseEvent* e) void SiteIcon::mousePressEvent(QMouseEvent* e)
{ {
if (e->buttons() & Qt::LeftButton) { if (e->buttons() == Qt::LeftButton) {
m_dragStartPosition = e->pos(); m_dragStartPosition = e->pos();
} }
@ -83,7 +83,7 @@ void SiteIcon::mousePressEvent(QMouseEvent* e)
void SiteIcon::mouseMoveEvent(QMouseEvent* e) void SiteIcon::mouseMoveEvent(QMouseEvent* e)
{ {
if (!m_locationBar || !(e->buttons() & Qt::LeftButton)) { if (!m_locationBar || e->buttons() != Qt::LeftButton) {
ToolButton::mouseMoveEvent(e); ToolButton::mouseMoveEvent(e);
return; return;
} }

View File

@ -1056,7 +1056,7 @@ void TabBarHelper::paintEvent(QPaintEvent* event)
void TabBarHelper::mousePressEvent(QMouseEvent* event) void TabBarHelper::mousePressEvent(QMouseEvent* event)
{ {
event->ignore(); event->ignore();
if (event->button() == Qt::LeftButton) { if (event->buttons() == Qt::LeftButton) {
m_pressedIndex = tabAt(event->pos()); m_pressedIndex = tabAt(event->pos());
if (m_pressedIndex != -1) { if (m_pressedIndex != -1) {
m_pressedGlobalX = event->globalX(); m_pressedGlobalX = event->globalX();

View File

@ -125,20 +125,20 @@ void ToolButton::setMultiIcon(const QPixmap &image)
void ToolButton::mousePressEvent(QMouseEvent* e) void ToolButton::mousePressEvent(QMouseEvent* e)
{ {
if (e->button() == Qt::LeftButton && menu() && popupMode() == QToolButton::InstantPopup) { if (e->buttons() == Qt::LeftButton && menu() && popupMode() == QToolButton::InstantPopup) {
setDown(true); setDown(true);
showMenu(); showMenu();
return; return;
} }
if (e->button() == Qt::RightButton && menu()) { if (e->buttons() == Qt::RightButton && menu()) {
setDown(true); setDown(true);
showMenu(); showMenu();
return; return;
} }
if (e->button() == Qt::MiddleButton) { if (e->buttons() == Qt::MiddleButton) {
setDown(true); setDown(true);
} }
@ -167,7 +167,7 @@ void ToolButton::mouseDoubleClickEvent(QMouseEvent* e)
{ {
QToolButton::mouseDoubleClickEvent(e); QToolButton::mouseDoubleClickEvent(e);
if (e->button() == Qt::LeftButton) { if (e->buttons() == Qt::LeftButton) {
emit doubleClicked(); emit doubleClicked();
} }
} }

View File

@ -572,7 +572,7 @@ void TabBar::mouseDoubleClickEvent(QMouseEvent* event)
return; return;
} }
if (event->button() == Qt::LeftButton && tabAt(event->pos()) == -1) { if (event->buttons() == Qt::LeftButton && tabAt(event->pos()) == -1) {
m_tabWidget->addView(QUrl(), Qz::NT_SelectedTabAtTheEnd, true); m_tabWidget->addView(QUrl(), Qz::NT_SelectedTabAtTheEnd, true);
return; return;
} }
@ -588,7 +588,7 @@ void TabBar::mousePressEvent(QMouseEvent* event)
return; return;
} }
if (event->buttons() & Qt::LeftButton && tabAt(event->pos()) != -1) { if (event->buttons() == Qt::LeftButton && tabAt(event->pos()) != -1) {
m_dragStartPosition = mapFromGlobal(event->globalPos()); m_dragStartPosition = mapFromGlobal(event->globalPos());
} }
else { else {