Add QScrollArea to configdialog and resize to max_screen

This commit is contained in:
Simon De Backer
2020-07-22 21:03:54 +02:00
parent 03425bcb5b
commit 6b95c6bf6f

View File

@@ -15,6 +15,7 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QScrollArea>
#include "configdialog.h"
#include "configpages.h"
#include "qetapp.h"
@@ -27,6 +28,11 @@
*/
ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent) {
Machine_info *mymachineinfo= new Machine_info(this);
//ScrollArea for low screens
QScrollArea *scroll = new QScrollArea(this);
scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
// liste des pages
pages_list = new QListWidget();
pages_list -> setViewMode(QListView::IconMode);
@@ -43,24 +49,39 @@ ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent) {
// pages
pages_widget = new QStackedWidget();
// boutons
buttons = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
buttons = new QDialogButtonBox(
QDialogButtonBox::Ok
|QDialogButtonBox::Cancel);
QWidget *viewport = new QWidget(this);
scroll->setWidget(viewport);
scroll->setWidgetResizable(true);
// layouts
QHBoxLayout *hlayout1 = new QHBoxLayout();
QHBoxLayout *hlayout1 = new QHBoxLayout(viewport);
// add needed widgets to layout "hlayout1"
hlayout1 -> addWidget(pages_list);
hlayout1 -> addWidget(pages_widget);
QVBoxLayout *vlayout1 = new QVBoxLayout();
vlayout1 -> addLayout(hlayout1);
vlayout1 -> addWidget(buttons);
setLayout(vlayout1);
//add hlayout1 to widget
viewport->setLayout(hlayout1);
// Add a layout for QDialog
QVBoxLayout *dialog_layout = new QVBoxLayout(this);
dialog_layout->addWidget(scroll); // add scroll to the QDialog's layout
dialog_layout -> addWidget(buttons);
setLayout(dialog_layout);
// connexion signaux / slots
connect(buttons, SIGNAL(accepted()), this, SLOT(applyConf()));
connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
connect(pages_list, SIGNAL(currentRowChanged(int)), pages_widget, SLOT(setCurrentIndex(int)));
connect(pages_list, SIGNAL(currentRowChanged(int)),
pages_widget, SLOT(setCurrentIndex(int)));
resize(mymachineinfo->get_max_screen_width(),
mymachineinfo->get_max_screen_height());
#ifdef Q_OS_MACOS
if (parent) {