Skip to content

Commit

Permalink
fix: hide dock icon when close to minitray
Browse files Browse the repository at this point in the history
Change-Id: Ice4bf9369faa4f2b39087e8f0c4d2f89bf11d7e8
  • Loading branch information
Iceyer committed Mar 2, 2018
1 parent 7ce74ff commit 1845992
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
2 changes: 0 additions & 2 deletions music-player/presenter/presenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ Presenter::~Presenter()
void Presenter::handleQuit()
{
Q_D(Presenter);
qDebug() << "handleQuit";

d->settings->setOption("base.play.last_position", d->lastPlayPosition);
d->player->stop();
}
Expand Down
23 changes: 11 additions & 12 deletions music-player/view/mainframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,15 +608,18 @@ void MainFrame::postInitUI()
connect(trayIcon, &QSystemTrayIcon::activated,
this, [ = ](QSystemTrayIcon::ActivationReason reason) {
if (QSystemTrayIcon::Trigger == reason) {
if (isMinimized()) {
showNormal();
if (isVisible()) {
if (isMinimized()) {
showNormal();
// when window flags changed, should call hide() and show()
hide();
show();
} else {
showMinimized();
}
} else {
showMinimized();
showNormal();
}

// when window flags changed, should can hide and show
hide();
show();
}
});
}
Expand Down Expand Up @@ -1131,12 +1134,8 @@ void MainFrame::closeEvent(QCloseEvent *event)
MusicSettings::setOption("base.play.state", int(windowState()));
MusicSettings::setOption("base.play.geometry", saveGeometry());
DMainWindow::closeEvent(event);
} else {
event->ignore();
showMinimized();
hide();
show();
}
DMainWindow::closeEvent(event);
}

void MainFrame::paintEvent(QPaintEvent *e)
Expand Down

0 comments on commit 1845992

Please sign in to comment.