# HG changeset patch # User Teemu Piippo # Date 1406418021 -10800 # Node ID 68410477c8bb6e18f6b75de9f4cf4f57ed41daf2 # Parent 274a7fac44fcb100f2971208d004c91642af4bd2 - refactoring - removed the non-CA license option, made CA license a checkbox diff -r 274a7fac44fc -r 68410477c8bb codegen/codegen.cpp --- a/codegen/codegen.cpp Sat Jul 26 03:43:37 2014 +0300 +++ b/codegen/codegen.cpp Sun Jul 27 02:40:21 2014 +0300 @@ -161,12 +161,16 @@ os << "EXTERN_CFGENTRY (" << it->type << ", " << it->name << ")" << endl; os << endl; - os << "static void initConfigurationEntry (ConfigEntry* entry);" << endl; - os << "static void setupConfigurationLists()" << endl; + os << "static void InitConfigurationEntry (AbstractConfigEntry* entry);" << endl; + os << "static void SetupConfigurationLists()" << endl; os << "{" << endl; for (vector::const_iterator it = entries.begin(); it != entries.end(); ++it) - os << "\tinitConfigurationEntry (new " << it->type << "ConfigEntry (&cfg::" << it->name << ", \"" << it->name << "\", " << it->defvalue << "));" << endl; + { + os << "\tInitConfigurationEntry (new " << it->type << "ConfigEntry (&cfg::" << + it->name << ", \"" << it->name << "\", " << it->defvalue << "));" << endl; + } + os << "}" << endl; cout << "Wrote configuration options list to " << argv[argc - 1] << "." << endl; diff -r 274a7fac44fc -r 68410477c8bb src/actions.cc --- a/src/actions.cc Sat Jul 26 03:43:37 2014 +0300 +++ b/src/actions.cc Sun Jul 27 02:40:21 2014 +0300 @@ -43,7 +43,7 @@ EXTERN_CFGENTRY (Bool, bfcRedGreenView); EXTERN_CFGENTRY (String, defaultName); EXTERN_CFGENTRY (String, defaultUser); -EXTERN_CFGENTRY (Int, defaultLicense); +EXTERN_CFGENTRY (Bool, UseCALicense); EXTERN_CFGENTRY (Bool, drawAngles); EXTERN_CFGENTRY (Bool, randomColors) EXTERN_CFGENTRY (Bool, drawSurfaces) @@ -64,26 +64,7 @@ authortext.append (format (" [%1]", cfg::defaultUser)); ui.le_author->setText (authortext); - - switch (cfg::defaultLicense) - { - case 0: - ui.rb_license_ca->setChecked (true); - break; - - case 1: - ui.rb_license_nonca->setChecked (true); - break; - - case 2: - ui.rb_license_none->setChecked (true); - break; - - default: - QMessageBox::warning (null, "Warning", - format ("Unknown ld_defaultlicense value %1!", cfg::defaultLicense)); - break; - } + ui.caLicense->setChecked (cfg::UseCALicense); if (dlg->exec() == QDialog::Rejected) return; @@ -93,10 +74,7 @@ BFCStatement const bfctype = ui.rb_bfc_ccw->isChecked() ? BFCStatement::CertifyCCW : ui.rb_bfc_cw->isChecked() ? BFCStatement::CertifyCW : BFCStatement::NoCertify; - - QString const license = - ui.rb_license_ca->isChecked() ? g_CALicense : - ui.rb_license_nonca->isChecked() ? g_nonCALicense : ""; + QString const license = ui.caLicense->isChecked() ? CALicenseText : ""; LDObjectList objs; objs << spawn (ui.le_title->text()); @@ -754,7 +732,7 @@ LDCommentPtr titleobj (getCurrentDocument()->getObject (0).dynamicCast()); // License text for the subfile - QString license (getLicenseText (cfg::defaultLicense)); + QString license (PreferredLicenseText()); // LDraw code body of the new subfile (i.e. code of the selection) QStringList code; diff -r 274a7fac44fc -r 68410477c8bb src/configDialog.cc --- a/src/configDialog.cc Sat Jul 26 03:43:37 2014 +0300 +++ b/src/configDialog.cc Sun Jul 27 02:40:21 2014 +0300 @@ -56,7 +56,7 @@ EXTERN_CFGENTRY (Bool, drawLineLengths); EXTERN_CFGENTRY (String, defaultName); EXTERN_CFGENTRY (String, defaultUser); -EXTERN_CFGENTRY (Int, defaultLicense); +EXTERN_CFGENTRY (Bool, UseCALicense); EXTERN_CFGENTRY (String, selectColorBlend); EXTERN_CFGENTRY (String, ytruderPath); EXTERN_CFGENTRY (String, rectifierPath); @@ -178,7 +178,7 @@ ui->m_profileName->setText (cfg::defaultName); ui->m_profileUsername->setText (cfg::defaultUser); - ui->m_profileLicense->setCurrentIndex (cfg::defaultLicense); + ui->UseCALicense->setChecked (cfg::UseCALicense); ui->gridCoarseCoordinateSnap->setValue (cfg::gridCoarseCoordinateSnap); ui->gridCoarseAngleSnap->setValue (cfg::gridCoarseAngleSnap); ui->gridMediumCoordinateSnap->setValue (cfg::gridMediumCoordinateSnap); @@ -295,7 +295,7 @@ cfg::drawLineLengths = ui->linelengths->isChecked(); cfg::defaultUser = ui->m_profileUsername->text(); cfg::defaultName = ui->m_profileName->text(); - cfg::defaultLicense = ui->m_profileLicense->currentIndex(); + cfg::UseCALicense = ui->UseCALicense->isChecked(); cfg::antiAliasedLines = ui->m_aa->isChecked(); cfg::highlightObjectBelowCursor = ui->highlightObjectBelowCursor->isChecked(); cfg::roundPosition = ui->roundPosition->value(); @@ -329,7 +329,7 @@ item->action()->setShortcut (item->sequence()); } - Config::save(); + Config::Save(); reloadAllSubfiles(); loadLogoedStuds(); g_win->R()->setBackground(); diff -r 274a7fac44fc -r 68410477c8bb src/configuration.cc --- a/src/configuration.cc Sat Jul 26 03:43:37 2014 +0300 +++ b/src/configuration.cc Sun Jul 27 02:40:21 2014 +0300 @@ -42,33 +42,33 @@ #define MAX_CONFIG 512 -static QMap g_configsByName; -static QList g_configs; +static QMap EntriesByName; +static QList ConfigurationEntries; -ConfigEntry::ConfigEntry (QString name) : +AbstractConfigEntry::AbstractConfigEntry (QString name) : m_name (name) {} -void Config::init() +void Config::Initialize() { - setupConfigurationLists(); - print ("Configuration initialized with %1 entries\n", g_configs.size()); + SetupConfigurationLists(); + print ("Configuration initialized with %1 entries\n", ConfigurationEntries.size()); } -static void initConfigurationEntry (ConfigEntry* entry) +static void InitConfigurationEntry (AbstractConfigEntry* entry) { - g_configs << entry; - g_configsByName[entry->name()] = entry; + ConfigurationEntries << entry; + EntriesByName[entry->name()] = entry; } // // Load the configuration from file // -bool Config::load() +bool Config::Load() { - QSettings* settings = settingsObject(); + QSettings* settings = SettingsObject(); print ("Loading configuration file from %1\n", settings->fileName()); - for (ConfigEntry* cfg : g_configs) + for (AbstractConfigEntry* cfg : ConfigurationEntries) { if (cfg == null) break; @@ -87,11 +87,11 @@ // // Save the configuration to disk // -bool Config::save() +bool Config::Save() { - QSettings* settings = settingsObject(); + QSettings* settings = SettingsObject(); - for (ConfigEntry* cfg : g_configs) + for (AbstractConfigEntry* cfg : ConfigurationEntries) { if (not cfg->isDefault()) settings->setValue (cfg->name(), cfg->toVariant()); @@ -111,26 +111,26 @@ // // Reset configuration to defaults. // -void Config::reset() +void Config::ResetToDefaults() { - for (ConfigEntry* cfg : g_configs) + for (AbstractConfigEntry* cfg : ConfigurationEntries) cfg->resetValue(); } // // Where is the configuration file located at? // -QString Config::filepath (QString file) +QString Config::FilePath (QString file) { - return Config::dirpath() + DIRSLASH + file; + return Config::DirectoryPath() + DIRSLASH + file; } // // Directory of the configuration file. // -QString Config::dirpath() +QString Config::DirectoryPath() { - QSettings* settings = settingsObject(); + QSettings* settings = SettingsObject(); QString result = dirname (settings->fileName()); delete settings; return result; @@ -139,21 +139,21 @@ // // Accessor to the settings object // -QSettings* Config::settingsObject() +QSettings* Config::SettingsObject() { QString path = qApp->applicationDirPath() + "/" UNIXNAME EXTENSION; return new QSettings (path, QSettings::IniFormat); } template -T* getConfigByName (QString name, ConfigEntry::Type type) +static T* GetConfigByName (QString name, AbstractConfigEntry::Type type) { - auto it = g_configsByName.find (name); + auto it = EntriesByName.find (name); - if (it == g_configsByName.end()) + if (it == EntriesByName.end()) return null; - ConfigEntry* cfg = it.value(); + AbstractConfigEntry* cfg = it.value(); if (cfg->getType() != type) { @@ -169,7 +169,7 @@ #define IMPLEMENT_CONFIG(NAME) \ NAME##ConfigEntry* NAME##ConfigEntry::getByName (QString name) \ { \ - return getConfigByName (name, E##NAME##Type); \ + return GetConfigByName (name, E##NAME##Type); \ } IMPLEMENT_CONFIG (Int) diff -r 274a7fac44fc -r 68410477c8bb src/configuration.h --- a/src/configuration.h Sat Jul 26 03:43:37 2014 +0300 +++ b/src/configuration.h Sun Jul 27 02:40:21 2014 +0300 @@ -25,21 +25,21 @@ class QSettings; -#define CFGENTRY(T, NAME, DEFAULT) namespace cfg { ConfigEntry::T##Type NAME; } -#define EXTERN_CFGENTRY(T, NAME) namespace cfg { extern ConfigEntry::T##Type NAME; } +#define CFGENTRY(T, NAME, DEFAULT) namespace cfg { AbstractConfigEntry::T##Type NAME; } +#define EXTERN_CFGENTRY(T, NAME) namespace cfg { extern AbstractConfigEntry::T##Type NAME; } namespace Config { - void init(); - bool load(); - bool save(); - void reset(); - QString dirpath(); - QString filepath (QString file); - QSettings* settingsObject(); + void Initialize(); + bool Load(); + bool Save(); + void ResetToDefaults(); + QString DirectoryPath(); + QString FilePath (QString file); + QSettings* SettingsObject(); } -class ConfigEntry +class AbstractConfigEntry { PROPERTY (private, QString, name, setName, STOCK_WRITE) @@ -63,7 +63,7 @@ using ListType = QList; using VertexType = Vertex; - ConfigEntry (QString name); + AbstractConfigEntry (QString name); virtual QVariant getDefaultAsVariant() const = 0; virtual Type getType() const = 0; @@ -73,13 +73,12 @@ virtual QVariant toVariant() const = 0; }; -// ============================================================================= #define IMPLEMENT_CONFIG(NAME) \ public: \ - using ValueType = ConfigEntry::NAME##Type; \ + using ValueType = AbstractConfigEntry::NAME##Type; \ \ NAME##ConfigEntry (ValueType* valueptr, QString name, ValueType def) : \ - ConfigEntry (name), \ + AbstractConfigEntry (name), \ m_valueptr (valueptr), \ m_default (def) \ { \ @@ -96,9 +95,9 @@ *m_valueptr = val; \ } \ \ - virtual ConfigEntry::Type getType() const \ + virtual AbstractConfigEntry::Type getType() const \ { \ - return ConfigEntry::E##NAME##Type; \ + return AbstractConfigEntry::E##NAME##Type; \ } \ \ virtual void resetValue() \ @@ -137,39 +136,37 @@ ValueType* m_valueptr; \ ValueType m_default; -// ============================================================================= -// -class IntConfigEntry : public ConfigEntry +class IntConfigEntry : public AbstractConfigEntry { IMPLEMENT_CONFIG (Int) }; -class StringConfigEntry : public ConfigEntry +class StringConfigEntry : public AbstractConfigEntry { IMPLEMENT_CONFIG (String) }; -class FloatConfigEntry : public ConfigEntry +class FloatConfigEntry : public AbstractConfigEntry { IMPLEMENT_CONFIG (Float) }; -class BoolConfigEntry : public ConfigEntry +class BoolConfigEntry : public AbstractConfigEntry { IMPLEMENT_CONFIG (Bool) }; -class KeySequenceConfigEntry : public ConfigEntry +class KeySequenceConfigEntry : public AbstractConfigEntry { IMPLEMENT_CONFIG (KeySequence) }; -class ListConfigEntry : public ConfigEntry +class ListConfigEntry : public AbstractConfigEntry { IMPLEMENT_CONFIG (List) }; -class VertexConfigEntry : public ConfigEntry +class VertexConfigEntry : public AbstractConfigEntry { IMPLEMENT_CONFIG (Vertex) }; diff -r 274a7fac44fc -r 68410477c8bb src/crashCatcher.cc --- a/src/crashCatcher.cc Sat Jul 26 03:43:37 2014 +0300 +++ b/src/crashCatcher.cc Sun Jul 27 02:40:21 2014 +0300 @@ -29,23 +29,24 @@ #endif // Is the crash catcher active now? -static bool g_crashCatcherActive = false; +static bool IsCrashCatcherActive = false; // If an assertion failed, what was it? -static QString g_assertionFailure; +static QString AssertionFailureText; // List of signals to catch and crash on -static QList g_signalsToCatch ({ +static QList SignalsToCatch ({ SIGSEGV, // segmentation fault SIGABRT, // abort() calls SIGFPE, // floating point exceptions (e.g. division by zero) SIGILL, // illegal instructions }); +// ------------------------------------------------------------------------------------------------- // // Removes the signal handler from SIGABRT and then aborts. // -static void finalAbort() +static void FinalAbort() { struct sigaction sighandler; sighandler.sa_handler = SIG_DFL; @@ -54,23 +55,23 @@ abort(); } -// ============================================================================= +// ------------------------------------------------------------------------------------------------- // -static void handleCrash (int sig) +static void HandleCrash (int sig) { printf ("!! Caught signal %d, launching gdb\n", sig); - if (g_crashCatcherActive) + if (IsCrashCatcherActive) { printf ("Caught signal while crash catcher is active! Execution cannot continue.\n"); - finalAbort(); + FinalAbort(); } - const pid_t pid = getpid(); + pid_t const pid (getpid()); QProcess proc; QTemporaryFile commandsFile; - g_crashCatcherActive = true; + IsCrashCatcherActive = true; if (commandsFile.open()) { @@ -91,67 +92,62 @@ #endif proc.waitForFinished (1000); - QString output = QString (proc.readAllStandardOutput()); - QString err = QString (proc.readAllStandardError()); + QString output (proc.readAllStandardOutput()); + QString err (proc.readAllStandardError()); QFile f (UNIXNAME "-crash.log"); if (f.open (QIODevice::WriteOnly)) { fprint (f, format ("=== Program crashed with signal %1 ===\n\n%2" - "GDB stdout:\n%3\n" - "GDB stderr:\n%4\n", - sig, (not g_assertionFailure.isEmpty()) ? g_assertionFailure + "\n\n" : "", output, err)); + "GDB stdout:\n%3\nGDB stderr:\n%4\n", sig, + (not AssertionFailureText.isEmpty()) ? AssertionFailureText + "\n\n" : "", + output, err)); f.close(); } - if (g_assertionFailure.isEmpty()) - { - printf ("Crashlog written to " UNIXNAME "-crash.log. Aborting.\n"); - } - else - { - printf ("Assertion failed: \"%s\". Backtrace written to " UNIXNAME "-crash.log.\n", - qPrintable (g_assertionFailure)); - } + if (not AssertionFailureText.isEmpty()) + printf ("Assertion failed: \"%s\".\n", qPrintable (AssertionFailureText)); - finalAbort(); + printf ("Backtrace written to " UNIXNAME "-crash.log. Aborting.\n"); + FinalAbort(); } +// ------------------------------------------------------------------------------------------------- // // Initializes the crash catcher. // -void initCrashCatcher() +void InitCrashCatcher() { struct sigaction sighandler; - sighandler.sa_handler = &handleCrash; + sighandler.sa_handler = &HandleCrash; sighandler.sa_flags = 0; sigemptyset (&sighandler.sa_mask); - for (int sig : g_signalsToCatch) + for (int sig : SignalsToCatch) { if (sigaction (sig, &sighandler, null) == -1) { fprint (stderr, "Couldn't set signal handler %1: %2", sig, strerror (errno)); - g_signalsToCatch.removeOne (sig); + SignalsToCatch.removeOne (sig); } } - print ("Crash catcher hooked to signals: %1\n", g_signalsToCatch); + print ("Crash catcher hooked to signals: %1\n", SignalsToCatch); } #endif // #ifdef __unix__ -// ============================================================================= +// ------------------------------------------------------------------------------------------------- // -// This function must be readily available in both Windows and Linux. We display -// the bomb box straight in Windows while in Linux we let abort() trigger the -// signal handler, which will cause the usual bomb box with GDB diagnostics. -// Said prompt will embed the assertion failure information. +// This function catches an assertion failure. It must be readily available in both Windows and +// Linux. We display the bomb box straight in Windows while in Linux we let abort() trigger +// the signal handler, which will cause the usual bomb box with GDB diagnostics. Said prompt will +// embed the assertion failure information. // void assertionFailure (const char* file, int line, const char* funcname, const char* expr) { #ifdef __unix__ - g_assertionFailure = format ("%1:%2: %3: %4", file, line, funcname, expr); + AssertionFailureText = format ("%1:%2: %3: %4", file, line, funcname, expr); #else bombBox (format ( "

File: %1
" diff -r 274a7fac44fc -r 68410477c8bb src/crashCatcher.h --- a/src/crashCatcher.h Sat Jul 26 03:43:37 2014 +0300 +++ b/src/crashCatcher.h Sun Jul 27 02:40:21 2014 +0300 @@ -20,7 +20,7 @@ #include "main.h" #ifdef __unix__ -void initCrashCatcher(); +void InitCrashCatcher(); #else // ifdef __unix__ -# define initCrashCatcher() +# define InitCrashCatcher() #endif // ifdef __unix__ diff -r 274a7fac44fc -r 68410477c8bb src/dialogs.cc --- a/src/dialogs.cc Sat Jul 26 03:43:37 2014 +0300 +++ b/src/dialogs.cc Sun Jul 27 02:40:21 2014 +0300 @@ -255,7 +255,7 @@ // ============================================================================= void LDrawPathDialog::slot_accept() { - Config::save(); + Config::Save(); accept(); } diff -r 274a7fac44fc -r 68410477c8bb src/editmodes/circleMode.cc --- a/src/editmodes/circleMode.cc Sat Jul 26 03:43:37 2014 +0300 +++ b/src/editmodes/circleMode.cc Sun Jul 27 02:40:21 2014 +0300 @@ -71,7 +71,7 @@ void CircleMode::buildCircle() { LDObjectList objs; - const int segs = g_lores, divs = g_lores; // TODO: make customizable + const int segs = LowResolution, divs = LowResolution; // TODO: make customizable double dist0 = getCircleDrawDist (0), dist1 = getCircleDrawDist (1); LDDocumentPtr refFile; @@ -102,9 +102,10 @@ { // Get a ref file for this primitive. If we cannot find it in the // LDraw library, generate it. - if ((refFile = ::getDocument (radialFileName (::Ring, g_lores, g_lores, cmp.num))) == null) + if ((refFile = ::getDocument (radialFileName (::Ring, LowResolution, LowResolution, +cmp.num))) == null) { - refFile = generatePrimitive (::Ring, g_lores, g_lores, cmp.num); + refFile = generatePrimitive (::Ring, LowResolution, LowResolution, cmp.num); refFile->setImplicit (false); } @@ -186,7 +187,7 @@ QVector verts, verts2; const double dist0 = getCircleDrawDist (0), dist1 = (_drawedVerts.size() >= 2) ? getCircleDrawDist (1) : -1; - const int segs = g_lores; + const int segs = LowResolution; const double angleUnit = (2 * pi) / segs; Axis relX, relY; QVector ringpoints, circlepoints, circle2points; diff -r 274a7fac44fc -r 68410477c8bb src/ldDocument.cc --- a/src/ldDocument.cc Sat Jul 26 03:43:37 2014 +0300 +++ b/src/ldDocument.cc Sun Jul 27 02:40:21 2014 +0300 @@ -675,7 +675,7 @@ // Add the file rfiles << path; - Config::save(); + Config::Save(); g_win->updateRecentFilesMenu(); } diff -r 274a7fac44fc -r 68410477c8bb src/ldObject.cc --- a/src/ldObject.cc Sat Jul 26 03:43:37 2014 +0300 +++ b/src/ldObject.cc Sun Jul 27 02:40:21 2014 +0300 @@ -27,9 +27,9 @@ #include "colors.h" #include "glCompiler.h" -CFGENTRY (String, defaultName, ""); -CFGENTRY (String, defaultUser, ""); -CFGENTRY (Int, defaultLicense, 0); +CFGENTRY (String, defaultName, ""); +CFGENTRY (String, defaultUser, ""); +CFGENTRY (Bool, UseCALicense, true); // List of all LDObjects QMap g_allObjects; @@ -887,22 +887,9 @@ // ============================================================================= // -QString getLicenseText (int id) +QString PreferredLicenseText() { - switch (id) - { - case 0: - return g_CALicense; - - case 1: - return g_nonCALicense; - - case 2: - return ""; - } - - assert (false); - return ""; + return (cfg::UseCALicense ? CALicenseText : ""); } // ============================================================================= diff -r 274a7fac44fc -r 68410477c8bb src/ldObject.h --- a/src/ldObject.h Sat Jul 26 03:43:37 2014 +0300 +++ b/src/ldObject.h Sun Jul 27 02:40:21 2014 +0300 @@ -598,9 +598,9 @@ using LDOverlayWeakPtr = QWeakPointer; // Other common LDraw stuff -static const QString g_CALicense ("!LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt"); -static const QString g_nonCALicense ("!LICENSE Not redistributable : see NonCAreadme.txt"); -static const int g_lores = 16; -static const int g_hires = 48; +static const QString CALicenseText ("!LICENSE Redistributable under CCAL version 2.0 : " + "see CAreadme.txt"); +static const int LowResolution = 16; +static const int HighResolution = 48; -QString getLicenseText (int id); +QString PreferredLicenseText(); diff -r 274a7fac44fc -r 68410477c8bb src/main.cc --- a/src/main.cc Sat Jul 26 03:43:37 2014 +0300 +++ b/src/main.cc Sun Jul 27 02:40:21 2014 +0300 @@ -49,15 +49,15 @@ QApplication app (argc, argv); app.setOrganizationName (APPNAME); app.setApplicationName (APPNAME); - initCrashCatcher(); - Config::init(); + InitCrashCatcher(); + Config::Initialize(); // Load or create the configuration - if (not Config::load()) + if (not Config::Load()) { print ("Creating configuration file...\n"); - if (Config::save()) + if (Config::Save()) print ("Configuration file successfully created.\n"); else critical ("Failed to create configuration file!\n"); @@ -76,7 +76,7 @@ { (new ConfigDialog (ConfigDialog::ProfileTab))->exec(); cfg::firstStart = false; - Config::save(); + Config::Save(); } return app.exec(); diff -r 274a7fac44fc -r 68410477c8bb src/mainWindow.cc --- a/src/mainWindow.cc Sat Jul 26 03:43:37 2014 +0300 +++ b/src/mainWindow.cc Sun Jul 27 02:40:21 2014 +0300 @@ -118,7 +118,7 @@ updateRecentFilesMenu(); updateColorToolbar(); updateTitle(); - loadShortcuts (Config::settingsObject()); + loadShortcuts (Config::SettingsObject()); setMinimumSize (300, 200); connect (qApp, SIGNAL (aboutToQuit()), this, SLOT (slot_lastSecondCleanup())); } @@ -598,7 +598,7 @@ // Save the configuration before leaving so that, for instance, grid choice // is preserved across instances. - Config::save(); + Config::Save(); ev->accept(); } diff -r 274a7fac44fc -r 68410477c8bb src/miscallenous.h --- a/src/miscallenous.h Sat Jul 26 03:43:37 2014 +0300 +++ b/src/miscallenous.h Sun Jul 27 02:40:21 2014 +0300 @@ -50,8 +50,8 @@ struct gridinfo { const char* name; - ConfigEntry::FloatType* coordsnap; - ConfigEntry::FloatType* anglesnap; + AbstractConfigEntry::FloatType* coordsnap; + AbstractConfigEntry::FloatType* anglesnap; }; EXTERN_CFGENTRY (Int, grid); diff -r 274a7fac44fc -r 68410477c8bb src/primitives.cc --- a/src/primitives.cc Sat Jul 26 03:43:37 2014 +0300 +++ b/src/primitives.cc Sun Jul 27 02:40:21 2014 +0300 @@ -55,7 +55,7 @@ void loadPrimitives() { // Try to load prims.cfg - QFile conf (Config::filepath ("prims.cfg")); + QFile conf (Config::FilePath ("prims.cfg")); if (not conf.open (QIODevice::ReadOnly)) { @@ -164,7 +164,7 @@ if (m_i == m_files.size()) { // Done with primitives, now save to a config file - QString path = Config::filepath ("prims.cfg"); + QString path = Config::FilePath ("prims.cfg"); QFile conf (path); if (not conf.open (QIODevice::WriteOnly | QIODevice::Text)) @@ -283,7 +283,7 @@ delete cat; g_PrimitiveCategories.clear(); - QString path = Config::dirpath() + "primregexps.cfg"; + QString path = Config::DirectoryPath() + "primregexps.cfg"; if (not QFile::exists (path)) path = ":/data/primitive-categories.cfg"; @@ -574,7 +574,7 @@ } // Compose some general information: prefix, fraction, root, ring number - QString prefix = (divs == g_lores) ? "" : format ("%1/", divs); + QString prefix = (divs == LowResolution) ? "" : format ("%1/", divs); QString frac = format ("%1-%2", numer, denom); QString root = g_radialNameRoots[type]; QString numstr = (type == Ring or type == Cone) ? format ("%1", num) : ""; @@ -613,7 +613,7 @@ descr = format ("%1 %2", primitiveTypeName (type), frac); // Prepend "Hi-Res" if 48/ primitive. - if (divs == g_hires) + if (divs == HighResolution) descr.insert (0, "Hi-Res "); LDDocumentPtr f = LDDocument::createNew(); @@ -624,7 +624,7 @@ if (not cfg::defaultName.isEmpty()) { - license = getLicenseText (cfg::defaultLicense); + license = PreferredLicenseText(); author = format ("%1 [%2]", cfg::defaultName, cfg::defaultUser); } @@ -633,7 +633,8 @@ objs << spawn (descr) << spawn (format ("Name: %1", name)) << spawn (format ("Author: %1", author)) - << spawn (format ("!LDRAW_ORG Unofficial_%1Primitive", divs == g_hires ? "48_" : "")) + << spawn (format ("!LDRAW_ORG Unofficial_%1Primitive", divs == HighResolution ? +"48_" : "")) << spawn (license) << spawn() << spawn (BFCStatement::CertifyCCW) @@ -678,12 +679,12 @@ // void PrimitivePrompt::hiResToggled (bool on) { - ui->sb_segs->setMaximum (on ? g_hires : g_lores); + ui->sb_segs->setMaximum (on ? HighResolution : LowResolution); // If the current value is 16 and we switch to hi-res, default the // spinbox to 48. - if (on and ui->sb_segs->value() == g_lores) - ui->sb_segs->setValue (g_hires); + if (on and ui->sb_segs->value() == LowResolution) + ui->sb_segs->setValue (HighResolution); } // ============================================================================= @@ -696,7 +697,7 @@ return; int segs = dlg->ui->sb_segs->value(); - int divs = dlg->ui->cb_hires->isChecked() ? g_hires : g_lores; + int divs = dlg->ui->cb_hires->isChecked() ? HighResolution : LowResolution; int num = dlg->ui->sb_ringnum->value(); PrimitiveType type = dlg->ui->rb_circle->isChecked() ? Circle : diff -r 274a7fac44fc -r 68410477c8bb ui/config.ui --- a/ui/config.ui Sat Jul 26 03:43:37 2014 +0300 +++ b/ui/config.ui Sun Jul 27 02:40:21 2014 +0300 @@ -79,7 +79,7 @@ - 0 + 2 @@ -391,13 +391,9 @@ - - - - Username: - - - + + QFormLayout::ExpandingFieldsGrow + @@ -405,42 +401,24 @@ - - + + + + + - License: + Username: - - - - - - - 0 - 0 - + + + Use CA license - - - CA - redistributable - - - - - NonCA - not redistributable - - - - - None - - diff -r 274a7fac44fc -r 68410477c8bb ui/newpart.ui --- a/ui/newpart.ui Sat Jul 26 03:43:37 2014 +0300 +++ b/ui/newpart.ui Sun Jul 27 02:40:21 2014 +0300 @@ -7,13 +7,13 @@ 0 0 491 - 203 + 233 New Part - + @@ -24,7 +24,7 @@ - :/icons/brick.png + :/icons/brick.png @@ -45,10 +45,17 @@ - - - - Title: + + + + + + + + + + + @@ -59,11 +66,12 @@ - - - - - + + + + Title: + + @@ -72,39 +80,6 @@ - - - License - - - - - - CCAL Redistributable - - - true - - - - - - - Non-redistributable - - - - - - - None - - - - - - - BFC winding @@ -137,6 +112,30 @@ + + + + + + Use CA license + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + @@ -152,6 +151,7 @@ +