yolobs-studio/UI/platform-x11.cpp

111 lines
2.7 KiB
C++
Raw Normal View History

2016-02-23 23:16:51 +00:00
/******************************************************************************
Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
Copyright (C) 2014 by Zachary Lund <admin@computerquip.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include <obs-config.h>
#include "obs-app.hpp"
2017-04-15 19:02:06 +00:00
#include <QGuiApplication>
#include <QScreen>
2016-02-23 23:16:51 +00:00
#include <unistd.h>
#include <sstream>
#include <locale.h>
#include "platform.hpp"
using namespace std;
static inline bool check_path(const char* data, const char *path,
string &output)
{
ostringstream str;
str << path << data;
output = str.str();
printf("Attempted path: %s\n", output.c_str());
return (access(output.c_str(), R_OK) == 0);
}
#define INSTALL_DATA_PATH OBS_INSTALL_PREFIX OBS_DATA_PATH "/obs-studio/"
bool GetDataFilePath(const char *data, string &output)
{
char *data_path = getenv("OBS_DATA_PATH");
if (data_path != NULL) {
if (check_path(data, data_path, output))
return true;
}
if (check_path(data, OBS_DATA_PATH "/obs-studio/", output))
return true;
if (check_path(data, INSTALL_DATA_PATH, output))
return true;
return false;
}
bool InitApplicationBundle()
{
return true;
}
string GetDefaultVideoSavePath()
{
return string(getenv("HOME"));
}
vector<string> GetPreferredLocales()
{
setlocale(LC_ALL, "");
string messages = setlocale(LC_MESSAGES, NULL);
if (!messages.size() || messages == "C" || messages == "POSIX")
return {};
if (messages.size() > 2)
messages[2] = '-';
for (auto &locale_pair : GetLocaleNames()) {
auto &locale = locale_pair.first;
if (locale == messages.substr(0, locale.size()))
return {locale};
if (locale.substr(0, 2) == messages.substr(0, 2))
return {locale};
}
return {};
}
2016-10-10 19:01:40 +00:00
bool IsAlwaysOnTop(QWidget *window)
2016-02-23 23:16:51 +00:00
{
return (window->windowFlags() & Qt::WindowStaysOnTopHint) != 0;
}
2016-10-10 19:01:40 +00:00
void SetAlwaysOnTop(QWidget *window, bool enable)
2016-02-23 23:16:51 +00:00
{
Qt::WindowFlags flags = window->windowFlags();
if (enable)
flags |= Qt::WindowStaysOnTopHint;
else
flags &= ~Qt::WindowStaysOnTopHint;
window->setWindowFlags(flags);
window->show();
}