void PrefSlider::savePreferences() { if (getWindowParameter().isNull()) { Console().Warning("Cannot save!\n"); return; } getWindowParameter()->SetInt(entryName() , (int)value()); }
void PrefRadioButton::savePreferences() { if (getWindowParameter().isNull()) { Console().Warning("Cannot save!\n"); return; } getWindowParameter()->SetBool( entryName() , isChecked() ); }
void PrefComboBox::savePreferences() { if (getWindowParameter().isNull()) { Console().Warning("Cannot save!\n"); return; } getWindowParameter()->SetInt(entryName() , currentIndex()); }
void PrefFileChooser::savePreferences() { if (getWindowParameter().isNull()) { Console().Warning("Cannot save!\n"); return; } getWindowParameter()->SetASCII(entryName(), fileName().toUtf8()); }
void PrefLineEdit::savePreferences() { if (getWindowParameter().isNull()) { Console().Warning("Cannot save!\n"); return; } getWindowParameter()->SetASCII(entryName(), text().toUtf8()); }
void PrefDoubleSpinBox::savePreferences() { if (getWindowParameter().isNull()) { Console().Warning("Cannot save!\n"); return; } getWindowParameter()->SetFloat( entryName(), value() ); }
void PrefSlider::restorePreferences() { if ( getWindowParameter().isNull() ) { Console().Warning("Cannot restore!\n"); return; } int nVal = getWindowParameter()->GetInt(entryName(), QSlider::value()); setValue(nVal); }
void PrefRadioButton::restorePreferences() { if (getWindowParameter().isNull()) { Console().Warning("Cannot restore!\n"); return; } bool enable = getWindowParameter()->GetBool( entryName(), isChecked() ); setChecked(enable); }
void PrefComboBox::restorePreferences() { if (getWindowParameter().isNull()) { Console().Warning("Cannot restore!\n"); return; } int index = getWindowParameter()->GetInt(entryName(), currentIndex()); setCurrentIndex(index); }
void PrefFileChooser::restorePreferences() { if (getWindowParameter().isNull()) { Console().Warning("Cannot restore!\n"); return; } QString txt = QString::fromUtf8(getWindowParameter()->GetASCII(entryName(), fileName().toUtf8()).c_str()); setFileName(txt); }
void PrefDoubleSpinBox::restorePreferences() { if ( getWindowParameter().isNull() ) { Console().Warning("Cannot restore!\n"); return; } double fVal = (double)getWindowParameter()->GetFloat( entryName() , value() ); setValue(fVal); }
void PrefLineEdit::restorePreferences() { if (getWindowParameter().isNull()) { Console().Warning("Cannot restore!\n"); return; } QString text = this->text(); text = QString::fromUtf8(getWindowParameter()->GetASCII(entryName(), text.toUtf8()).c_str()); setText(text); }
void PrefColorButton::savePreferences() { if (getWindowParameter().isNull()) { Console().Warning("Cannot save!\n"); return; } QColor col = color(); // (r,g,b,a) with a = 255 (opaque) unsigned long lcol = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8) | 255; getWindowParameter()->SetUnsigned( entryName(), lcol ); }
void PrefColorButton::restorePreferences() { if (getWindowParameter().isNull()) { Console().Warning("Cannot restore!\n"); return; } QColor col = color(); unsigned long lcol = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); lcol = getWindowParameter()->GetUnsigned( entryName(), lcol ); int r = (lcol >> 24)&0xff; int g = (lcol >> 16)&0xff; int b = (lcol >> 8)&0xff; setColor(QColor(r,g,b)); }
int main( int argc, char ** argv ) { // Make sure that we use '.' as decimal point #if defined(FC_OS_LINUX) putenv("LANG=C"); putenv("LC_ALL=C"); #else setlocale(LC_NUMERIC, "C"); #endif // Name and Version of the Application App::Application::Config()["ExeName"] = "FreeCAD"; App::Application::Config()["ExeVendor"] = "FreeCAD"; App::Application::Config()["AppDataSkipVendor"] = "true"; // set the banner (for logging and console) App::Application::Config()["CopyrightInfo"] = sBanner; try { // Init phase =========================================================== // sets the default run mode for FC, starts with command prompt if not overridden in InitConfig... App::Application::Config()["RunMode"] = "Exit"; // Inits the Application App::Application::init(argc,argv); } catch (const Base::UnknownProgramOption& e) { std::cerr << e.what(); exit(1); } catch (const Base::ProgramInformation& e) { std::cout << e.what(); exit(0); } catch (const Base::Exception& e) { std::string appName = App::Application::Config()["ExeName"]; std::stringstream msg; msg << "While initializing " << appName << " the following exception occurred: '" << e.what() << "'\n\n"; msg << "Python is searching for its runtime files in the following directories:\n" << Py_GetPath() << "\n\n"; msg << "Python version information:\n" << Py_GetVersion() << "\n"; const char* pythonhome = getenv("PYTHONHOME"); if ( pythonhome ) { msg << "\nThe environment variable PYTHONHOME is set to '" << pythonhome << "'."; msg << "\nSetting this environment variable might cause Python to fail. Please contact your administrator to unset it on your system.\n\n"; } else { msg << "\nPlease contact the application's support team for more information.\n\n"; } printf("Initialization of %s failed:\n%s", appName.c_str(), msg.str().c_str()); exit(100); } catch (...) { std::string appName = App::Application::Config()["ExeName"]; std::stringstream msg; msg << "Unknown runtime error occurred while initializing " << appName <<".\n\n"; msg << "Please contact the application's support team for more information.\n\n"; printf("Initialization of %s failed:\n%s", appName.c_str(), msg.str().c_str()); exit(101); } // Run phase =========================================================== Application::runApplication(); // Destruction phase =========================================================== Console().Log("FreeCAD terminating...\n"); // close open documents App::GetApplication().closeAllDocuments(); // cleans up Application::destruct(); Console().Log("FreeCAD completely terminated\n"); return 0; }