Falkon Develop
Cross-platform Qt-based web browser
locationbarpopup.cpp
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2012-2014 Franz Fellner <alpine.art.de@googlemail.com>
4* Copyright (C) 2012-2017 David Rosca <nowrep@gmail.com>
5*
6* This program is free software: you can redistribute it and/or modify
7* it under the terms of the GNU General Public License as published by
8* the Free Software Foundation, either version 3 of the License, or
9* (at your option) any later version.
10*
11* This program is distributed in the hope that it will be useful,
12* but WITHOUT ANY WARRANTY; without even the implied warranty of
13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14* GNU General Public License for more details.
15*
16* You should have received a copy of the GNU General Public License
17* along with this program. If not, see <http://www.gnu.org/licenses/>.
18* ============================================================ */
19#include "locationbarpopup.h"
20
21#include <QLayout>
22
24 : QFrame(parent, Qt::Popup)
25 , m_alignment(Qt::AlignRight)
26{
27 setAttribute(Qt::WA_DeleteOnClose);
28 setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
29 setLineWidth(1);
30 setMidLineWidth(2);
31}
32
33void LocationBarPopup::showAt(QWidget* parent)
34{
35 if (!parent || !parent->parentWidget())
36 return;
37
38 parent = parent->parentWidget();
39
40 // Calculate sizes before showing
41 layout()->invalidate();
42 layout()->activate();
43
44 QPoint p = parent->mapToGlobal(QPoint(0, 0));
45
46 if (m_alignment == Qt::AlignRight) {
47 p.setX(p.x() + parent->width() - width());
48 }
49
50 p.setY(p.y() + parent->height());
51 move(p);
52
53 QFrame::show();
54}
55
56void LocationBarPopup::setPopupAlignment(Qt::Alignment alignment)
57{
58 m_alignment = alignment;
59}
60
62{
63 return m_alignment;
64}
Qt::Alignment popupAlignment() const
void showAt(QWidget *parent)
void setPopupAlignment(Qt::Alignment alignment)
LocationBarPopup(QWidget *parent)