mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Fix optionsdlg position
This commit is contained in:
parent
46abe42a54
commit
933f9f1451
@ -1139,16 +1139,6 @@ void Preferences::setPrefSize(const QSize &size)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QPoint Preferences::getPrefPos() const
|
|
||||||
{
|
|
||||||
return value("Preferences/State/pos").toPoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Preferences::setPrefPos(const QPoint &pos)
|
|
||||||
{
|
|
||||||
setValue("Preferences/State/pos", pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList Preferences::getPrefHSplitterSizes() const
|
QStringList Preferences::getPrefHSplitterSizes() const
|
||||||
{
|
{
|
||||||
return value("Preferences/State/hSplitterSizes").toStringList();
|
return value("Preferences/State/hSplitterSizes").toStringList();
|
||||||
|
@ -278,8 +278,6 @@ public:
|
|||||||
QSize getPrefSize(const QSize &defaultSize) const;
|
QSize getPrefSize(const QSize &defaultSize) const;
|
||||||
void setPrefSize(const QSize &size);
|
void setPrefSize(const QSize &size);
|
||||||
#endif
|
#endif
|
||||||
QPoint getPrefPos() const;
|
|
||||||
void setPrefPos(const QPoint &pos);
|
|
||||||
QStringList getPrefHSplitterSizes() const;
|
QStringList getPrefHSplitterSizes() const;
|
||||||
void setPrefHSplitterSizes(const QStringList &sizes);
|
void setPrefHSplitterSizes(const QStringList &sizes);
|
||||||
QByteArray getPeerListState() const;
|
QByteArray getPeerListState() const;
|
||||||
|
@ -357,7 +357,6 @@ OptionsDialog::OptionsDialog(QWidget *parent)
|
|||||||
m_ui->advPageLayout->addWidget(advancedSettings);
|
m_ui->advPageLayout->addWidget(advancedSettings);
|
||||||
connect(advancedSettings, SIGNAL(settingsChanged()), this, SLOT(enableApplyButton()));
|
connect(advancedSettings, SIGNAL(settingsChanged()), this, SLOT(enableApplyButton()));
|
||||||
|
|
||||||
// Adapt size
|
|
||||||
show();
|
show();
|
||||||
loadWindowState();
|
loadWindowState();
|
||||||
}
|
}
|
||||||
@ -404,14 +403,9 @@ void OptionsDialog::changePage(QListWidgetItem *current, QListWidgetItem *previo
|
|||||||
void OptionsDialog::loadWindowState()
|
void OptionsDialog::loadWindowState()
|
||||||
{
|
{
|
||||||
const Preferences* const pref = Preferences::instance();
|
const Preferences* const pref = Preferences::instance();
|
||||||
resize(pref->getPrefSize(sizeFittingScreen()));
|
|
||||||
QPoint p = pref->getPrefPos();
|
resize(pref->getPrefSize(this->size()));
|
||||||
QRect scr_rect = qApp->desktop()->screenGeometry();
|
|
||||||
if (!p.isNull() && scr_rect.contains(p))
|
|
||||||
move(p);
|
|
||||||
// Load slider size
|
|
||||||
const QStringList sizes_str = pref->getPrefHSplitterSizes();
|
const QStringList sizes_str = pref->getPrefHSplitterSizes();
|
||||||
// Splitter size
|
|
||||||
QList<int> sizes;
|
QList<int> sizes;
|
||||||
if (sizes_str.size() == 2) {
|
if (sizes_str.size() == 2) {
|
||||||
sizes << sizes_str.first().toInt();
|
sizes << sizes_str.first().toInt();
|
||||||
@ -427,8 +421,10 @@ void OptionsDialog::loadWindowState()
|
|||||||
void OptionsDialog::saveWindowState() const
|
void OptionsDialog::saveWindowState() const
|
||||||
{
|
{
|
||||||
Preferences* const pref = Preferences::instance();
|
Preferences* const pref = Preferences::instance();
|
||||||
|
|
||||||
|
// window size
|
||||||
pref->setPrefSize(size());
|
pref->setPrefSize(size());
|
||||||
pref->setPrefPos(pos());
|
|
||||||
// Splitter size
|
// Splitter size
|
||||||
QStringList sizes_str;
|
QStringList sizes_str;
|
||||||
sizes_str << QString::number(m_ui->hsplitter->sizes().first());
|
sizes_str << QString::number(m_ui->hsplitter->sizes().first());
|
||||||
@ -436,25 +432,6 @@ void OptionsDialog::saveWindowState() const
|
|||||||
pref->setPrefHSplitterSizes(sizes_str);
|
pref->setPrefHSplitterSizes(sizes_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize OptionsDialog::sizeFittingScreen() const
|
|
||||||
{
|
|
||||||
int scrn = 0;
|
|
||||||
QWidget *w = this->topLevelWidget();
|
|
||||||
|
|
||||||
if (w)
|
|
||||||
scrn = QApplication::desktop()->screenNumber(w);
|
|
||||||
else if (QApplication::desktop()->isVirtualDesktop())
|
|
||||||
scrn = QApplication::desktop()->screenNumber(QCursor::pos());
|
|
||||||
else
|
|
||||||
scrn = QApplication::desktop()->screenNumber(this);
|
|
||||||
|
|
||||||
QRect desk(QApplication::desktop()->availableGeometry(scrn));
|
|
||||||
if (width() > desk.width() || height() > desk.height())
|
|
||||||
if (desk.width() > 0 && desk.height() > 0)
|
|
||||||
return QSize(desk.width(), desk.height());
|
|
||||||
return size();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OptionsDialog::saveOptions()
|
void OptionsDialog::saveOptions()
|
||||||
{
|
{
|
||||||
applyButton->setEnabled(false);
|
applyButton->setEnabled(false);
|
||||||
|
@ -170,7 +170,6 @@ private:
|
|||||||
quint16 webUiPort() const;
|
quint16 webUiPort() const;
|
||||||
QString webUiUsername() const;
|
QString webUiUsername() const;
|
||||||
QString webUiPassword() const;
|
QString webUiPassword() const;
|
||||||
QSize sizeFittingScreen() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool setSslKey(const QByteArray &key);
|
bool setSslKey(const QByteArray &key);
|
||||||
|
Loading…
Reference in New Issue
Block a user