Skip to content

Commit

Permalink
Hi-DPI Support - Compare Pane
Browse files Browse the repository at this point in the history
.. can't quite sort the color button and checkbox sizing in the
   table view, might be a QT bug.
  • Loading branch information
liversedge committed Mar 12, 2017
1 parent d0df811 commit 2c56835
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
13 changes: 7 additions & 6 deletions src/Gui/ColorButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

#include "ColorButton.h"
#include "Colors.h"

#include <QPainter>
#include <QColorDialog>
Expand All @@ -33,21 +34,21 @@ ColorButton::setColor(QColor ncolor)
{
color = ncolor;

QPixmap pix(24, 24);
QPixmap pix(24*dpiXFactor, 24*dpiYFactor);
QPainter painter(&pix);
if (color.isValid()) {
painter.setPen(Qt::gray);
painter.setBrush(QBrush(color));
painter.drawRect(0, 0, 24, 24);
painter.drawRect(0, 0, 24*dpiXFactor, 24*dpiYFactor);
}
QIcon icon;
icon.addPixmap(pix);
setIcon(icon);
setContentsMargins(2,2,2,2);
setContentsMargins(2*dpiXFactor,2*dpiYFactor,2*dpiXFactor,2*dpiYFactor);
setFlat(true);
setFixedWidth(34);
setMinimumWidth(34);
setMaximumWidth(34);
setFixedWidth(34 * dpiXFactor);
setMinimumWidth(34 *dpiXFactor);
setMaximumWidth(34 *dpiXFactor);
}

void
Expand Down
6 changes: 4 additions & 2 deletions src/Gui/ComparePane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ ComparePane::refreshTable()
// Checkbox
QCheckBox *check = new QCheckBox(this);
check->setChecked(x.checked);
check->setFixedHeight(23 * dpiYFactor);
if (!counter) check->setEnabled(false);
table->setCellWidget(counter, 0, check);
connect(check, SIGNAL(stateChanged(int)), this, SLOT(intervalButtonsChanged()));
Expand Down Expand Up @@ -314,7 +315,7 @@ ComparePane::refreshTable()
for (int i=3; i<(worklist.count()+5); i++)
table->item(counter,i)->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter);

table->setRowHeight(counter, 23);
table->setRowHeight(counter, 23 *dpiYFactor);
counter++;
}

Expand Down Expand Up @@ -414,6 +415,7 @@ ComparePane::refreshTable()
// Checkbox
QCheckBox *check = new QCheckBox(this);
check->setChecked(x.checked);
check->setFixedHeight(23 * dpiYFactor);
if (!counter) check->setEnabled(false);
table->setCellWidget(counter, 0, check);
connect(check, SIGNAL(stateChanged(int)), this, SLOT(daterangeButtonsChanged()));
Expand Down Expand Up @@ -470,7 +472,7 @@ ComparePane::refreshTable()
for (int i=3; i<(worklist.count()+5); i++)
table->item(counter,i)->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter);

table->setRowHeight(counter, 23);
table->setRowHeight(counter, 23 *dpiYFactor);
counter++;
}

Expand Down
8 changes: 4 additions & 4 deletions src/Gui/TabView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

TabView::TabView(Context *context, int type) :
QWidget(context->tab), context(context), type(type),
_sidebar(true), _tiled(false), _selected(false), lastHeight(130), sidewidth(0),
_sidebar(true), _tiled(false), _selected(false), lastHeight(130*dpiYFactor), sidewidth(0),
active(false), bottomRequested(false), bottomHideOnIdle(false),
stack(NULL), splitter(NULL), mainSplitter(NULL),
sidebar_(NULL), bottom_(NULL), page_(NULL), blank_(NULL)
Expand All @@ -47,8 +47,8 @@ TabView::TabView(Context *context, int type) :
stack = new QStackedWidget(this);
stack->setContentsMargins(0,0,0,0);
stack->setFrameStyle(QFrame::Plain | QFrame::NoFrame);
stack->setMinimumWidth(500);
stack->setMinimumHeight(500);
stack->setMinimumWidth(500*dpiXFactor);
stack->setMinimumHeight(500*dpiYFactor);

layout->addWidget(stack);

Expand All @@ -66,7 +66,7 @@ TabView::TabView(Context *context, int type) :
else if (type == VIEW_TRAIN) heading = tr("Intensity Adjustments and Workout Control");

mainSplitter = new ViewSplitter(Qt::Vertical, heading, this);
mainSplitter->setHandleWidth(23);
mainSplitter->setHandleWidth(23 *dpiXFactor);
mainSplitter->setFrameStyle(QFrame::NoFrame);
mainSplitter->setContentsMargins(0, 0, 0, 0); // attempting to follow some UI guides
mainSplitter->setOpaqueResize(true); // redraw when released, snappier UI
Expand Down
7 changes: 4 additions & 3 deletions src/Gui/TabView.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <QStackedWidget>

#include "HomeWindow.h"
#include "Colors.h"
#include "GcSideBarItem.h"
#include "GcWindowRegistry.h"

Expand Down Expand Up @@ -176,13 +177,13 @@ class ViewSplitter : public QSplitter
}
return new GcSplitterHandle(name, orientation, NULL, newclear(), newtoggle(), this);
}
int handleWidth() { return 23; };
int handleWidth() { return 23 *dpiXFactor; };

QPushButton *newclear() {
if (clearbutton) delete clearbutton; // we only need one!
clearbutton = new QPushButton(tr("Clear"), this);
// clearbutton->setFixedWidth(60); // no fixed length to allow translation
clearbutton->setFixedHeight(20);
clearbutton->setFixedHeight(20 *dpiYFactor);
clearbutton->setFocusPolicy(Qt::NoFocus);
connect(clearbutton, SIGNAL(clicked()), this, SLOT(clearClicked()));

Expand All @@ -195,7 +196,7 @@ class ViewSplitter : public QSplitter
toggle->setCheckable(true);
toggle->setChecked(false);
// toggle->setFixedWidth(40); // no fixed length to allow translation
toggle->setFixedHeight(20);
toggle->setFixedHeight(20 *dpiYFactor);
toggle->setFocusPolicy(Qt::NoFocus);
connect(toggle, SIGNAL(clicked()), this, SLOT(toggled()));

Expand Down

0 comments on commit 2c56835

Please sign in to comment.