1 /* SPDX-FileCopyrightText: 2003-2010 Jesper K. Pedersen <blackie@kde.org>
2 
3    SPDX-License-Identifier: GPL-2.0-or-later
4 */
5 #include "InfoBoxResizer.h"
6 
7 #include "InfoBox.h"
8 
InfoBoxResizer(Viewer::InfoBox * infoBox)9 Viewer::InfoBoxResizer::InfoBoxResizer(Viewer::InfoBox *infoBox)
10     : m_infoBox(infoBox)
11 {
12 }
13 
setPos(QPoint pos)14 void Viewer::InfoBoxResizer::setPos(QPoint pos)
15 {
16     QRect rect = m_infoBox->geometry();
17     pos = m_infoBox->mapToParent(pos);
18 
19     if (m_left)
20         rect.setLeft(pos.x());
21     if (m_right)
22         rect.setRight(pos.x());
23     if (m_top)
24         rect.setTop(pos.y());
25     if (m_bottom)
26         rect.setBottom(pos.y());
27 
28     if (rect.width() > 100 && rect.height() > 50)
29         m_infoBox->setGeometry(rect);
30 }
31 
setup(bool left,bool right,bool top,bool bottom)32 void Viewer::InfoBoxResizer::setup(bool left, bool right, bool top, bool bottom)
33 {
34     m_left = left;
35     m_right = right;
36     m_top = top;
37     m_bottom = bottom;
38     m_active = true;
39 }
40 
deactivate()41 void Viewer::InfoBoxResizer::deactivate()
42 {
43     m_active = false;
44 }
45 
isActive() const46 bool Viewer::InfoBoxResizer::isActive() const
47 {
48     return m_active;
49 }
50 // vi:expandtab:tabstop=4 shiftwidth=4:
51