mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-27 08:19:30 +08:00
parent
e1ca0f3ff9
commit
baa8d2c326
@ -1256,22 +1256,24 @@ void Preferences::setMainGeometry(const QByteArray &geometry)
|
||||
setValue(u"MainWindow/geometry"_qs, geometry);
|
||||
}
|
||||
|
||||
QByteArray Preferences::getMainVSplitterState() const
|
||||
bool Preferences::isFiltersSidebarVisible() const
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
return value<QByteArray>(u"GUI/Qt6/MainWindow/VSplitterState"_qs);
|
||||
#else
|
||||
return value<QByteArray>(u"MainWindow/qt5/vsplitterState"_qs);
|
||||
#endif
|
||||
return value(u"GUI/MainWindow/FiltersSidebarVisible"_qs, true);
|
||||
}
|
||||
|
||||
void Preferences::setMainVSplitterState(const QByteArray &state)
|
||||
void Preferences::setFiltersSidebarVisible(const bool value)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
setValue(u"GUI/Qt6/MainWindow/VSplitterState"_qs, state);
|
||||
#else
|
||||
setValue(u"MainWindow/qt5/vsplitterState"_qs, state);
|
||||
#endif
|
||||
setValue(u"GUI/MainWindow/FiltersSidebarVisible"_qs, value);
|
||||
}
|
||||
|
||||
int Preferences::getFiltersSidebarWidth() const
|
||||
{
|
||||
return value(u"GUI/MainWindow/FiltersSidebarWidth"_qs, 120);
|
||||
}
|
||||
|
||||
void Preferences::setFiltersSidebarWidth(const int value)
|
||||
{
|
||||
setValue(u"GUI/MainWindow/FiltersSidebarWidth"_qs, value);
|
||||
}
|
||||
|
||||
Path Preferences::getMainLastDir() const
|
||||
|
@ -340,8 +340,10 @@ public:
|
||||
void setAcceptedLegal(bool accepted);
|
||||
QByteArray getMainGeometry() const;
|
||||
void setMainGeometry(const QByteArray &geometry);
|
||||
QByteArray getMainVSplitterState() const;
|
||||
void setMainVSplitterState(const QByteArray &state);
|
||||
bool isFiltersSidebarVisible() const;
|
||||
void setFiltersSidebarVisible(bool value);
|
||||
int getFiltersSidebarWidth() const;
|
||||
void setFiltersSidebarWidth(int value);
|
||||
Path getMainLastDir() const;
|
||||
void setMainLastDir(const Path &path);
|
||||
QByteArray getPeerListState() const;
|
||||
|
@ -223,13 +223,10 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
// m_transferListWidget->setStyleSheet("QTreeView {border: none;}"); // borderless
|
||||
m_propertiesWidget = new PropertiesWidget(hSplitter);
|
||||
connect(m_transferListWidget, &TransferListWidget::currentTorrentChanged, m_propertiesWidget, &PropertiesWidget::loadTorrentInfos);
|
||||
m_transferListFiltersWidget = new TransferListFiltersWidget(m_splitter, m_transferListWidget, isDownloadTrackerFavicon());
|
||||
hSplitter->addWidget(m_transferListWidget);
|
||||
hSplitter->addWidget(m_propertiesWidget);
|
||||
m_splitter->addWidget(m_transferListFiltersWidget);
|
||||
m_splitter->addWidget(hSplitter);
|
||||
m_splitter->setCollapsible(0, true);
|
||||
m_splitter->setCollapsible(1, false);
|
||||
m_splitter->setCollapsible(0, false);
|
||||
m_tabs->addTab(m_splitter,
|
||||
#ifndef Q_OS_MACOS
|
||||
UIThemeManager::instance()->getIcon(u"folder-remote"_qs),
|
||||
@ -238,12 +235,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
connect(m_searchFilter, &LineEdit::textChanged, m_transferListWidget, &TransferListWidget::applyNameFilter);
|
||||
connect(hSplitter, &QSplitter::splitterMoved, this, &MainWindow::writeSettings);
|
||||
connect(m_splitter, &QSplitter::splitterMoved, this, &MainWindow::writeSettings);
|
||||
connect(m_splitter, &QSplitter::splitterMoved, this, &MainWindow::writeSplitterSettings);
|
||||
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackersChanged, m_propertiesWidget, &PropertiesWidget::loadTrackers);
|
||||
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::trackerlessStateChanged, m_transferListFiltersWidget, &TransferListFiltersWidget::changeTrackerless);
|
||||
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerEntriesUpdated, m_transferListFiltersWidget, &TransferListFiltersWidget::trackerEntriesUpdated);
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
// Increase top spacing to avoid tab overlapping
|
||||
@ -435,6 +428,20 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
m_propertiesWidget->readSettings();
|
||||
|
||||
const bool isFiltersSidebarVisible = pref->isFiltersSidebarVisible();
|
||||
m_ui->actionShowFiltersSidebar->setChecked(isFiltersSidebarVisible);
|
||||
if (isFiltersSidebarVisible)
|
||||
{
|
||||
showFiltersSidebar(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_transferListWidget->applyStatusFilter(pref->getTransSelFilter());
|
||||
m_transferListWidget->applyCategoryFilter(QString());
|
||||
m_transferListWidget->applyTagFilter(QString());
|
||||
m_transferListWidget->applyTrackerFilterAll();
|
||||
}
|
||||
|
||||
// Start watching the executable for updates
|
||||
m_executableWatcher = new QFileSystemWatcher(this);
|
||||
connect(m_executableWatcher, &QFileSystemWatcher::fileChanged, this, &MainWindow::notifyOfUpdate);
|
||||
@ -538,7 +545,8 @@ bool MainWindow::isDownloadTrackerFavicon() const
|
||||
|
||||
void MainWindow::setDownloadTrackerFavicon(const bool value)
|
||||
{
|
||||
m_transferListFiltersWidget->setDownloadTrackerFavicon(value);
|
||||
if (m_transferListFiltersWidget)
|
||||
m_transferListFiltersWidget->setDownloadTrackerFavicon(value);
|
||||
m_storeDownloadTrackerFavicon = value;
|
||||
}
|
||||
|
||||
@ -784,11 +792,16 @@ void MainWindow::writeSettings()
|
||||
{
|
||||
Preferences *const pref = Preferences::instance();
|
||||
pref->setMainGeometry(saveGeometry());
|
||||
// Splitter size
|
||||
pref->setMainVSplitterState(m_splitter->saveState());
|
||||
m_propertiesWidget->saveSettings();
|
||||
}
|
||||
|
||||
void MainWindow::writeSplitterSettings()
|
||||
{
|
||||
Q_ASSERT(m_splitter->widget(0) == m_transferListFiltersWidget);
|
||||
Preferences *const pref = Preferences::instance();
|
||||
pref->setFiltersSidebarWidth(m_splitter->sizes()[0]);
|
||||
}
|
||||
|
||||
void MainWindow::cleanup()
|
||||
{
|
||||
writeSettings();
|
||||
@ -817,12 +830,6 @@ void MainWindow::readSettings()
|
||||
const QByteArray mainGeo = pref->getMainGeometry();
|
||||
if (!mainGeo.isEmpty() && restoreGeometry(mainGeo))
|
||||
m_posInitialized = true;
|
||||
const QByteArray splitterState = pref->getMainVSplitterState();
|
||||
if (splitterState.isEmpty())
|
||||
// Default sizes
|
||||
m_splitter->setSizes({ 120, m_splitter->width() - 120 });
|
||||
else
|
||||
m_splitter->restoreState(splitterState);
|
||||
}
|
||||
|
||||
void MainWindow::balloonClicked()
|
||||
@ -1475,6 +1482,33 @@ void MainWindow::showStatusBar(bool show)
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::showFiltersSidebar(const bool show)
|
||||
{
|
||||
Preferences *const pref = Preferences::instance();
|
||||
|
||||
if (show && !m_transferListFiltersWidget)
|
||||
{
|
||||
const int width = pref->getFiltersSidebarWidth();
|
||||
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::trackersRemoved, m_transferListFiltersWidget, &TransferListFiltersWidget::removeTrackers);
|
||||
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerlessStateChanged, m_transferListFiltersWidget, &TransferListFiltersWidget::changeTrackerless);
|
||||
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerEntriesUpdated, m_transferListFiltersWidget, &TransferListFiltersWidget::trackerEntriesUpdated);
|
||||
}
|
||||
else if (!show && m_transferListFiltersWidget)
|
||||
{
|
||||
Q_ASSERT(m_splitter->widget(0) == m_transferListFiltersWidget);
|
||||
|
||||
pref->setFiltersSidebarWidth(m_splitter->sizes()[0]);
|
||||
delete m_transferListFiltersWidget;
|
||||
m_transferListFiltersWidget = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::loadPreferences()
|
||||
{
|
||||
const Preferences *pref = Preferences::instance();
|
||||
@ -1801,6 +1835,13 @@ void MainWindow::on_actionShowStatusbar_triggered()
|
||||
showStatusBar(isVisible);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionShowFiltersSidebar_triggered(const bool checked)
|
||||
{
|
||||
Preferences *const pref = Preferences::instance();
|
||||
pref->setFiltersSidebarVisible(checked);
|
||||
showFiltersSidebar(checked);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionSpeedInTitleBar_triggered()
|
||||
{
|
||||
m_displaySpeedInTitle = static_cast<QAction *>(sender())->isChecked();
|
||||
|
@ -115,6 +115,7 @@ private slots:
|
||||
void showFilterContextMenu();
|
||||
void balloonClicked();
|
||||
void writeSettings();
|
||||
void writeSplitterSettings();
|
||||
void readSettings();
|
||||
void fullDiskError(BitTorrent::Torrent *const torrent, const QString &msg) const;
|
||||
void handleDownloadFromUrlFailure(const QString &, const QString &) const;
|
||||
@ -158,6 +159,7 @@ private slots:
|
||||
void on_actionSpeedInTitleBar_triggered();
|
||||
void on_actionTopToolBar_triggered();
|
||||
void on_actionShowStatusbar_triggered();
|
||||
void on_actionShowFiltersSidebar_triggered(bool checked);
|
||||
void on_actionDonateMoney_triggered();
|
||||
void on_actionExecutionLogs_triggered(bool checked);
|
||||
void on_actionNormalMessages_triggered(bool checked);
|
||||
@ -214,6 +216,7 @@ private:
|
||||
void displaySearchTab(bool enable);
|
||||
void createTorrentTriggered(const Path &path);
|
||||
void showStatusBar(bool show);
|
||||
void showFiltersSidebar(bool show);
|
||||
|
||||
Ui::MainWindow *m_ui;
|
||||
|
||||
@ -234,7 +237,7 @@ private:
|
||||
QPointer<QMenu> m_trayIconMenu;
|
||||
|
||||
TransferListWidget *m_transferListWidget;
|
||||
TransferListFiltersWidget *m_transferListFiltersWidget;
|
||||
TransferListFiltersWidget *m_transferListFiltersWidget = nullptr;
|
||||
PropertiesWidget *m_propertiesWidget;
|
||||
bool m_displaySpeedInTitle;
|
||||
bool m_forceExit = false;
|
||||
|
@ -112,6 +112,7 @@
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionTopToolBar"/>
|
||||
<addaction name="actionShowStatusbar"/>
|
||||
<addaction name="actionShowFiltersSidebar"/>
|
||||
<addaction name="actionSpeedInTitleBar"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionSearchWidget"/>
|
||||
@ -307,6 +308,14 @@
|
||||
<string>Status &Bar</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionShowFiltersSidebar">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Filters Sidebar</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSpeedInTitleBar">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
|
@ -73,6 +73,7 @@
|
||||
<ul>
|
||||
<li><a id="showTopToolbarLink"><img class="MyMenuIcon" src="icons/checked.svg" alt="QBT_TR(Top Toolbar)QBT_TR[CONTEXT=MainWindow]" width="16" height="16" />QBT_TR(Top Toolbar)QBT_TR[CONTEXT=MainWindow]</a></li>
|
||||
<li><a id="showStatusBarLink"><img class="MyMenuIcon" src="icons/checked.svg" alt="QBT_TR(Status Bar)QBT_TR[CONTEXT=MainWindow]" width="16" height="16" />QBT_TR(Status Bar)QBT_TR[CONTEXT=MainWindow]</a></li>
|
||||
<li><a id="showFiltersSidebarLink"><img class="MyMenuIcon" src="icons/checked.svg" alt="QBT_TR(Filters Sidebar)QBT_TR[CONTEXT=MainWindow]" width="16" height="16" />QBT_TR(Filters Sidebar)QBT_TR[CONTEXT=MainWindow]</a></li>
|
||||
<li><a id="speedInBrowserTitleBarLink"><img class="MyMenuIcon" src="icons/checked.svg" alt="QBT_TR(Speed in Title Bar)QBT_TR[CONTEXT=MainWindow]" width="16" height="16" />QBT_TR(Speed in Title Bar)QBT_TR[CONTEXT=MainWindow]</a></li>
|
||||
<li class="divider"><a id="showSearchEngineLink"><img class="MyMenuIcon" src="icons/checked.svg" alt="QBT_TR(Search Engine)QBT_TR[CONTEXT=MainWindow]" width="16" height="16" />QBT_TR(Search Engine)QBT_TR[CONTEXT=MainWindow]</a></li>
|
||||
<li><a id="showRssReaderLink"><img class="MyMenuIcon" src="icons/checked.svg" alt="QBT_TR(RSS)QBT_TR[CONTEXT=MainWindow]" width="16" height="16" />QBT_TR(RSS Reader)QBT_TR[CONTEXT=MainWindow]</a></li>
|
||||
|
@ -87,6 +87,12 @@ const loadSelectedTracker = function() {
|
||||
};
|
||||
loadSelectedTracker();
|
||||
|
||||
const getShowFiltersSidebar = function() {
|
||||
// Show Filters Sidebar is enabled by default
|
||||
const show = LocalPreferences.get('show_filters_sidebar');
|
||||
return (show === null) || (show === 'true');
|
||||
}
|
||||
|
||||
function genHash(string) {
|
||||
// origins:
|
||||
// https://stackoverflow.com/a/8831937
|
||||
@ -284,6 +290,13 @@ window.addEvent('load', function() {
|
||||
$('desktopFooterWrapper').addClass('invisible');
|
||||
}
|
||||
|
||||
const showFiltersSidebar = getShowFiltersSidebar();
|
||||
if (!showFiltersSidebar) {
|
||||
$('showFiltersSidebarLink').firstChild.style.opacity = '0';
|
||||
$('filtersColumn').addClass('invisible');
|
||||
$('filtersColumn_handle').addClass('invisible');
|
||||
}
|
||||
|
||||
let speedInTitle = LocalPreferences.get('speed_in_browser_title_bar') == "true";
|
||||
if (!speedInTitle)
|
||||
$('speedInBrowserTitleBarLink').firstChild.style.opacity = '0';
|
||||
@ -855,6 +868,22 @@ window.addEvent('load', function() {
|
||||
registerMagnetHandler();
|
||||
});
|
||||
|
||||
$('showFiltersSidebarLink').addEvent('click', function(e) {
|
||||
const showFiltersSidebar = !getShowFiltersSidebar();
|
||||
LocalPreferences.set('show_filters_sidebar', showFiltersSidebar.toString());
|
||||
if (showFiltersSidebar) {
|
||||
$('showFiltersSidebarLink').firstChild.style.opacity = '1';
|
||||
$('filtersColumn').removeClass('invisible');
|
||||
$('filtersColumn_handle').removeClass('invisible');
|
||||
}
|
||||
else {
|
||||
$('showFiltersSidebarLink').firstChild.style.opacity = '0';
|
||||
$('filtersColumn').addClass('invisible');
|
||||
$('filtersColumn_handle').addClass('invisible');
|
||||
}
|
||||
MochaUI.Desktop.setDesktopSize();
|
||||
});
|
||||
|
||||
$('speedInBrowserTitleBarLink').addEvent('click', function(e) {
|
||||
speedInTitle = !speedInTitle;
|
||||
LocalPreferences.set('speed_in_browser_title_bar', speedInTitle.toString());
|
||||
|
Loading…
Reference in New Issue
Block a user