summaryrefslogtreecommitdiff
path: root/src/webwindow
diff options
context:
space:
mode:
Diffstat (limited to 'src/webwindow')
-rw-r--r--src/webwindow/rekonqmenu.cpp12
-rw-r--r--src/webwindow/rekonqmenu.h5
2 files changed, 12 insertions, 5 deletions
diff --git a/src/webwindow/rekonqmenu.cpp b/src/webwindow/rekonqmenu.cpp
index a5cea784..c32d71f5 100644
--- a/src/webwindow/rekonqmenu.cpp
+++ b/src/webwindow/rekonqmenu.cpp
@@ -51,20 +51,24 @@ void RekonqMenu::showEvent(QShowEvent* event)
{
KMenu::showEvent(event);
- if (!m_button)
+ if (m_button.isNull())
return;
+ kDebug() << "but: " << m_button.data();
+ kDebug() << "but w: " << m_button.data()->width();
+ kDebug() << "but h: " << m_button.data()->height();
+
// Adjust the position of the menu to be shown within the
// rekonq window to reduce the cases that sub-menus might overlap
// the right screen border.
QPoint pos;
if (layoutDirection() == Qt::RightToLeft)
{
- pos = m_button->mapToGlobal(QPoint(0, m_button->height()));
+ pos = m_button.data()->mapToGlobal(QPoint(0, m_button.data()->height()));
}
else
{
- pos = m_button->mapToGlobal(QPoint(m_button->width(), m_button->height()));
+ pos = m_button.data()->mapToGlobal(QPoint(m_button.data()->width(), m_button.data()->height()));
pos.rx() -= width();
}
@@ -91,7 +95,7 @@ void RekonqMenu::showEvent(QShowEvent* event)
{
if (pos.y() + height() > screen.y() + screen.height())
{
- pos.ry() = m_button->mapToGlobal(QPoint(0, 0)).y() + height();
+ pos.ry() = m_button.data()->mapToGlobal(QPoint(0, 0)).y() + height();
}
}
diff --git a/src/webwindow/rekonqmenu.h b/src/webwindow/rekonqmenu.h
index 8bda008b..24aaba91 100644
--- a/src/webwindow/rekonqmenu.h
+++ b/src/webwindow/rekonqmenu.h
@@ -36,6 +36,9 @@
// KDE Includes
#include <KMenu>
+// Qt Includes
+#include <QWeakPointer>
+
// Forward Declarations
class QWidget;
@@ -58,7 +61,7 @@ protected:
virtual void showEvent(QShowEvent* event);
private:
- QWidget *m_button;
+ QWeakPointer<QWidget> m_button;
};
#endif // REKONQ_MENU_H