mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-17 20:09:50 +01:00
Put each settings page in a scroll area, and resize the settings dialog to fit on the user's screen if it's too big. Fixes issue 953.
This commit is contained in:
parent
dad76b78dd
commit
4b1e2f08e9
@ -26,6 +26,7 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "settingsdialog.h"
|
#include "settingsdialog.h"
|
||||||
#include "core/backgroundstreams.h"
|
#include "core/backgroundstreams.h"
|
||||||
|
#include "core/logging.h"
|
||||||
#include "core/networkproxyfactory.h"
|
#include "core/networkproxyfactory.h"
|
||||||
#include "engines/enginebase.h"
|
#include "engines/enginebase.h"
|
||||||
#include "engines/gstengine.h"
|
#include "engines/gstengine.h"
|
||||||
@ -56,7 +57,9 @@
|
|||||||
# include "internet/spotifysettingspage.h"
|
# include "internet/spotifysettingspage.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <QDesktopWidget>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QScrollArea>
|
||||||
|
|
||||||
|
|
||||||
SettingsDialog::SettingsDialog(BackgroundStreams* streams, QWidget* parent)
|
SettingsDialog::SettingsDialog(BackgroundStreams* streams, QWidget* parent)
|
||||||
@ -129,17 +132,26 @@ void SettingsDialog::AddPage(Page id, SettingsPage* page) {
|
|||||||
item->setFlags(Qt::NoItemFlags);
|
item->setFlags(Qt::NoItemFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create a scroll area containing the page
|
||||||
|
QScrollArea* area = new QScrollArea;
|
||||||
|
area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
area->setWidget(page);
|
||||||
|
area->setWidgetResizable(true);
|
||||||
|
area->setFrameShape(QFrame::NoFrame);
|
||||||
|
|
||||||
// Add the page to the stack
|
// Add the page to the stack
|
||||||
ui_->stacked_widget->addWidget(page);
|
ui_->stacked_widget->addWidget(area);
|
||||||
|
|
||||||
// Remember where the page is
|
// Remember where the page is
|
||||||
PageData data;
|
PageData data;
|
||||||
data.index_ = ui_->list->row(item);
|
data.index_ = ui_->list->row(item);
|
||||||
|
data.scroll_area_ = area;
|
||||||
data.page_ = page;
|
data.page_ = page;
|
||||||
pages_[id] = data;
|
pages_[id] = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::accept() {
|
void SettingsDialog::accept() {
|
||||||
|
// Save settings
|
||||||
foreach (const PageData& data, pages_.values()) {
|
foreach (const PageData& data, pages_.values()) {
|
||||||
data.page_->Save();
|
data.page_->Save();
|
||||||
}
|
}
|
||||||
@ -148,12 +160,19 @@ void SettingsDialog::accept() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::showEvent(QShowEvent* e) {
|
void SettingsDialog::showEvent(QShowEvent* e) {
|
||||||
|
// Load settings
|
||||||
loading_settings_ = true;
|
loading_settings_ = true;
|
||||||
foreach (const PageData& data, pages_.values()) {
|
foreach (const PageData& data, pages_.values()) {
|
||||||
data.page_->Load();
|
data.page_->Load();
|
||||||
}
|
}
|
||||||
loading_settings_ = false;
|
loading_settings_ = false;
|
||||||
|
|
||||||
|
// Resize the dialog if it's too big
|
||||||
|
const QSize available = QApplication::desktop()->availableGeometry(this).size();
|
||||||
|
if (available.height() < height()) {
|
||||||
|
resize(width(), sizeHint().height());
|
||||||
|
}
|
||||||
|
|
||||||
QDialog::showEvent(e);
|
QDialog::showEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "widgets/osd.h"
|
#include "widgets/osd.h"
|
||||||
|
|
||||||
|
class QScrollArea;
|
||||||
|
|
||||||
class BackgroundStreams;
|
class BackgroundStreams;
|
||||||
class GlobalShortcuts;
|
class GlobalShortcuts;
|
||||||
class LibraryDirectoryModel;
|
class LibraryDirectoryModel;
|
||||||
@ -88,6 +90,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
struct PageData {
|
struct PageData {
|
||||||
int index_;
|
int index_;
|
||||||
|
QScrollArea* scroll_area_;
|
||||||
SettingsPage* page_;
|
SettingsPage* page_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user