if (!toolBar && important) {
// Create tool bar if needed
toolBar = new QToolBar("", this);
- // toolBar->setFixedWidth(QApplication::desktop()->
- // availableGeometry().width());
- toolBar->setFixedHeight(65);
+ // toolBar->setFixedHeight(63);
toolBar->setStyleSheet("margin:0; border:0; padding:0");
toolBar->setSizePolicy(QSizePolicy::MinimumExpanding,
QSizePolicy::Maximum);
return;
}
unsigned long val = grab? 1: 0;
- Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
+ Atom atom =
+ XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
if (!atom) {
qCritical() << "Unable to obtain _HILDON_ZOOM_KEY_ATOM";
return;
#endif // Q_WS_MAEMO_5
-void AdopterWindow::showEvent(QShowEvent *e)
-{
- Trace t("AdopterWindow::showEvent");
-
#ifdef Q_OS_SYMBIAN
+
+void AdopterWindow::updateToolBar()
+{
+ TRACE;
if (toolBar) {
- if (portrait()) {
+ QRect geometry = QApplication::desktop()->geometry();
+ bool isPortrait = geometry.width() < geometry.height();
+ bool isToolBarHidden = toolBar->isHidden();
+ if (isPortrait && isToolBarHidden) {
qDebug() << "Show tool bar";
toolBar->setVisible(true);
- } else {
+ } else if (!isPortrait && !isToolBarHidden) {
qDebug() << "Hide tool bar";
toolBar->setVisible(false);
}
}
+}
+
+bool AdopterWindow::portrait()
+{
+ QRect geometry = QApplication::desktop()->geometry();
+ return geometry.width() < geometry.height();
+}
+
#endif // Q_OS_SYMBIAN
+
+void AdopterWindow::showEvent(QShowEvent *e)
+{
+ Trace t("AdopterWindow::showEvent");
+
+#ifdef Q_OS_SYMBIAN
+ updateToolBar();
+#endif
QMainWindow::showEvent(e);
#if defined(Q_WS_MAEMO_5)
doGrabVolumeKeys(grabbingVolumeKeys);
-#endif // Q_WS_MAEMO_5
+#endif
placeDecorations();
}
{
Trace t("AdopterWindow::resizeEvent");
#ifdef Q_OS_SYMBIAN
- if (toolBar) {
- if (portrait()) {
- qDebug() << "Show tool bar";
- toolBar->setVisible(true);
- } else {
- qDebug() << "Hide tool bar";
- toolBar->setVisible(false);
- }
- }
-#endif // Q_OS_SYMBIAN
-
+ updateToolBar();
+#endif
QMainWindow::resizeEvent(event);
placeDecorations();
}
}
}
-bool AdopterWindow::portrait()
-{
- QRect geometry = QApplication::desktop()->geometry();
- return geometry.width() < geometry.height();
-}
-
void AdopterWindow::placeDecorations()
{
Trace t("AdopterWindow::placeDecorations");
#ifdef Q_OS_SYMBIAN
// Work around Symbian bug: If tool bar is hidden, increase bottom
// decorator widgets' Y coordinates by the tool bar's height
- if (!portrait() && toolBar) {
+ if (toolBar && toolBar->isHidden()) {
toolBarHeight = toolBar->height();
}
void onSettingsChanged(const QString &key);
protected:
- /** Return true, if we are in portrait mode. */
- bool portrait();
-
/** Handle key press events. */
void keyPressEvent(QKeyEvent *event);
/** Handle resize events. */
void resizeEvent(QResizeEvent *event);
+#ifdef Q_OS_SYMBIAN
+ /** Update toolbar visibility. */
+ void updateToolBar();
+
+ /** Return true in portrait mode. */
+ bool portrait();
+#endif // Q_OS_SYMBIAN
+
#ifdef Q_WS_MAEMO_5
/** Actually grab the volume keys. */
void doGrabVolumeKeys(bool grab);
-#endif
+#endif // Q_WS_MAEMO_5
protected slots:
void placeDecorations();