mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-06-21 12:03:43 -05:00
Move GetMonitorNames() to utility
This commit is contained in:
parent
a07a84a8b1
commit
018daf7f09
|
|
@ -117,46 +117,6 @@ static inline void populateWindowTypes(QComboBox *list)
|
|||
"AdvSceneSwitcher.action.projector.fullscreen"));
|
||||
}
|
||||
|
||||
static QStringList getMonitorNames()
|
||||
{
|
||||
QStringList monitorNames;
|
||||
QList<QScreen *> screens = QGuiApplication::screens();
|
||||
for (int i = 0; i < screens.size(); i++) {
|
||||
QScreen *screen = screens[i];
|
||||
QRect screenGeometry = screen->geometry();
|
||||
qreal ratio = screen->devicePixelRatio();
|
||||
QString name = "";
|
||||
#if defined(__APPLE__) || defined(_WIN32)
|
||||
name = screen->name();
|
||||
#else
|
||||
name = screen->model().simplified();
|
||||
if (name.length() > 1 && name.endsWith("-")) {
|
||||
name.chop(1);
|
||||
}
|
||||
#endif
|
||||
name = name.simplified();
|
||||
|
||||
if (name.length() == 0) {
|
||||
name = QString("%1 %2")
|
||||
.arg(obs_module_text(
|
||||
"AdvSceneSwitcher.action.projector.display"))
|
||||
.arg(QString::number(i + 1));
|
||||
}
|
||||
QString str =
|
||||
QString("%1: %2x%3 @ %4,%5")
|
||||
.arg(name,
|
||||
QString::number(screenGeometry.width() *
|
||||
ratio),
|
||||
QString::number(screenGeometry.height() *
|
||||
ratio),
|
||||
QString::number(screenGeometry.x()),
|
||||
QString::number(screenGeometry.y()));
|
||||
|
||||
monitorNames << str;
|
||||
}
|
||||
return monitorNames;
|
||||
}
|
||||
|
||||
MacroActionProjectorEdit::MacroActionProjectorEdit(
|
||||
QWidget *parent, std::shared_ptr<MacroActionProjector> entryData)
|
||||
: QWidget(parent),
|
||||
|
|
@ -173,7 +133,7 @@ MacroActionProjectorEdit::MacroActionProjectorEdit(
|
|||
auto sources = GetSourceNames();
|
||||
sources.sort();
|
||||
_sources->SetSourceNameList(sources);
|
||||
_monitors->addItems(getMonitorNames());
|
||||
_monitors->addItems(GetMonitorNames());
|
||||
|
||||
QWidget::connect(_windowTypes, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(WindowTypeChanged(int)));
|
||||
|
|
|
|||
|
|
@ -559,6 +559,46 @@ void AddSelectionEntry(QComboBox *sel, const char *description, bool selectable,
|
|||
}
|
||||
}
|
||||
|
||||
QStringList GetMonitorNames()
|
||||
{
|
||||
QStringList monitorNames;
|
||||
QList<QScreen *> screens = QGuiApplication::screens();
|
||||
for (int i = 0; i < screens.size(); i++) {
|
||||
QScreen *screen = screens[i];
|
||||
QRect screenGeometry = screen->geometry();
|
||||
qreal ratio = screen->devicePixelRatio();
|
||||
QString name = "";
|
||||
#if defined(__APPLE__) || defined(_WIN32)
|
||||
name = screen->name();
|
||||
#else
|
||||
name = screen->model().simplified();
|
||||
if (name.length() > 1 && name.endsWith("-")) {
|
||||
name.chop(1);
|
||||
}
|
||||
#endif
|
||||
name = name.simplified();
|
||||
|
||||
if (name.length() == 0) {
|
||||
name = QString("%1 %2")
|
||||
.arg(obs_module_text(
|
||||
"AdvSceneSwitcher.action.projector.display"))
|
||||
.arg(QString::number(i + 1));
|
||||
}
|
||||
QString str =
|
||||
QString("%1: %2x%3 @ %4,%5")
|
||||
.arg(name,
|
||||
QString::number(screenGeometry.width() *
|
||||
ratio),
|
||||
QString::number(screenGeometry.height() *
|
||||
ratio),
|
||||
QString::number(screenGeometry.x()),
|
||||
QString::number(screenGeometry.y()));
|
||||
|
||||
monitorNames << str;
|
||||
}
|
||||
return monitorNames;
|
||||
}
|
||||
|
||||
QStringList GetSourceNames()
|
||||
{
|
||||
auto sourceEnum = [](void *param, obs_source_t *source) -> bool /* -- */
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
#include <QColor>
|
||||
#include <QScreen>
|
||||
#include <obs.hpp>
|
||||
#include <obs-frontend-api.h>
|
||||
#include <deque>
|
||||
|
|
@ -121,6 +122,7 @@ void ReplaceAll(std::string &str, const std::string &from,
|
|||
const std::string &to);
|
||||
QString GetDefaultSettingsSaveLocation();
|
||||
std::string GetPathInProfileDir(const char *filePath);
|
||||
QStringList GetMonitorNames();
|
||||
|
||||
/* Legacy helpers */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user