Exemplo n.º 1
0
void ResourcesDialog::init()
{
	QSETTINGS_OBJECT(s);

	setupUi(this);
	
#if defined(Q_OS_WIN)
	if(ConfigurableApp::instance()->getSettingsFormat() == QSettings::NativeFormat)
		locationOfSettings->setText(tr("Registry (%1)").arg(s.fileName()));
	else
		locationOfSettings->setText(pathToLink(s.fileName()));
#else
	locationOfSettings->setText(pathToLink(s.fileName()));
#endif

	locationOfResources->setText(pathToLink(TWUtils::getLibraryPath(QString(), false)));

	connect(locationOfSettings, SIGNAL(linkActivated(const QString&)), this, SLOT(openURL(const QString&)));
	connect(locationOfResources, SIGNAL(linkActivated(const QString&)), this, SLOT(openURL(const QString&)));

	adjustSize();

// TODO: Implement Details (e.g., files that are versioned, ...)
//	connect(labelDetails, SIGNAL(linkActivated(const QString&)), this, SLOT(toggleDetails()));
//	toggleDetails();
}
Exemplo n.º 2
0
void TemplateDialog::init()
{
	setupUi(this);

	QString templatePath = TWUtils::getLibraryPath("templates");
		// do this before creating the model, as getLibraryPath might initialize a new dir
		
	model = new QDirModel(this);
	treeView->setModel(model);
	treeView->setRootIndex(model->index(templatePath));
	treeView->expandAll();
	treeView->resizeColumnToContents(0);
	treeView->hideColumn(2);
	treeView->collapseAll();
	
	connect(treeView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
			this, SLOT(selectionChanged(const QItemSelection&, const QItemSelection&)));
	
	connect(treeView, SIGNAL(activated(const QModelIndex&)), this, SLOT(itemActivated(const QModelIndex&)));

	QSETTINGS_OBJECT(settings);
	if (settings.value("syntaxColoring", true).toBool()) {
		new TeXHighlighter(textEdit->document());
	}
}
Exemplo n.º 3
0
void
HardWrapDialog::saveSettings()
{
	QSETTINGS_OBJECT(settings);
	settings.setValue("hardWrapWidth", spinbox_charCount->value());
	settings.setValue("hardWrapMode", mode());
	settings.setValue("hardWrapRewrap", checkbox_rewrap->isChecked());
}
Exemplo n.º 4
0
bool JSScript::execute(TWScriptAPI *tw) const
{
	QFile scriptFile(m_Filename);
	if (!scriptFile.open(QIODevice::ReadOnly)) {
		// handle error
		return false;
	}
	QTextStream stream(&scriptFile);
	stream.setCodec(m_Codec);
	QString contents = stream.readAll();
	scriptFile.close();
	
	QScriptEngine engine;
	QScriptValue twObject = engine.newQObject(tw);
	engine.globalObject().setProperty("TW", twObject);
	
	QScriptValue val;

#if QT_VERSION >= 0x040500
	QSETTINGS_OBJECT(settings);
	if (settings.value("scriptDebugger", false).toBool()) {
		QScriptEngineDebugger debugger;
		debugger.attachTo(&engine);
		val = engine.evaluate(contents, m_Filename);
	}
	else {
		val = engine.evaluate(contents, m_Filename);
	}
#else
	val = engine.evaluate(contents, m_Filename);
#endif

	if (engine.hasUncaughtException()) {
		tw->SetResult(engine.uncaughtException().toString());
		return false;
	}
	else {
		if (!val.isUndefined()) {
			tw->SetResult(convertValue(val));
		}
		return true;
	}
}
Exemplo n.º 5
0
void
HardWrapDialog::init()
{
	QSETTINGS_OBJECT(settings);
	int	wrapWidth = settings.value("hardWrapWidth", kDefault_HardWrapWidth).toInt();
	spinbox_charCount->setMaximum(INT_MAX);
	spinbox_charCount->setValue(wrapWidth);
	spinbox_charCount->selectAll();
	
	connect(radio_Unwrap, SIGNAL(toggled(bool)), this, SLOT(unwrapModeToggled(bool)));

	int wrapMode = settings.value("hardWrapMode", kHardWrapMode_Fixed).toInt();
	radio_currentWidth->setChecked(wrapMode == kHardWrapMode_Window);
	radio_fixedLineLength->setChecked(wrapMode == kHardWrapMode_Fixed);
	radio_Unwrap->setChecked(wrapMode == kHardWrapMode_Unwrap);
	
	bool rewrapParagraphs = settings.value("hardWrapRewrap", false).toBool();
	checkbox_rewrap->setChecked(rewrapParagraphs);

#ifdef Q_WS_MAC
	setWindowFlags(Qt::Sheet);
#endif
}