diff --git a/sources/configdialog.cpp b/sources/configdialog.cpp index 12f6f0ea9..d890548ba 100644 --- a/sources/configdialog.cpp +++ b/sources/configdialog.cpp @@ -15,46 +15,74 @@ You should have received a copy of the GNU General Public License along with QElectroTech. If not, see . */ +#include #include "configdialog.h" #include "configpages.h" #include "qetapp.h" +#include "machine_info.h" + /** Constructeur @param parent QWidget parent */ 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); - pages_list -> setIconSize(QSize(128, 128)); + if(mymachineinfo->i_max_screen_height()<1000){ + pages_list -> setIconSize(QSize(64, 64)); + } else { + pages_list -> setIconSize(QSize(128, 128)); + } pages_list -> setMovement(QListView::Static); - pages_list -> setMinimumWidth(168); - pages_list -> setMaximumWidth(168); - pages_list -> setSpacing(16); - pages_list -> setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - + pages_list -> setMinimumWidth(168); + pages_list -> setMaximumWidth(168); + pages_list -> setSpacing(16); + pages_list -> setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + // 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->i_max_screen_width(), + mymachineinfo->i_max_screen_height()); + #ifdef Q_OS_MACOS if (parent) { setWindowFlags(Qt::Sheet); diff --git a/sources/machine_info.cpp b/sources/machine_info.cpp new file mode 100644 index 000000000..14de9d386 --- /dev/null +++ b/sources/machine_info.cpp @@ -0,0 +1,85 @@ +/* + Copyright 2006-2020 The QElectroTech Team + This file is part of QElectroTech. + + QElectroTech is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + QElectroTech is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QElectroTech. If not, see . +*/ +#include "machine_info.h" +#include +#include + +/** + @brief Machine_info::Machine_info + @param parent +*/ +Machine_info::Machine_info(QObject *parent) : QObject(parent) +{ + init_get_Screen_info(); +} + +/** + @brief Machine_info::init_get_Screen_info + Finds the largest screen and saves the values +*/ +void Machine_info::init_get_Screen_info() +{ + const auto screens = qApp->screens(); + for (int ii = 0; ii < screens.count(); ++ii) + { + if( + Max_screen_width + < + screens[ii]->geometry().width() + * + screens[ii]->devicePixelRatio() + ) + { + Max_screen_width = + screens[ii]->geometry().width() + * + screens[ii]->devicePixelRatio(); + } + if( + Max_screen_height + < + screens[ii]->geometry().height() + * + screens[ii]->devicePixelRatio() + ) + { + Max_screen_height = + screens[ii]->geometry().height() + * + screens[ii]->devicePixelRatio(); + } + } +} + +/** + @brief Machine_info::get_max_screen_width + @return max screen width + */ +int32_t Machine_info::get_max_screen_width() +{ + return Max_screen_width; +} + +/** + @brief Machine_info::get_max_screen_height + @return max screen height +*/ +int32_t Machine_info::get_max_screen_height() +{ + return Max_screen_height; +} diff --git a/sources/machine_info.h b/sources/machine_info.h new file mode 100644 index 000000000..86c89183a --- /dev/null +++ b/sources/machine_info.h @@ -0,0 +1,45 @@ +/* + Copyright 2006-2020 The QElectroTech Team + This file is part of QElectroTech. + + QElectroTech is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + QElectroTech is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QElectroTech. If not, see . +*/ +#ifndef MACHINE_INFO_H +#define MACHINE_INFO_H + +#include + +/** + @brief The Machine_info class + This class hold information from your PC. +*/ +class Machine_info : public QObject +{ + Q_OBJECT +public: + explicit Machine_info(QObject *parent = nullptr); + int32_t i_max_screen_width(); + int32_t i_max_screen_height(); + +signals: + +private: + void init_get_Screen_info(); + int32_t Max_screen_width; + int32_t Max_screen_height; + + +}; + +#endif // MACHINE_INFO_H