Wed, 18 Nov 2015 19:05:22 +0200
It worx again!
--- a/src/colors.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/colors.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -24,6 +24,7 @@ #include "miscallenous.h" #include "mainwindow.h" #include "documentmanager.h" +#include "ldpaths.h" static ColorData* colorData = nullptr; @@ -174,10 +175,7 @@ void ColorData::loadFromLdconfig() { - if (not g_win) - return; - - QString path = g_win->documents()->findDocumentPath ("LDConfig.ldr", false); + QString path = LDPaths::ldConfigPath(); QFile fp (path); if (not fp.open (QIODevice::ReadOnly))
--- a/src/dialogs/colorselector.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/dialogs/colorselector.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -55,8 +55,8 @@ if (ldcolor == MainColor) { - color = QColor (m_config->mainColor()); - color.setAlphaF (m_config->mainColorAlpha()); + color = QColor (Config->mainColor()); + color.setAlphaF (Config->mainColorAlpha()); } QString color2name (luma (color) < 80 ? "white" : "black");
--- a/src/dialogs/configdialog.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/dialogs/configdialog.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -74,7 +74,7 @@ QDialog (parent, f), HierarchyElement (parent), ui (*new Ui_ConfigDialog), - m_settings (m_window->makeSettings (this)) + m_settings (makeSettings (this)) { ui.setupUi (this); @@ -82,7 +82,7 @@ applyToWidgetOptions ( [&](QWidget* widget, QString confname) { - QVariant value = m_settings->value (confname, m_config->defaultValueByName (confname)); + QVariant value = m_settings->value (confname, Config->defaultValueByName (confname)); QLineEdit* le; QSpinBox* spinbox; QDoubleSpinBox* doublespinbox; @@ -232,7 +232,7 @@ QString optionname (widget->objectName().mid (strlen ("config"))); - if (m_config->existsEntry (optionname)) + if (Config->existsEntry (optionname)) func (widget, optionname); else print ("Couldn't find configuration entry named %1", optionname); @@ -277,7 +277,7 @@ // Rebuild the quick color toolbar m_window->setQuickColors (quickColors); - m_config->setQuickColorToolbar (quickColorString()); + Config->setQuickColorToolbar (quickColorString()); // Ext program settings for (int i = 0; i < NumExternalPrograms; ++i)
--- a/src/dialogs/newpartdialog.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/dialogs/newpartdialog.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -31,13 +31,13 @@ { ui.setupUi (this); - QString authortext = m_config->defaultName(); + QString authortext = Config->defaultName(); - if (not m_config->defaultUser().isEmpty()) - authortext.append (format (" [%1]", m_config->defaultUser())); + if (not Config->defaultUser().isEmpty()) + authortext.append (format (" [%1]", Config->defaultUser())); ui.author->setText (authortext); - ui.useCaLicense->setChecked (m_config->useCaLicense()); + ui.useCaLicense->setChecked (Config->useCaLicense()); } BfcStatement NewPartDialog::getWinding() const
--- a/src/documentmanager.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/documentmanager.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -139,7 +139,7 @@ unknowns << static_cast<LDError*> (obj)->fileReferenced(); } - if (m_window->configBag()->tryDownloadMissingFiles() and not unknowns.isEmpty()) + if (Config->tryDownloadMissingFiles() and not unknowns.isEmpty()) { PartDownloader dl (m_window); dl.setSourceType (PartDownloader::PartsTracker); @@ -225,7 +225,7 @@ return relativePath; // Try with just the LDraw path first - QString fullPath = format ("%1" DIRSLASH "%2", m_window->configBag()->lDrawPath(), relativePath); + QString fullPath = format ("%1" DIRSLASH "%2", Config->lDrawPath(), relativePath); if (QFileInfo::exists (fullPath)) return fullPath; @@ -234,7 +234,7 @@ { // Look in sub-directories: parts and p. Also look in the download path, since that's where we download parts // from the PT to. - QStringList dirs = { m_window->configBag()->lDrawPath(), m_window->configBag()->downloadFilePath() }; + QStringList dirs = { Config->lDrawPath(), Config->downloadFilePath() }; for (const QString& topdir : dirs) { for (const QString& subdir : QStringList ({ "parts", "p" })) @@ -362,7 +362,7 @@ void DocumentManager::addRecentFile (QString path) { - QStringList recentFiles = m_window->configBag()->recentFiles(); + QStringList recentFiles = Config->recentFiles(); int idx = recentFiles.indexOf (path); // If this file already is in the list, pop it out. @@ -380,7 +380,7 @@ // Add the file recentFiles << path; - m_window->configBag()->setRecentFiles (recentFiles); + Config->setRecentFiles (recentFiles); m_window->syncSettings(); m_window->updateRecentFilesMenu(); } @@ -415,7 +415,7 @@ // Possibly substitute with logoed studs: // stud.dat -> stud-logo.dat // stud2.dat -> stud-logo2.dat - if (m_config->useLogoStuds() and renderinline) + if (Config->useLogoStuds() and renderinline) { // Ensure logoed studs are loaded first loadLogoedStuds();
--- a/src/documentmanager.h Sat Oct 24 13:19:27 2015 +0300 +++ b/src/documentmanager.h Wed Nov 18 19:05:22 2015 +0200 @@ -54,4 +54,6 @@ LDDocument* m_logoedStud2; }; +QString Basename (QString path); +QString Dirname (QString path); static const QStringList g_specialSubdirectories ({ "s", "48", "8" }); \ No newline at end of file
--- a/src/editmodes/abstractEditMode.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/editmodes/abstractEditMode.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -189,7 +189,7 @@ void AbstractDrawMode::drawLength (QPainter &painter, const Vertex &v0, const Vertex &v1, const QPointF& v0p, const QPointF& v1p) const { - if (not m_config->drawLineLengths()) + if (not Config->drawLineLengths()) return; const QString label = QString::number ((v1 - v0).length()); @@ -231,7 +231,7 @@ if (withlengths) drawLength (painter, poly3d[i], poly3d[j], poly[i], poly[j]); - if (withangles and m_config->drawAngles()) + if (withangles and Config->drawAngles()) { QLineF l0 (poly[h], poly[i]), l1 (poly[i], poly[j]);
--- a/src/glCompiler.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/glCompiler.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -27,6 +27,7 @@ #include "glRenderer.h" #include "dialogs.h" #include "guiutilities.h" +#include "documentmanager.h" struct GLErrorInfo { @@ -144,7 +145,7 @@ } else if (poly.color == EdgeColor) { - qcol = luma (QColor (m_config->backgroundColor())) > 40 ? Qt::black : Qt::white; + qcol = luma (QColor (Config->backgroundColor())) > 40 ? Qt::black : Qt::white; } else { @@ -185,7 +186,7 @@ if (blendAlpha != 0.0) { - QColor selcolor (m_config->selectColorBlend()); + QColor selcolor (Config->selectColorBlend()); double denom = blendAlpha + 1.0; qcol.setRed ((qcol.red() + (selcolor.red() * blendAlpha)) / denom); qcol.setGreen ((qcol.green() + (selcolor.green() * blendAlpha)) / denom);
--- a/src/glRenderer.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/glRenderer.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -78,7 +78,7 @@ m_initialized (false) { m_isPicking = false; - m_camera = (ECamera) m_config->camera(); + m_camera = (ECamera) Config->camera(); m_drawToolTip = false; m_currentEditMode = AbstractEditMode::createByType (this, EditModeType::Select); m_panning = false; @@ -174,7 +174,7 @@ glShadeModel (GL_SMOOTH); glEnable (GL_MULTISAMPLE); - if (m_config->antiAliasedLines()) + if (Config->antiAliasedLines()) { glEnable (GL_LINE_SMOOTH); glEnable (GL_POLYGON_SMOOTH); @@ -264,7 +264,7 @@ initializeOpenGLFunctions(); #endif setBackground(); - glLineWidth (m_config->lineThickness()); + glLineWidth (Config->lineThickness()); glLineStipple (1, 0x6666); setAutoFillBackground (false); setMouseTracking (true); @@ -331,7 +331,7 @@ return; } - QColor color = m_config->backgroundColor(); + QColor color = Config->backgroundColor(); if (not color.isValid()) return; @@ -392,7 +392,7 @@ zoomAllToFit(); } - if (m_config->drawWireframe() and not isPicking()) + if (Config->drawWireframe() and not isPicking()) glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -446,7 +446,7 @@ } else { - if (m_config->bfcRedGreenView()) + if (Config->bfcRedGreenView()) { glEnable (GL_CULL_FACE); glCullFace (GL_BACK); @@ -461,7 +461,7 @@ { ComplementVboType colors; - if (m_config->randomColors()) + if (Config->randomColors()) colors = RandomColorsVboComplement; else colors = NormalColorsVboComplement; @@ -475,7 +475,7 @@ drawVbos (ConditionalLinesVbo, NormalColorsVboComplement, GL_LINES); glDisable (GL_LINE_STIPPLE); - if (m_config->drawAxes()) + if (Config->drawAxes()) { glBindBuffer (GL_ARRAY_BUFFER, m_axesVbo); glVertexPointer (3, GL_FLOAT, 0, NULL); @@ -501,9 +501,9 @@ void GLRenderer::drawVbos (SurfaceVboType surface, ComplementVboType colors, GLenum type) { // Filter this through some configuration options - if ((isOneOf (surface, QuadsVbo, TrianglesVbo) and m_config->drawSurfaces() == false) - or (surface == LinesVbo and m_config->drawEdgeLines() == false) - or (surface == ConditionalLinesVbo and m_config->drawConditionalLines() == false)) + if ((isOneOf (surface, QuadsVbo, TrianglesVbo) and Config->drawSurfaces() == false) + or (surface == LinesVbo and Config->drawEdgeLines() == false) + or (surface == ConditionalLinesVbo and Config->drawConditionalLines() == false)) { return; } @@ -914,7 +914,7 @@ return; m_camera = cam; - m_config->setCamera ((int) cam); + Config->setCamera ((int) cam); m_window->updateEditModeActions(); } @@ -1096,14 +1096,14 @@ glDisable (GL_DITHER); // Use particularly thick lines while picking ease up selecting lines. - glLineWidth (qMax<double> (m_config->lineThickness(), 6.5)); + glLineWidth (qMax<double> (Config->lineThickness(), 6.5)); } else { glEnable (GL_DITHER); // Restore line thickness - glLineWidth (m_config->lineThickness()); + glLineWidth (Config->lineThickness()); } } @@ -1540,14 +1540,14 @@ // void GLRenderer::highlightCursorObject() { - if (not m_config->highlightObjectBelowCursor() and objectAtCursor() == nullptr) + if (not Config->highlightObjectBelowCursor() and objectAtCursor() == nullptr) return; LDObject* newObject = nullptr; LDObject* oldObject = objectAtCursor(); qint32 newIndex; - if (m_isCameraMoving or not m_config->highlightObjectBelowCursor()) + if (m_isCameraMoving or not Config->highlightObjectBelowCursor()) { newIndex = 0; }
--- a/src/guiutilities.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/guiutilities.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -37,8 +37,8 @@ if (ldcolor == MainColor) { // Use the user preferences for main color here - color = m_config->mainColor(); - color.setAlphaF (m_config->mainColorAlpha()); + color = Config->mainColor(); + color.setAlphaF (Config->mainColorAlpha()); } // Paint the icon border @@ -84,11 +84,11 @@ QColor GuiUtilities::mainColorRepresentation() { - QColor col (m_config->mainColor()); + QColor col (Config->mainColor()); if (not col.isValid()) return QColor (0, 0, 0); - col.setAlpha (m_config->mainColorAlpha() * 255.f); + col.setAlpha (Config->mainColorAlpha() * 255.f); return col; }
--- a/src/hierarchyelement.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/hierarchyelement.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -23,8 +23,7 @@ #include "guiutilities.h" HierarchyElement::HierarchyElement (QObject* parent) : - m_window (nullptr), - m_config (nullptr) + m_window (nullptr) { if (parent) { @@ -41,7 +40,6 @@ "MainWindow but isn't.\n", this); } - m_config = m_window->configBag(); m_documents = m_window->documents(); }
--- a/src/hierarchyelement.h Sat Oct 24 13:19:27 2015 +0300 +++ b/src/hierarchyelement.h Wed Nov 18 19:05:22 2015 +0200 @@ -41,6 +41,5 @@ protected: MainWindow* m_window; - ConfigurationValueBag* m_config; DocumentManager* m_documents; };
--- a/src/ldDocument.h Sat Oct 24 13:19:27 2015 +0300 +++ b/src/ldDocument.h Wed Nov 18 19:05:22 2015 +0200 @@ -123,5 +123,3 @@ // Parses a string line containing an LDraw object and returns the object parsed. LDObject* ParseLine (QString line); -QString Basename (QString path); -QString Dirname (QString path);
--- a/src/ldObject.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/ldObject.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -1167,7 +1167,7 @@ // QString PreferredLicenseText() { - return g_win->configBag()->useCaLicense() ? CALicenseText : ""; + return Config->useCaLicense() ? CALicenseText : ""; } // =============================================================================
--- a/src/ldpaths.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/ldpaths.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -25,12 +25,11 @@ LDPaths::LDPaths (QObject* parent) : QObject (parent), - HierarchyElement (parent), m_dialog (nullptr) {} void LDPaths::checkPaths() { - QString pathconfig = m_config->lDrawPath(); + QString pathconfig = Config->lDrawPath(); if (not configurePaths (pathconfig)) { @@ -40,7 +39,7 @@ if (not m_dialog->exec()) exit (1); else - m_config->setLDrawPath (m_dialog->path()); + Config->setLDrawPath (m_dialog->path()); } }
--- a/src/ldpaths.h Sat Oct 24 13:19:27 2015 +0300 +++ b/src/ldpaths.h Wed Nov 18 19:05:22 2015 +0200 @@ -22,12 +22,12 @@ class QDir; class MainWindow; -class LDPaths : public QObject, public HierarchyElement +class LDPaths : public QObject { Q_OBJECT public: - LDPaths (QObject* parent); + LDPaths (QObject* parent = nullptr); void checkPaths(); bool isValid (const class QDir& path) const;
--- a/src/main.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/main.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -35,6 +35,7 @@ #include "documentmanager.h" MainWindow* g_win = nullptr; +ConfigurationValueBag* Config = nullptr; const Vertex Origin (0.0f, 0.0f, 0.0f); const Matrix IdentityMatrix ({1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}); @@ -47,12 +48,17 @@ QApplication app (argc, argv); app.setOrganizationName (APPNAME); app.setApplicationName (APPNAME); - initCrashCatcher(); - MainWindow* win = new MainWindow; - LDPaths* paths = new LDPaths (win); + + static ConfigurationValueBag configObject; + Config = &configObject; + + LDPaths* paths = new LDPaths; paths->checkPaths(); paths->deleteLater(); + + initCrashCatcher(); initColors(); + MainWindow* win = new MainWindow; LoadPrimitives(); win->show(); @@ -61,4 +67,4 @@ win->documents()->openMainModel (QString::fromLocal8Bit (argv[arg])); return app.exec(); -} \ No newline at end of file +}
--- a/src/main.h Sat Oct 24 13:19:27 2015 +0300 +++ b/src/main.h Wed Nov 18 19:05:22 2015 +0200 @@ -31,3 +31,6 @@ #include "version.h" #include "format.h" #include "hierarchyelement.h" +#include "configurationvaluebag.h" + +extern ConfigurationValueBag* Config; \ No newline at end of file
--- a/src/mainwindow.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/mainwindow.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -66,7 +66,6 @@ // MainWindow::MainWindow (QWidget* parent, Qt::WindowFlags flags) : QMainWindow (parent, flags), - m_configOptions (this), m_guiUtilities (new GuiUtilities (this)), ui (*new Ui_MainWindow), m_externalPrograms (nullptr), @@ -161,7 +160,7 @@ } } - for (QVariant const& toolbarname : m_configOptions.hiddenToolbars()) + for (QVariant const& toolbarname : Config->hiddenToolbars()) { QToolBar* toolbar = findChild<QToolBar*> (toolbarname.toString()); @@ -171,11 +170,11 @@ // If this is the first start, get the user to configuration. Especially point // them to the profile tab, it's the most important form to fill in. - if (m_configOptions.firstStart()) + if (Config->firstStart()) { ConfigDialog* dialog = new ConfigDialog (this, ConfigDialog::ProfileTab); dialog->show(); - m_configOptions.setFirstStart (false); + Config->setFirstStart (false); } } @@ -235,7 +234,7 @@ QAction* first = nullptr; - for (const QVariant& it : m_configOptions.recentFiles()) + for (const QVariant& it : Config->recentFiles()) { QString file = it.toString(); QAction* recent = new QAction (GetIcon ("open-recent"), file, this); @@ -253,7 +252,7 @@ { QList<ColorToolbarItem> colors; - for (QString colorname : g_win->configBag()->quickColorToolbar().split (":")) + for (QString colorname : Config->quickColorToolbar().split (":")) { if (colorname == "|") colors << ColorToolbarItem::makeSeparator(); @@ -307,7 +306,7 @@ void MainWindow::updateGridToolBar() { // Ensure that the current grid - and only the current grid - is selected. - int grid = m_configOptions.grid(); + int grid = Config->grid(); ui.actionGridCoarse->setChecked (grid == Grid::Coarse); ui.actionGridMedium->setChecked (grid == Grid::Medium); ui.actionGridFine->setChecked (grid == Grid::Fine); @@ -482,7 +481,7 @@ item->setBackground (QColor ("#AA0000")); item->setForeground (QColor ("#FFAA00")); } - else if (m_configOptions.colorizeObjectsList() + else if (Config->colorizeObjectsList() and obj->isColored() and obj->color().isValid() and obj->color() != MainColor @@ -715,7 +714,7 @@ } // Save the configuration before leaving. - m_configOptions.setHiddenToolbars (hiddenToolbars); + Config->setHiddenToolbars (hiddenToolbars); syncSettings(); ev->accept(); } @@ -1041,14 +1040,14 @@ ui.actionRedo->setEnabled (pos < (long) his->size() - 1); } - ui.actionWireframe->setChecked (m_configOptions.drawWireframe()); - ui.actionAxes->setChecked (m_configOptions.drawAxes()); - ui.actionBfcView->setChecked (m_configOptions.bfcRedGreenView()); - ui.actionRandomColors->setChecked (m_configOptions.randomColors()); - ui.actionDrawAngles->setChecked (m_configOptions.drawAngles()); - ui.actionDrawSurfaces->setChecked (m_configOptions.drawSurfaces()); - ui.actionDrawEdgeLines->setChecked (m_configOptions.drawEdgeLines()); - ui.actionDrawConditionalLines->setChecked (m_configOptions.drawConditionalLines()); + ui.actionWireframe->setChecked (Config->drawWireframe()); + ui.actionAxes->setChecked (Config->drawAxes()); + ui.actionBfcView->setChecked (Config->bfcRedGreenView()); + ui.actionRandomColors->setChecked (Config->randomColors()); + ui.actionDrawAngles->setChecked (Config->drawAngles()); + ui.actionDrawSurfaces->setChecked (Config->drawSurfaces()); + ui.actionDrawEdgeLines->setChecked (Config->drawEdgeLines()); + ui.actionDrawConditionalLines->setChecked (Config->drawConditionalLines()); } // --------------------------------------------------------------------------------------------------------------------- @@ -1186,7 +1185,7 @@ // // Accessor to the settings object // -QSettings* MainWindow::makeSettings (QObject* parent) +QSettings* makeSettings (QObject* parent) { QString path = qApp->applicationDirPath() + "/" UNIXNAME ".ini"; return new QSettings (path, QSettings::IniFormat, parent); @@ -1203,7 +1202,7 @@ // QVariant MainWindow::getConfigValue (QString name) { - QVariant value = m_settings->value (name, m_configOptions.defaultValueByName (name)); + QVariant value = m_settings->value (name, Config->defaultValueByName (name)); return value; }
--- a/src/mainwindow.h Sat Oct 24 13:19:27 2015 +0300 +++ b/src/mainwindow.h Wed Nov 18 19:05:22 2015 +0200 @@ -26,7 +26,6 @@ #include <QMetaMethod> #include "ldObject.h" #include "colors.h" -#include "configurationvaluebag.h" #include "doublemap.h" class MessageManager; @@ -79,7 +78,6 @@ void buildObjectList(); void changeDocument (LDDocument* f); void closeInitialDocument(); - ConfigurationValueBag* configBag() { return &m_configOptions; } void createBlankDocument(); LDDocument* currentDocument(); void currentDocumentClosed(); @@ -96,7 +94,6 @@ LDColor getUniformSelectedColor(); class GuiUtilities* guiUtilities(); void loadShortcuts(); - class QSettings* makeSettings (QObject* parent = nullptr); LDDocument* newDocument (bool cache = false); GLRenderer* renderer(); void refresh(); @@ -136,7 +133,6 @@ private: struct ToolInfo { QMetaMethod method; Toolset* object; }; - ConfigurationValueBag m_configOptions; class GuiUtilities* m_guiUtilities; GLRenderer* m_renderer; LDObjectList m_sel; @@ -226,3 +222,4 @@ }; void populatePrimitivesTree (QTreeWidget* tw, const QString& selectByDefault = QString()); +QSettings* makeSettings (QObject* parent = nullptr);
--- a/src/miscallenous.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/miscallenous.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -100,13 +100,11 @@ float gridCoordinateSnap() { - ConfigurationValueBag* config = g_win->configBag(); - - switch (config->grid()) + switch (Config->grid()) { - case Grid::Coarse: return config->gridCoarseCoordinateSnap(); - case Grid::Medium: return config->gridMediumCoordinateSnap(); - case Grid::Fine: return config->gridFineCoordinateSnap(); + case Grid::Coarse: return Config->gridCoarseCoordinateSnap(); + case Grid::Medium: return Config->gridMediumCoordinateSnap(); + case Grid::Fine: return Config->gridFineCoordinateSnap(); } return 1.0f; @@ -114,13 +112,11 @@ float gridAngleSnap() { - ConfigurationValueBag* config = g_win->configBag(); - - switch (config->grid()) + switch (Config->grid()) { - case Grid::Coarse: return config->gridCoarseAngleSnap(); - case Grid::Medium: return config->gridMediumAngleSnap(); - case Grid::Fine: return config->gridFineAngleSnap(); + case Grid::Coarse: return Config->gridCoarseAngleSnap(); + case Grid::Medium: return Config->gridMediumAngleSnap(); + case Grid::Fine: return Config->gridFineAngleSnap(); } return 45.0f; @@ -128,14 +124,12 @@ float gridBezierCurveSegments() { - ConfigurationValueBag* config = g_win->configBag(); - - switch (config->grid()) + switch (Config->grid()) { default: - case Grid::Coarse: return config->gridCoarseBezierCurveSegments(); - case Grid::Medium: return config->gridMediumBezierCurveSegments(); - case Grid::Fine: return config->gridFineBezierCurveSegments(); + case Grid::Coarse: return Config->gridCoarseBezierCurveSegments(); + case Grid::Medium: return Config->gridMediumBezierCurveSegments(); + case Grid::Fine: return Config->gridFineBezierCurveSegments(); } } @@ -190,7 +184,7 @@ // Vertex GetRotationPoint (const LDObjectList& objs) { - switch (RotationPoint (g_win->configBag()->rotationPointType())) + switch (RotationPoint (Config->rotationPointType())) { case RotationPoint::ObjectOrigin: { @@ -212,7 +206,7 @@ return Origin; case RotationPoint::CustomPoint: - return g_win->configBag()->customRotationPoint(); + return Config->customRotationPoint(); case RotationPoint::NumValues: break; @@ -229,7 +223,7 @@ Ui::RotPointUI ui; ui.setupUi (dlg); - switch (RotationPoint (g_win->configBag()->rotationPointType())) + switch (RotationPoint (Config->rotationPointType())) { case RotationPoint::ObjectOrigin: ui.objectPoint->setChecked (true); @@ -247,7 +241,7 @@ break; } - Vertex custompoint = g_win->configBag()->customRotationPoint(); + Vertex custompoint = Config->customRotationPoint(); ui.customX->setValue (custompoint.x()); ui.customY->setValue (custompoint.y()); ui.customZ->setValue (custompoint.z()); @@ -255,7 +249,7 @@ if (not dlg->exec()) return; - g_win->configBag()->setRotationPointType (int ( + Config->setRotationPointType (int ( (ui.objectPoint->isChecked()) ? RotationPoint::ObjectOrigin : (ui.worldPoint->isChecked()) ? RotationPoint::WorldOrigin : RotationPoint::CustomPoint)); @@ -263,7 +257,7 @@ custompoint.setX (ui.customX->value()); custompoint.setY (ui.customY->value()); custompoint.setZ (ui.customZ->value()); - g_win->configBag()->setCustomRotationPoint (custompoint); + Config->setCustomRotationPoint (custompoint); } // =============================================================================
--- a/src/miscallenous.h Sat Oct 24 13:19:27 2015 +0300 +++ b/src/miscallenous.h Wed Nov 18 19:05:22 2015 +0200 @@ -21,7 +21,6 @@ #include <functional> #include "main.h" #include "basics.h" -#include "configurationvaluebag.h" class LDDocument; class QColor;
--- a/src/partdownloader.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/partdownloader.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -28,6 +28,7 @@ #include "mainwindow.h" #include "ldDocument.h" #include "glRenderer.h" +#include "documentmanager.h" ConfigOption (QString DownloadFilePath) ConfigOption (bool GuessDownloadPaths = true) @@ -73,7 +74,7 @@ if (path.isEmpty()) reject(); else - m_config->setDownloadFilePath (path); + Config->setDownloadFilePath (path); } } @@ -102,7 +103,7 @@ dest = dest.simplified(); // If the user doesn't want us to guess, stop right here. - if (not m_config->guessDownloadPaths()) + if (not Config->guessDownloadPaths()) return; // Ensure .dat extension @@ -270,7 +271,7 @@ for (LDDocument* f : m_files) f->reloadAllSubfiles(); - if (m_config->autoCloseDownloadDialog() and not failed) + if (Config->autoCloseDownloadDialog() and not failed) { // Close automatically if desired. accept(); @@ -322,7 +323,7 @@ QString PartDownloader::downloadPath() { - QString path = m_config->downloadFilePath(); + QString path = Config->downloadFilePath(); if (DIRSLASH[0] != '/') path.replace (DIRSLASH, "/");
--- a/src/primitives.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/primitives.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -625,10 +625,10 @@ QString author = APPNAME; QString license = ""; - if (not g_win->configBag()->defaultName().isEmpty()) + if (not Config->defaultName().isEmpty()) { license = PreferredLicenseText(); - author = format ("%1 [%2]", g_win->configBag()->defaultName(), g_win->configBag()->defaultUser()); + author = format ("%1 [%2]", Config->defaultName(), Config->defaultUser()); } LDObjectList objs;
--- a/src/toolsets/algorithmtoolset.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/toolsets/algorithmtoolset.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -161,12 +161,12 @@ v.apply ([&](Axis, double& a) { - RoundToDecimals (a, m_config->roundPositionPrecision()); + RoundToDecimals (a, Config->roundPositionPrecision()); }); ApplyToMatrix (t, [&](int, double& a) { - RoundToDecimals (a, m_config->roundMatrixPrecision()); + RoundToDecimals (a, Config->roundMatrixPrecision()); }); mo->setPosition (v); @@ -180,7 +180,7 @@ Vertex v = obj->vertex (i); v.apply ([&](Axis, double& a) { - RoundToDecimals (a, m_config->roundPositionPrecision()); + RoundToDecimals (a, Config->roundPositionPrecision()); }); obj->setVertex (i, v); num += 3; @@ -333,7 +333,7 @@ QDialog* dlg = new QDialog; Ui_AddHistoryLine* ui = new Ui_AddHistoryLine; ui->setupUi (dlg); - ui->m_username->setText (m_config->defaultUser()); + ui->m_username->setText (Config->defaultUser()); ui->m_date->setDate (QDate::currentDate()); ui->m_comment->setFocus(); @@ -378,12 +378,12 @@ { bool ok; int segments = QInputDialog::getInt (m_window, APPNAME, "Amount of segments:", - m_config->splitLinesSegments(), 0, std::numeric_limits<int>::max(), 1, &ok); + Config->splitLinesSegments(), 0, std::numeric_limits<int>::max(), 1, &ok); if (not ok) return; - m_config->setSplitLinesSegments (segments); + Config->setSplitLinesSegments (segments); for (LDObject* obj : selectedObjects()) { @@ -544,7 +544,7 @@ LDObjectList objs; objs << LDSpawn<LDComment> (subtitle); objs << LDSpawn<LDComment> ("Name: "); // This gets filled in when the subfile is saved - objs << LDSpawn<LDComment> (format ("Author: %1 [%2]", m_config->defaultName(), m_config->defaultUser())); + objs << LDSpawn<LDComment> (format ("Author: %1 [%2]", Config->defaultName(), Config->defaultUser())); objs << LDSpawn<LDComment> ("!LDRAW_ORG Unofficial_Subpart"); if (not license.isEmpty())
--- a/src/toolsets/extprogramtoolset.h Sat Oct 24 13:19:27 2015 +0300 +++ b/src/toolsets/extprogramtoolset.h Wed Nov 18 19:05:22 2015 +0200 @@ -18,7 +18,6 @@ #pragma once #include "toolset.h" -#include "configurationvaluebag.h" enum ExtProgramType {
--- a/src/toolsets/filetoolset.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/toolsets/filetoolset.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -98,10 +98,10 @@ void FileToolset::setLDrawPath() { - LDrawPathDialog* dialog = new LDrawPathDialog (m_config->lDrawPath(), true); + LDrawPathDialog* dialog = new LDrawPathDialog (Config->lDrawPath(), true); if (dialog->exec()) - m_config->setLDrawPath (dialog->path()); + Config->setLDrawPath (dialog->path()); } void FileToolset::exit()
--- a/src/toolsets/movetoolset.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/toolsets/movetoolset.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -44,19 +44,19 @@ void MoveToolset::gridCoarse() { - m_config->setGrid (Grid::Coarse); + Config->setGrid (Grid::Coarse); m_window->updateGridToolBar(); } void MoveToolset::gridMedium() { - m_config->setGrid (Grid::Medium); + Config->setGrid (Grid::Medium); m_window->updateGridToolBar(); } void MoveToolset::gridFine() { - m_config->setGrid (Grid::Fine); + Config->setGrid (Grid::Fine); m_window->updateGridToolBar(); }
--- a/src/toolsets/viewtoolset.cpp Sat Oct 24 13:19:27 2015 +0300 +++ b/src/toolsets/viewtoolset.cpp Wed Nov 18 19:05:22 2015 +0200 @@ -26,6 +26,7 @@ #include "../colors.h" #include "../dialogs.h" #include "../glCompiler.h" +#include "../documentmanager.h" #include "viewtoolset.h" ViewToolset::ViewToolset (MainWindow *parent) : @@ -125,7 +126,7 @@ void ViewToolset::axes() { - m_config->setDrawAxes (not m_config->drawAxes()); + Config->setDrawAxes (not Config->drawAxes()); m_window->updateActions(); m_window->renderer()->update(); } @@ -150,7 +151,7 @@ void ViewToolset::wireframe() { - m_config->setDrawWireframe (not m_config->drawWireframe()); + Config->setDrawWireframe (not Config->drawWireframe()); m_window->renderer()->refresh(); } @@ -172,7 +173,7 @@ void ViewToolset::drawAngles() { - m_config->setDrawAngles (not m_config->drawAngles()); + Config->setDrawAngles (not Config->drawAngles()); m_window->renderer()->refresh(); } @@ -241,10 +242,10 @@ void ViewToolset::bfcView() { - m_config->setBfcRedGreenView (not m_config->bfcRedGreenView()); + Config->setBfcRedGreenView (not Config->bfcRedGreenView()); - if (m_config->bfcRedGreenView()) - m_config->setRandomColors (false); + if (Config->bfcRedGreenView()) + Config->setRandomColors (false); m_window->updateActions(); m_window->renderer()->refresh(); @@ -272,10 +273,10 @@ void ViewToolset::randomColors() { - m_config->setRandomColors (not m_config->randomColors()); + Config->setRandomColors (not Config->randomColors()); - if (m_config->randomColors()) - m_config->setBfcRedGreenView (false); + if (Config->randomColors()) + Config->setBfcRedGreenView (false); m_window->updateActions(); m_window->renderer()->refresh(); @@ -283,18 +284,18 @@ void ViewToolset::drawSurfaces() { - m_config->setDrawSurfaces (not m_config->drawSurfaces()); + Config->setDrawSurfaces (not Config->drawSurfaces()); m_window->updateActions(); } void ViewToolset::drawEdgeLines() { - m_config->setDrawEdgeLines (not m_config->drawEdgeLines()); + Config->setDrawEdgeLines (not Config->drawEdgeLines()); m_window->updateActions(); } void ViewToolset::drawConditionalLines() { - m_config->setDrawConditionalLines (not m_config->drawConditionalLines()); + Config->setDrawConditionalLines (not Config->drawConditionalLines()); m_window->updateActions(); } \ No newline at end of file
--- a/tools/configcollector.py Sat Oct 24 13:19:27 2015 +0300 +++ b/tools/configcollector.py Wed Nov 18 19:05:22 2015 +0200 @@ -158,7 +158,7 @@ write ('class ConfigurationValueBag\n') write ('{\n') write ('public:\n') - write ('\tConfigurationValueBag (class MainWindow* window);\n') + write ('\tConfigurationValueBag();\n') write ('\t~ConfigurationValueBag();\n') write ('\tbool existsEntry (const QString& name);\n') write ('\tQVariant defaultValueByName (const QString& name);\n') @@ -184,8 +184,8 @@ fp.write ( '\n' - 'ConfigurationValueBag::ConfigurationValueBag (MainWindow* window) :\n' - '\tm_settings (window->makeSettings (nullptr))\n' + 'ConfigurationValueBag::ConfigurationValueBag() :\n' + '\tm_settings (makeSettings (nullptr))\n' '{\n') for decl in self.decls: @@ -250,4 +250,4 @@ source.save (verbose = True) if __name__ == '__main__': - main() \ No newline at end of file + main()