|
|
@ -219,8 +219,8 @@ MainWindow::MainWindow(IGUIApplication *app, const State initialState) |
|
|
|
tr("Transfers")); |
|
|
|
tr("Transfers")); |
|
|
|
|
|
|
|
|
|
|
|
connect(m_searchFilter, &LineEdit::textChanged, m_transferListWidget, &TransferListWidget::applyNameFilter); |
|
|
|
connect(m_searchFilter, &LineEdit::textChanged, m_transferListWidget, &TransferListWidget::applyNameFilter); |
|
|
|
connect(hSplitter, &QSplitter::splitterMoved, this, &MainWindow::writeSettings); |
|
|
|
connect(hSplitter, &QSplitter::splitterMoved, this, &MainWindow::saveSettings); |
|
|
|
connect(m_splitter, &QSplitter::splitterMoved, this, &MainWindow::writeSplitterSettings); |
|
|
|
connect(m_splitter, &QSplitter::splitterMoved, this, &MainWindow::saveSplitterSettings); |
|
|
|
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackersChanged, m_propertiesWidget, &PropertiesWidget::loadTrackers); |
|
|
|
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackersChanged, m_propertiesWidget, &PropertiesWidget::loadTrackers); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef Q_OS_MACOS |
|
|
|
#ifdef Q_OS_MACOS |
|
|
@ -357,7 +357,7 @@ MainWindow::MainWindow(IGUIApplication *app, const State initialState) |
|
|
|
m_ui->actionAutoShutdownDisabled->setChecked(true); |
|
|
|
m_ui->actionAutoShutdownDisabled->setChecked(true); |
|
|
|
|
|
|
|
|
|
|
|
// Load Window state and sizes
|
|
|
|
// Load Window state and sizes
|
|
|
|
readSettings(); |
|
|
|
loadSettings(); |
|
|
|
|
|
|
|
|
|
|
|
app->desktopIntegration()->setMenu(createDesktopIntegrationMenu()); |
|
|
|
app->desktopIntegration()->setMenu(createDesktopIntegrationMenu()); |
|
|
|
#ifndef Q_OS_MACOS |
|
|
|
#ifndef Q_OS_MACOS |
|
|
@ -739,23 +739,26 @@ void MainWindow::tabChanged(int newTab) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::writeSettings() |
|
|
|
void MainWindow::saveSettings() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
Preferences *const pref = Preferences::instance(); |
|
|
|
auto *pref = Preferences::instance(); |
|
|
|
pref->setMainGeometry(saveGeometry()); |
|
|
|
pref->setMainGeometry(saveGeometry()); |
|
|
|
m_propertiesWidget->saveSettings(); |
|
|
|
m_propertiesWidget->saveSettings(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::writeSplitterSettings() |
|
|
|
void MainWindow::saveSplitterSettings() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
Q_ASSERT(m_splitter->widget(0) == m_transferListFiltersWidget); |
|
|
|
if (!m_transferListFiltersWidget) |
|
|
|
Preferences *const pref = Preferences::instance(); |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto *pref = Preferences::instance(); |
|
|
|
pref->setFiltersSidebarWidth(m_splitter->sizes()[0]); |
|
|
|
pref->setFiltersSidebarWidth(m_splitter->sizes()[0]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::cleanup() |
|
|
|
void MainWindow::cleanup() |
|
|
|
{ |
|
|
|
{ |
|
|
|
writeSettings(); |
|
|
|
saveSettings(); |
|
|
|
|
|
|
|
saveSplitterSettings(); |
|
|
|
|
|
|
|
|
|
|
|
// delete RSSWidget explicitly to avoid crash in
|
|
|
|
// delete RSSWidget explicitly to avoid crash in
|
|
|
|
// handleRSSUnreadCountUpdated() at application shutdown
|
|
|
|
// handleRSSUnreadCountUpdated() at application shutdown
|
|
|
@ -775,12 +778,15 @@ void MainWindow::cleanup() |
|
|
|
delete w; |
|
|
|
delete w; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::readSettings() |
|
|
|
void MainWindow::loadSettings() |
|
|
|
{ |
|
|
|
{ |
|
|
|
const Preferences *const pref = Preferences::instance(); |
|
|
|
const auto *pref = Preferences::instance(); |
|
|
|
const QByteArray mainGeo = pref->getMainGeometry(); |
|
|
|
|
|
|
|
if (!mainGeo.isEmpty() && restoreGeometry(mainGeo)) |
|
|
|
if (const QByteArray mainGeo = pref->getMainGeometry(); |
|
|
|
|
|
|
|
!mainGeo.isEmpty() && restoreGeometry(mainGeo)) |
|
|
|
|
|
|
|
{ |
|
|
|
m_posInitialized = true; |
|
|
|
m_posInitialized = true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::desktopNotificationClicked() |
|
|
|
void MainWindow::desktopNotificationClicked() |
|
|
@ -1377,27 +1383,27 @@ void MainWindow::showStatusBar(bool show) |
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::showFiltersSidebar(const bool show) |
|
|
|
void MainWindow::showFiltersSidebar(const bool show) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Preferences *const pref = Preferences::instance(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (show && !m_transferListFiltersWidget) |
|
|
|
if (show && !m_transferListFiltersWidget) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const int width = pref->getFiltersSidebarWidth(); |
|
|
|
|
|
|
|
m_transferListFiltersWidget = new TransferListFiltersWidget(m_splitter, m_transferListWidget, isDownloadTrackerFavicon()); |
|
|
|
m_transferListFiltersWidget = new TransferListFiltersWidget(m_splitter, m_transferListWidget, isDownloadTrackerFavicon()); |
|
|
|
m_splitter->insertWidget(0, m_transferListFiltersWidget); |
|
|
|
|
|
|
|
m_splitter->setCollapsible(0, true); |
|
|
|
|
|
|
|
m_splitter->setSizes({width, (m_splitter->width() - width)}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackersAdded, m_transferListFiltersWidget, &TransferListFiltersWidget::addTrackers); |
|
|
|
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackersAdded, m_transferListFiltersWidget, &TransferListFiltersWidget::addTrackers); |
|
|
|
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackersRemoved, m_transferListFiltersWidget, &TransferListFiltersWidget::removeTrackers); |
|
|
|
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackersRemoved, m_transferListFiltersWidget, &TransferListFiltersWidget::removeTrackers); |
|
|
|
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackersChanged, m_transferListFiltersWidget, &TransferListFiltersWidget::refreshTrackers); |
|
|
|
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackersChanged, m_transferListFiltersWidget, &TransferListFiltersWidget::refreshTrackers); |
|
|
|
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerlessStateChanged, m_transferListFiltersWidget, &TransferListFiltersWidget::changeTrackerless); |
|
|
|
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerlessStateChanged, m_transferListFiltersWidget, &TransferListFiltersWidget::changeTrackerless); |
|
|
|
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerEntriesUpdated, m_transferListFiltersWidget, &TransferListFiltersWidget::trackerEntriesUpdated); |
|
|
|
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerEntriesUpdated, m_transferListFiltersWidget, &TransferListFiltersWidget::trackerEntriesUpdated); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_splitter->insertWidget(0, m_transferListFiltersWidget); |
|
|
|
|
|
|
|
m_splitter->setCollapsible(0, true); |
|
|
|
|
|
|
|
// From https://doc.qt.io/qt-5/qsplitter.html#setSizes:
|
|
|
|
|
|
|
|
// Instead, any additional/missing space is distributed amongst the widgets
|
|
|
|
|
|
|
|
// according to the relative weight of the sizes.
|
|
|
|
|
|
|
|
m_splitter->setStretchFactor(0, 0); |
|
|
|
|
|
|
|
m_splitter->setStretchFactor(1, 1); |
|
|
|
|
|
|
|
m_splitter->setSizes({Preferences::instance()->getFiltersSidebarWidth()}); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (!show && m_transferListFiltersWidget) |
|
|
|
else if (!show && m_transferListFiltersWidget) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Q_ASSERT(m_splitter->widget(0) == m_transferListFiltersWidget); |
|
|
|
saveSplitterSettings(); |
|
|
|
|
|
|
|
|
|
|
|
pref->setFiltersSidebarWidth(m_splitter->sizes()[0]); |
|
|
|
|
|
|
|
delete m_transferListFiltersWidget; |
|
|
|
delete m_transferListFiltersWidget; |
|
|
|
m_transferListFiltersWidget = nullptr; |
|
|
|
m_transferListFiltersWidget = nullptr; |
|
|
|
} |
|
|
|
} |
|
|
|