~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to plasma/netbook/shell/netdialogmanager.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright (C) 2010 Marco Martin <notmart@gmail.com>
 
3
 *
 
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 as
 
6
 *   published by the Free Software Foundation; either version 2, or
 
7
 *   (at your option) any later version.
 
8
 *
 
9
 *   This program is distributed in the hope that it will be useful,
 
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 *   GNU General Public License for more details
 
13
 *
 
14
 *   You should have received a copy of the GNU Library General Public
 
15
 *   License along with this program; if not, write to the
 
16
 *   Free Software Foundation, Inc.,
 
17
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
18
 */
 
19
 
 
20
#include "netdialogmanager.h"
 
21
 
 
22
#include <QtGui/QWidget>
 
23
#include <QtGui/QStyleOptionGraphicsItem>
 
24
#include <QtGui/QGraphicsProxyWidget>
 
25
#include <QtGui/QPainter>
 
26
#include <QtGui/QApplication>
 
27
 
 
28
#include <KWindowSystem>
 
29
 
 
30
#include <Plasma/Applet>
 
31
#include <Plasma/Containment>
 
32
#include <Plasma/Corona>
 
33
#include <Plasma/WindowEffects>
 
34
 
 
35
NetDialogManager::NetDialogManager(Plasma::Corona *parent)
 
36
    : Plasma::AbstractDialogManager(parent),
 
37
      m_corona(parent)
 
38
{
 
39
}
 
40
 
 
41
NetDialogManager::~NetDialogManager()
 
42
{
 
43
}
 
44
 
 
45
void NetDialogManager::showDialog(QWidget *widget, Plasma::Applet *applet)
 
46
{
 
47
    Q_UNUSED(applet)
 
48
    if (KWindowSystem::compositingActive()) {
 
49
        widget->setAttribute(Qt::WA_WindowPropagation, false);
 
50
        widget->setAttribute(Qt::WA_TranslucentBackground);
 
51
        widget->setAttribute(Qt::WA_NoSystemBackground, false);
 
52
        widget->setWindowFlags(Qt::FramelessWindowHint);
 
53
        KWindowSystem::setState(widget->effectiveWinId(), NET::MaxVert|NET::MaxHoriz);
 
54
        Plasma::WindowEffects::enableBlurBehind(widget->effectiveWinId(), true);
 
55
 
 
56
        QPalette palette = widget->palette();
 
57
        palette.setColor(QPalette::Window, QColor(0,0,0,100));
 
58
        widget->setAttribute(Qt::WA_WindowPropagation);
 
59
        palette.setColor(QPalette::WindowText, Qt::white);
 
60
        palette.setColor(QPalette::ToolTipText, Qt::white);
 
61
        widget->setPalette(palette);
 
62
    }
 
63
 
 
64
    Plasma::Containment *containment = applet->containment();
 
65
    if (containment) {
 
66
        Plasma::Corona *corona = containment->corona();
 
67
        if (corona) {
 
68
            QRect r = corona->availableScreenRegion(containment->screen()).boundingRect();
 
69
            //assumption: the panel is 100% wide
 
70
            QRect screenRect = corona->screenGeometry(containment->screen());
 
71
 
 
72
            widget->setContentsMargins(r.left() - screenRect.left(),
 
73
                                       r.top() - screenRect.top(),
 
74
                                       screenRect.right() - r.right(),
 
75
                                       screenRect.bottom() - r.bottom());
 
76
        }
 
77
    }
 
78
 
 
79
    widget->show();
 
80
}
 
81
 
 
82
 
 
83
#include "netdialogmanager.moc"