clang-format: Apply formatting

Code submissions have continually suffered from formatting
inconsistencies that constantly have to be addressed.  Using
clang-format simplifies this by making code formatting more consistent,
and allows automation of the code formatting so that maintainers can
focus more on the code itself instead of code formatting.
This commit is contained in:
jp9000
2019-06-22 22:13:45 -07:00
parent 53615ee10f
commit f53df7da64
567 changed files with 34068 additions and 32903 deletions

View File

@@ -20,10 +20,10 @@
struct QCef;
struct QCefCookieManager;
extern QCef *cef;
extern QCef *cef;
extern QCefCookieManager *panel_cookies;
#define wiz reinterpret_cast<AutoConfig*>(wizard())
#define wiz reinterpret_cast<AutoConfig *>(wizard())
/* ------------------------------------------------------------------------- */
@@ -33,12 +33,12 @@ static OBSData OpenServiceSettings(std::string &type)
{
char serviceJsonPath[512];
int ret = GetProfilePath(serviceJsonPath, sizeof(serviceJsonPath),
SERVICE_PATH);
SERVICE_PATH);
if (ret <= 0)
return OBSData();
OBSData data = obs_data_create_from_json_file_safe(serviceJsonPath,
"bak");
OBSData data =
obs_data_create_from_json_file_safe(serviceJsonPath, "bak");
obs_data_release(data);
obs_data_set_default_string(data, "type", "rtmp_common");
@@ -51,7 +51,7 @@ static OBSData OpenServiceSettings(std::string &type)
}
static void GetServiceInfo(std::string &type, std::string &service,
std::string &server, std::string &key)
std::string &server, std::string &key)
{
OBSData settings = OpenServiceSettings(type);
@@ -63,8 +63,7 @@ static void GetServiceInfo(std::string &type, std::string &service,
/* ------------------------------------------------------------------------- */
AutoConfigStartPage::AutoConfigStartPage(QWidget *parent)
: QWizardPage (parent),
ui (new Ui_AutoConfigStartPage)
: QWizardPage(parent), ui(new Ui_AutoConfigStartPage)
{
ui->setupUi(this);
setTitle(QTStr("Basic.AutoConfig.StartPage"));
@@ -93,16 +92,15 @@ void AutoConfigStartPage::on_prioritizeRecording_clicked()
/* ------------------------------------------------------------------------- */
#define RES_TEXT(x) "Basic.AutoConfig.VideoPage." x
#define RES_USE_CURRENT RES_TEXT("BaseResolution.UseCurrent")
#define RES_USE_DISPLAY RES_TEXT("BaseResolution.Display")
#define FPS_USE_CURRENT RES_TEXT("FPS.UseCurrent")
#define FPS_PREFER_HIGH_FPS RES_TEXT("FPS.PreferHighFPS")
#define FPS_PREFER_HIGH_RES RES_TEXT("FPS.PreferHighRes")
#define RES_TEXT(x) "Basic.AutoConfig.VideoPage." x
#define RES_USE_CURRENT RES_TEXT("BaseResolution.UseCurrent")
#define RES_USE_DISPLAY RES_TEXT("BaseResolution.Display")
#define FPS_USE_CURRENT RES_TEXT("FPS.UseCurrent")
#define FPS_PREFER_HIGH_FPS RES_TEXT("FPS.PreferHighFPS")
#define FPS_PREFER_HIGH_RES RES_TEXT("FPS.PreferHighRes")
AutoConfigVideoPage::AutoConfigVideoPage(QWidget *parent)
: QWizardPage (parent),
ui (new Ui_AutoConfigVideoPage)
: QWizardPage(parent), ui(new Ui_AutoConfigVideoPage)
{
ui->setupUi(this);
@@ -115,16 +113,15 @@ AutoConfigVideoPage::AutoConfigVideoPage(QWidget *parent)
long double fpsVal =
(long double)ovi.fps_num / (long double)ovi.fps_den;
QString fpsStr = (ovi.fps_den > 1)
? QString::number(fpsVal, 'f', 2)
: QString::number(fpsVal, 'g', 2);
QString fpsStr = (ovi.fps_den > 1) ? QString::number(fpsVal, 'f', 2)
: QString::number(fpsVal, 'g', 2);
ui->fps->addItem(QTStr(FPS_PREFER_HIGH_FPS),
(int)AutoConfig::FPSType::PreferHighFPS);
(int)AutoConfig::FPSType::PreferHighFPS);
ui->fps->addItem(QTStr(FPS_PREFER_HIGH_RES),
(int)AutoConfig::FPSType::PreferHighRes);
(int)AutoConfig::FPSType::PreferHighRes);
ui->fps->addItem(QTStr(FPS_USE_CURRENT).arg(fpsStr),
(int)AutoConfig::FPSType::UseCurrent);
(int)AutoConfig::FPSType::UseCurrent);
ui->fps->addItem(QStringLiteral("30"), (int)AutoConfig::FPSType::fps30);
ui->fps->addItem(QStringLiteral("60"), (int)AutoConfig::FPSType::fps60);
ui->fps->setCurrentIndex(0);
@@ -134,9 +131,9 @@ AutoConfigVideoPage::AutoConfigVideoPage(QWidget *parent)
int encRes = int(ovi.base_width << 16) | int(ovi.base_height);
ui->canvasRes->addItem(QTStr(RES_USE_CURRENT).arg(cxStr, cyStr),
(int)encRes);
(int)encRes);
QList<QScreen*> screens = QGuiApplication::screens();
QList<QScreen *> screens = QGuiApplication::screens();
for (int i = 0; i < screens.size(); i++) {
QScreen *screen = screens[i];
QSize as = screen->size();
@@ -144,19 +141,17 @@ AutoConfigVideoPage::AutoConfigVideoPage(QWidget *parent)
encRes = int(as.width() << 16) | int(as.height());
QString str = QTStr(RES_USE_DISPLAY)
.arg(QString::number(i + 1),
QString::number(as.width()),
QString::number(as.height()));
.arg(QString::number(i + 1),
QString::number(as.width()),
QString::number(as.height()));
ui->canvasRes->addItem(str, encRes);
}
auto addRes = [&] (int cx, int cy)
{
auto addRes = [&](int cx, int cy) {
encRes = (cx << 16) | cy;
QString str = QString("%1x%2").arg(
QString::number(cx),
QString::number(cy));
QString str = QString("%1x%2").arg(QString::number(cx),
QString::number(cy));
ui->canvasRes->addItem(str, encRes);
};
@@ -174,8 +169,8 @@ AutoConfigVideoPage::~AutoConfigVideoPage()
int AutoConfigVideoPage::nextId() const
{
return wiz->type == AutoConfig::Type::Recording
? AutoConfig::TestPage
: AutoConfig::StreamPage;
? AutoConfig::TestPage
: AutoConfig::StreamPage;
}
bool AutoConfigVideoPage::validatePage()
@@ -223,12 +218,11 @@ bool AutoConfigVideoPage::validatePage()
enum class ListOpt : int {
ShowAll = 1,
Custom
Custom,
};
AutoConfigStreamPage::AutoConfigStreamPage(QWidget *parent)
: QWizardPage (parent),
ui (new Ui_AutoConfigStreamPage)
: QWizardPage(parent), ui(new Ui_AutoConfigStreamPage)
{
ui->setupUi(this);
ui->bitrateLabel->setVisible(false);
@@ -255,29 +249,29 @@ AutoConfigStreamPage::AutoConfigStreamPage(QWidget *parent)
LoadServices(false);
connect(ui->service, SIGNAL(currentIndexChanged(int)),
this, SLOT(ServiceChanged()));
connect(ui->customServer, SIGNAL(textChanged(const QString &)),
this, SLOT(ServiceChanged()));
connect(ui->doBandwidthTest, SIGNAL(toggled(bool)),
this, SLOT(ServiceChanged()));
connect(ui->service, SIGNAL(currentIndexChanged(int)), this,
SLOT(ServiceChanged()));
connect(ui->customServer, SIGNAL(textChanged(const QString &)), this,
SLOT(ServiceChanged()));
connect(ui->doBandwidthTest, SIGNAL(toggled(bool)), this,
SLOT(ServiceChanged()));
connect(ui->service, SIGNAL(currentIndexChanged(int)),
this, SLOT(UpdateServerList()));
connect(ui->service, SIGNAL(currentIndexChanged(int)), this,
SLOT(UpdateServerList()));
connect(ui->service, SIGNAL(currentIndexChanged(int)),
this, SLOT(UpdateKeyLink()));
connect(ui->service, SIGNAL(currentIndexChanged(int)), this,
SLOT(UpdateKeyLink()));
connect(ui->key, SIGNAL(textChanged(const QString &)),
this, SLOT(UpdateCompleted()));
connect(ui->regionUS, SIGNAL(toggled(bool)),
this, SLOT(UpdateCompleted()));
connect(ui->regionEU, SIGNAL(toggled(bool)),
this, SLOT(UpdateCompleted()));
connect(ui->regionAsia, SIGNAL(toggled(bool)),
this, SLOT(UpdateCompleted()));
connect(ui->regionOther, SIGNAL(toggled(bool)),
this, SLOT(UpdateCompleted()));
connect(ui->key, SIGNAL(textChanged(const QString &)), this,
SLOT(UpdateCompleted()));
connect(ui->regionUS, SIGNAL(toggled(bool)), this,
SLOT(UpdateCompleted()));
connect(ui->regionEU, SIGNAL(toggled(bool)), this,
SLOT(UpdateCompleted()));
connect(ui->regionAsia, SIGNAL(toggled(bool)), this,
SLOT(UpdateCompleted()));
connect(ui->regionOther, SIGNAL(toggled(bool)), this,
SLOT(UpdateCompleted()));
}
AutoConfigStreamPage::~AutoConfigStreamPage()
@@ -307,17 +301,16 @@ bool AutoConfigStreamPage::validatePage()
wiz->customServer = IsCustom();
const char *serverType = wiz->customServer
? "rtmp_custom"
: "rtmp_common";
const char *serverType = wiz->customServer ? "rtmp_custom"
: "rtmp_common";
if (!wiz->customServer) {
obs_data_set_string(service_settings, "service",
QT_TO_UTF8(ui->service->currentText()));
QT_TO_UTF8(ui->service->currentText()));
}
OBSService service = obs_service_create(serverType, "temp_service",
service_settings, nullptr);
service_settings, nullptr);
obs_service_release(service);
int bitrate = 10000;
@@ -365,9 +358,8 @@ bool AutoConfigStreamPage::validatePage()
if (wiz->service != AutoConfig::Service::Twitch && wiz->bandwidthTest) {
QMessageBox::StandardButton button;
#define WARNING_TEXT(x) QTStr("Basic.AutoConfig.StreamPage.StreamWarning." x)
button = OBSMessageBox::question(this,
WARNING_TEXT("Title"),
WARNING_TEXT("Text"));
button = OBSMessageBox::question(this, WARNING_TEXT("Title"),
WARNING_TEXT("Text"));
#undef WARNING_TEXT
if (button == QMessageBox::No)
@@ -391,7 +383,7 @@ void AutoConfigStreamPage::on_show_clicked()
void AutoConfigStreamPage::OnOAuthStreamKeyConnected()
{
#ifdef BROWSER_AVAILABLE
OAuthStreamKey *a = reinterpret_cast<OAuthStreamKey*>(auth.get());
OAuthStreamKey *a = reinterpret_cast<OAuthStreamKey *>(auth.get());
if (a) {
bool validKey = !a->key().empty();
@@ -440,9 +432,8 @@ void AutoConfigStreamPage::on_disconnectAccount_clicked()
{
QMessageBox::StandardButton button;
button = OBSMessageBox::question(this,
QTStr(DISCONNECT_COMFIRM_TITLE),
QTStr(DISCONNECT_COMFIRM_TEXT));
button = OBSMessageBox::question(this, QTStr(DISCONNECT_COMFIRM_TITLE),
QTStr(DISCONNECT_COMFIRM_TEXT));
if (button == QMessageBox::No) {
return;
@@ -479,14 +470,13 @@ static inline bool is_auth_service(const std::string &service)
void AutoConfigStreamPage::ServiceChanged()
{
bool showMore =
ui->service->currentData().toInt() == (int)ListOpt::ShowAll;
bool showMore = ui->service->currentData().toInt() ==
(int)ListOpt::ShowAll;
if (showMore)
return;
std::string service = QT_TO_UTF8(ui->service->currentText());
bool regionBased = service == "Twitch" ||
service == "Smashcast";
bool regionBased = service == "Twitch" || service == "Smashcast";
bool testBandwidth = ui->doBandwidthTest->isChecked();
bool custom = IsCustom();
@@ -496,9 +486,8 @@ void AutoConfigStreamPage::ServiceChanged()
if (cef) {
if (lastService != service.c_str()) {
bool can_auth = is_auth_service(service);
int page = can_auth
? (int)Section::Connect
: (int)Section::StreamKey;
int page = can_auth ? (int)Section::Connect
: (int)Section::StreamKey;
ui->stackedWidget->setCurrentIndex(page);
ui->streamKeyWidget->setVisible(true);
@@ -525,7 +514,7 @@ void AutoConfigStreamPage::ServiceChanged()
if (custom) {
ui->streamkeyPageLayout->insertRow(1, ui->serverLabel,
ui->serverStackedWidget);
ui->serverStackedWidget);
ui->region->setVisible(false);
ui->serverStackedWidget->setCurrentIndex(1);
@@ -533,8 +522,8 @@ void AutoConfigStreamPage::ServiceChanged()
ui->serverLabel->setVisible(true);
} else {
if (!testBandwidth)
ui->streamkeyPageLayout->insertRow(2, ui->serverLabel,
ui->serverStackedWidget);
ui->streamkeyPageLayout->insertRow(
2, ui->serverLabel, ui->serverStackedWidget);
ui->region->setVisible(regionBased && testBandwidth);
ui->serverStackedWidget->setCurrentIndex(0);
@@ -574,13 +563,15 @@ void AutoConfigStreamPage::UpdateKeyLink()
text += " <a href=\"https://";
text += "www.twitch.tv/broadcast/dashboard/streamkey";
text += "\">";
text += QTStr("Basic.AutoConfig.StreamPage.StreamKey.LinkToSite");
text += QTStr(
"Basic.AutoConfig.StreamPage.StreamKey.LinkToSite");
text += "</a>";
} else if (serviceName == "YouTube / YouTube Gaming") {
text += " <a href=\"https://";
text += "www.youtube.com/live_dashboard";
text += "\">";
text += QTStr("Basic.AutoConfig.StreamPage.StreamKey.LinkToSite");
text += QTStr(
"Basic.AutoConfig.StreamPage.StreamKey.LinkToSite");
text += "</a>";
isYoutube = true;
@@ -632,9 +623,9 @@ void AutoConfigStreamPage::LoadServices(bool showAll)
QVariant((int)ListOpt::ShowAll));
}
ui->service->insertItem(0,
QTStr("Basic.AutoConfig.StreamPage.Service.Custom"),
QVariant((int)ListOpt::Custom));
ui->service->insertItem(
0, QTStr("Basic.AutoConfig.StreamPage.Service.Custom"),
QVariant((int)ListOpt::Custom));
if (!lastService.isEmpty()) {
int idx = ui->service->findText(lastService);
@@ -650,8 +641,8 @@ void AutoConfigStreamPage::LoadServices(bool showAll)
void AutoConfigStreamPage::UpdateServerList()
{
QString serviceName = ui->service->currentText();
bool showMore =
ui->service->currentData().toInt() == (int)ListOpt::ShowAll;
bool showMore = ui->service->currentData().toInt() ==
(int)ListOpt::ShowAll;
if (showMore) {
LoadServices(true);
@@ -706,8 +697,7 @@ void AutoConfigStreamPage::UpdateCompleted()
/* ------------------------------------------------------------------------- */
AutoConfig::AutoConfig(QWidget *parent)
: QWizard(parent)
AutoConfig::AutoConfig(QWidget *parent) : QWizard(parent)
{
EnableThreadedMessageBoxes(true);
@@ -718,7 +708,7 @@ AutoConfig::AutoConfig(QWidget *parent)
proc_handler_call(ph, "twitch_ingests_refresh", &cd);
calldata_free(&cd);
OBSBasic *main = reinterpret_cast<OBSBasic*>(parent);
OBSBasic *main = reinterpret_cast<OBSBasic *>(parent);
main->EnableOutputs(false);
installEventFilter(CreateShortcutFilter());
@@ -805,14 +795,15 @@ AutoConfig::AutoConfig(QWidget *parent)
} else {
streamPage->ui->customServer->setText(server.c_str());
int idx = streamPage->ui->service->findData(
QVariant((int)ListOpt::Custom));
QVariant((int)ListOpt::Custom));
streamPage->ui->service->setCurrentIndex(idx);
}
if (!key.empty())
streamPage->ui->key->setText(key.c_str());
int bitrate = config_get_int(main->Config(), "SimpleOutput", "VBitrate");
int bitrate =
config_get_int(main->Config(), "SimpleOutput", "VBitrate");
streamPage->ui->bitrate->setValue(bitrate);
streamPage->ServiceChanged();
@@ -825,13 +816,13 @@ AutoConfig::AutoConfig(QWidget *parent)
* bitrate ratio that if NVENC is available, it makes sense to
* just always prefer hardware encoding by default */
bool preferHardware = nvencAvailable ||
os_get_physical_cores() <= 4;
os_get_physical_cores() <= 4;
streamPage->ui->preferHardware->setChecked(preferHardware);
}
setOptions(0);
setButtonText(QWizard::FinishButton,
QTStr("Basic.AutoConfig.ApplySettings"));
QTStr("Basic.AutoConfig.ApplySettings"));
setButtonText(QWizard::BackButton, QTStr("Back"));
setButtonText(QWizard::NextButton, QTStr("Next"));
setButtonText(QWizard::CancelButton, QTStr("Cancel"));
@@ -839,7 +830,7 @@ AutoConfig::AutoConfig(QWidget *parent)
AutoConfig::~AutoConfig()
{
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
main->EnableOutputs(true);
EnableThreadedMessageBoxes(false);
}
@@ -879,13 +870,13 @@ bool AutoConfig::CanTestServer(const char *server)
if (strcmp(server, "Default") == 0) {
return true;
} else if (astrcmp_n(server, "US-West:", 8) == 0 ||
astrcmp_n(server, "US-East:", 8) == 0) {
astrcmp_n(server, "US-East:", 8) == 0) {
return regionUS;
} else if (astrcmp_n(server, "EU-", 3) == 0) {
return regionEU;
} else if (astrcmp_n(server, "South Korea:", 12) == 0 ||
astrcmp_n(server, "Asia:", 5) == 0 ||
astrcmp_n(server, "China:", 6) == 0) {
astrcmp_n(server, "Asia:", 5) == 0 ||
astrcmp_n(server, "China:", 6) == 0) {
return regionAsia;
} else if (regionOther) {
return true;
@@ -924,14 +915,12 @@ inline const char *AutoConfig::GetEncoderId(Encoder enc)
void AutoConfig::SaveStreamSettings()
{
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
/* ---------------------------------- */
/* save service */
const char *service_id = customServer
? "rtmp_custom"
: "rtmp_common";
const char *service_id = customServer ? "rtmp_custom" : "rtmp_common";
obs_service_t *oldService = main->GetService();
OBSData hotkeyData = obs_hotkeys_save_service(oldService);
@@ -945,8 +934,8 @@ void AutoConfig::SaveStreamSettings()
obs_data_set_string(settings, "server", server.c_str());
obs_data_set_string(settings, "key", key.c_str());
OBSService newService = obs_service_create(service_id,
"default_service", settings, hotkeyData);
OBSService newService = obs_service_create(
service_id, "default_service", settings, hotkeyData);
obs_service_release(newService);
if (!newService)
@@ -962,26 +951,26 @@ void AutoConfig::SaveStreamSettings()
/* save stream settings */
config_set_int(main->Config(), "SimpleOutput", "VBitrate",
idealBitrate);
idealBitrate);
config_set_string(main->Config(), "SimpleOutput", "StreamEncoder",
GetEncoderId(streamingEncoder));
GetEncoderId(streamingEncoder));
config_remove_value(main->Config(), "SimpleOutput", "UseAdvanced");
}
void AutoConfig::SaveSettings()
{
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
if (recordingEncoder != Encoder::Stream)
config_set_string(main->Config(), "SimpleOutput", "RecEncoder",
GetEncoderId(recordingEncoder));
GetEncoderId(recordingEncoder));
const char *quality = recordingQuality == Quality::High
? "Small"
: "Stream";
const char *quality = recordingQuality == Quality::High ? "Small"
: "Stream";
config_set_string(main->Config(), "Output", "Mode", "Simple");
config_set_string(main->Config(), "SimpleOutput", "RecQuality", quality);
config_set_string(main->Config(), "SimpleOutput", "RecQuality",
quality);
config_set_int(main->Config(), "Video", "BaseCX", baseResolutionCX);
config_set_int(main->Config(), "Video", "BaseCY", baseResolutionCY);
config_set_int(main->Config(), "Video", "OutputCX", idealResolutionCX);
@@ -990,7 +979,7 @@ void AutoConfig::SaveSettings()
if (fpsType != FPSType::UseCurrent) {
config_set_uint(main->Config(), "Video", "FPSType", 0);
config_set_string(main->Config(), "Video", "FPSCommon",
std::to_string(idealFPSNum).c_str());
std::to_string(idealFPSNum).c_str());
}
main->ResetVideo();