2 * Copyright (C) 2006 Aaron Seigo <aseigo@kde.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License version 2 as
6 * published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details
13 * You should have received a copy of the GNU Library General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "krunnerdialog.h"
22 #include <QSvgRenderer>
23 #include <QResizeEvent>
24 #include <QMouseEvent>
28 #include <NETRootInfo>
30 #include <plasma/svgpanel.h>
31 #include <plasma/theme.h>
33 #include "krunnerapp.h"
37 KRunnerDialog::KRunnerDialog( QWidget
* parent
, Qt::WindowFlags f
)
41 m_background
= new Plasma::SvgPanel("dialogs/background", this);
42 m_background
->setBorderFlags(Plasma::SvgPanel::DrawAllBorders
);
44 connect(m_background
, SIGNAL(repaintNeeded()), this, SLOT(update()));
46 connect(Plasma::Theme::self(), SIGNAL(changed()), this, SLOT(themeUpdated()));
50 KRunnerDialog::~KRunnerDialog()
54 void KRunnerDialog::themeUpdated()
56 const int topHeight
= m_background
->marginSize(Plasma::TopMargin
);
57 const int leftWidth
= m_background
->marginSize(Plasma::LeftMargin
);
58 const int rightWidth
= m_background
->marginSize(Plasma::RightMargin
);
59 const int bottomHeight
= m_background
->marginSize(Plasma::BottomMargin
);
60 setContentsMargins(leftWidth
, topHeight
, rightWidth
, bottomHeight
);
63 void KRunnerDialog::paintEvent(QPaintEvent
*e
)
66 p
.setRenderHint(QPainter::Antialiasing
);
67 p
.setClipRect(e
->rect());
68 //kDebug() << "clip rect set to: " << e->rect();
70 if (KRunnerApp::self()->hasCompositeManager()) {
71 //kDebug() << "gots us a compmgr!";
72 p
.setCompositionMode(QPainter::CompositionMode_Source
);
73 p
.fillRect(rect(), Qt::transparent
);
76 m_background
->paint(&p
, e
->rect());
79 void KRunnerDialog::resizeEvent(QResizeEvent
*e
)
81 m_background
->resize(e
->size());
82 KDialog::resizeEvent(e
);
85 void KRunnerDialog::mousePressEvent(QMouseEvent
*e
)
87 // We have to release the mouse grab before initiating the move operation.
88 // Ideally we would call releaseMouse() to do this, but when we only have an
89 // implicit passive grab, Qt is unaware of it, and will refuse to release it.
90 XUngrabPointer(x11Info().display(), CurrentTime
);
92 // Ask the window manager to start an interactive move operation.
93 NETRootInfo
rootInfo(x11Info().display(), NET::WMMoveResize
);
94 rootInfo
.moveResizeRequest(winId(), e
->globalX(), e
->globalY(), NET::Move
);
99 #include "krunnerdialog.moc"