qDebug() << __PRETTY_FUNCTION__;
static Qt::HANDLE rootWindow = QX11Info::appRootWindow();
- static Atom activeAppAtom = XInternAtom(QX11Info::display(),
- ACTIVE_APP_ATOM, false);
-
- if (event->type == PropertyNotify) {
- XPropertyEvent *pevent = (XPropertyEvent*)event;
- if (pevent->window == rootWindow) {
- if (pevent->atom == activeAppAtom) {
- WId activeWindow = activeDesktopWindow(pevent->display,
- rootWindow);
-
- if(m_topmost != m_windows.contains(activeWindow)) {
- m_topmost = !m_topmost;
- emit topmostChanged(!m_topmost);
+ static Atom activeAppAtom = XInternAtom(QX11Info::display(), ACTIVE_APP_ATOM, false);
+
+ switch (event->type) {
+ case PropertyNotify: {
+ XPropertyEvent *pevent = (XPropertyEvent*)event;
+ if (pevent->window == rootWindow) {
+ if (pevent->atom == activeAppAtom) {
+ WId activeWindow = activeDesktopWindow(pevent->display, rootWindow);
+
+ if(m_topmost != m_windows.contains(activeWindow)) {
+ m_topmost = !m_topmost;
+ emit topmostChanged(!m_topmost);
+ }
}
}
}
+ break;
+ case KeyPress:
+ case KeyRelease:
+ case ButtonPress:
+ case ButtonRelease:
+ case MotionNotify:
+ case EnterNotify: // required when returning from statusbar menu
+ case FocusIn: // required when returning from update location dialog
+ emit showFullScreenButton();
+ break;
}
+
+ // don't block any events here, so false is returned
return false;
}
class Application : public QApplication
{
Q_OBJECT
-public:
+public:
/**
* @brief Constructor
*
*/
Application(int &argc, char **argv);
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+public:
/**
* @brief Registers window
*
void unregisterWindow(WId wId);
private:
-
/**
* @brief Return active window
*
*/
bool x11EventFilter(XEvent *event);
+/*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
signals:
+ /**
+ * @brief Signal is emitted when full screen button must be invoked and it's hiding timer
+ cleared.
+ *
+ * Signal is emitted when user interacts with keyboard or with mouse/finger, or when the
+ * main window is exposed.
+ */
+ void showFullScreenButton();
/**
* @brief Signals when window state is changed
*/
void topmostChanged(bool topmost);
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
private:
+ bool m_topmost; ///< Flag for topmost
- bool m_topmost; ///< Flag for topmost
-
- QList<WId> m_windows; ///< List of window ids
+ QList<WId> m_windows; ///< List of window ids
};
#endif // APPLICATION_H
#include <QDebug>
#include <QPainter>
+#include <QTimer>
#include "math.h"
{
qDebug() << __PRETTY_FUNCTION__;
+ const int HIDING_DELAY_MS = 5000;
+
setIcon(QIcon::fromTheme(QLatin1String("general_fullsize")));
setFixedSize(sizeHint());
m_backgroundPath.lineTo(0, this->height()); // Bottom left corner
m_backgroundPath.lineTo(this->width(), this->height()); // Bottom right corner
m_backgroundPath.closeSubpath(); // Back to the beginning
+
+ // Timer for hiding the button automatically after a delay
+ m_hidingTimer = new QTimer(this);
+ if (m_hidingTimer) {
+ m_hidingTimer->setSingleShot(true);
+ m_hidingTimer->setInterval(HIDING_DELAY_MS);
+
+ connect(m_hidingTimer, SIGNAL(timeout()),
+ this, SLOT(hide()));
+ }
}
FullScreenButton::~FullScreenButton()
delete m_selectedGradient;
}
+void FullScreenButton::invoke()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (isHidden())
+ show();
+
+ if (m_hidingTimer)
+ m_hidingTimer->start();
+}
+
void FullScreenButton::paintEvent(QPaintEvent *event)
{
qDebug() << __PRETTY_FUNCTION__;
#include <QToolButton>
+class QTimer;
+
/**
* @brief Fullscreen button class
*
void paintEvent(QPaintEvent *event);
/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+public slots:
+ /**
+ * @brief Invoke the button (if not already visible) and set hiding timer
+ */
+ void invoke();
+
+/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
private:
QColor *m_normalColor; ///< Normal background color
QLinearGradient *m_selectedGradient; ///< Selected background
QPainterPath m_backgroundPath; ///< Item shape path
+ QTimer *m_hidingTimer; ///< Timer for hiding the button after a delay
};
#endif // FULLSCREENBUTTON_H
void MainWindow::buildFullScreenButton()
{
qDebug() << __PRETTY_FUNCTION__;
+
#ifdef Q_WS_MAEMO_5
m_fullScreenButton = new FullScreenButton(this);
- connect(m_fullScreenButton, SIGNAL(clicked()),
- this, SLOT(toggleFullScreen()));
+
+ if (m_fullScreenButton) {
+ connect(m_fullScreenButton, SIGNAL(clicked()),
+ this, SLOT(toggleFullScreen()));
+
+ connect(qApp, SIGNAL(showFullScreenButton()),
+ m_fullScreenButton, SLOT(invoke()));
+ }
#endif // Q_WS_MAEMO_5
}
class UserInfoPanel;
class ZoomButtonPanel;
-
/**
* @brief Main Window Class
*/
const QString username();
public slots:
-
/**
* @brief Build direction indicator button and connect slots
*/