4 # include <QtGui/QX11Info>
6 # include <X11/Xatom.h>
9 #include "adopterwindow.h"
13 # define ICON_PREFIX ":/icons/mac/"
15 # define ICON_PREFIX ":/icons/"
18 AdopterWindow::AdopterWindow(QWidget *parent):
19 QMainWindow(parent), grabbingZoomKeys(false), mainChild(0)
22 setAttribute(Qt::WA_Maemo5StackedWindow, true);
23 #endif // Q_WS_MAEMO_5
25 QFrame *frame = new QFrame(this);
26 QVBoxLayout *layout = new QVBoxLayout(frame);
28 frame->setLayout(layout);
29 setCentralWidget(frame);
33 setUnifiedTitleAndToolBarOnMac(true);
34 toolBar = addToolBar("controls");
35 toolBar->setMovable(false);
36 toolBar->setFloatable(false);
37 toolBar->toggleViewAction()->setVisible(false);
38 #if defined(Q_WS_X11) && !defined(Q_WS_MAEMO_5)
39 toolBar->setIconSize(QSize(42, 42));
41 #endif // Q_OS_SYMBIAN
44 void AdopterWindow::takeChildren(QWidget *main, const QList<QWidget *> &others)
46 Trace t("AdopterWindow::takeChildren");
50 mainChild->setParent(centralWidget());
51 centralWidget()->layout()->addWidget(mainChild);
54 foreach (QWidget *child, others) {
56 child->setParent(this);
61 void AdopterWindow::leaveChildren()
63 Trace t("AdopterWindow::leaveChildren");
65 centralWidget()->layout()->removeWidget(mainChild);
70 void AdopterWindow::grabZoomKeys(bool grab)
72 Trace t("AdopterWindow::grabZoomKeys");
73 grabbingZoomKeys = grab;
77 void AdopterWindow::showEvent(QShowEvent *e)
79 Trace t("AdopterWindow::showEvent");
80 doGrabZoomKeys(grabbingZoomKeys);
81 QMainWindow::showEvent(e);
84 void AdopterWindow::doGrabZoomKeys(bool grab)
86 Trace t("AdopterWindow::doGrabZoomKeys");
89 qDebug() << "Not visible - skipping";
92 qDebug() << "Could not get window ID - skipping";
95 unsigned long val = grab? 1: 0;
96 Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
98 qCritical() << "Unable to obtain _HILDON_ZOOM_KEY_ATOM";
101 XChangeProperty(QX11Info::display(),
107 reinterpret_cast<unsigned char *>(&val),
111 #endif // Q_WS_MAEMO_5
114 void AdopterWindow::show()
123 QAction *AdopterWindow::addToolBarAction(QObject *receiver,
125 const QString &iconName,
129 return toolBar->addAction(QIcon(ICON_PREFIX + iconName + ".png"), text,
133 QAction *action = new QAction(text, this);
134 menuBar()->addAction(action);
135 connect(action, SIGNAL(triggered()), receiver, member);