mirror of
https://github.com/vicr123/the-libs.git
synced 2025-01-22 18:32:10 -05:00
Add some functions
This commit is contained in:
parent
8f0ae78fdb
commit
0db229689a
2 changed files with 22 additions and 0 deletions
|
@ -17,6 +17,8 @@
|
|||
# define THELIBSSHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#define THE_LIBS_API_VERSION 1
|
||||
|
||||
class THELIBSSHARED_EXPORT theLibsGlobal : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -24,6 +26,7 @@ public:
|
|||
static theLibsGlobal* instance();
|
||||
|
||||
static float getDPIScaling();
|
||||
static QStringList searchInPath(QString executable);
|
||||
|
||||
public slots:
|
||||
bool powerStretchEnabled();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "the-libs_global.h"
|
||||
|
||||
#include <QDesktopWidget>
|
||||
#include <QDir>
|
||||
#include <QDirIterator>
|
||||
|
||||
theLibsGlobal::theLibsGlobal() : QObject(NULL) {
|
||||
#ifdef Q_OS_UNIX
|
||||
|
@ -47,3 +49,20 @@ float theLibsGlobal::getDPIScaling() {
|
|||
float currentDPI = QApplication::desktop()->logicalDpiX();
|
||||
return currentDPI / (float) 96;
|
||||
}
|
||||
|
||||
QStringList theLibsGlobal::searchInPath(QString executable) {
|
||||
QStringList executables;
|
||||
QStringList pathDirs = QString(qgetenv("PATH")).split(":");
|
||||
for (QString dir : pathDirs) {
|
||||
QDir path(dir);
|
||||
QDirIterator i(path);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
if (i.fileName() == executable) {
|
||||
executables.append(i.filePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return executables;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue