syncthingtray/tray/gui/traymenu.h

89 lines
1.8 KiB
C
Raw Normal View History

2016-08-30 20:01:07 +02:00
#ifndef TRAY_MENU_H
#define TRAY_MENU_H
#include <QMenu>
QT_FORWARD_DECLARE_CLASS(QHBoxLayout)
#if defined(Q_OS_WINDOWS) && (QT_VERSION >= QT_VERSION_CHECK(6, 1, 0))
#define TRAY_MENU_HANDLE_WINDOWS11_STYLE
#endif
2016-08-30 20:01:07 +02:00
namespace QtGui {
class TrayIcon;
2016-08-30 20:01:07 +02:00
class TrayWidget;
2017-05-01 03:34:43 +02:00
class TrayMenu : public QMenu {
2016-08-30 20:01:07 +02:00
Q_OBJECT
public:
enum class WindowType {
Popup,
NormalWindow,
CustomWindow,
None,
};
explicit TrayMenu(TrayIcon *trayIcon = nullptr, QWidget *parent = nullptr);
2016-08-30 20:01:07 +02:00
2018-10-10 21:26:46 +02:00
QSize sizeHint() const override;
TrayWidget &widget();
const TrayWidget &widget() const;
TrayIcon *icon();
WindowType windowType() const;
void setWindowType(int windowType);
void setWindowType(WindowType windowType);
2016-08-30 20:01:07 +02:00
Q_SIGNALS:
void positioningSettingsChanged();
2020-03-08 13:50:32 +01:00
public Q_SLOTS:
void showUsingPositioningSettings();
protected:
bool event(QEvent *) override;
void mouseReleaseEvent(QMouseEvent *) override;
void mousePressEvent(QMouseEvent *) override;
void moveEvent(QMoveEvent *) override;
void resizeEvent(QResizeEvent *) override;
void paintEvent(QPaintEvent *) override;
void focusOutEvent(QFocusEvent *) override;
2016-12-26 19:50:10 +01:00
2016-08-30 20:01:07 +02:00
private:
void updateContentMargins();
QHBoxLayout *m_layout;
2016-08-30 20:01:07 +02:00
TrayWidget *m_trayWidget;
TrayIcon *m_trayIcon;
WindowType m_windowType;
bool m_startedSystemWindowCommand;
#ifdef TRAY_MENU_HANDLE_WINDOWS11_STYLE
bool m_isWindows11Style;
#endif
2016-08-30 20:01:07 +02:00
};
inline TrayWidget &TrayMenu::widget()
2016-08-30 20:01:07 +02:00
{
return *m_trayWidget;
2016-08-30 20:01:07 +02:00
}
inline const TrayWidget &TrayMenu::widget() const
{
return *m_trayWidget;
}
inline TrayIcon *TrayMenu::icon()
{
return m_trayIcon;
}
inline TrayMenu::WindowType TrayMenu::windowType() const
{
return m_windowType;
}
} // namespace QtGui
2016-08-30 20:01:07 +02:00
#endif // TRAY_MENU_H