Skip to content

Commit

Permalink
Fix main window turns blank after restoring from tray (qbittorrent#15031
Browse files Browse the repository at this point in the history
)

When restoring from tray icon, although the window manager shows qbt
window but qbt itself didn't handle the event correctly, i.e. the
`show()` was missing and thus qbt did nothing and the window is blank.
Note that at this point the `visible` property is `false`.
After invoking `show()` qbt will start showing the contents and also
fire another showEvent where `visible` property is `true` and here is where
qbt should handle preparations for the window.

Fix qbittorrent#9510.
  • Loading branch information
Chocobo1 authored May 31, 2021
1 parent d335f26 commit 2503271
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1131,17 +1131,26 @@ void MainWindow::on_actionStatistics_triggered()
void MainWindow::showEvent(QShowEvent *e)
{
qDebug("** Show Event **");
e->accept();

if (currentTabWidget() == m_transferListWidget)
m_propertiesWidget->loadDynamicData();
if (isVisible())
{
// preparations before showing the window

e->accept();
if (currentTabWidget() == m_transferListWidget)
m_propertiesWidget->loadDynamicData();

// Make sure the window is initially centered
if (!m_posInitialized)
// Make sure the window is initially centered
if (!m_posInitialized)
{
move(Utils::Gui::screenCenter(this));
m_posInitialized = true;
}
}
else
{
move(Utils::Gui::screenCenter(this));
m_posInitialized = true;
// to avoid blank screen when restoring from tray icon
show();
}
}

Expand Down

0 comments on commit 2503271

Please sign in to comment.