| Home · All Namespaces · All Classes |
00001 /*************************************************************************** 00002 ** 00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 00004 ** All rights reserved. 00005 ** Contact: Nokia Corporation (directui@nokia.com) 00006 ** 00007 ** This file is part of mhome. 00008 ** 00009 ** If you have questions regarding the use of this file, please contact 00010 ** Nokia at directui@nokia.com. 00011 ** 00012 ** This library is free software; you can redistribute it and/or 00013 ** modify it under the terms of the GNU Lesser General Public 00014 ** License version 2.1 as published by the Free Software Foundation 00015 ** and appearing in the file LICENSE.LGPL included in the packaging 00016 ** of this file. 00017 ** 00018 ****************************************************************************/ 00019 #include "switcherbutton.h" 00020 #include <MApplication> 00021 #include "homeapplication.h" 00022 #include "switcherbuttonview.h" 00023 #include "mainwindow.h" 00024 #include "x11wrapper.h" 00025 #include <QX11Info> 00026 00027 #include <MWidgetCreator> 00028 M_REGISTER_WIDGET(SwitcherButton) 00029 00030 Atom SwitcherButton::visibleAtom = 0; 00031 00032 SwitcherButton::SwitcherButton(QGraphicsItem *parent) : 00033 MButton(parent, new SwitcherButtonModel), visibilityPropertyEnabled(true) 00034 { 00035 // Configure timers 00036 windowCloseTimer.setSingleShot(true); 00037 connect(&windowCloseTimer, SIGNAL(timeout()), this, SLOT(resetState())); 00038 00039 if (visibleAtom == 0) { 00040 // Get the icon geometry X11 Atom if it doesn't exist yet 00041 visibleAtom = X11Wrapper::XInternAtom(QX11Info::display(), "_MEEGOTOUCH_VISIBLE_IN_SWITCHER", False); 00042 } 00043 00044 connect(this, SIGNAL(clicked()), this, SLOT(switchToWindow())); 00045 } 00046 00047 SwitcherButton::~SwitcherButton() 00048 { 00049 } 00050 00051 Window SwitcherButton::xWindow() 00052 { 00053 return model()->xWindow(); 00054 } 00055 00056 void SwitcherButton::setXWindow(Window window) 00057 { 00058 model()->setXWindow(window); 00059 } 00060 00061 void SwitcherButton::switchToWindow() 00062 { 00063 emit windowToFront(model()->xWindow()); 00064 } 00065 00066 void SwitcherButton::close() 00067 { 00068 setVisible(false); 00069 windowCloseTimer.start(5000); 00070 00071 emit closeWindow(model()->xWindow()); 00072 } 00073 00074 void SwitcherButton::prepareGeometryChange() 00075 { 00076 QGraphicsItem::prepareGeometryChange(); 00077 } 00078 00079 void SwitcherButton::resetState() 00080 { 00081 setVisible(true); 00082 prepareGeometryChange(); 00083 } 00084 00085 void SwitcherButton::enterDisplayEvent() 00086 { 00087 setVisibleInSwitcherProperty(true); 00088 } 00089 00090 void SwitcherButton::exitDisplayEvent() 00091 { 00092 setVisibleInSwitcherProperty(false); 00093 } 00094 00095 void SwitcherButton::setVisibleInSwitcherProperty(bool set) 00096 { 00097 if(visibilityPropertyEnabled) { 00098 Display *dpy = QX11Info::display(); 00099 if (dpy) { 00100 if (set) { 00101 unsigned char data = 1; 00102 X11Wrapper::XChangeProperty(dpy, xWindow(), visibleAtom, XA_CARDINAL, 8, PropModeReplace, &data, 1); 00103 } else { 00104 unsigned char data = 0; 00105 X11Wrapper::XChangeProperty(dpy, xWindow(), visibleAtom, XA_CARDINAL, 8, PropModeReplace, &data, 1); 00106 } 00107 } 00108 } else { 00109 visibility = set; 00110 } 00111 } 00112 00113 void SwitcherButton::setVisibilityPropertyEnabled(bool enable) 00114 { 00115 visibilityPropertyEnabled = enable; 00116 if(enable) { 00117 setVisibleInSwitcherProperty(visibility); 00118 } 00119 }
| Copyright © 2010 Nokia Corporation | Generated on Thu Nov 4 2010 18:20:42 Doxygen 1.7.1 |
MeeGo Touch |