Browse Source

Fix optionsdlg position

adaptive-webui-19844
Chocobo1 9 years ago
parent
commit
933f9f1451
  1. 10
      src/base/preferences.cpp
  2. 2
      src/base/preferences.h
  3. 33
      src/gui/optionsdlg.cpp
  4. 1
      src/gui/optionsdlg.h

10
src/base/preferences.cpp

@ -1139,16 +1139,6 @@ void Preferences::setPrefSize(const QSize &size) @@ -1139,16 +1139,6 @@ void Preferences::setPrefSize(const QSize &size)
}
#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
{
return value("Preferences/State/hSplitterSizes").toStringList();

2
src/base/preferences.h

@ -278,8 +278,6 @@ public: @@ -278,8 +278,6 @@ public:
QSize getPrefSize(const QSize &defaultSize) const;
void setPrefSize(const QSize &size);
#endif
QPoint getPrefPos() const;
void setPrefPos(const QPoint &pos);
QStringList getPrefHSplitterSizes() const;
void setPrefHSplitterSizes(const QStringList &sizes);
QByteArray getPeerListState() const;

33
src/gui/optionsdlg.cpp

@ -357,7 +357,6 @@ OptionsDialog::OptionsDialog(QWidget *parent) @@ -357,7 +357,6 @@ OptionsDialog::OptionsDialog(QWidget *parent)
m_ui->advPageLayout->addWidget(advancedSettings);
connect(advancedSettings, SIGNAL(settingsChanged()), this, SLOT(enableApplyButton()));
// Adapt size
show();
loadWindowState();
}
@ -404,14 +403,9 @@ void OptionsDialog::changePage(QListWidgetItem *current, QListWidgetItem *previo @@ -404,14 +403,9 @@ void OptionsDialog::changePage(QListWidgetItem *current, QListWidgetItem *previo
void OptionsDialog::loadWindowState()
{
const Preferences* const pref = Preferences::instance();
resize(pref->getPrefSize(sizeFittingScreen()));
QPoint p = pref->getPrefPos();
QRect scr_rect = qApp->desktop()->screenGeometry();
if (!p.isNull() && scr_rect.contains(p))
move(p);
// Load slider size
resize(pref->getPrefSize(this->size()));
const QStringList sizes_str = pref->getPrefHSplitterSizes();
// Splitter size
QList<int> sizes;
if (sizes_str.size() == 2) {
sizes << sizes_str.first().toInt();
@ -427,8 +421,10 @@ void OptionsDialog::loadWindowState() @@ -427,8 +421,10 @@ void OptionsDialog::loadWindowState()
void OptionsDialog::saveWindowState() const
{
Preferences* const pref = Preferences::instance();
// window size
pref->setPrefSize(size());
pref->setPrefPos(pos());
// Splitter size
QStringList sizes_str;
sizes_str << QString::number(m_ui->hsplitter->sizes().first());
@ -436,25 +432,6 @@ void OptionsDialog::saveWindowState() const @@ -436,25 +432,6 @@ void OptionsDialog::saveWindowState() const
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()
{
applyButton->setEnabled(false);

1
src/gui/optionsdlg.h

@ -170,7 +170,6 @@ private: @@ -170,7 +170,6 @@ private:
quint16 webUiPort() const;
QString webUiUsername() const;
QString webUiPassword() const;
QSize sizeFittingScreen() const;
private:
bool setSslKey(const QByteArray &key);

Loading…
Cancel
Save