/* The dialog that pops up when "preferences" is clicked in the menu. */ Preferences::Preferences(MainWindow *mainWindow) : QDialog( 0 ) { this->mainWindow = mainWindow; setupUi(this); connect(buttonBox, SIGNAL(accepted()), this, SLOT(applyChanges())); connect(browseWorkspaceButton, SIGNAL(clicked()), this, SLOT(browseWorkspace())); connect(fontButton, SIGNAL(clicked()), this, SLOT(getNewFont())); // initialize the parts that the main window needs to know about QSettings settings("MakingThings", "mcbuilder"); QString editorFont = settings.value("editorFont", DEFAULT_FONT).toString(); int editorFontSize = settings.value("editorFontSize", DEFAULT_FONT_SIZE).toInt(); currentFont = QFont(editorFont, editorFontSize); tempFont = currentFont; mainWindow->setEditorFont(editorFont, editorFontSize); fontBox->setText(QString("%1, %2pt").arg(editorFont).arg(editorFontSize)); mainWindow->setTabWidth( settings.value("tabWidth", DEFAULT_TAB_WIDTH).toInt() ); }
void Properties::setupFolders() { QVBoxLayout *layout = new QVBoxLayout(this); QFrame *box = new QFrame(); box->setLayout(layout); tabWidget.addTab(box," Folders "); QGroupBox *gbCompiler = new QGroupBox(tr("Compiler"), this); QGroupBox *gbIncludes = new QGroupBox(tr("Loader Folder"), this); QGroupBox *gbWorkspace = new QGroupBox(tr("Workspace Folder"), this); QPushButton *btnCompilerBrowse = new QPushButton(tr("Browse"), this); leditCompiler = new QLineEdit(this); QHBoxLayout *clayout = new QHBoxLayout(); clayout->addWidget(leditCompiler); clayout->addWidget(btnCompilerBrowse); QPushButton *btnIncludesBrowse = new QPushButton(tr("Browse"), this); leditIncludes = new QLineEdit(this); QHBoxLayout *ilayout = new QHBoxLayout(); ilayout->addWidget(leditIncludes); ilayout->addWidget(btnIncludesBrowse); QPushButton *btnWorkspaceBrowse = new QPushButton(tr("Browse"), this); leditWorkspace = new QLineEdit(this); QHBoxLayout *wlayout = new QHBoxLayout(); wlayout->addWidget(leditWorkspace); wlayout->addWidget(btnWorkspaceBrowse); connect(btnCompilerBrowse, SIGNAL(clicked()), this, SLOT(browseCompiler())); connect(btnIncludesBrowse, SIGNAL(clicked()), this, SLOT(browseIncludes())); connect(btnWorkspaceBrowse, SIGNAL(clicked()), this, SLOT(browseWorkspace())); gbCompiler->setLayout(clayout); gbIncludes->setLayout(ilayout); gbWorkspace->setLayout(wlayout); layout->addWidget(gbCompiler); layout->addWidget(gbIncludes); layout->addWidget(gbWorkspace); QSettings settings(publisherKey, ASideGuiKey,this); #if defined(Q_WS_WIN32) mypath = "C:/propgcc/"; QString mygcc = mypath+"bin/propeller-elf-gcc.exe"; #elif defined(Q_WS_MAC) QString apath = QApplication::applicationFilePath(); apath = apath.mid(0,apath.lastIndexOf(".app")); apath = apath.mid(0,apath.lastIndexOf("/")); mypath = apath+"/parallax/"; QString mygcc = mypath+"bin/propeller-elf-gcc"; #else mypath = "/opt/parallax/"; QString mygcc = mypath+"bin/propeller-elf-gcc"; if(QFile::exists(mygcc) == false) { qDebug() << "Alternative Default Compiler?"; mypath = "./parallax/"; mygcc = mypath+"bin/propeller-elf-gcc"; } #endif QString myinc = mypath+"propeller-load/"; if(QFile::exists(mygcc)) qDebug() << "Found Default Compiler."; if(QFile::exists(myinc)) qDebug() << "Found Default Loader Path."; QVariant compv = settings.value(compilerKey,mygcc); QVariant incv = settings.value(includesKey,myinc); QVariant wrkv = settings.value(workspaceKey); if(compv.canConvert(QVariant::String)) { QString s = compv.toString(); if(s.length() > 0) { s = QDir::fromNativeSeparators(s); leditCompiler->setText(s); } else { leditCompiler->setText(mygcc); settings.setValue(compilerKey,mygcc); } } else { leditCompiler->setText(mygcc); settings.setValue(compilerKey,mygcc); } if(incv.canConvert(QVariant::String)) { QString s = incv.toString(); if(s.length() > 0) { s = QDir::fromNativeSeparators(s); leditIncludes->setText(s); } else { leditIncludes->setText(myinc); settings.setValue(includesKey,myinc); } } else { leditIncludes->setText(myinc); settings.setValue(includesKey,myinc); } if(wrkv.canConvert(QVariant::String)) { QString s = wrkv.toString(); s = QDir::fromNativeSeparators(s); leditWorkspace->setText(s); } }