mirror of
https://github.com/leozide/leocad
synced 2025-01-18 22:26:44 +01:00
Workaround for a Qt bug recreating QApplication. Fixes #610.
This commit is contained in:
parent
4f8252eff9
commit
28c91d0656
3 changed files with 33 additions and 23 deletions
|
@ -157,10 +157,6 @@ lcApplication::lcApplication(int& Argc, char** Argv)
|
|||
: QApplication(Argc, Argv)
|
||||
{
|
||||
setApplicationDisplayName(QLatin1String("LeoCAD"));
|
||||
setOrganizationDomain(QLatin1String("leocad.org"));
|
||||
setOrganizationName(QLatin1String("LeoCAD Software"));
|
||||
setApplicationName(QLatin1String("LeoCAD"));
|
||||
setApplicationVersion(QLatin1String(LC_VERSION_TEXT));
|
||||
|
||||
gApplication = this;
|
||||
mDefaultStyle = style()->objectName();
|
||||
|
@ -333,6 +329,9 @@ bool lcApplication::LoadPartsLibrary(const QList<QPair<QString, bool>>& LibraryP
|
|||
|
||||
lcCommandLineOptions lcApplication::ParseCommandLineOptions()
|
||||
{
|
||||
lcPreferences Preferences;
|
||||
Preferences.LoadDefaults();
|
||||
|
||||
lcCommandLineOptions Options;
|
||||
|
||||
Options.ParseOK = true;
|
||||
|
@ -349,10 +348,12 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
|
|||
Options.SetZPlanes = false;
|
||||
Options.SetFadeStepsColor = false;
|
||||
Options.SetHighlightColor = false;
|
||||
Options.FadeSteps = mPreferences.mFadeSteps;
|
||||
Options.ImageHighlight = mPreferences.mHighlightNewParts;
|
||||
Options.FadeSteps = Preferences.mFadeSteps;
|
||||
Options.ImageHighlight = Preferences.mHighlightNewParts;
|
||||
Options.ImageWidth = lcGetProfileInt(LC_PROFILE_IMAGE_WIDTH);
|
||||
Options.ImageHeight = lcGetProfileInt(LC_PROFILE_IMAGE_HEIGHT);
|
||||
Options.ShadingMode = Preferences.mShadingMode;
|
||||
Options.LineWidth = Preferences.mLineWidth;
|
||||
Options.AASamples = lcGetProfileInt(LC_PROFILE_ANTIALIASING_SAMPLES);
|
||||
Options.StudStyle = static_cast<lcStudStyle>(lcGetProfileInt(LC_PROFILE_STUD_STYLE));
|
||||
Options.ImageStart = 0;
|
||||
|
@ -364,15 +365,15 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
|
|||
Options.FoV = 0.0f;
|
||||
Options.ZPlanes = lcVector2(0.0f, 0.0f);
|
||||
Options.Viewpoint = lcViewpoint::Count;
|
||||
Options.FadeStepsColor = mPreferences.mFadeStepsColor;
|
||||
Options.HighlightColor = mPreferences.mHighlightNewPartsColor;
|
||||
Options.StudCylinderColor = mPreferences.mStudCylinderColor;
|
||||
Options.PartEdgeColor = mPreferences.mPartEdgeColor;
|
||||
Options.BlackEdgeColor = mPreferences.mBlackEdgeColor;
|
||||
Options.DarkEdgeColor = mPreferences.mDarkEdgeColor;
|
||||
Options.PartEdgeContrast = mPreferences.mPartEdgeContrast;
|
||||
Options.PartColorValueLDIndex = mPreferences.mPartColorValueLDIndex;
|
||||
Options.AutomateEdgeColor = mPreferences.mAutomateEdgeColor;
|
||||
Options.FadeStepsColor = Preferences.mFadeStepsColor;
|
||||
Options.HighlightColor = Preferences.mHighlightNewPartsColor;
|
||||
Options.StudCylinderColor = Preferences.mStudCylinderColor;
|
||||
Options.PartEdgeColor = Preferences.mPartEdgeColor;
|
||||
Options.BlackEdgeColor = Preferences.mBlackEdgeColor;
|
||||
Options.DarkEdgeColor = Preferences.mDarkEdgeColor;
|
||||
Options.PartEdgeContrast = Preferences.mPartEdgeContrast;
|
||||
Options.PartColorValueLDIndex = Preferences.mPartColorValueLDIndex;
|
||||
Options.AutomateEdgeColor = Preferences.mAutomateEdgeColor;
|
||||
|
||||
QStringList Arguments = arguments();
|
||||
|
||||
|
@ -721,13 +722,13 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
|
|||
if (ParseString(ShadingString, true))
|
||||
{
|
||||
if (ShadingString == QLatin1String("wireframe"))
|
||||
mPreferences.mShadingMode = lcShadingMode::Wireframe;
|
||||
Options.ShadingMode = lcShadingMode::Wireframe;
|
||||
else if (ShadingString == QLatin1String("flat"))
|
||||
mPreferences.mShadingMode = lcShadingMode::Flat;
|
||||
Options.ShadingMode = lcShadingMode::Flat;
|
||||
else if (ShadingString == QLatin1String("default"))
|
||||
mPreferences.mShadingMode = lcShadingMode::DefaultLights;
|
||||
Options.ShadingMode = lcShadingMode::DefaultLights;
|
||||
else if (ShadingString == QLatin1String("full"))
|
||||
mPreferences.mShadingMode = lcShadingMode::Full;
|
||||
Options.ShadingMode = lcShadingMode::Full;
|
||||
else
|
||||
{
|
||||
Options.StdErr += tr("Invalid parameter value specified for the '%1' option: '%2'.\n").arg(Option, ShadingString);
|
||||
|
@ -736,7 +737,7 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
|
|||
}
|
||||
}
|
||||
else if (Option == QLatin1String("--line-width"))
|
||||
ParseFloat(mPreferences.mLineWidth, 0.0f, 10.0f);
|
||||
ParseFloat(Options.LineWidth, 0.0f, 10.0f);
|
||||
else if (Option == QLatin1String("--aa-samples"))
|
||||
{
|
||||
if (ParseInteger(Options.AASamples, 1, 8) && Options.AASamples != 1 && Options.AASamples != 2 && Options.AASamples != 4 && Options.AASamples != 8)
|
||||
|
@ -939,6 +940,8 @@ lcStartupMode lcApplication::Initialize(const QList<QPair<QString, bool>>& Libra
|
|||
}
|
||||
}
|
||||
|
||||
mPreferences.mShadingMode = Options.ShadingMode;
|
||||
mPreferences.mLineWidth = Options.LineWidth;
|
||||
mPreferences.mStudCylinderColor = Options.StudCylinderColor;
|
||||
mPreferences.mPartEdgeColor = Options.PartEdgeColor;
|
||||
mPreferences.mBlackEdgeColor = Options.BlackEdgeColor;
|
||||
|
|
|
@ -104,6 +104,8 @@ struct lcCommandLineOptions
|
|||
int ImageWidth;
|
||||
int ImageHeight;
|
||||
int AASamples;
|
||||
lcShadingMode ShadingMode;
|
||||
float LineWidth;
|
||||
lcStudStyle StudStyle;
|
||||
lcStep ImageStart;
|
||||
lcStep ImageEnd;
|
||||
|
@ -149,7 +151,7 @@ public:
|
|||
~lcApplication();
|
||||
|
||||
void SetProject(Project* Project);
|
||||
lcCommandLineOptions ParseCommandLineOptions();
|
||||
static lcCommandLineOptions ParseCommandLineOptions();
|
||||
lcStartupMode Initialize(const QList<QPair<QString, bool>>& LibraryPaths);
|
||||
void Shutdown();
|
||||
void ShowPreferencesDialog();
|
||||
|
|
|
@ -123,8 +123,8 @@ static void lcRegisterShellFileTypes()
|
|||
|
||||
static void lcInitializeSurfaceFormat(int argc, char* argv[])
|
||||
{
|
||||
lcApplication Application(argc, argv);
|
||||
const lcCommandLineOptions Options = Application.ParseCommandLineOptions();
|
||||
QCoreApplication Application(argc, argv);
|
||||
const lcCommandLineOptions Options = lcApplication::ParseCommandLineOptions();
|
||||
|
||||
if (Options.ParseOK && Options.AASamples > 1)
|
||||
{
|
||||
|
@ -136,6 +136,11 @@ static void lcInitializeSurfaceFormat(int argc, char* argv[])
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication::setOrganizationDomain(QLatin1String("leocad.org"));
|
||||
QCoreApplication::setOrganizationName(QLatin1String("LeoCAD Software"));
|
||||
QCoreApplication::setApplicationName(QLatin1String("LeoCAD"));
|
||||
QCoreApplication::setApplicationVersion(QLatin1String(LC_VERSION_TEXT));
|
||||
|
||||
lcInitializeSurfaceFormat(argc, argv);
|
||||
|
||||
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
||||
|
|
Loading…
Reference in a new issue