return _isOpen;
}
+Q_INVOKABLE int Systray::screenIndex()
+{
+ auto qPos = QCursor::pos();
+ for (int i = 0; i < QGuiApplication::screens().count(); i++) {
+ if (QGuiApplication::screens().at(i)->geometry().contains(qPos)) {
+ return i;
+ }
+ }
+ return 0;
+}
+
Q_INVOKABLE void Systray::setOpened()
{
_isOpen = true;
int trayIconTopCenterX = (topRight - ((topRight - topLeft) * 0.5)).x();
return trayIconTopCenterX - (400 * 0.5);
#else
-QScreen* trayScreen = nullptr;
-#if (QT_VERSION >= QT_VERSION_CHECK(5,10,0))
- if (this->geometry().left() == 0 || this->geometry().top() == 0) {
- trayScreen = QGuiApplication::screenAt(QCursor::pos());
+ QScreen* trayScreen = nullptr;
+ if (QGuiApplication::screens().count() > 1) {
+ trayScreen = QGuiApplication::screens().at(screenIndex());
} else {
- trayScreen = QGuiApplication::screenAt(this->geometry().topLeft());
- }
-#else
- foreach (QScreen* screen, QGuiApplication::screens()) {
- if (this->geometry().left() == 0 || this->geometry().top() == 0) {
- if (screen->geometry().contains(QCursor::pos())) {
- trayScreen = screen;
- }
- } else {
- if (screen->geometry().contains(this->geometry().topLeft())) {
- trayScreen = screen;
- }
- }
- }
- if (trayScreen == nullptr) {
trayScreen = QGuiApplication::primaryScreen();
}
-#endif
+
int screenWidth = trayScreen->geometry().width();
int screenHeight = trayScreen->geometry().height();
int availableWidth = trayScreen->availableGeometry().width();
// don't use availableGeometry() here, because this also excludes the dock
return 22+6;
#else
-QScreen* trayScreen = nullptr;
-#if (QT_VERSION >= QT_VERSION_CHECK(5,10,0))
- if (this->geometry().left() == 0 || this->geometry().top() == 0) {
- trayScreen = QGuiApplication::screenAt(QCursor::pos());
+ QScreen* trayScreen = nullptr;
+ if (QGuiApplication::screens().count() > 1) {
+ trayScreen = QGuiApplication::screens().at(screenIndex());
} else {
- trayScreen = QGuiApplication::screenAt(this->geometry().topLeft());
- }
-#else
- foreach (QScreen* screen, QGuiApplication::screens()) {
- if (this->geometry().left() == 0 || this->geometry().top() == 0) {
- if (screen->geometry().contains(QCursor::pos())) {
- trayScreen = screen;
- }
- } else {
- if (screen->geometry().contains(this->geometry().topLeft())) {
- trayScreen = screen;
- }
- }
- }
- if (trayScreen == nullptr) {
trayScreen = QGuiApplication::primaryScreen();
}
-#endif
- int screenWidth = trayScreen->geometry().width();
+
int screenHeight = trayScreen->geometry().height();
int availableHeight = trayScreen->availableGeometry().height();
import QtQml 2.1\r
import QtQml.Models 2.1\r
import QtQuick 2.9\r
-import QtQuick.Window 2.2\r
+import QtQuick.Window 2.3\r
import QtQuick.Controls 2.2\r
import QtQuick.Layouts 1.2\r
import QtGraphicalEffects 1.0\r
trayWindow.show();\r
trayWindow.raise();\r
trayWindow.requestActivate();\r
- trayWindow.setX( systrayBackend.calcTrayWindowX());\r
- trayWindow.setY( systrayBackend.calcTrayWindowY());\r
+ trayWindow.setX( Qt.application.screens[systrayBackend.screenIndex()].virtualX + systrayBackend.calcTrayWindowX());\r
+ trayWindow.setY( Qt.application.screens[systrayBackend.screenIndex()].virtualY + systrayBackend.calcTrayWindowY());\r
systrayBackend.setOpened();\r
userModelBackend.fetchCurrentActivityModel();\r
}\r