Skip to content
Snippets Groups Projects
Commit 0a2a0311 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

Position of progress bar under Mac is different than in linux.

parent 7f4cf2b0
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include <QApplication> #include <QApplication>
#include <QWidget> #include <QWidget>
#include <QMouseEvent> #include <QMouseEvent>
#include <QStyleOptionProgressBarV2>
#include "hostosinfo.h"
JobListViewDelegate::JobListViewDelegate(QWidget *parent) JobListViewDelegate::JobListViewDelegate(QWidget *parent)
: QItemDelegate(parent) : QItemDelegate(parent)
...@@ -35,18 +37,19 @@ void JobListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o ...@@ -35,18 +37,19 @@ void JobListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
QString text = item->getName(); QString text = item->getName();
QRect textRect = getTextRect(option.rect); QRect textRect = getTextRect(option.rect);
textRect.setHeight( 30); //textRect.setHeight( 10);
painter->drawText(textRect,text); painter->drawText(textRect,text);
QStyleOptionProgressBar progressBarOption; QStyleOptionProgressBar progressBarOption;
progressBarOption.state = QStyle::State_Enabled; progressBarOption.state = QStyle::State_Enabled;
progressBarOption.direction = QApplication::layoutDirection(); progressBarOption.direction = QApplication::layoutDirection();
progressBarOption.rect = getProgressBarRect(option.rect); progressBarOption.rect = getProgressBarRect(option.rect);
progressBarOption.fontMetrics = QApplication::fontMetrics(); //progressBarOption.rect = option.rect;
//progressBarOption.fontMetrics = QApplication::fontMetrics();
progressBarOption.minimum = 0; progressBarOption.minimum = 0;
progressBarOption.maximum = 100; progressBarOption.maximum = 100;
progressBarOption.textAlignment = Qt::AlignCenter; //progressBarOption.textAlignment = Qt::AlignCenter;
progressBarOption.textVisible = true; progressBarOption.textVisible = false;
// Set the progress and text values of the style option. // Set the progress and text values of the style option.
int progress = item->getProgress(); int progress = item->getProgress();
...@@ -127,6 +130,12 @@ QRect JobListViewDelegate::getProgressBarRect(QRect optionRect) const ...@@ -127,6 +130,12 @@ QRect JobListViewDelegate::getProgressBarRect(QRect optionRect) const
int height = optionRect.height()*0.6; int height = optionRect.height()*0.6;
int x = optionRect.x() + optionRect.width()*0.5; int x = optionRect.x() + optionRect.width()*0.5;
int y = optionRect.y() + (optionRect.height() - height)/2.; int y = optionRect.y() + (optionRect.height() - height)/2.;
if( Utils::HostOsInfo::isMacHost() ) {
// for Mac the height of progress bar can't be made smaller
y = optionRect.y();
height = optionRect.height()*0.5;
}
QRect result(x,y,width,height); QRect result(x,y,width,height);
return result; return result;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment