2013-11-07 15:45:03 -08:00
|
|
|
/******************************************************************************
|
|
|
|
Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.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
|
2013-12-02 21:24:38 -08:00
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
2013-11-07 15:45:03 -08:00
|
|
|
(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/>.
|
|
|
|
******************************************************************************/
|
|
|
|
|
2014-05-14 17:47:38 -07:00
|
|
|
#include <time.h>
|
|
|
|
#include <stdio.h>
|
2013-11-23 22:38:52 -08:00
|
|
|
#include <sstream>
|
2013-11-22 19:43:48 -08:00
|
|
|
#include <util/bmem.h>
|
2013-12-17 19:23:57 -08:00
|
|
|
#include <util/dstr.h>
|
2013-11-23 22:38:52 -08:00
|
|
|
#include <util/platform.h>
|
2014-05-15 19:11:33 -07:00
|
|
|
#include <obs-config.h>
|
2013-12-22 16:42:02 -08:00
|
|
|
#include <obs.hpp>
|
|
|
|
|
2014-01-25 10:42:55 -08:00
|
|
|
#include <QProxyStyle>
|
|
|
|
|
Change the UI to Qt (work in progress)
--------------------------------------------------
Notes and details
--------------------------------------------------
Why was this done? Because wxWidgets was just lacking in many areas. I
know wxWidgets is designed to be used with native controls, and that's
great, but wxWidgets just is not a feature-complete toolkit for
multiplatform applications. It lacks in dialog editors, its code is
archaic and outdated, and I just feel frustrated every time I try to do
things with it.
Qt on the other hand.. I had to actually try Qt to realize how much
better it was as a toolkit. They've got everything from dialog editors,
to an IDE, a debugger, build tools, just everything, and it's all
top-notch and highly maintained. The focus of the toolkit is
application development, and they spend their time trying to help
people do exactly that: make programs. Great support, great tools,
and because of that, great toolkit. I just didn't want to alienate any
developers by being stubborn about native widgets.
There *are* some things that are rather lackluster about it and design
choices I disagree with though. For example, I realize that to have an
easy to use toolkit you have to have some level of code generation.
However, in my personal and humble opinion, moc just feels like a
terrible way to approach the problem. Even now I feel like there are a
variety of ways you could handle code generation and automatic
management of things like that. I don't like the idea of circumventing
the language itself like that. It feels like one giant massive hack.
--------------------------------------------------
Things that aren't working properly:
--------------------------------------------------
- Settings dialog is not implemented. The dialog is complete but the
code to handle the dialog hasn't been constructed yet.
- There is a problem with using Qt widgets as a device target on
windows, with at least OpenGL: if I have the preview widget
automatically resize itself, it seems to cause some sort of video
card failure that I don't understand.
- Because of the above, resizing the preview widget has been disabled
until I can figure out what's going on, so it's currently only a
32x32 area.
- Direct3D doesn't seem to render correctly either, seems that the
viewport is messed up or something. I'm sort of confused about
what's going on with it.
- The new main window seems to be triggering more race conditions than
the wxWidgets main window dialog did. I'm not entirely sure what's
going on here, but this may just be existing race conditions within
libobs itself that I just never spotted before (even though I tend to
be very thorough with race conditions any time I use variables
cross-thread)
2014-01-23 10:53:55 -08:00
|
|
|
#include "qt-wrappers.hpp"
|
2013-11-22 15:25:38 -08:00
|
|
|
#include "obs-app.hpp"
|
2013-12-28 20:51:18 -08:00
|
|
|
#include "window-basic-main.hpp"
|
2013-12-07 09:22:56 -08:00
|
|
|
#include "platform.hpp"
|
2013-12-06 08:16:33 -08:00
|
|
|
|
2014-04-14 04:02:11 -07:00
|
|
|
#include <fstream>
|
2014-05-14 17:47:38 -07:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
Change the UI to Qt (work in progress)
--------------------------------------------------
Notes and details
--------------------------------------------------
Why was this done? Because wxWidgets was just lacking in many areas. I
know wxWidgets is designed to be used with native controls, and that's
great, but wxWidgets just is not a feature-complete toolkit for
multiplatform applications. It lacks in dialog editors, its code is
archaic and outdated, and I just feel frustrated every time I try to do
things with it.
Qt on the other hand.. I had to actually try Qt to realize how much
better it was as a toolkit. They've got everything from dialog editors,
to an IDE, a debugger, build tools, just everything, and it's all
top-notch and highly maintained. The focus of the toolkit is
application development, and they spend their time trying to help
people do exactly that: make programs. Great support, great tools,
and because of that, great toolkit. I just didn't want to alienate any
developers by being stubborn about native widgets.
There *are* some things that are rather lackluster about it and design
choices I disagree with though. For example, I realize that to have an
easy to use toolkit you have to have some level of code generation.
However, in my personal and humble opinion, moc just feels like a
terrible way to approach the problem. Even now I feel like there are a
variety of ways you could handle code generation and automatic
management of things like that. I don't like the idea of circumventing
the language itself like that. It feels like one giant massive hack.
--------------------------------------------------
Things that aren't working properly:
--------------------------------------------------
- Settings dialog is not implemented. The dialog is complete but the
code to handle the dialog hasn't been constructed yet.
- There is a problem with using Qt widgets as a device target on
windows, with at least OpenGL: if I have the preview widget
automatically resize itself, it seems to cause some sort of video
card failure that I don't understand.
- Because of the above, resizing the preview widget has been disabled
until I can figure out what's going on, so it's currently only a
32x32 area.
- Direct3D doesn't seem to render correctly either, seems that the
viewport is messed up or something. I'm sort of confused about
what's going on with it.
- The new main window seems to be triggering more race conditions than
the wxWidgets main window dialog did. I'm not entirely sure what's
going on here, but this may just be existing race conditions within
libobs itself that I just never spotted before (even though I tend to
be very thorough with race conditions any time I use variables
cross-thread)
2014-01-23 10:53:55 -08:00
|
|
|
#include <windows.h>
|
2014-05-14 17:47:38 -07:00
|
|
|
#define snprintf _snprintf
|
2014-04-24 14:50:40 -07:00
|
|
|
#else
|
|
|
|
#include <signal.h>
|
2014-01-23 16:00:42 -08:00
|
|
|
#endif
|
2013-11-07 15:45:03 -08:00
|
|
|
|
Change the UI to Qt (work in progress)
--------------------------------------------------
Notes and details
--------------------------------------------------
Why was this done? Because wxWidgets was just lacking in many areas. I
know wxWidgets is designed to be used with native controls, and that's
great, but wxWidgets just is not a feature-complete toolkit for
multiplatform applications. It lacks in dialog editors, its code is
archaic and outdated, and I just feel frustrated every time I try to do
things with it.
Qt on the other hand.. I had to actually try Qt to realize how much
better it was as a toolkit. They've got everything from dialog editors,
to an IDE, a debugger, build tools, just everything, and it's all
top-notch and highly maintained. The focus of the toolkit is
application development, and they spend their time trying to help
people do exactly that: make programs. Great support, great tools,
and because of that, great toolkit. I just didn't want to alienate any
developers by being stubborn about native widgets.
There *are* some things that are rather lackluster about it and design
choices I disagree with though. For example, I realize that to have an
easy to use toolkit you have to have some level of code generation.
However, in my personal and humble opinion, moc just feels like a
terrible way to approach the problem. Even now I feel like there are a
variety of ways you could handle code generation and automatic
management of things like that. I don't like the idea of circumventing
the language itself like that. It feels like one giant massive hack.
--------------------------------------------------
Things that aren't working properly:
--------------------------------------------------
- Settings dialog is not implemented. The dialog is complete but the
code to handle the dialog hasn't been constructed yet.
- There is a problem with using Qt widgets as a device target on
windows, with at least OpenGL: if I have the preview widget
automatically resize itself, it seems to cause some sort of video
card failure that I don't understand.
- Because of the above, resizing the preview widget has been disabled
until I can figure out what's going on, so it's currently only a
32x32 area.
- Direct3D doesn't seem to render correctly either, seems that the
viewport is messed up or something. I'm sort of confused about
what's going on with it.
- The new main window seems to be triggering more race conditions than
the wxWidgets main window dialog did. I'm not entirely sure what's
going on here, but this may just be existing race conditions within
libobs itself that I just never spotted before (even though I tend to
be very thorough with race conditions any time I use variables
cross-thread)
2014-01-23 10:53:55 -08:00
|
|
|
using namespace std;
|
2013-11-23 22:38:52 -08:00
|
|
|
|
2014-05-14 17:47:38 -07:00
|
|
|
static log_handler_t def_log_handler;
|
|
|
|
|
2014-05-18 17:44:10 -07:00
|
|
|
static string currentLogFile;
|
|
|
|
static string lastLogFile;
|
|
|
|
|
|
|
|
string CurrentTimeString()
|
|
|
|
{
|
|
|
|
time_t now = time(0);
|
|
|
|
struct tm tstruct;
|
|
|
|
char buf[80];
|
|
|
|
tstruct = *localtime(&now);
|
|
|
|
strftime(buf, sizeof(buf), "%X", &tstruct);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
string CurrentDateTimeString()
|
|
|
|
{
|
|
|
|
time_t now = time(0);
|
|
|
|
struct tm tstruct;
|
|
|
|
char buf[80];
|
|
|
|
tstruct = *localtime(&now);
|
|
|
|
strftime(buf, sizeof(buf), "%Y-%m-%d, %X", &tstruct);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2014-04-14 04:02:11 -07:00
|
|
|
static void do_log(int log_level, const char *msg, va_list args, void *param)
|
|
|
|
{
|
|
|
|
fstream &logFile = *static_cast<fstream*>(param);
|
2014-05-14 17:47:38 -07:00
|
|
|
char str[4096];
|
|
|
|
|
2014-05-18 17:44:10 -07:00
|
|
|
#ifndef _WIN32
|
2014-05-22 03:59:51 -07:00
|
|
|
va_list args2;
|
2014-05-14 17:47:38 -07:00
|
|
|
va_copy(args2, args);
|
2014-05-18 17:44:10 -07:00
|
|
|
#endif
|
2013-11-23 22:38:52 -08:00
|
|
|
|
2014-05-14 17:47:38 -07:00
|
|
|
vsnprintf(str, 4095, msg, args);
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
OutputDebugStringA(str);
|
2013-11-23 22:38:52 -08:00
|
|
|
OutputDebugStringA("\n");
|
2014-05-14 17:47:38 -07:00
|
|
|
#else
|
|
|
|
def_log_handler(log_level, msg, args2, nullptr);
|
|
|
|
#endif
|
2013-11-23 22:38:52 -08:00
|
|
|
|
2014-04-14 04:02:11 -07:00
|
|
|
if (log_level <= LOG_INFO)
|
2014-05-18 17:44:10 -07:00
|
|
|
logFile << CurrentTimeString() << ": " << str << endl;
|
2014-04-14 04:02:11 -07:00
|
|
|
|
2014-05-14 17:47:38 -07:00
|
|
|
#ifdef _WIN32
|
2014-03-10 13:10:35 -07:00
|
|
|
if (log_level <= LOG_ERROR && IsDebuggerPresent())
|
2013-11-23 22:38:52 -08:00
|
|
|
__debugbreak();
|
2014-04-14 04:02:11 -07:00
|
|
|
#endif
|
2014-05-14 17:47:38 -07:00
|
|
|
}
|
2013-11-23 22:38:52 -08:00
|
|
|
|
2013-12-15 23:07:08 -08:00
|
|
|
bool OBSApp::InitGlobalConfigDefaults()
|
2013-11-23 22:38:52 -08:00
|
|
|
{
|
2013-12-12 20:47:42 -08:00
|
|
|
config_set_default_string(globalConfig, "General", "Language", "en");
|
2014-05-14 17:47:38 -07:00
|
|
|
config_set_default_uint(globalConfig, "General", "MaxLogs", 10);
|
2013-12-15 23:07:08 -08:00
|
|
|
|
2013-12-17 01:08:41 -08:00
|
|
|
#if _WIN32
|
|
|
|
config_set_default_string(globalConfig, "Video", "Renderer",
|
|
|
|
"Direct3D 11");
|
|
|
|
#else
|
2014-03-06 20:08:12 -08:00
|
|
|
config_set_default_string(globalConfig, "Video", "Renderer", "OpenGL");
|
2013-12-17 01:08:41 -08:00
|
|
|
#endif
|
|
|
|
|
2013-12-15 23:07:08 -08:00
|
|
|
return true;
|
2013-11-23 22:38:52 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool do_mkdir(const char *path)
|
|
|
|
{
|
|
|
|
if (os_mkdir(path) == MKDIR_ERROR) {
|
2013-12-07 09:22:56 -08:00
|
|
|
OBSErrorBox(NULL, "Failed to create directory %s", path);
|
2013-11-23 22:38:52 -08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool MakeUserDirs()
|
|
|
|
{
|
2014-05-14 17:47:38 -07:00
|
|
|
BPtr<char> path;
|
|
|
|
|
|
|
|
path = os_get_config_path("obs-studio");
|
|
|
|
if (!do_mkdir(path))
|
|
|
|
return false;
|
2014-03-06 20:08:12 -08:00
|
|
|
|
2014-05-14 17:47:38 -07:00
|
|
|
path = os_get_config_path("obs-studio/basic");
|
|
|
|
if (!do_mkdir(path))
|
2014-03-06 20:08:12 -08:00
|
|
|
return false;
|
|
|
|
|
2014-05-14 17:47:38 -07:00
|
|
|
path = os_get_config_path("obs-studio/studio");
|
|
|
|
if (!do_mkdir(path))
|
2014-03-06 20:08:12 -08:00
|
|
|
return false;
|
|
|
|
|
2014-05-14 17:47:38 -07:00
|
|
|
path = os_get_config_path("obs-studio/logs");
|
|
|
|
if (!do_mkdir(path))
|
2014-03-06 20:08:12 -08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2013-11-23 22:38:52 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool OBSApp::InitGlobalConfig()
|
|
|
|
{
|
2013-12-23 17:59:54 -08:00
|
|
|
BPtr<char> path(os_get_config_path("obs-studio/global.ini"));
|
2013-11-23 22:38:52 -08:00
|
|
|
|
2013-12-23 17:59:54 -08:00
|
|
|
int errorcode = globalConfig.Open(path, CONFIG_OPEN_ALWAYS);
|
2013-11-23 22:38:52 -08:00
|
|
|
if (errorcode != CONFIG_SUCCESS) {
|
2013-12-07 09:22:56 -08:00
|
|
|
OBSErrorBox(NULL, "Failed to open global.ini: %d", errorcode);
|
2013-11-23 22:38:52 -08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-12-23 17:59:54 -08:00
|
|
|
return InitGlobalConfigDefaults();
|
2013-11-23 22:38:52 -08:00
|
|
|
}
|
2013-11-07 15:45:03 -08:00
|
|
|
|
2013-12-17 12:56:28 -08:00
|
|
|
#define DEFAULT_LANG "en"
|
|
|
|
|
2013-12-07 09:22:56 -08:00
|
|
|
bool OBSApp::InitLocale()
|
|
|
|
{
|
|
|
|
const char *lang = config_get_string(globalConfig, "General",
|
|
|
|
"Language");
|
|
|
|
|
2013-12-30 05:56:39 -08:00
|
|
|
locale = lang;
|
|
|
|
|
2013-12-07 09:22:56 -08:00
|
|
|
stringstream file;
|
|
|
|
file << "locale/" << lang << ".txt";
|
|
|
|
|
2013-12-17 12:56:28 -08:00
|
|
|
string englishPath;
|
|
|
|
if (!GetDataFilePath("locale/" DEFAULT_LANG ".txt", englishPath)) {
|
|
|
|
OBSErrorBox(NULL, "Failed to find locale/" DEFAULT_LANG ".txt");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
textLookup = text_lookup_create(englishPath.c_str());
|
|
|
|
if (!textLookup) {
|
|
|
|
OBSErrorBox(NULL, "Failed to create locale from file '%s'",
|
|
|
|
englishPath.c_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-12-17 19:23:57 -08:00
|
|
|
if (astrcmpi(lang, DEFAULT_LANG) == 0)
|
2013-12-17 12:56:28 -08:00
|
|
|
return true;
|
|
|
|
|
2013-12-07 09:22:56 -08:00
|
|
|
string path;
|
2013-12-17 12:56:28 -08:00
|
|
|
if (GetDataFilePath(file.str().c_str(), path)) {
|
|
|
|
if (!text_lookup_add(textLookup, path.c_str()))
|
2014-02-28 19:02:29 -08:00
|
|
|
blog(LOG_ERROR, "Failed to add locale file '%s'",
|
2013-12-17 12:56:28 -08:00
|
|
|
path.c_str());
|
|
|
|
} else {
|
2014-02-28 19:02:29 -08:00
|
|
|
blog(LOG_ERROR, "Could not find locale file '%s'",
|
2013-12-17 12:56:28 -08:00
|
|
|
file.str().c_str());
|
2013-12-07 09:22:56 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Change the UI to Qt (work in progress)
--------------------------------------------------
Notes and details
--------------------------------------------------
Why was this done? Because wxWidgets was just lacking in many areas. I
know wxWidgets is designed to be used with native controls, and that's
great, but wxWidgets just is not a feature-complete toolkit for
multiplatform applications. It lacks in dialog editors, its code is
archaic and outdated, and I just feel frustrated every time I try to do
things with it.
Qt on the other hand.. I had to actually try Qt to realize how much
better it was as a toolkit. They've got everything from dialog editors,
to an IDE, a debugger, build tools, just everything, and it's all
top-notch and highly maintained. The focus of the toolkit is
application development, and they spend their time trying to help
people do exactly that: make programs. Great support, great tools,
and because of that, great toolkit. I just didn't want to alienate any
developers by being stubborn about native widgets.
There *are* some things that are rather lackluster about it and design
choices I disagree with though. For example, I realize that to have an
easy to use toolkit you have to have some level of code generation.
However, in my personal and humble opinion, moc just feels like a
terrible way to approach the problem. Even now I feel like there are a
variety of ways you could handle code generation and automatic
management of things like that. I don't like the idea of circumventing
the language itself like that. It feels like one giant massive hack.
--------------------------------------------------
Things that aren't working properly:
--------------------------------------------------
- Settings dialog is not implemented. The dialog is complete but the
code to handle the dialog hasn't been constructed yet.
- There is a problem with using Qt widgets as a device target on
windows, with at least OpenGL: if I have the preview widget
automatically resize itself, it seems to cause some sort of video
card failure that I don't understand.
- Because of the above, resizing the preview widget has been disabled
until I can figure out what's going on, so it's currently only a
32x32 area.
- Direct3D doesn't seem to render correctly either, seems that the
viewport is messed up or something. I'm sort of confused about
what's going on with it.
- The new main window seems to be triggering more race conditions than
the wxWidgets main window dialog did. I'm not entirely sure what's
going on here, but this may just be existing race conditions within
libobs itself that I just never spotted before (even though I tend to
be very thorough with race conditions any time I use variables
cross-thread)
2014-01-23 10:53:55 -08:00
|
|
|
OBSApp::OBSApp(int &argc, char **argv)
|
|
|
|
: QApplication(argc, argv)
|
2013-11-07 15:45:03 -08:00
|
|
|
{
|
2014-01-08 16:17:30 -08:00
|
|
|
if (!InitApplicationBundle())
|
Change the UI to Qt (work in progress)
--------------------------------------------------
Notes and details
--------------------------------------------------
Why was this done? Because wxWidgets was just lacking in many areas. I
know wxWidgets is designed to be used with native controls, and that's
great, but wxWidgets just is not a feature-complete toolkit for
multiplatform applications. It lacks in dialog editors, its code is
archaic and outdated, and I just feel frustrated every time I try to do
things with it.
Qt on the other hand.. I had to actually try Qt to realize how much
better it was as a toolkit. They've got everything from dialog editors,
to an IDE, a debugger, build tools, just everything, and it's all
top-notch and highly maintained. The focus of the toolkit is
application development, and they spend their time trying to help
people do exactly that: make programs. Great support, great tools,
and because of that, great toolkit. I just didn't want to alienate any
developers by being stubborn about native widgets.
There *are* some things that are rather lackluster about it and design
choices I disagree with though. For example, I realize that to have an
easy to use toolkit you have to have some level of code generation.
However, in my personal and humble opinion, moc just feels like a
terrible way to approach the problem. Even now I feel like there are a
variety of ways you could handle code generation and automatic
management of things like that. I don't like the idea of circumventing
the language itself like that. It feels like one giant massive hack.
--------------------------------------------------
Things that aren't working properly:
--------------------------------------------------
- Settings dialog is not implemented. The dialog is complete but the
code to handle the dialog hasn't been constructed yet.
- There is a problem with using Qt widgets as a device target on
windows, with at least OpenGL: if I have the preview widget
automatically resize itself, it seems to cause some sort of video
card failure that I don't understand.
- Because of the above, resizing the preview widget has been disabled
until I can figure out what's going on, so it's currently only a
32x32 area.
- Direct3D doesn't seem to render correctly either, seems that the
viewport is messed up or something. I'm sort of confused about
what's going on with it.
- The new main window seems to be triggering more race conditions than
the wxWidgets main window dialog did. I'm not entirely sure what's
going on here, but this may just be existing race conditions within
libobs itself that I just never spotted before (even though I tend to
be very thorough with race conditions any time I use variables
cross-thread)
2014-01-23 10:53:55 -08:00
|
|
|
throw "Failed to initialize application bundle";
|
2013-11-23 22:38:52 -08:00
|
|
|
if (!MakeUserDirs())
|
Change the UI to Qt (work in progress)
--------------------------------------------------
Notes and details
--------------------------------------------------
Why was this done? Because wxWidgets was just lacking in many areas. I
know wxWidgets is designed to be used with native controls, and that's
great, but wxWidgets just is not a feature-complete toolkit for
multiplatform applications. It lacks in dialog editors, its code is
archaic and outdated, and I just feel frustrated every time I try to do
things with it.
Qt on the other hand.. I had to actually try Qt to realize how much
better it was as a toolkit. They've got everything from dialog editors,
to an IDE, a debugger, build tools, just everything, and it's all
top-notch and highly maintained. The focus of the toolkit is
application development, and they spend their time trying to help
people do exactly that: make programs. Great support, great tools,
and because of that, great toolkit. I just didn't want to alienate any
developers by being stubborn about native widgets.
There *are* some things that are rather lackluster about it and design
choices I disagree with though. For example, I realize that to have an
easy to use toolkit you have to have some level of code generation.
However, in my personal and humble opinion, moc just feels like a
terrible way to approach the problem. Even now I feel like there are a
variety of ways you could handle code generation and automatic
management of things like that. I don't like the idea of circumventing
the language itself like that. It feels like one giant massive hack.
--------------------------------------------------
Things that aren't working properly:
--------------------------------------------------
- Settings dialog is not implemented. The dialog is complete but the
code to handle the dialog hasn't been constructed yet.
- There is a problem with using Qt widgets as a device target on
windows, with at least OpenGL: if I have the preview widget
automatically resize itself, it seems to cause some sort of video
card failure that I don't understand.
- Because of the above, resizing the preview widget has been disabled
until I can figure out what's going on, so it's currently only a
32x32 area.
- Direct3D doesn't seem to render correctly either, seems that the
viewport is messed up or something. I'm sort of confused about
what's going on with it.
- The new main window seems to be triggering more race conditions than
the wxWidgets main window dialog did. I'm not entirely sure what's
going on here, but this may just be existing race conditions within
libobs itself that I just never spotted before (even though I tend to
be very thorough with race conditions any time I use variables
cross-thread)
2014-01-23 10:53:55 -08:00
|
|
|
throw "Failed to created required user directories";
|
2013-11-23 22:38:52 -08:00
|
|
|
if (!InitGlobalConfig())
|
Change the UI to Qt (work in progress)
--------------------------------------------------
Notes and details
--------------------------------------------------
Why was this done? Because wxWidgets was just lacking in many areas. I
know wxWidgets is designed to be used with native controls, and that's
great, but wxWidgets just is not a feature-complete toolkit for
multiplatform applications. It lacks in dialog editors, its code is
archaic and outdated, and I just feel frustrated every time I try to do
things with it.
Qt on the other hand.. I had to actually try Qt to realize how much
better it was as a toolkit. They've got everything from dialog editors,
to an IDE, a debugger, build tools, just everything, and it's all
top-notch and highly maintained. The focus of the toolkit is
application development, and they spend their time trying to help
people do exactly that: make programs. Great support, great tools,
and because of that, great toolkit. I just didn't want to alienate any
developers by being stubborn about native widgets.
There *are* some things that are rather lackluster about it and design
choices I disagree with though. For example, I realize that to have an
easy to use toolkit you have to have some level of code generation.
However, in my personal and humble opinion, moc just feels like a
terrible way to approach the problem. Even now I feel like there are a
variety of ways you could handle code generation and automatic
management of things like that. I don't like the idea of circumventing
the language itself like that. It feels like one giant massive hack.
--------------------------------------------------
Things that aren't working properly:
--------------------------------------------------
- Settings dialog is not implemented. The dialog is complete but the
code to handle the dialog hasn't been constructed yet.
- There is a problem with using Qt widgets as a device target on
windows, with at least OpenGL: if I have the preview widget
automatically resize itself, it seems to cause some sort of video
card failure that I don't understand.
- Because of the above, resizing the preview widget has been disabled
until I can figure out what's going on, so it's currently only a
32x32 area.
- Direct3D doesn't seem to render correctly either, seems that the
viewport is messed up or something. I'm sort of confused about
what's going on with it.
- The new main window seems to be triggering more race conditions than
the wxWidgets main window dialog did. I'm not entirely sure what's
going on here, but this may just be existing race conditions within
libobs itself that I just never spotted before (even though I tend to
be very thorough with race conditions any time I use variables
cross-thread)
2014-01-23 10:53:55 -08:00
|
|
|
throw "Failed to initialize global config";
|
2013-12-07 09:22:56 -08:00
|
|
|
if (!InitLocale())
|
Change the UI to Qt (work in progress)
--------------------------------------------------
Notes and details
--------------------------------------------------
Why was this done? Because wxWidgets was just lacking in many areas. I
know wxWidgets is designed to be used with native controls, and that's
great, but wxWidgets just is not a feature-complete toolkit for
multiplatform applications. It lacks in dialog editors, its code is
archaic and outdated, and I just feel frustrated every time I try to do
things with it.
Qt on the other hand.. I had to actually try Qt to realize how much
better it was as a toolkit. They've got everything from dialog editors,
to an IDE, a debugger, build tools, just everything, and it's all
top-notch and highly maintained. The focus of the toolkit is
application development, and they spend their time trying to help
people do exactly that: make programs. Great support, great tools,
and because of that, great toolkit. I just didn't want to alienate any
developers by being stubborn about native widgets.
There *are* some things that are rather lackluster about it and design
choices I disagree with though. For example, I realize that to have an
easy to use toolkit you have to have some level of code generation.
However, in my personal and humble opinion, moc just feels like a
terrible way to approach the problem. Even now I feel like there are a
variety of ways you could handle code generation and automatic
management of things like that. I don't like the idea of circumventing
the language itself like that. It feels like one giant massive hack.
--------------------------------------------------
Things that aren't working properly:
--------------------------------------------------
- Settings dialog is not implemented. The dialog is complete but the
code to handle the dialog hasn't been constructed yet.
- There is a problem with using Qt widgets as a device target on
windows, with at least OpenGL: if I have the preview widget
automatically resize itself, it seems to cause some sort of video
card failure that I don't understand.
- Because of the above, resizing the preview widget has been disabled
until I can figure out what's going on, so it's currently only a
32x32 area.
- Direct3D doesn't seem to render correctly either, seems that the
viewport is messed up or something. I'm sort of confused about
what's going on with it.
- The new main window seems to be triggering more race conditions than
the wxWidgets main window dialog did. I'm not entirely sure what's
going on here, but this may just be existing race conditions within
libobs itself that I just never spotted before (even though I tend to
be very thorough with race conditions any time I use variables
cross-thread)
2014-01-23 10:53:55 -08:00
|
|
|
throw "Failed to load locale";
|
2013-12-22 22:40:07 -08:00
|
|
|
}
|
2013-11-22 19:43:48 -08:00
|
|
|
|
2013-12-22 22:40:07 -08:00
|
|
|
const char *OBSApp::GetRenderModule() const
|
2013-11-23 22:38:52 -08:00
|
|
|
{
|
2013-12-22 22:40:07 -08:00
|
|
|
const char *renderer = config_get_string(globalConfig, "Video",
|
|
|
|
"Renderer");
|
|
|
|
|
2014-05-18 17:44:10 -07:00
|
|
|
return (astrcmpi(renderer, "Direct3D 11") == 0) ?
|
|
|
|
"libobs-d3d11" : "libobs-opengl";
|
2013-11-22 19:43:48 -08:00
|
|
|
}
|
Change the UI to Qt (work in progress)
--------------------------------------------------
Notes and details
--------------------------------------------------
Why was this done? Because wxWidgets was just lacking in many areas. I
know wxWidgets is designed to be used with native controls, and that's
great, but wxWidgets just is not a feature-complete toolkit for
multiplatform applications. It lacks in dialog editors, its code is
archaic and outdated, and I just feel frustrated every time I try to do
things with it.
Qt on the other hand.. I had to actually try Qt to realize how much
better it was as a toolkit. They've got everything from dialog editors,
to an IDE, a debugger, build tools, just everything, and it's all
top-notch and highly maintained. The focus of the toolkit is
application development, and they spend their time trying to help
people do exactly that: make programs. Great support, great tools,
and because of that, great toolkit. I just didn't want to alienate any
developers by being stubborn about native widgets.
There *are* some things that are rather lackluster about it and design
choices I disagree with though. For example, I realize that to have an
easy to use toolkit you have to have some level of code generation.
However, in my personal and humble opinion, moc just feels like a
terrible way to approach the problem. Even now I feel like there are a
variety of ways you could handle code generation and automatic
management of things like that. I don't like the idea of circumventing
the language itself like that. It feels like one giant massive hack.
--------------------------------------------------
Things that aren't working properly:
--------------------------------------------------
- Settings dialog is not implemented. The dialog is complete but the
code to handle the dialog hasn't been constructed yet.
- There is a problem with using Qt widgets as a device target on
windows, with at least OpenGL: if I have the preview widget
automatically resize itself, it seems to cause some sort of video
card failure that I don't understand.
- Because of the above, resizing the preview widget has been disabled
until I can figure out what's going on, so it's currently only a
32x32 area.
- Direct3D doesn't seem to render correctly either, seems that the
viewport is messed up or something. I'm sort of confused about
what's going on with it.
- The new main window seems to be triggering more race conditions than
the wxWidgets main window dialog did. I'm not entirely sure what's
going on here, but this may just be existing race conditions within
libobs itself that I just never spotted before (even though I tend to
be very thorough with race conditions any time I use variables
cross-thread)
2014-01-23 10:53:55 -08:00
|
|
|
|
2014-01-25 08:08:56 -08:00
|
|
|
void OBSApp::OBSInit()
|
|
|
|
{
|
2014-05-10 18:47:48 -07:00
|
|
|
mainWindow = move(unique_ptr<OBSBasic>(new OBSBasic()));
|
2014-01-25 08:08:56 -08:00
|
|
|
mainWindow->OBSInit();
|
|
|
|
}
|
|
|
|
|
2014-05-15 14:04:18 -07:00
|
|
|
string OBSApp::GetVersionString() const
|
|
|
|
{
|
|
|
|
stringstream ver;
|
|
|
|
ver << "v" <<
|
|
|
|
LIBOBS_API_MAJOR_VER << "." <<
|
|
|
|
LIBOBS_API_MINOR_VER << "." <<
|
|
|
|
LIBOBS_API_PATCH_VER;
|
|
|
|
|
2014-05-18 17:44:10 -07:00
|
|
|
ver << " (";
|
|
|
|
|
2014-05-15 19:18:13 -07:00
|
|
|
#ifdef HAVE_OBSCONFIG_H
|
2014-05-18 17:44:10 -07:00
|
|
|
ver << OBS_VERSION << ", ";
|
2014-05-15 19:18:13 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
2014-05-15 14:04:18 -07:00
|
|
|
if (sizeof(void*) == 8)
|
2014-05-18 17:44:10 -07:00
|
|
|
ver << "64bit, ";
|
2014-05-15 14:04:18 -07:00
|
|
|
else
|
2014-05-18 17:44:10 -07:00
|
|
|
ver << "32bit, ";
|
2014-05-15 14:04:18 -07:00
|
|
|
|
2014-05-18 17:44:10 -07:00
|
|
|
ver << "windows)";
|
|
|
|
#elif __APPLE__
|
|
|
|
ver << "mac)";
|
|
|
|
#else /* assume linux for the time being */
|
|
|
|
ver << "linux)";
|
|
|
|
#endif
|
2014-05-15 19:14:19 -07:00
|
|
|
|
2014-05-15 14:04:18 -07:00
|
|
|
return ver.str();
|
|
|
|
}
|
|
|
|
|
2014-03-07 16:03:34 -08:00
|
|
|
#ifdef __APPLE__
|
2014-03-07 16:19:26 -08:00
|
|
|
#define INPUT_AUDIO_SOURCE "coreaudio_input_capture"
|
|
|
|
#define OUTPUT_AUDIO_SOURCE "coreaudio_output_capture"
|
2014-03-07 16:03:34 -08:00
|
|
|
#elif _WIN32
|
|
|
|
#define INPUT_AUDIO_SOURCE "wasapi_input_capture"
|
|
|
|
#define OUTPUT_AUDIO_SOURCE "wasapi_output_capture"
|
|
|
|
#else
|
2014-03-10 15:02:37 -07:00
|
|
|
#define INPUT_AUDIO_SOURCE "pulse_input_capture"
|
|
|
|
#define OUTPUT_AUDIO_SOURCE "pulse_output_capture"
|
2014-03-07 16:03:34 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
const char *OBSApp::InputAudioSource() const
|
|
|
|
{
|
|
|
|
return INPUT_AUDIO_SOURCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *OBSApp::OutputAudioSource() const
|
|
|
|
{
|
|
|
|
return OUTPUT_AUDIO_SOURCE;
|
|
|
|
}
|
|
|
|
|
2014-05-18 17:44:10 -07:00
|
|
|
const char *OBSApp::GetLastLog() const
|
|
|
|
{
|
|
|
|
return lastLogFile.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *OBSApp::GetCurrentLog() const
|
|
|
|
{
|
|
|
|
return currentLogFile.c_str();
|
|
|
|
}
|
|
|
|
|
2014-05-10 18:47:48 -07:00
|
|
|
QString OBSTranslator::translate(const char *context, const char *sourceText,
|
|
|
|
const char *disambiguation, int n) const
|
|
|
|
{
|
|
|
|
const char *out = nullptr;
|
|
|
|
if (!text_lookup_getstr(App()->GetTextLookup(), sourceText, &out))
|
|
|
|
return QString();
|
|
|
|
|
|
|
|
UNUSED_PARAMETER(context);
|
|
|
|
UNUSED_PARAMETER(disambiguation);
|
|
|
|
UNUSED_PARAMETER(n);
|
|
|
|
return QT_UTF8(out);
|
|
|
|
}
|
|
|
|
|
2014-01-25 10:42:55 -08:00
|
|
|
struct NoFocusFrameStyle : QProxyStyle
|
|
|
|
{
|
|
|
|
void drawControl(ControlElement element, const QStyleOption *option,
|
|
|
|
QPainter *painter, const QWidget *widget=nullptr)
|
|
|
|
const override
|
|
|
|
{
|
|
|
|
if (element == CE_FocusFrame)
|
|
|
|
return;
|
|
|
|
|
|
|
|
QProxyStyle::drawControl(element, option, painter, widget);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-05-18 17:44:10 -07:00
|
|
|
static bool get_token(lexer *lex, string &str, base_token_type type)
|
|
|
|
{
|
|
|
|
base_token token;
|
|
|
|
if (!lexer_getbasetoken(lex, &token, IGNORE_WHITESPACE))
|
|
|
|
return false;
|
|
|
|
if (token.type != type)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
str.assign(token.text.array, token.text.len);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool expect_token(lexer *lex, const char *str, base_token_type type)
|
|
|
|
{
|
|
|
|
base_token token;
|
|
|
|
if (!lexer_getbasetoken(lex, &token, IGNORE_WHITESPACE))
|
|
|
|
return false;
|
|
|
|
if (token.type != type)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return strref_cmp(&token.text, str) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint64_t convert_log_name(const char *name)
|
|
|
|
{
|
|
|
|
BaseLexer lex;
|
|
|
|
string year, month, day, hour, minute, second;
|
|
|
|
|
|
|
|
lexer_start(lex, name);
|
|
|
|
|
|
|
|
if (!get_token(lex, year, BASETOKEN_DIGIT)) return 0;
|
|
|
|
if (!expect_token(lex, "-", BASETOKEN_OTHER)) return 0;
|
|
|
|
if (!get_token(lex, month, BASETOKEN_DIGIT)) return 0;
|
|
|
|
if (!expect_token(lex, "-", BASETOKEN_OTHER)) return 0;
|
|
|
|
if (!get_token(lex, day, BASETOKEN_DIGIT)) return 0;
|
|
|
|
if (!get_token(lex, hour, BASETOKEN_DIGIT)) return 0;
|
|
|
|
if (!expect_token(lex, "-", BASETOKEN_OTHER)) return 0;
|
|
|
|
if (!get_token(lex, minute, BASETOKEN_DIGIT)) return 0;
|
|
|
|
if (!expect_token(lex, "-", BASETOKEN_OTHER)) return 0;
|
|
|
|
if (!get_token(lex, second, BASETOKEN_DIGIT)) return 0;
|
|
|
|
|
|
|
|
stringstream timestring;
|
|
|
|
timestring << year << month << day << hour << minute << second;
|
|
|
|
return std::stoull(timestring.str());
|
|
|
|
}
|
|
|
|
|
2014-05-14 17:47:38 -07:00
|
|
|
static void delete_oldest_log(void)
|
Change the UI to Qt (work in progress)
--------------------------------------------------
Notes and details
--------------------------------------------------
Why was this done? Because wxWidgets was just lacking in many areas. I
know wxWidgets is designed to be used with native controls, and that's
great, but wxWidgets just is not a feature-complete toolkit for
multiplatform applications. It lacks in dialog editors, its code is
archaic and outdated, and I just feel frustrated every time I try to do
things with it.
Qt on the other hand.. I had to actually try Qt to realize how much
better it was as a toolkit. They've got everything from dialog editors,
to an IDE, a debugger, build tools, just everything, and it's all
top-notch and highly maintained. The focus of the toolkit is
application development, and they spend their time trying to help
people do exactly that: make programs. Great support, great tools,
and because of that, great toolkit. I just didn't want to alienate any
developers by being stubborn about native widgets.
There *are* some things that are rather lackluster about it and design
choices I disagree with though. For example, I realize that to have an
easy to use toolkit you have to have some level of code generation.
However, in my personal and humble opinion, moc just feels like a
terrible way to approach the problem. Even now I feel like there are a
variety of ways you could handle code generation and automatic
management of things like that. I don't like the idea of circumventing
the language itself like that. It feels like one giant massive hack.
--------------------------------------------------
Things that aren't working properly:
--------------------------------------------------
- Settings dialog is not implemented. The dialog is complete but the
code to handle the dialog hasn't been constructed yet.
- There is a problem with using Qt widgets as a device target on
windows, with at least OpenGL: if I have the preview widget
automatically resize itself, it seems to cause some sort of video
card failure that I don't understand.
- Because of the above, resizing the preview widget has been disabled
until I can figure out what's going on, so it's currently only a
32x32 area.
- Direct3D doesn't seem to render correctly either, seems that the
viewport is messed up or something. I'm sort of confused about
what's going on with it.
- The new main window seems to be triggering more race conditions than
the wxWidgets main window dialog did. I'm not entirely sure what's
going on here, but this may just be existing race conditions within
libobs itself that I just never spotted before (even though I tend to
be very thorough with race conditions any time I use variables
cross-thread)
2014-01-23 10:53:55 -08:00
|
|
|
{
|
2014-05-14 17:47:38 -07:00
|
|
|
BPtr<char> logDir(os_get_config_path("obs-studio/logs"));
|
2014-05-18 17:44:10 -07:00
|
|
|
string oldestLog;
|
2014-06-25 01:50:44 -07:00
|
|
|
uint64_t oldest_ts = (uint64_t)-1;
|
2014-05-14 17:47:38 -07:00
|
|
|
struct os_dirent *entry;
|
2014-04-24 14:50:40 -07:00
|
|
|
|
2014-05-14 17:47:38 -07:00
|
|
|
unsigned int maxLogs = (unsigned int)config_get_uint(
|
|
|
|
App()->GlobalConfig(), "General", "MaxLogs");
|
2014-04-14 04:02:11 -07:00
|
|
|
|
2014-05-14 17:47:38 -07:00
|
|
|
os_dir_t dir = os_opendir(logDir);
|
|
|
|
if (dir) {
|
|
|
|
unsigned int count = 0;
|
2014-04-14 04:02:11 -07:00
|
|
|
|
2014-05-14 17:47:38 -07:00
|
|
|
while ((entry = os_readdir(dir)) != NULL) {
|
2014-05-18 17:44:10 -07:00
|
|
|
if (entry->directory || *entry->d_name == '.')
|
2014-05-14 17:47:38 -07:00
|
|
|
continue;
|
|
|
|
|
2014-05-18 17:44:10 -07:00
|
|
|
uint64_t ts = convert_log_name(entry->d_name);
|
2014-05-14 17:47:38 -07:00
|
|
|
|
2014-05-18 17:44:10 -07:00
|
|
|
if (ts) {
|
|
|
|
if (ts < oldest_ts) {
|
|
|
|
oldestLog = entry->d_name;
|
|
|
|
oldest_ts = ts;
|
|
|
|
}
|
2014-05-14 17:47:38 -07:00
|
|
|
|
2014-05-18 17:44:10 -07:00
|
|
|
count++;
|
|
|
|
}
|
2014-05-14 17:47:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
os_closedir(dir);
|
|
|
|
|
2014-05-18 17:44:10 -07:00
|
|
|
if (count > maxLogs) {
|
2014-05-14 17:47:38 -07:00
|
|
|
stringstream delPath;
|
|
|
|
|
2014-05-18 17:44:10 -07:00
|
|
|
delPath << logDir << "/" << oldestLog;
|
2014-05-14 17:47:38 -07:00
|
|
|
os_unlink(delPath.str().c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-18 17:44:10 -07:00
|
|
|
static void get_last_log(void)
|
|
|
|
{
|
|
|
|
BPtr<char> logDir(os_get_config_path("obs-studio/logs"));
|
|
|
|
struct os_dirent *entry;
|
|
|
|
os_dir_t dir = os_opendir(logDir);
|
|
|
|
uint64_t highest_ts = 0;
|
|
|
|
|
|
|
|
if (dir) {
|
|
|
|
while ((entry = os_readdir(dir)) != NULL) {
|
|
|
|
if (entry->directory || *entry->d_name == '.')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
uint64_t ts = convert_log_name(entry->d_name);
|
|
|
|
|
|
|
|
if (ts > highest_ts) {
|
|
|
|
lastLogFile = entry->d_name;
|
|
|
|
highest_ts = ts;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
os_closedir(dir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-20 23:26:19 -07:00
|
|
|
string GenerateTimeDateFilename(const char *extension)
|
2014-05-14 17:47:38 -07:00
|
|
|
{
|
2014-05-20 23:26:19 -07:00
|
|
|
time_t now = time(0);
|
|
|
|
char file[256] = {};
|
|
|
|
struct tm *cur_time;
|
2014-05-18 17:44:10 -07:00
|
|
|
|
2014-05-14 17:47:38 -07:00
|
|
|
cur_time = localtime(&now);
|
2014-05-20 23:26:19 -07:00
|
|
|
snprintf(file, sizeof(file), "%d-%02d-%02d %02d-%02d-%02d.%s",
|
|
|
|
cur_time->tm_year+1900,
|
|
|
|
cur_time->tm_mon+1,
|
|
|
|
cur_time->tm_mday,
|
|
|
|
cur_time->tm_hour,
|
|
|
|
cur_time->tm_min,
|
|
|
|
cur_time->tm_sec,
|
|
|
|
extension);
|
|
|
|
|
|
|
|
return string(file);
|
|
|
|
}
|
2014-05-14 17:47:38 -07:00
|
|
|
|
2014-05-20 23:26:19 -07:00
|
|
|
static void create_log_file(fstream &logFile)
|
|
|
|
{
|
|
|
|
stringstream dst;
|
2014-05-14 17:47:38 -07:00
|
|
|
|
2014-05-20 23:26:19 -07:00
|
|
|
get_last_log();
|
2014-05-18 17:44:10 -07:00
|
|
|
|
2014-05-20 23:26:19 -07:00
|
|
|
currentLogFile = GenerateTimeDateFilename("txt");
|
|
|
|
dst << "obs-studio/logs/" << currentLogFile.c_str();
|
2014-05-14 17:47:38 -07:00
|
|
|
|
2014-05-20 23:26:19 -07:00
|
|
|
BPtr<char> path(os_get_config_path(dst.str().c_str()));
|
|
|
|
logFile.open(path,
|
|
|
|
ios_base::in | ios_base::out | ios_base::trunc);
|
2014-05-14 17:47:38 -07:00
|
|
|
|
|
|
|
if (logFile.is_open()) {
|
|
|
|
delete_oldest_log();
|
2014-04-14 04:02:11 -07:00
|
|
|
base_set_log_handler(do_log, &logFile);
|
2014-05-14 17:47:38 -07:00
|
|
|
} else {
|
|
|
|
blog(LOG_ERROR, "Failed to open log file");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int run_program(fstream &logFile, int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
QCoreApplication::addLibraryPath(".");
|
Change the UI to Qt (work in progress)
--------------------------------------------------
Notes and details
--------------------------------------------------
Why was this done? Because wxWidgets was just lacking in many areas. I
know wxWidgets is designed to be used with native controls, and that's
great, but wxWidgets just is not a feature-complete toolkit for
multiplatform applications. It lacks in dialog editors, its code is
archaic and outdated, and I just feel frustrated every time I try to do
things with it.
Qt on the other hand.. I had to actually try Qt to realize how much
better it was as a toolkit. They've got everything from dialog editors,
to an IDE, a debugger, build tools, just everything, and it's all
top-notch and highly maintained. The focus of the toolkit is
application development, and they spend their time trying to help
people do exactly that: make programs. Great support, great tools,
and because of that, great toolkit. I just didn't want to alienate any
developers by being stubborn about native widgets.
There *are* some things that are rather lackluster about it and design
choices I disagree with though. For example, I realize that to have an
easy to use toolkit you have to have some level of code generation.
However, in my personal and humble opinion, moc just feels like a
terrible way to approach the problem. Even now I feel like there are a
variety of ways you could handle code generation and automatic
management of things like that. I don't like the idea of circumventing
the language itself like that. It feels like one giant massive hack.
--------------------------------------------------
Things that aren't working properly:
--------------------------------------------------
- Settings dialog is not implemented. The dialog is complete but the
code to handle the dialog hasn't been constructed yet.
- There is a problem with using Qt widgets as a device target on
windows, with at least OpenGL: if I have the preview widget
automatically resize itself, it seems to cause some sort of video
card failure that I don't understand.
- Because of the above, resizing the preview widget has been disabled
until I can figure out what's going on, so it's currently only a
32x32 area.
- Direct3D doesn't seem to render correctly either, seems that the
viewport is messed up or something. I'm sort of confused about
what's going on with it.
- The new main window seems to be triggering more race conditions than
the wxWidgets main window dialog did. I'm not entirely sure what's
going on here, but this may just be existing race conditions within
libobs itself that I just never spotted before (even though I tend to
be very thorough with race conditions any time I use variables
cross-thread)
2014-01-23 10:53:55 -08:00
|
|
|
|
|
|
|
try {
|
|
|
|
OBSApp program(argc, argv);
|
2014-05-14 17:47:38 -07:00
|
|
|
OBSTranslator translator;
|
|
|
|
|
|
|
|
create_log_file(logFile);
|
|
|
|
|
|
|
|
program.installTranslator(&translator);
|
2014-01-25 10:42:55 -08:00
|
|
|
program.setStyle(new NoFocusFrameStyle);
|
2014-01-25 08:08:56 -08:00
|
|
|
program.OBSInit();
|
2014-05-14 17:47:38 -07:00
|
|
|
|
Change the UI to Qt (work in progress)
--------------------------------------------------
Notes and details
--------------------------------------------------
Why was this done? Because wxWidgets was just lacking in many areas. I
know wxWidgets is designed to be used with native controls, and that's
great, but wxWidgets just is not a feature-complete toolkit for
multiplatform applications. It lacks in dialog editors, its code is
archaic and outdated, and I just feel frustrated every time I try to do
things with it.
Qt on the other hand.. I had to actually try Qt to realize how much
better it was as a toolkit. They've got everything from dialog editors,
to an IDE, a debugger, build tools, just everything, and it's all
top-notch and highly maintained. The focus of the toolkit is
application development, and they spend their time trying to help
people do exactly that: make programs. Great support, great tools,
and because of that, great toolkit. I just didn't want to alienate any
developers by being stubborn about native widgets.
There *are* some things that are rather lackluster about it and design
choices I disagree with though. For example, I realize that to have an
easy to use toolkit you have to have some level of code generation.
However, in my personal and humble opinion, moc just feels like a
terrible way to approach the problem. Even now I feel like there are a
variety of ways you could handle code generation and automatic
management of things like that. I don't like the idea of circumventing
the language itself like that. It feels like one giant massive hack.
--------------------------------------------------
Things that aren't working properly:
--------------------------------------------------
- Settings dialog is not implemented. The dialog is complete but the
code to handle the dialog hasn't been constructed yet.
- There is a problem with using Qt widgets as a device target on
windows, with at least OpenGL: if I have the preview widget
automatically resize itself, it seems to cause some sort of video
card failure that I don't understand.
- Because of the above, resizing the preview widget has been disabled
until I can figure out what's going on, so it's currently only a
32x32 area.
- Direct3D doesn't seem to render correctly either, seems that the
viewport is messed up or something. I'm sort of confused about
what's going on with it.
- The new main window seems to be triggering more race conditions than
the wxWidgets main window dialog did. I'm not entirely sure what's
going on here, but this may just be existing race conditions within
libobs itself that I just never spotted before (even though I tend to
be very thorough with race conditions any time I use variables
cross-thread)
2014-01-23 10:53:55 -08:00
|
|
|
ret = program.exec();
|
|
|
|
|
|
|
|
} catch (const char *error) {
|
|
|
|
blog(LOG_ERROR, "%s", error);
|
|
|
|
}
|
|
|
|
|
2014-05-14 17:47:38 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
#ifndef WIN32
|
|
|
|
signal(SIGPIPE, SIG_IGN);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
base_get_log_handler(&def_log_handler, nullptr);
|
|
|
|
|
|
|
|
fstream logFile;
|
|
|
|
|
|
|
|
int ret = run_program(logFile, argc, argv);
|
|
|
|
|
2014-04-07 01:25:38 -07:00
|
|
|
blog(LOG_INFO, "Number of memory leaks: %ld", bnum_allocs());
|
2014-04-14 04:02:11 -07:00
|
|
|
base_set_log_handler(nullptr, nullptr);
|
Change the UI to Qt (work in progress)
--------------------------------------------------
Notes and details
--------------------------------------------------
Why was this done? Because wxWidgets was just lacking in many areas. I
know wxWidgets is designed to be used with native controls, and that's
great, but wxWidgets just is not a feature-complete toolkit for
multiplatform applications. It lacks in dialog editors, its code is
archaic and outdated, and I just feel frustrated every time I try to do
things with it.
Qt on the other hand.. I had to actually try Qt to realize how much
better it was as a toolkit. They've got everything from dialog editors,
to an IDE, a debugger, build tools, just everything, and it's all
top-notch and highly maintained. The focus of the toolkit is
application development, and they spend their time trying to help
people do exactly that: make programs. Great support, great tools,
and because of that, great toolkit. I just didn't want to alienate any
developers by being stubborn about native widgets.
There *are* some things that are rather lackluster about it and design
choices I disagree with though. For example, I realize that to have an
easy to use toolkit you have to have some level of code generation.
However, in my personal and humble opinion, moc just feels like a
terrible way to approach the problem. Even now I feel like there are a
variety of ways you could handle code generation and automatic
management of things like that. I don't like the idea of circumventing
the language itself like that. It feels like one giant massive hack.
--------------------------------------------------
Things that aren't working properly:
--------------------------------------------------
- Settings dialog is not implemented. The dialog is complete but the
code to handle the dialog hasn't been constructed yet.
- There is a problem with using Qt widgets as a device target on
windows, with at least OpenGL: if I have the preview widget
automatically resize itself, it seems to cause some sort of video
card failure that I don't understand.
- Because of the above, resizing the preview widget has been disabled
until I can figure out what's going on, so it's currently only a
32x32 area.
- Direct3D doesn't seem to render correctly either, seems that the
viewport is messed up or something. I'm sort of confused about
what's going on with it.
- The new main window seems to be triggering more race conditions than
the wxWidgets main window dialog did. I'm not entirely sure what's
going on here, but this may just be existing race conditions within
libobs itself that I just never spotted before (even though I tend to
be very thorough with race conditions any time I use variables
cross-thread)
2014-01-23 10:53:55 -08:00
|
|
|
return ret;
|
|
|
|
}
|