Browse Source

Don't resize dialog with invalid sizes

This fixes wrong dialog sizes on first startup.
adaptive-webui-19844
Chocobo1 2 years ago
parent
commit
fcf50820e8
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 29
      src/base/preferences.cpp
  2. 5
      src/base/preferences.h
  3. 3
      src/gui/aboutdialog.cpp
  4. 4
      src/gui/addnewtorrentdialog.cpp
  5. 3
      src/gui/banlistoptionsdialog.cpp
  6. 4
      src/gui/cookiesdialog.cpp
  7. 3
      src/gui/downloadfromurldialog.cpp
  8. 3
      src/gui/ipsubnetwhitelistoptionsdialog.cpp
  9. 13
      src/gui/optionsdialog.cpp
  10. 2
      src/gui/optionsdialog.h
  11. 9
      src/gui/previewselectdialog.cpp
  12. 22
      src/gui/rss/automatedrssdownloader.cpp
  13. 4
      src/gui/rss/automatedrssdownloader.h
  14. 3
      src/gui/search/pluginselectdialog.cpp
  15. 3
      src/gui/search/pluginsourcedialog.cpp
  16. 3
      src/gui/speedlimitdialog.cpp
  17. 3
      src/gui/statsdialog.cpp
  18. 3
      src/gui/torrentcreatordialog.cpp
  19. 3
      src/gui/torrentoptionsdialog.cpp
  20. 3
      src/gui/trackerentriesdialog.cpp
  21. 3
      src/gui/watchedfolderoptionsdialog.cpp

29
src/base/preferences.cpp

@ -45,7 +45,6 @@
#include <QLocale> #include <QLocale>
#include <QNetworkCookie> #include <QNetworkCookie>
#include <QSettings> #include <QSettings>
#include <QSize>
#include <QTime> #include <QTime>
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
@ -1371,34 +1370,6 @@ void Preferences::setPropTrackerListState(const QByteArray &state)
#endif #endif
} }
QSize Preferences::getRssGeometrySize() const
{
return value<QSize>(u"RssFeedDownloader/geometrySize"_qs);
}
void Preferences::setRssGeometrySize(const QSize &geometry)
{
setValue(u"RssFeedDownloader/geometrySize"_qs, geometry);
}
QByteArray Preferences::getRssHSplitterSizes() const
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
return value<QByteArray>(u"GUI/Qt6/RSSFeedDownloader/HSplitterSizes"_qs);
#else
return value<QByteArray>(u"RssFeedDownloader/qt5/hsplitterSizes"_qs);
#endif
}
void Preferences::setRssHSplitterSizes(const QByteArray &sizes)
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
setValue(u"GUI/Qt6/RSSFeedDownloader/HSplitterSizes"_qs, sizes);
#else
setValue(u"RssFeedDownloader/qt5/hsplitterSizes"_qs, sizes);
#endif
}
QStringList Preferences::getRssOpenFolders() const QStringList Preferences::getRssOpenFolders() const
{ {
return value<QStringList>(u"GUI/RSSWidget/OpenedFolders"_qs); return value<QStringList>(u"GUI/RSSWidget/OpenedFolders"_qs);

5
src/base/preferences.h

@ -38,7 +38,6 @@
class QDateTime; class QDateTime;
class QNetworkCookie; class QNetworkCookie;
class QSize;
class QTime; class QTime;
namespace Scheduler namespace Scheduler
@ -353,10 +352,6 @@ public:
void setPropVisible(bool visible); void setPropVisible(bool visible);
QByteArray getPropTrackerListState() const; QByteArray getPropTrackerListState() const;
void setPropTrackerListState(const QByteArray &state); void setPropTrackerListState(const QByteArray &state);
QSize getRssGeometrySize() const;
void setRssGeometrySize(const QSize &geometry);
QByteArray getRssHSplitterSizes() const;
void setRssHSplitterSizes(const QByteArray &sizes);
QStringList getRssOpenFolders() const; QStringList getRssOpenFolders() const;
void setRssOpenFolders(const QStringList &folders); void setRssOpenFolders(const QStringList &folders);
QByteArray getRssSideSplitterState() const; QByteArray getRssSideSplitterState() const;

3
src/gui/aboutdialog.cpp

@ -112,7 +112,8 @@ AboutDialog::AboutDialog(QWidget *parent)
"The database is licensed under the Creative Commons Attribution 4.0 International License")); "The database is licensed under the Creative Commons Attribution 4.0 International License"));
m_ui->labelDBIP->setText(DBIPText); m_ui->labelDBIP->setText(DBIPText);
resize(m_storeDialogSize); if (const QSize dialogSize = m_storeDialogSize; dialogSize.isValid())
resize(dialogSize);
} }
AboutDialog::~AboutDialog() AboutDialog::~AboutDialog()

4
src/gui/addnewtorrentdialog.cpp

@ -336,7 +336,9 @@ void AddNewTorrentDialog::setSavePathHistoryLength(const int value)
void AddNewTorrentDialog::loadState() void AddNewTorrentDialog::loadState()
{ {
resize(m_storeDialogSize); if (const QSize dialogSize = m_storeDialogSize; dialogSize.isValid())
resize(dialogSize);
m_ui->splitter->restoreState(m_storeSplitterState);; m_ui->splitter->restoreState(m_storeSplitterState);;
} }

3
src/gui/banlistoptionsdialog.cpp

@ -56,7 +56,8 @@ BanListOptionsDialog::BanListOptionsDialog(QWidget *parent)
m_ui->bannedIPList->sortByColumn(0, Qt::AscendingOrder); m_ui->bannedIPList->sortByColumn(0, Qt::AscendingOrder);
m_ui->buttonBanIP->setEnabled(false); m_ui->buttonBanIP->setEnabled(false);
resize(m_storeDialogSize); if (const QSize dialogSize = m_storeDialogSize; dialogSize.isValid())
resize(dialogSize);
} }
BanListOptionsDialog::~BanListOptionsDialog() BanListOptionsDialog::~BanListOptionsDialog()

4
src/gui/cookiesdialog.cpp

@ -64,7 +64,9 @@ CookiesDialog::CookiesDialog(QWidget *parent)
m_cookiesModel->index(0, 0), m_cookiesModel->index(0, 0),
QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
resize(m_storeDialogSize); if (const QSize dialogSize = m_storeDialogSize; dialogSize.isValid())
resize(dialogSize);
m_ui->treeView->header()->restoreState(m_storeViewState); m_ui->treeView->header()->restoreState(m_storeViewState);
} }

3
src/gui/downloadfromurldialog.cpp

@ -92,7 +92,8 @@ DownloadFromURLDialog::DownloadFromURLDialog(QWidget *parent)
m_ui->textUrls->setText(text); m_ui->textUrls->setText(text);
m_ui->textUrls->moveCursor(QTextCursor::End); m_ui->textUrls->moveCursor(QTextCursor::End);
resize(m_storeDialogSize); if (const QSize dialogSize = m_storeDialogSize; dialogSize.isValid())
resize(dialogSize);
} }
DownloadFromURLDialog::~DownloadFromURLDialog() DownloadFromURLDialog::~DownloadFromURLDialog()

3
src/gui/ipsubnetwhitelistoptionsdialog.cpp

@ -60,7 +60,8 @@ IPSubnetWhitelistOptionsDialog::IPSubnetWhitelistOptionsDialog(QWidget *parent)
m_ui->whitelistedIPSubnetList->sortByColumn(0, Qt::AscendingOrder); m_ui->whitelistedIPSubnetList->sortByColumn(0, Qt::AscendingOrder);
m_ui->buttonWhitelistIPSubnet->setEnabled(false); m_ui->buttonWhitelistIPSubnet->setEnabled(false);
resize(m_storeDialogSize); if (const QSize dialogSize = m_storeDialogSize; dialogSize.isValid())
resize(dialogSize);
} }
IPSubnetWhitelistOptionsDialog::~IPSubnetWhitelistOptionsDialog() IPSubnetWhitelistOptionsDialog::~IPSubnetWhitelistOptionsDialog()

13
src/gui/optionsdialog.cpp

@ -572,10 +572,8 @@ OptionsDialog::OptionsDialog(QWidget *parent)
m_ui->tabSelection->setCurrentRow(m_storeLastViewedPage); m_ui->tabSelection->setCurrentRow(m_storeLastViewedPage);
resize(m_storeDialogSize); if (const QSize dialogSize = m_storeDialogSize; dialogSize.isValid())
resize(dialogSize);
// Have to be called after show(), because splitter width needed
loadSplitterState();
} }
void OptionsDialog::initializeLanguageCombo() void OptionsDialog::initializeLanguageCombo()
@ -646,6 +644,13 @@ void OptionsDialog::loadSplitterState()
m_ui->hsplitter->setSizes(splitterSizes); m_ui->hsplitter->setSizes(splitterSizes);
} }
void OptionsDialog::showEvent(QShowEvent *e)
{
QDialog::showEvent(e);
loadSplitterState();
}
void OptionsDialog::saveOptions() void OptionsDialog::saveOptions()
{ {
auto *pref = Preferences::instance(); auto *pref = Preferences::instance();

2
src/gui/optionsdialog.h

@ -115,6 +115,8 @@ private slots:
void webUIHttpsKeyChanged(const Path &path, ShowError showError); void webUIHttpsKeyChanged(const Path &path, ShowError showError);
private: private:
void showEvent(QShowEvent *e) override;
// Methods // Methods
void saveOptions(); void saveOptions();
void loadOptions(); void loadOptions();

9
src/gui/previewselectdialog.cpp

@ -173,13 +173,12 @@ void PreviewSelectDialog::saveWindowState()
void PreviewSelectDialog::loadWindowState() void PreviewSelectDialog::loadWindowState()
{ {
// Restore dialog size // Restore dialog size
resize(m_storeDialogSize); if (const QSize dialogSize = m_storeDialogSize; dialogSize.isValid())
resize(dialogSize);
// Restore TreeView Header state // Restore TreeView Header state
if (!m_storeTreeHeaderState.get().isEmpty()) if (const QByteArray treeHeaderState = m_storeTreeHeaderState; !treeHeaderState.isEmpty())
{ m_headerStateInitialized = m_ui->previewList->header()->restoreState(treeHeaderState);
m_headerStateInitialized = m_ui->previewList->header()->restoreState(m_storeTreeHeaderState);
}
} }
void PreviewSelectDialog::showEvent(QShowEvent *event) void PreviewSelectDialog::showEvent(QShowEvent *event)

22
src/gui/rss/automatedrssdownloader.cpp

@ -29,6 +29,7 @@
#include "automatedrssdownloader.h" #include "automatedrssdownloader.h"
#include <QtGlobal>
#include <QCursor> #include <QCursor>
#include <QFileDialog> #include <QFileDialog>
#include <QMenu> #include <QMenu>
@ -41,7 +42,6 @@
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"
#include "base/global.h" #include "base/global.h"
#include "base/path.h" #include "base/path.h"
#include "base/preferences.h"
#include "base/rss/rss_article.h" #include "base/rss/rss_article.h"
#include "base/rss/rss_autodownloader.h" #include "base/rss/rss_autodownloader.h"
#include "base/rss/rss_feed.h" #include "base/rss/rss_feed.h"
@ -65,6 +65,13 @@ AutomatedRssDownloader::AutomatedRssDownloader(QWidget *parent)
, m_formatFilterLegacy(u"%1 (*%2)"_qs.arg(tr("Rules (legacy)"), EXT_LEGACY)) , m_formatFilterLegacy(u"%1 (*%2)"_qs.arg(tr("Rules (legacy)"), EXT_LEGACY))
, m_ui(new Ui::AutomatedRssDownloader) , m_ui(new Ui::AutomatedRssDownloader)
, m_currentRuleItem(nullptr) , m_currentRuleItem(nullptr)
, m_storeDialogSize {u"RssFeedDownloader/geometrySize"_qs}
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
, m_storeHSplitterSize {u"GUI/Qt6/RSSFeedDownloader/HSplitterSizes"_qs}
#else
, m_storeHSplitterSize {u"RssFeedDownloader/qt5/hsplitterSizes"_qs}
#endif
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
// Icons // Icons
@ -160,16 +167,17 @@ AutomatedRssDownloader::~AutomatedRssDownloader()
void AutomatedRssDownloader::loadSettings() void AutomatedRssDownloader::loadSettings()
{ {
const auto *pref = Preferences::instance(); if (const QSize dialogSize = m_storeDialogSize; dialogSize.isValid())
resize(pref->getRssGeometrySize()); resize(dialogSize);
m_ui->hsplitter->restoreState(pref->getRssHSplitterSizes());
if (const QByteArray hSplitterSize = m_storeHSplitterSize; !hSplitterSize.isEmpty())
m_ui->hsplitter->restoreState(hSplitterSize);
} }
void AutomatedRssDownloader::saveSettings() void AutomatedRssDownloader::saveSettings()
{ {
Preferences *const pref = Preferences::instance(); m_storeDialogSize = size();
pref->setRssGeometrySize(size()); m_storeHSplitterSize = m_ui->hsplitter->saveState();
pref->setRssHSplitterSizes(m_ui->hsplitter->saveState());
} }
void AutomatedRssDownloader::createRuleItem(const RSS::AutoDownloadRule &rule) void AutomatedRssDownloader::createRuleItem(const RSS::AutoDownloadRule &rule)

4
src/gui/rss/automatedrssdownloader.h

@ -36,6 +36,7 @@
#include <QSet> #include <QSet>
#include "base/rss/rss_autodownloadrule.h" #include "base/rss/rss_autodownloadrule.h"
#include "base/settingvalue.h"
class QListWidgetItem; class QListWidgetItem;
class QRegularExpression; class QRegularExpression;
@ -106,4 +107,7 @@ private:
RSS::AutoDownloadRule m_currentRule; RSS::AutoDownloadRule m_currentRule;
QHash<QString, QListWidgetItem *> m_itemsByRuleName; QHash<QString, QListWidgetItem *> m_itemsByRuleName;
QRegularExpression *m_episodeRegex; QRegularExpression *m_episodeRegex;
SettingValue<QSize> m_storeDialogSize;
SettingValue<QByteArray> m_storeHSplitterSize;
}; };

3
src/gui/search/pluginselectdialog.cpp

@ -87,7 +87,8 @@ PluginSelectDialog::PluginSelectDialog(SearchPluginManager *pluginManager, QWidg
connect(m_pluginManager, &SearchPluginManager::checkForUpdatesFinished, this, &PluginSelectDialog::checkForUpdatesFinished); connect(m_pluginManager, &SearchPluginManager::checkForUpdatesFinished, this, &PluginSelectDialog::checkForUpdatesFinished);
connect(m_pluginManager, &SearchPluginManager::checkForUpdatesFailed, this, &PluginSelectDialog::checkForUpdatesFailed); connect(m_pluginManager, &SearchPluginManager::checkForUpdatesFailed, this, &PluginSelectDialog::checkForUpdatesFailed);
resize(m_storeDialogSize); if (const QSize dialogSize = m_storeDialogSize; dialogSize.isValid())
resize(dialogSize);
} }
PluginSelectDialog::~PluginSelectDialog() PluginSelectDialog::~PluginSelectDialog()

3
src/gui/search/pluginsourcedialog.cpp

@ -40,7 +40,8 @@ PluginSourceDialog::PluginSourceDialog(QWidget *parent)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
resize(m_storeDialogSize); if (const QSize dialogSize = m_storeDialogSize; dialogSize.isValid())
resize(dialogSize);
} }
PluginSourceDialog::~PluginSourceDialog() PluginSourceDialog::~PluginSourceDialog()

3
src/gui/speedlimitdialog.cpp

@ -108,7 +108,8 @@ SpeedLimitDialog::SpeedLimitDialog(QWidget *parent)
connect(m_ui->spinAltDownloadLimit, qOverload<int>(&QSpinBox::valueChanged) connect(m_ui->spinAltDownloadLimit, qOverload<int>(&QSpinBox::valueChanged)
, this, [this](const int value) { updateSliderValue(m_ui->sliderAltDownloadLimit, value); }); , this, [this](const int value) { updateSliderValue(m_ui->sliderAltDownloadLimit, value); });
resize(m_storeDialogSize); if (const QSize dialogSize = m_storeDialogSize; dialogSize.isValid())
resize(dialogSize);
} }
SpeedLimitDialog::~SpeedLimitDialog() SpeedLimitDialog::~SpeedLimitDialog()

3
src/gui/statsdialog.cpp

@ -60,7 +60,8 @@ StatsDialog::StatsDialog(QWidget *parent)
m_ui->labelCacheHits->hide(); m_ui->labelCacheHits->hide();
#endif #endif
resize(m_storeDialogSize); if (const QSize dialogSize = m_storeDialogSize; dialogSize.isValid())
resize(dialogSize);
} }
StatsDialog::~StatsDialog() StatsDialog::~StatsDialog()

3
src/gui/torrentcreatordialog.cpp

@ -340,5 +340,6 @@ void TorrentCreatorDialog::loadSettings()
m_ui->txtComment->setPlainText(m_storeComments); m_ui->txtComment->setPlainText(m_storeComments);
m_ui->lineEditSource->setText(m_storeSource); m_ui->lineEditSource->setText(m_storeSource);
resize(m_storeDialogSize); if (const QSize dialogSize = m_storeDialogSize; dialogSize.isValid())
resize(dialogSize);
} }

3
src/gui/torrentoptionsdialog.cpp

@ -390,7 +390,8 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor
connect(m_ui->buttonGroup, &QButtonGroup::idClicked, this, &TorrentOptionsDialog::handleRatioTypeChanged); connect(m_ui->buttonGroup, &QButtonGroup::idClicked, this, &TorrentOptionsDialog::handleRatioTypeChanged);
resize(m_storeDialogSize); if (const QSize dialogSize = m_storeDialogSize; dialogSize.isValid())
resize(dialogSize);
} }
TorrentOptionsDialog::~TorrentOptionsDialog() TorrentOptionsDialog::~TorrentOptionsDialog()

3
src/gui/trackerentriesdialog.cpp

@ -110,5 +110,6 @@ void TrackerEntriesDialog::saveSettings()
void TrackerEntriesDialog::loadSettings() void TrackerEntriesDialog::loadSettings()
{ {
resize(m_storeDialogSize); if (const QSize dialogSize = m_storeDialogSize; dialogSize.isValid())
resize(dialogSize);
} }

3
src/gui/watchedfolderoptionsdialog.cpp

@ -125,7 +125,8 @@ TorrentFilesWatcher::WatchedFolderOptions WatchedFolderOptionsDialog::watchedFol
void WatchedFolderOptionsDialog::loadState() void WatchedFolderOptionsDialog::loadState()
{ {
resize(m_storeDialogSize); if (const QSize dialogSize = m_storeDialogSize; dialogSize.isValid())
resize(dialogSize);
} }
void WatchedFolderOptionsDialog::saveState() void WatchedFolderOptionsDialog::saveState()

Loading…
Cancel
Save