Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resize all dialogs relative to user's screen size #104

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/gui_impl/commands/help_gui_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "ui_about_dialog.h"

#include <QMessageBox>

#include <QDesktopWidget>

namespace sigviewer
{
Expand Down Expand Up @@ -48,7 +48,12 @@ void HelpGuiCommand::showAboutDialog ()
ui.aboutLabel->setText(ui.aboutLabel->text().replace(QString("VERSION_MAJOR"), QString::number(VERSION_MAJOR))
.replace(QString("VERSION_MINOR"), QString::number(VERSION_MINOR))
.replace(QString("VERSION_BUILD"), QString::number(VERSION_BUILD)));
dialog_->setFixedSize(dialog_->minimumSizeHint());

QDesktopWidget dw;
int x=dw.width()*0.2;
int y=dw.height()*0.2;
dialog_->setFixedSize(x,y);

dialog_->show();
}

Expand Down
11 changes: 9 additions & 2 deletions src/gui_impl/dialogs/basic_header_info_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <QSettings>
#include <QFileInfo>
#include <QtXml>
#include <QDesktopWidget>

namespace sigviewer
{
Expand All @@ -42,8 +43,14 @@ BasicHeaderInfoDialog::BasicHeaderInfoDialog(QSharedPointer<BasicHeader> header,
button_layout->addWidget(toggle_button_);
button_layout->addWidget(close_button_);
button_layout->addStretch(1);

QDesktopWidget dw;
int x=dw.width()*0.45;
int y=dw.height()*0.8;
resize(x,y);

buildTree();
resize(850, 850);

top_layout->activate();
readSettings();
connect(close_button_, SIGNAL(clicked()), this, SLOT(closeInfoDialog()));
Expand Down Expand Up @@ -121,7 +128,7 @@ void BasicHeaderInfoDialog::buildTree()
info_tree_widget_->setHeaderLabels(header_labels);

info_tree_widget_->header()->setSectionResizeMode(QHeaderView::Interactive);
info_tree_widget_->setColumnWidth(0, width() * 0.65);
info_tree_widget_->setColumnWidth(0, width() * 0.5);
info_tree_widget_->setAnimated(true);

QTreeWidgetItem* root_item;
Expand Down
10 changes: 8 additions & 2 deletions src/gui_impl/dialogs/channel_selection_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "application_context_impl.h"

#include <QColorDialog>

#include <QDesktopWidget>

namespace sigviewer
{
Expand All @@ -34,7 +34,13 @@ ChannelSelectionDialog::ChannelSelectionDialog(ChannelManager const& channel_man
headerLabels << tr("Channel") << tr("Color");
ui_.treeWidget->setHeaderLabels(headerLabels);
ui_.treeWidget->setColumnCount(2);
ui_.treeWidget->header()->resizeSection(0, width() * 0.6);

QDesktopWidget dw;
int x=dw.width()*0.35;
int y=dw.height()*0.7;
resize(x,y);

ui_.treeWidget->header()->resizeSection(0, width() * 0.4);
ui_.treeWidget->setAnimated(true);

if (ApplicationContextImpl::getInstance()->getCurrentFileContext()->getFileName().endsWith("XDF", Qt::CaseInsensitive))
Expand Down
6 changes: 6 additions & 0 deletions src/gui_impl/dialogs/event_time_selection_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "file_handling/event_manager.h"

#include <QPushButton>
#include <QDesktopWidget>
#include <limits>

namespace sigviewer
Expand All @@ -24,6 +25,11 @@ EventTimeSelectionDialog::EventTimeSelectionDialog (std::set<EventType> const& s
{
ui_.setupUi (this);

QDesktopWidget dw;
int x=dw.width()*0.3;
int y=dw.height()*0.6;
resize(x,y);

foreach (ChannelID channel_id, shown_channels)
{
QListWidgetItem* item = new QListWidgetItem (channel_manager.getChannelLabel(channel_id), ui_.list_widget_);
Expand Down
6 changes: 6 additions & 0 deletions src/gui_impl/dialogs/event_types_selection_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <QColorDialog>
#include <QInputDialog>
#include <QDesktopWidget>

#define max(a,b) ((a) > (b) ? (a) : (b))

Expand Down Expand Up @@ -39,6 +40,11 @@ void EventTypesSelectionDialog::buildTree (bool only_existing_events)
ui_.tree_widget_->setHeaderLabels (header_labels);
ui_.tree_widget_->setColumnWidth(ID_COLUMN_INDEX_, 0);

QDesktopWidget dw;
int x=dw.width()*0.35;
int y=dw.height()*0.7;
resize(x,y);

ui_.tree_widget_->header()->setSectionResizeMode (QHeaderView::Interactive);
ui_.tree_widget_->header()->resizeSection (NAME_COLUMN_INDEX_, width() * 0.6);
ui_.tree_widget_->header()->resizeSection (COLOR_COLUMN_INDEX_, width() * 0.18);
Expand Down
10 changes: 9 additions & 1 deletion src/gui_impl/dialogs/resampling_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "ui_resampling_dialog.h"
#include "file_handling_impl/xdf_reader.h"

#include <QDesktopWidget>

namespace sigviewer {

ResamplingDialog::ResamplingDialog(QWidget *parent) :
Expand All @@ -23,6 +25,12 @@ ResamplingDialog::ResamplingDialog(int nativeSrate, int highestSampleRate, QWidg
ui->setupUi(this);
this->setWindowTitle("Resampling");

QDesktopWidget dw;
int x=dw.width()*0.35;
int y=dw.height()*0.6;
resize(x,y);


if (XDFdata->sampleRateMap.size() > 1)
{
QString text = "This file contains signals of multiple sample rates.<br> "
Expand All @@ -42,7 +50,7 @@ ResamplingDialog::ResamplingDialog(int nativeSrate, int highestSampleRate, QWidg
ui->label->setText(text);
}
ui->treeWidget->setColumnCount(2);
ui->treeWidget->setColumnWidth(0, this->width()/2.15);
ui->treeWidget->setColumnWidth(0, this->width() * 0.48);
ui->treeWidget->setAnimated(true);
QStringList headers;
headers << "Stream" << "Info";
Expand Down
6 changes: 6 additions & 0 deletions src/gui_impl/dialogs/scale_channel_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <QDebug>
#include <QSettings>
#include <QDesktopWidget>

#include <limits>

Expand All @@ -25,6 +26,11 @@ ScaleChannelDialog::ScaleChannelDialog (ChannelID preselected_channel,
{
ui_.setupUi (this);

QDesktopWidget dw;
int x=dw.width()*0.22;
int y=dw.height()*0.22;
resize(x,y);

if (selected_channel_ == UNDEFINED_CHANNEL)
setWindowTitle (tr("Scale All Channels"));
else
Expand Down
7 changes: 6 additions & 1 deletion src/gui_impl/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <QLabel>
#include <QSettings>
#include <QMimeData>
#include <QDesktopWidget>

namespace sigviewer
{
Expand All @@ -29,8 +30,12 @@ MainWindow::MainWindow(QSharedPointer<ApplicationContext> application_context)
initMenus(application_context);
setUnifiedTitleAndToolBarOnMac (true);

QDesktopWidget dw;
int x=dw.width()*0.7;
int y=dw.height()*0.7;

QSettings settings;
resize(settings.value("MainWindow/size", QSize(1200, 800)).toSize());
resize(settings.value("MainWindow/size", QSize(x, y)).toSize());
setMinimumSize(900, 800);
restoreGeometry(settings.value("geometry").toByteArray()); //restore geometry and window state (full screen etc.)
restoreState(settings.value("windowState").toByteArray());
Expand Down