Skip to content

Commit

Permalink
Merge 765d962 into dd6a04a
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Nov 20, 2018
2 parents dd6a04a + 765d962 commit d53fe55
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 19 deletions.
39 changes: 39 additions & 0 deletions src/plugins/miscellaneous/Core/src/corecliutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,45 @@ QByteArray serialiseDomDocument(const QDomDocument &pDomDocument)

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

QStringList filters(const FileTypeInterfaces &pFileTypeInterfaces,
bool pCheckMimeTypes, const QString &pMimeType)
{
// Convert and return as a list of strings the filters corresponding to the
// given file type interfaces, using the given MIME types, if any

QStringList res = QStringList();

foreach (FileTypeInterface *fileTypeInterface, pFileTypeInterfaces) {
if (!pCheckMimeTypes || !pMimeType.compare(fileTypeInterface->mimeType()))
res << fileTypeInterface->fileTypeDescription()+" (*."+fileTypeInterface->fileExtension()+")";
}

return res;
}

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

QStringList filters(const FileTypeInterfaces &pFileTypeInterfaces)
{
// Convert and return as a list of strings the filters corresponding to the
// given file type interfaces

return filters(pFileTypeInterfaces, false, QString());
}

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

QStringList filters(const FileTypeInterfaces &pFileTypeInterfaces,
const QString &pMimeType)
{
// Convert and return as a list of strings the filters corresponding to the
// given file type interfaces, using the given MIME types

return filters(pFileTypeInterfaces, true, pMimeType);
}

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

} // namespace Core
} // namespace OpenCOR

Expand Down
5 changes: 5 additions & 0 deletions src/plugins/miscellaneous/Core/src/corecliutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//==============================================================================

#include "coreglobal.h"
#include "filetypeinterface.h"
#include "plugin.h"
#include "plugininfo.h"

Expand Down Expand Up @@ -163,6 +164,10 @@ bool CORE_EXPORT validXmlFile(const QString &pXmlFileName,

QByteArray CORE_EXPORT serialiseDomDocument(const QDomDocument &pDomDocument);

QStringList CORE_EXPORT filters(const FileTypeInterfaces &pFileTypeInterfaces);
QStringList CORE_EXPORT filters(const FileTypeInterfaces &pFileTypeInterfaces,
const QString &pMimeType);

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

} // namespace Core
Expand Down
30 changes: 16 additions & 14 deletions src/plugins/miscellaneous/Core/src/coreguiutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ QIcon overlayedIcon(const QIcon &pBaseIcon, const QIcon &pOverlayIcon,
{
// Create and return an overlayed icon using the given base and overlay
// icons
// Note: there is a bug in QIcon::pixmap() when it comes to HiDPI screens
// Note: there is a bug in QIcon::pixmap() when it comes to HiDPI screens
// (see https://bugreports.qt.io/browse/QTBUG-71333), hence we need to
// scale things...

Expand Down Expand Up @@ -778,26 +778,28 @@ QColor lockedColor(const QColor &pColor)

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

QStringList filters(const FileTypeInterfaces &pFileTypeInterfaces,
bool pCheckMimeTypes, const QString &pMimeType)
bool opencorActive()
{
// Convert and return as a list of strings the filters corresponding to the
// given file type interfaces, using the given MIME types, if any
// Return whether OpenCOR is active
// Note: we only consider OpenCOR to be active if the main window or one of
// its dockable windows is active. In other words, if a dialog is
// opened, then we don't consider OpenCOR active since it could
// disturb our user's workflow...

QStringList res = QStringList();
return qApp->activeWindow()
&& !qApp->activeModalWidget()
&& !qApp->activePopupWidget();
}

foreach (FileTypeInterface *fileTypeInterface, pFileTypeInterfaces) {
if (!pCheckMimeTypes || !pMimeType.compare(fileTypeInterface->mimeType()))
res << fileTypeInterface->fileTypeDescription()+" (*."+fileTypeInterface->fileExtension()+")";
}
//==============================================================================

return res;
}
} // namespace Core
} // namespace OpenCOR

//==============================================================================
// End of file
//==============================================================================

QStringList filters(const FileTypeInterfaces &pFileTypeInterfaces)
{
// Convert and return as a list of strings the filters corresponding to the
// given file type interfaces

Expand Down
5 changes: 0 additions & 5 deletions src/plugins/miscellaneous/Core/src/coreguiutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//==============================================================================

#include "coreglobal.h"
#include "filetypeinterface.h"

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

Expand Down Expand Up @@ -208,10 +207,6 @@ void CORE_EXPORT showEnableWidget(QWidget *pWidget, bool pVisible,

QColor CORE_EXPORT lockedColor(const QColor &pColor);

QStringList CORE_EXPORT filters(const FileTypeInterfaces &pFileTypeInterfaces);
QStringList CORE_EXPORT filters(const FileTypeInterfaces &pFileTypeInterfaces,
const QString &pMimeType);

bool CORE_EXPORT opencorActive();

//==============================================================================
Expand Down

0 comments on commit d53fe55

Please sign in to comment.