Apply a number of fixes to the main window

- Fix the size issue with list boxes on mac.  Was displaying the list
  boxes with an improper size.  Turns out it was just the wrong size
  policies on the frame below.

- Ensure the main windows are fully displayed *before* initializing
  subsystems.  This ensures that the graphics system will properly start
  up on macos, and allows the glitch fix.

- Made a workaround for weird QT glitch that would happen to the parent
  of a pure native widget that also has internal painting fully
  disabled.  (Should definitely write an example and report this bug on
  the QT forums)
This commit is contained in:
jp9000 2014-01-25 09:08:56 -07:00
parent 3922679bf4
commit f09a9ed435
10 changed files with 70 additions and 130 deletions

View file

@ -110,6 +110,12 @@
</item>
<item>
<widget class="QFrame" name="frame_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
@ -186,6 +192,12 @@
</item>
<item>
<widget class="QFrame" name="frame_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
@ -311,6 +323,9 @@
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>

View file

@ -165,20 +165,6 @@ bool OBSApp::InitLocale()
return true;
}
bool OBSApp::InitOBSBasic()
{
try {
mainWindow = move(unique_ptr<OBSBasic>(new OBSBasic()));
mainWindow->show();
return true;
} catch (const char *error) {
blog(LOG_ERROR, "%s", error);
}
return false;
}
OBSApp::OBSApp(int &argc, char **argv)
: QApplication(argc, argv)
{
@ -190,8 +176,8 @@ OBSApp::OBSApp(int &argc, char **argv)
throw "Failed to initialize global config";
if (!InitLocale())
throw "Failed to load locale";
if (!InitOBSBasic())
throw "Failed to create main window";
mainWindow = move(unique_ptr<OBSBasic>(new OBSBasic()));
}
void OBSApp::GetFPSCommon(uint32_t &num, uint32_t &den) const
@ -268,6 +254,11 @@ const char *OBSApp::GetRenderModule() const
return "libobs-opengl";
}
void OBSApp::OBSInit()
{
mainWindow->OBSInit();
}
int main(int argc, char *argv[])
{
int ret = -1;
@ -276,6 +267,7 @@ int main(int argc, char *argv[])
try {
OBSApp program(argc, argv);
program.OBSInit();
ret = program.exec();
} catch (const char *error) {

View file

@ -18,25 +18,25 @@
#pragma once
#include <QApplication>
#include <QMainWindow>
#include <util/util.hpp>
#include <string>
#include <memory>
#include "window-main.hpp"
class OBSApp : public QApplication {
Q_OBJECT
private:
std::string locale;
ConfigFile globalConfig;
TextLookup textLookup;
std::unique_ptr<QMainWindow> mainWindow;
std::string locale;
ConfigFile globalConfig;
TextLookup textLookup;
std::unique_ptr<OBSMainWindow> mainWindow;
bool InitGlobalConfig();
bool InitGlobalConfigDefaults();
bool InitConfigDefaults();
bool InitLocale();
bool InitOBSBasic();
void GetFPSCommon(uint32_t &num, uint32_t &den) const;
void GetFPSInteger(uint32_t &num, uint32_t &den) const;
@ -46,6 +46,8 @@ private:
public:
OBSApp(int &argc, char **argv);
void OBSInit();
inline QMainWindow *GetMainWindow() const {return mainWindow.get();}
inline config_t GlobalConfig() const {return globalConfig;}

View file

@ -1,31 +0,0 @@
/******************************************************************************
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
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 "settings-basic.hpp"
#include "window-basic-settings.hpp"
void BasicSettingsData::SetChanged()
{
dataChanged = true;
window->applyButton->Enable();
}
void BasicSettingsData::SetSaved()
{
dataChanged = false;
window->applyButton->Disable();
}

View file

@ -1,36 +0,0 @@
/******************************************************************************
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
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/>.
******************************************************************************/
#pragma once
#include "settings.hpp"
class OBSBasicSettings;
class BasicSettingsData : public SettingsData {
protected:
OBSBasicSettings *window;
public:
inline BasicSettingsData(OBSBasicSettings *window) : window(window) {}
virtual void SetChanged();
virtual void SetSaved();
};
BasicSettingsData *CreateBasicGeneralSettings(OBSBasicSettings *window);
BasicSettingsData *CreateBasicVideoSettings(OBSBasicSettings *window);

View file

@ -1,34 +0,0 @@
/******************************************************************************
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
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/>.
******************************************************************************/
#pragma once
#include <wx/event.h>
class SettingsData : public wxEvtHandler {
protected:
bool dataChanged;
public:
inline SettingsData() : dataChanged(false) {}
virtual void Apply()=0;
virtual void SetChanged()=0;
virtual void SetSaved()=0;
inline bool DataChanged() const {return dataChanged;}
};

View file

@ -18,6 +18,7 @@
#include <obs.hpp>
#include <QMessageBox>
#include <QShowEvent>
#include "obs-app.hpp"
#include "window-basic-settings.hpp"
@ -202,10 +203,17 @@ void OBSBasic::ChannelChanged(void *data, calldata_t params)
/* Main class functions */
OBSBasic::OBSBasic(QWidget *parent)
: QMainWindow (parent),
ui (new Ui::OBSBasic)
: OBSMainWindow (parent),
ui (new Ui::OBSBasic)
{
ui->setupUi(this);
}
void OBSBasic::OBSInit()
{
/* make sure it's fully displayed before doing any initialization */
show();
App()->processEvents();
if (!obs_startup())
throw "Failed to initialize libobs";
@ -223,6 +231,12 @@ OBSBasic::OBSBasic(QWidget *parent)
/* TODO: this is a test */
obs_load_module("test-input");
#ifdef _WIN32
/* HACK: fixes a windows qt bug with native widgets with native
* repaint */
ui->previewContainer->repaint();
#endif
}
OBSBasic::~OBSBasic()

View file

@ -20,13 +20,13 @@
#include <obs.hpp>
#include <unordered_map>
#include <memory>
#include <QMainWindow>
#include "window-main.hpp"
class QListWidgetItem;
#include "ui_OBSBasic.h"
class OBSBasic : public QMainWindow {
class OBSBasic : public OBSMainWindow {
Q_OBJECT
private:
@ -60,9 +60,9 @@ private:
void LoadProject();
protected:
virtual void closeEvent(QCloseEvent *event);
virtual void changeEvent(QEvent *event);
virtual void resizeEvent(QResizeEvent *event);
virtual void closeEvent(QCloseEvent *event) override;
virtual void changeEvent(QEvent *event) override;
virtual void resizeEvent(QResizeEvent *event) override;
private slots:
void on_action_New_triggered();
@ -88,6 +88,8 @@ public:
explicit OBSBasic(QWidget *parent = 0);
~OBSBasic();
virtual void OBSInit() override;
private:
std::unique_ptr<Ui::OBSBasic> ui;
};

View file

@ -15,6 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#include "obs-app.hpp"
#include "window-basic-settings.hpp"
OBSBasicSettings::OBSBasicSettings(QWidget *parent)
@ -22,6 +23,9 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
ui (new Ui::OBSBasicSettings)
{
ui->setupUi(this);
/*ui->language = config_get_string(GetGlobalConfig(), "General",
"Language");*/
}
void OBSBasicSettings::closeEvent(QCloseEvent *event)

12
obs/window-main.hpp Normal file
View file

@ -0,0 +1,12 @@
#pragma once
#include <QMainWindow>
class OBSMainWindow : public QMainWindow {
Q_OBJECT
public:
inline OBSMainWindow(QWidget *parent) : QMainWindow(parent) {}
virtual void OBSInit()=0;
};