Skip to content

Commit

Permalink
Merge fe5577f into 11c3480
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Oct 25, 2018
2 parents 11c3480 + fe5577f commit 06a2b4d
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 35 deletions.
2 changes: 1 addition & 1 deletion doc/downloads/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var jsonData = { "versions": [
}
],
"changes": [
{ "change": "<strong>General:</strong> unmanage and (re)manage a new file that has been saved (see issue <a href=\"https://github.com/opencor/opencor/issues/1846\">#1846</a>). Recognise macOS Mojave (10.14) (see issue <a href=\"https://github.com/opencor/opencor/issues/1851\">#1851</a>)." },
{ "change": "<strong>General:</strong> unmanage and (re)manage a new file that has been saved (see issue <a href=\"https://github.com/opencor/opencor/issues/1846\">#1846</a>). Overlayed icons now have the same resolution as standard icons on HiDPI screens (see issue <a href=\"https://github.com/opencor/opencor/issues/1850\">#1850</a>). Recognise macOS Mojave (10.14) (see issue <a href=\"https://github.com/opencor/opencor/issues/1851\">#1851</a>)." },
{ "change": "<strong>Simulation Experiment view:</strong> now have two reset buttons rather than one with a drop-down menu (see issue <a href=\"https://github.com/opencor/opencor/issues/1835\">#1835</a>)." },
{ "change": "<strong>Third-party libraries:</strong> upgraded <a href=\"https://riverbankcomputing.com/software/qscintilla/intro\">QScintilla</a> to version 2.10.8 (see issue <a href=\"https://github.com/opencor/opencor/issues/1833\">#1833</a>). Upgraded <a href=\"https://libgit2.github.com/\">libgit2</a> to version 0.27.5 (see issue <a href=\"https://github.com/opencor/opencor/issues/1838\">#1838</a>). Upgraded the <a href=\"http://computation.llnl.gov/projects/sundials\">SUNDIALS</a> library to version 3.2.1 (see issue <a href=\"https://github.com/opencor/opencor/issues/1847\">#1847</a>)." }
]
Expand Down
47 changes: 32 additions & 15 deletions src/plugins/miscellaneous/Core/src/coreguiutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,18 +607,9 @@ QString iconDataUri(const QString &pIcon, int pWidth, int pHeight,
QIcon standardIcon(QStyle::StandardPixmap pStandardIcon,
const QStyleOption *pOption, const QWidget *pWidget)
{
// Retrieve the given standard icon and scale it to 48x48 pixels since this
// is the size of the Oxygen icons that we use
// Note: the scaling is needed if we, for instance, need to create an
// overlay icon. Indeed, the resolution of the overlay is dependent on
// that of the icon...
// Retrieve the given standard icon

static const QSize IconSize = QSize(48, 48);

QIcon icon = qApp->style()->standardIcon(pStandardIcon, pOption, pWidget);
QPixmap pixmap = icon.pixmap(icon.availableSizes().first());

return pixmap.scaled(IconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
return qApp->style()->standardIcon(pStandardIcon, pOption, pWidget);
}

//==============================================================================
Expand Down Expand Up @@ -668,20 +659,24 @@ QIcon overlayedIcon(const QIcon &pBaseIcon, const QIcon &pOverlayIcon,
{
// Create and return an overlayed icon using the given base and overlay
// icons
// Note: we must, in our conversiono of our icons to a pixmap, account for
// the fact that the user may be using a HiDPI screen, hence the
// scaling factor...

QImage image(pBaseWidth, pBaseHeight, QImage::Format_ARGB32_Premultiplied);
QPainter painter(&image);
double scalingFactor = 1.0/qApp->devicePixelRatio();

painter.setCompositionMode(QPainter::CompositionMode_Source);
painter.fillRect(image.rect(), Qt::transparent);

painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
painter.drawPixmap(0, 0, pBaseWidth, pBaseWidth,
pBaseIcon.pixmap(pBaseWidth, pBaseWidth));

painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
pBaseIcon.pixmap(int(scalingFactor*pBaseWidth),
int(scalingFactor*pBaseWidth)));
painter.drawPixmap(pOverlayLeft, pOverlayTop, pOverlayWidth, pOverlayHeight,
pOverlayIcon.pixmap(pOverlayWidth, pOverlayHeight));
pOverlayIcon.pixmap(int(scalingFactor*pOverlayWidth),
int(scalingFactor*pOverlayHeight)));

return QPixmap::fromImage(image);
}
Expand Down Expand Up @@ -727,6 +722,28 @@ QIcon overlayedIcon(const QString &pBaseIcon, const QString &pOverlayIcon,

//==============================================================================

QIcon scaledIcon(const QIcon &pIcon, int pWidth, int pHeight,
Qt::AspectRatioMode pAspectMode, Qt::TransformationMode pMode)
{
// Create and return a scaled version of the given icon

return pIcon.pixmap(pIcon.availableSizes().first()).scaled(pWidth, pHeight,
pAspectMode,
pMode);
}

//==============================================================================

QIcon scaledIcon(const QString &pIcon, int pWidth, int pHeight,
Qt::AspectRatioMode pAspectMode, Qt::TransformationMode pMode)
{
// Create and return a scaled version of the given icon

return scaledIcon(QIcon(pIcon), pWidth, pHeight, pAspectMode, pMode);
}

//==============================================================================

void showEnableWidget(QWidget *pWidget, bool pVisible, bool pEnabled)
{
// Show/enable or hide/disable the given widget
Expand Down
7 changes: 7 additions & 0 deletions src/plugins/miscellaneous/Core/src/coreguiutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@ QIcon CORE_EXPORT overlayedIcon(const QString &pBaseIcon,
int pOverlayLeft, int pOverlayTop,
int pOverlayWidth, int pOverlayHeight);

QIcon CORE_EXPORT scaledIcon(const QIcon &pIcon, int pWidth, int pHeight,
Qt::AspectRatioMode pAspectMode = Qt::IgnoreAspectRatio,
Qt::TransformationMode pMode = Qt::FastTransformation);
QIcon CORE_EXPORT scaledIcon(const QString &pIcon, int pWidth, int pHeight,
Qt::AspectRatioMode pAspectMode = Qt::IgnoreAspectRatio,
Qt::TransformationMode pMode = Qt::FastTransformation);

void CORE_EXPORT showEnableWidget(QWidget *pWidget, bool pVisible,
bool pEnabled = true);

Expand Down
18 changes: 9 additions & 9 deletions src/plugins/miscellaneous/Core/src/tabbarwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,24 @@ void TabBarStyle::drawControl(ControlElement pElement,
if (verticalTab) {
pPainter->save();

int newX, newY, newRot;
int x, y, rotation;

if ( (tab->shape == QTabBar::RoundedEast)
|| (tab->shape == QTabBar::TriangularEast)) {
newX = tabRect.x()+tabRect.width();
newY = tabRect.y();
x = tabRect.x()+tabRect.width();
y = tabRect.y();

newRot = 90;
rotation = 90;
} else {
newX = tabRect.x();
newY = tabRect.y()+tabRect.height();
x = tabRect.x();
y = tabRect.y()+tabRect.height();

newRot = -90;
rotation = -90;
}

QTransform transform = QTransform::fromTranslate(newX, newY);
QTransform transform = QTransform::fromTranslate(x, y);

transform.rotate(newRot);
transform.rotate(rotation);

pPainter->setTransform(transform, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,18 @@ FileOrganiserWindowWindow::FileOrganiserWindowWindow(QWidget *pParent) :
QIcon folderIcon = Core::standardIcon(QStyle::SP_DirClosedIcon);
int folderIconSize = folderIcon.availableSizes().first().width();
int plusIconSize = int(0.57*folderIconSize);

mGui->actionNew->setIcon(Core::overlayedIcon(folderIcon, PlusIcon,
folderIconSize, folderIconSize,
folderIconSize-plusIconSize, 0,
plusIconSize, plusIconSize));
int scaledIconSize = devicePixelRatio()*toolBarWidget->iconSize().width();
// Note: we scale the icon in case we are on a non-HiDPI screen, in which
// case the icon would be smaller than the what we need for our tool
// bar widget...

mGui->actionNew->setIcon(Core::scaledIcon(Core::overlayedIcon(folderIcon, PlusIcon,
folderIconSize, folderIconSize,
folderIconSize-plusIconSize, 0,
plusIconSize, plusIconSize),
scaledIconSize, scaledIconSize,
Qt::KeepAspectRatio,
Qt::SmoothTransformation));

toolBarWidget->addAction(mGui->actionNew);
toolBarWidget->addAction(mGui->actionDelete);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,18 @@ PmrWorkspacesWindowWindow::PmrWorkspacesWindowWindow(QWidget *pParent) :
QIcon folderIcon = Core::standardIcon(QStyle::SP_DirClosedIcon);
int folderIconSize = folderIcon.availableSizes().first().width();
int plusIconSize = int(0.57*folderIconSize);

mGui->actionNew->setIcon(Core::overlayedIcon(folderIcon, PlusIcon,
folderIconSize, folderIconSize,
folderIconSize-plusIconSize, 0,
plusIconSize, plusIconSize));
int scaledIconSize = devicePixelRatio()*toolBarWidget->iconSize().width();
// Note: we scale the icon in case we are on a non-HiDPI screen, in which
// case the icon would be smaller than the what we need for our tool
// bar widget...

mGui->actionNew->setIcon(Core::scaledIcon(Core::overlayedIcon(folderIcon, PlusIcon,
folderIconSize, folderIconSize,
folderIconSize-plusIconSize, 0,
plusIconSize, plusIconSize),
scaledIconSize, scaledIconSize,
Qt::KeepAspectRatio,
Qt::SmoothTransformation));

toolBarWidget->addAction(mGui->actionNew);
toolBarWidget->addSeparator();
Expand Down

0 comments on commit 06a2b4d

Please sign in to comment.