diff --git a/ui/appui.cpp b/ui/appui.cpp index 90effb0..d9752b3 100644 --- a/ui/appui.cpp +++ b/ui/appui.cpp @@ -50,9 +50,9 @@ Q_LOGGING_CATEGORY(log_appUi, "APPUI") #include "sqpath.h" -static const QString applicationJsonFileName = "qusb2snesapp.json"; -extern QSettings* globalSettings; -extern WSServer wsServer; +static const QString applicationJsonFileName = "qusb2snesapp.json"; +extern QSettings* globalSettings; +extern WSServer wsServer; AppUi::AppUi(QObject *parent) : QObject(parent) @@ -199,11 +199,19 @@ void AppUi::init() if (UiWidget->isVisible() == false) { QRect geo = sysTray->geometry(); + sDebug() << "Systray geo" << geo; QPoint tray_center = sysTray->geometry().center(); + if (tray_center == QPoint(0, 0)) + { + QPoint mousePos = QCursor::pos() - qApp->screenAt(QCursor::pos())->geometry().topLeft(); + geo = QRect(mousePos, QSize(10, 10)); + tray_center = mousePos; + } QRect screen_rect = qApp->screenAt(tray_center)->geometry(); QPoint screen_center = screen_rect.center(); Qt::Corner corner = Qt::TopLeftCorner; + sDebug() << tray_center << screen_center << UiWidget->size(); if (tray_center.x() > screen_center.x() && tray_center.y() <= screen_center.y()) corner = Qt::TopRightCorner; else if (tray_center.x() > screen_center.x() && tray_center.y() > screen_center.y()) @@ -211,14 +219,15 @@ void AppUi::init() else if (tray_center.x() <= screen_center.x() && tray_center.y() > screen_center.y()) corner = Qt::BottomLeftCorner; // Bottom + sDebug() << "Systray is in : " << corner; if (corner == Qt::BottomRightCorner) UiWidget->move(geo.x() - UiWidget->size().width(), geo.y() - UiWidget->size().height()); if (corner == Qt::BottomLeftCorner) UiWidget->move(geo.x() + UiWidget->size().width(), geo.y() - UiWidget->size().height()); if (corner == Qt::TopLeftCorner) - UiWidget->move(geo.x() + UiWidget->size().width(), geo.y() + UiWidget->size().height()); + UiWidget->move(geo.x() + UiWidget->size().width(), geo.y() + geo.height()); if (corner == Qt::TopRightCorner) - UiWidget->move(geo.x() - UiWidget->size().width(), geo.y() + UiWidget->size().height()); + UiWidget->move(geo.x() - UiWidget->size().width(), geo.y() + geo.height()); UiWidget->show(); onMenuHovered(nullptr); @@ -786,3 +795,4 @@ void AppUi::handleMagic2Snes(QString path) } + diff --git a/ui/appui.h b/ui/appui.h index 11321a2..c57ab42 100644 --- a/ui/appui.h +++ b/ui/appui.h @@ -36,7 +36,6 @@ #include #include - class AppUi : public QObject { Q_OBJECT diff --git a/ui/appuimenu.cpp b/ui/appuimenu.cpp index 6324e1a..7f4d9b9 100644 --- a/ui/appuimenu.cpp +++ b/ui/appuimenu.cpp @@ -90,7 +90,7 @@ void AppUi::setMenu() diag.setWSServer(&wsServer); diag.exec(); }); - QObject::connect(menu->addAction(tr("Exit")), &QAction::triggered, qApp, &QApplication::exit); + QObject::connect(menu->addAction(QIcon(":/img/quiticon.svg"), tr("Exit")), &QAction::triggered, qApp, &QApplication::exit); appsMenu->addSeparator(); appsMenu->addAction(tr("Remote Applications")); appsMenu->addSeparator(); @@ -104,6 +104,7 @@ void AppUi::setMenu() void AppUi::setLinuxDeviceMenu() { + linuxActionPos = 0; deviceMenu->addAction("Devices state"); auto serverStatus = wsServer.serverStatus(); for (quint8 i = 0; i < serverStatus.deviceFactoryCount * 3; i++) diff --git a/ui/systraywidget.cpp b/ui/systraywidget.cpp index a550d0c..cf6fcb6 100644 --- a/ui/systraywidget.cpp +++ b/ui/systraywidget.cpp @@ -70,10 +70,12 @@ void SysTrayWidget::on_pushButton_clicked() QPoint p = mapToGlobal(ui->pushButton->geometry().topRight()); if (corner == Qt::TopLeftCorner || corner == Qt::TopRightCorner) { - p.setY(p.y() + contextMenu->sizeHint().height()); + p.setY(p.y() + ui->pushButton->geometry().height()); } else { p.setY(p.y() - contextMenu->sizeHint().height()); } + if (corner == Qt::TopRightCorner) + p.setX(p.x() - contextMenu->sizeHint().width()); contextMenu->move(p); contextMenu->show(); } diff --git a/ui/systraywidget.ui b/ui/systraywidget.ui index d0c869d..d0cfa13 100644 --- a/ui/systraywidget.ui +++ b/ui/systraywidget.ui @@ -13,6 +13,10 @@ QUsb2Snes + + + :/img/icon64x64.ico:/img/icon64x64.ico +