mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-10-22 10:46:04 +03:00
parent
c3abe4c2a6
commit
904bcc14d5
4 changed files with 33 additions and 6 deletions
|
@ -793,12 +793,9 @@ try
|
|||
});
|
||||
|
||||
disconnect(m_desktopIntegration, &DesktopIntegration::activationRequested, this, &Application::createStartupProgressDialog);
|
||||
// we must not delete menu while it is used by DesktopIntegration
|
||||
auto *oldMenu = m_desktopIntegration->menu();
|
||||
const MainWindow::State windowState = (!m_startupProgressDialog || (m_startupProgressDialog->windowState() & Qt::WindowMinimized))
|
||||
? MainWindow::Minimized : MainWindow::Normal;
|
||||
m_window = new MainWindow(this, windowState);
|
||||
delete oldMenu;
|
||||
delete m_startupProgressDialog;
|
||||
#ifdef Q_OS_WIN
|
||||
auto *pref = Preferences::instance();
|
||||
|
|
|
@ -99,6 +99,12 @@ DesktopIntegration::DesktopIntegration(QObject *parent)
|
|||
connect(Preferences::instance(), &Preferences::changed, this, &DesktopIntegration::onPreferencesChanged);
|
||||
}
|
||||
|
||||
DesktopIntegration::~DesktopIntegration()
|
||||
{
|
||||
if (m_menu)
|
||||
delete m_menu;
|
||||
}
|
||||
|
||||
bool DesktopIntegration::isActive() const
|
||||
{
|
||||
#ifdef Q_OS_MACOS
|
||||
|
@ -135,12 +141,36 @@ void DesktopIntegration::setMenu(QMenu *menu)
|
|||
if (menu == m_menu)
|
||||
return;
|
||||
|
||||
#if defined Q_OS_MACOS
|
||||
if (m_menu)
|
||||
delete m_menu;
|
||||
|
||||
m_menu = menu;
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
if (m_menu)
|
||||
m_menu->setAsDockMenu();
|
||||
#elif defined Q_OS_UNIX
|
||||
const bool systemTrayEnabled = m_systrayIcon;
|
||||
if (m_menu)
|
||||
{
|
||||
if (m_systrayIcon)
|
||||
{
|
||||
delete m_systrayIcon;
|
||||
m_systrayIcon = nullptr;
|
||||
}
|
||||
delete m_menu;
|
||||
}
|
||||
|
||||
m_menu = menu;
|
||||
|
||||
if (systemTrayEnabled && !m_systrayIcon)
|
||||
createTrayIcon();
|
||||
#else
|
||||
if (m_menu)
|
||||
delete m_menu;
|
||||
|
||||
m_menu = menu;
|
||||
|
||||
if (m_systrayIcon)
|
||||
m_systrayIcon->setContextMenu(m_menu);
|
||||
#endif
|
||||
|
|
|
@ -49,6 +49,7 @@ class DesktopIntegration final : public QObject
|
|||
|
||||
public:
|
||||
explicit DesktopIntegration(QObject *parent = nullptr);
|
||||
~DesktopIntegration() override;
|
||||
|
||||
bool isActive() const;
|
||||
|
||||
|
|
|
@ -463,7 +463,6 @@ MainWindow::MainWindow(IGUIApplication *app, const State initialState)
|
|||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
app()->desktopIntegration()->setMenu(nullptr);
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
@ -1573,7 +1572,7 @@ void MainWindow::downloadFromURLList(const QStringList &urlList)
|
|||
|
||||
QMenu *MainWindow::createDesktopIntegrationMenu()
|
||||
{
|
||||
auto *menu = new QMenu(this);
|
||||
auto *menu = new QMenu;
|
||||
|
||||
#ifndef Q_OS_MACOS
|
||||
connect(menu, &QMenu::aboutToShow, this, [this]()
|
||||
|
|
Loading…
Reference in a new issue