更新内容
parent
04f586ebb9
commit
8be5fbc548
File diff suppressed because one or more lines are too long
|
@ -35,7 +35,7 @@ void TrayIcon::iconIsActived(QSystemTrayIcon::ActivationReason reason)
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case QSystemTrayIcon::Trigger:
|
case QSystemTrayIcon::Trigger:
|
||||||
case QSystemTrayIcon::DoubleClick: {
|
case QSystemTrayIcon::DoubleClick: {
|
||||||
mainWidget->showNormal();
|
this->showMainWidget();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ void TrayIcon::setExitDirect(bool exitDirect)
|
||||||
void TrayIcon::setMainWidget(QWidget *mainWidget)
|
void TrayIcon::setMainWidget(QWidget *mainWidget)
|
||||||
{
|
{
|
||||||
this->mainWidget = mainWidget;
|
this->mainWidget = mainWidget;
|
||||||
menu->addAction("主界面", mainWidget, SLOT(showNormal()));
|
menu->addAction("主界面", this, SLOT(showMainWidget()));
|
||||||
|
|
||||||
if (exitDirect) {
|
if (exitDirect) {
|
||||||
menu->addAction("退出", this, SLOT(closeAll()));
|
menu->addAction("退出", this, SLOT(closeAll()));
|
||||||
|
@ -70,6 +70,14 @@ void TrayIcon::setMainWidget(QWidget *mainWidget)
|
||||||
trayIcon->setContextMenu(menu);
|
trayIcon->setContextMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrayIcon::showMainWidget()
|
||||||
|
{
|
||||||
|
if (mainWidget) {
|
||||||
|
mainWidget->showNormal();
|
||||||
|
mainWidget->activateWindow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TrayIcon::showMessage(const QString &title, const QString &msg, QSystemTrayIcon::MessageIcon icon, int msecs)
|
void TrayIcon::showMessage(const QString &title, const QString &msg, QSystemTrayIcon::MessageIcon icon, int msecs)
|
||||||
{
|
{
|
||||||
trayIcon->showMessage(title, msg, icon, msecs);
|
trayIcon->showMessage(title, msg, icon, msecs);
|
||||||
|
|
|
@ -45,6 +45,8 @@ public Q_SLOTS:
|
||||||
|
|
||||||
//设置所属主窗体
|
//设置所属主窗体
|
||||||
void setMainWidget(QWidget *mainWidget);
|
void setMainWidget(QWidget *mainWidget);
|
||||||
|
//显示主窗体
|
||||||
|
void showMainWidget();
|
||||||
|
|
||||||
//显示消息
|
//显示消息
|
||||||
void showMessage(const QString &title, const QString &msg,
|
void showMessage(const QString &title, const QString &msg,
|
||||||
|
|
|
@ -35,7 +35,7 @@ void TrayIcon::iconIsActived(QSystemTrayIcon::ActivationReason reason)
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case QSystemTrayIcon::Trigger:
|
case QSystemTrayIcon::Trigger:
|
||||||
case QSystemTrayIcon::DoubleClick: {
|
case QSystemTrayIcon::DoubleClick: {
|
||||||
mainWidget->showNormal();
|
this->showMainWidget();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ void TrayIcon::setExitDirect(bool exitDirect)
|
||||||
void TrayIcon::setMainWidget(QWidget *mainWidget)
|
void TrayIcon::setMainWidget(QWidget *mainWidget)
|
||||||
{
|
{
|
||||||
this->mainWidget = mainWidget;
|
this->mainWidget = mainWidget;
|
||||||
menu->addAction("主界面", mainWidget, SLOT(showNormal()));
|
menu->addAction("主界面", this, SLOT(showMainWidget()));
|
||||||
|
|
||||||
if (exitDirect) {
|
if (exitDirect) {
|
||||||
menu->addAction("退出", this, SLOT(closeAll()));
|
menu->addAction("退出", this, SLOT(closeAll()));
|
||||||
|
@ -70,6 +70,14 @@ void TrayIcon::setMainWidget(QWidget *mainWidget)
|
||||||
trayIcon->setContextMenu(menu);
|
trayIcon->setContextMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrayIcon::showMainWidget()
|
||||||
|
{
|
||||||
|
if (mainWidget) {
|
||||||
|
mainWidget->showNormal();
|
||||||
|
mainWidget->activateWindow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TrayIcon::showMessage(const QString &title, const QString &msg, QSystemTrayIcon::MessageIcon icon, int msecs)
|
void TrayIcon::showMessage(const QString &title, const QString &msg, QSystemTrayIcon::MessageIcon icon, int msecs)
|
||||||
{
|
{
|
||||||
trayIcon->showMessage(title, msg, icon, msecs);
|
trayIcon->showMessage(title, msg, icon, msecs);
|
||||||
|
|
|
@ -45,6 +45,8 @@ public Q_SLOTS:
|
||||||
|
|
||||||
//设置所属主窗体
|
//设置所属主窗体
|
||||||
void setMainWidget(QWidget *mainWidget);
|
void setMainWidget(QWidget *mainWidget);
|
||||||
|
//显示主窗体
|
||||||
|
void showMainWidget();
|
||||||
|
|
||||||
//显示消息
|
//显示消息
|
||||||
void showMessage(const QString &title, const QString &msg,
|
void showMessage(const QString &title, const QString &msg,
|
||||||
|
|
Loading…
Reference in New Issue