Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / krunner / krunnerdialog.cpp
blob51e42a1a979416e19122635d98b744ad09e09b19
1 /*
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"
21 #include <QPainter>
22 #include <QSvgRenderer>
23 #include <QResizeEvent>
24 #include <QMouseEvent>
25 #include <QX11Info>
27 #include <KDebug>
28 #include <NETRootInfo>
30 #include <plasma/svgpanel.h>
31 #include <plasma/theme.h>
33 #include "krunnerapp.h"
35 #include <X11/Xlib.h>
37 KRunnerDialog::KRunnerDialog( QWidget * parent, Qt::WindowFlags f )
38 : KDialog(parent, f)
40 setButtons(0);
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()));
47 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)
65 QPainter p(this);
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);
96 e->accept();
99 #include "krunnerdialog.moc"