コード例 #1
0
ファイル: globe.cpp プロジェクト: Jheengut/subsurface
GlobeGPS::GlobeGPS(QWidget *parent) : MarbleWidget(parent),
    loadedDives(0),
    messageWidget(new KMessageWidget(this)),
    fixZoomTimer(new QTimer(this)),
    currentZoomLevel(0),
    needResetZoom(false),
    editingDiveLocation(false)
{
    // check if Google Sat Maps are installed
    // if not, check if they are in a known location
    MapThemeManager mtm;
    QStringList list = mtm.mapThemeIds();
    QString subsurfaceDataPath;
    QDir marble;
    if (!list.contains("earth/googlesat/googlesat.dgml")) {
        subsurfaceDataPath = getSubsurfaceDataPath("marbledata");
        if (subsurfaceDataPath.size()) {
            MarbleDirs::setMarbleDataPath(subsurfaceDataPath);
        } else {
            subsurfaceDataPath = getSubsurfaceDataPath("data");
            if (subsurfaceDataPath.size())
                MarbleDirs::setMarbleDataPath(subsurfaceDataPath);
        }
    }
    messageWidget->setCloseButtonVisible(false);
    messageWidget->setHidden(true);

    setMapThemeId("earth/googlesat/googlesat.dgml");
    //setMapThemeId("earth/openstreetmap/openstreetmap.dgml");
    setProjection(Marble::Spherical);

    setAnimationsEnabled(true);
    Q_FOREACH (AbstractFloatItem *i, floatItems()) {
        i->setVisible(false);
    }
コード例 #2
0
ファイル: qt-init.cpp プロジェクト: neolit123/subsurface
void init_qt_late()
{
	QApplication *application = qApp;
	// tell Qt to use system proxies
	// note: on Linux, "system" == "environment variables"
	QNetworkProxyFactory::setUseSystemConfiguration(true);

	// for Win32 and Qt5 we try to set the locale codec to UTF-8.
	// this makes QFile::encodeName() work.
#ifdef Q_OS_WIN
	QTextCodec::setCodecForLocale(QTextCodec::codecForMib(106));
#endif

	QCoreApplication::setOrganizationName("Subsurface");
	QCoreApplication::setOrganizationDomain("subsurface.hohndel.org");
	// enable user specific settings (based on command line argument)
	if (settings_suffix) {
		if (verbose)
			qDebug() << "using custom config for" << QString("Subsurface-%1").arg(settings_suffix);
		QCoreApplication::setApplicationName(QString("Subsurface-%1").arg(settings_suffix));
	} else {
		QCoreApplication::setApplicationName("Subsurface");
	}
	// find plugins installed in the application directory (without this SVGs don't work on Windows)
	SettingsObjectWrapper::instance()->load();

	QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath());
	QLocale loc;
	QString uiLang = uiLanguage(&loc);
	QLocale::setDefault(loc);

	qtTranslator = new QTranslator;
	QString translationLocation;
#if defined(Q_OS_ANDROID)
	translationLocation = QLatin1Literal("assets:/translations");
#elif defined(Q_OS_IOS)
	translationLocation = QLatin1Literal(":/translations/");
#else
	translationLocation = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
#endif
	if (qtTranslator->load(loc, "qt", "_", translationLocation)) {
		application->installTranslator(qtTranslator);
	} else {
		if (uiLang != "en_US" && uiLang != "en-US")
			qDebug() << "can't find Qt localization for locale" << uiLang << "searching in" << translationLocation;
	}
	ssrfTranslator = new QTranslator;
	if (ssrfTranslator->load(loc, "subsurface", "_") ||
	    ssrfTranslator->load(loc, "subsurface", "_", translationLocation) ||
	    ssrfTranslator->load(loc, "subsurface", "_", getSubsurfaceDataPath("translations")) ||
	    ssrfTranslator->load(loc, "subsurface", "_", getSubsurfaceDataPath("../translations"))) {
		application->installTranslator(ssrfTranslator);
	} else {
		qDebug() << "can't find Subsurface localization for locale" << uiLang;
	}
}
コード例 #3
0
ファイル: qt-gui.cpp プロジェクト: AsherBond/subsurface
void init_ui(void)
{
	// tell Qt to use system proxies
	// note: on Linux, "system" == "environment variables"
	QNetworkProxyFactory::setUseSystemConfiguration(true);

#if QT_VERSION < 0x050000
	// ask QString in Qt 4 to interpret all char* as UTF-8,
	// like Qt 5 does.
	// 106 is "UTF-8", this is faster than lookup by name
	// [http://www.iana.org/assignments/character-sets/character-sets.xml]
	QTextCodec::setCodecForCStrings(QTextCodec::codecForMib(106));
	// and for reasons I can't understand, I need to do the same again for tr
	// even though that clearly uses C strings as well...
	QTextCodec::setCodecForTr(QTextCodec::codecForMib(106));
#ifdef Q_OS_WIN
	QFile::setDecodingFunction(decodeUtf8);
	QFile::setEncodingFunction(encodeUtf8);
#endif
#endif
	QCoreApplication::setOrganizationName("Subsurface");
	QCoreApplication::setOrganizationDomain("subsurface.hohndel.org");
	QCoreApplication::setApplicationName("Subsurface");
	// find plugins installed in the application directory (without this SVGs don't work on Windows)
	QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath());
	QLocale loc;
	QString uiLang = uiLanguage(&loc);
	QLocale::setDefault(loc);

	// we don't have translations for English - if we don't check for this
	// Qt will proceed to load the second language in preference order - not what we want
	// on Linux this tends to be en-US, but on the Mac it's just en
	if (!uiLang.startsWith("en") || uiLang.startsWith("en-GB")) {
		qtTranslator = new QTranslator;
		if (qtTranslator->load(loc, "qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
			application->installTranslator(qtTranslator);
		} else {
			qDebug() << "can't find Qt localization for locale" << uiLang << "searching in" << QLibraryInfo::location(QLibraryInfo::TranslationsPath);
		}
		ssrfTranslator = new QTranslator;
		if (ssrfTranslator->load(loc, "subsurface", "_") ||
		    ssrfTranslator->load(loc, "subsurface", "_", getSubsurfaceDataPath("translations")) ||
		    ssrfTranslator->load(loc, "subsurface", "_", getSubsurfaceDataPath("../translations"))) {
			application->installTranslator(ssrfTranslator);
		} else {
			qDebug() << "can't find Subsurface localization for locale" << uiLang;
		}
	}
	window = new MainWindow();
	if (existing_filename && existing_filename[0] != '\0')
		window->setTitle(MWTF_FILENAME);
	else
		window->setTitle(MWTF_DEFAULT);
}
コード例 #4
0
void DiveLogExportDialog::exportHtmlInit(const QString &filename)
{
	QFile file(filename);
	QFileInfo info(file);
	QDir mainDir = info.absoluteDir();
	mainDir.mkdir(file.fileName() + "_files");
	QString exportFiles = file.fileName() + "_files";

	QString json_dive_data = exportFiles + QDir::separator() + "file.json";
	QString json_settings = exportFiles + QDir::separator() + "settings.json";
	QString photos_directory = exportFiles + QDir::separator() + "photos" + QDir::separator();
	mainDir.mkdir(photos_directory);
	exportFiles += "/";

	exportHTMLsettings(json_settings);
	export_HTML(json_dive_data.toUtf8().data(), photos_directory.toUtf8().data(), ui->exportSelectedDives->isChecked(), ui->exportListOnly->isChecked());

	QString searchPath = getSubsurfaceDataPath("theme");
	if (searchPath.isEmpty())
		return;

	searchPath += QDir::separator();

	copy_and_overwrite(searchPath + "dive_export.html", filename);
	copy_and_overwrite(searchPath + "list_lib.js", exportFiles + "list_lib.js");
	copy_and_overwrite(searchPath + "poster.png", exportFiles + "poster.png");
	copy_and_overwrite(searchPath + "jqplot.highlighter.min.js", exportFiles + "jqplot.highlighter.min.js");
	copy_and_overwrite(searchPath + "jquery.jqplot.min.js", exportFiles + "jquery.jqplot.min.js");
	copy_and_overwrite(searchPath + "jqplot.canvasAxisTickRenderer.min.js", exportFiles + "jqplot.canvasAxisTickRenderer.min.js");
	copy_and_overwrite(searchPath + "jqplot.canvasTextRenderer.min.js", exportFiles + "jqplot.canvasTextRenderer.min.js");
	copy_and_overwrite(searchPath + "jquery.min.js", exportFiles + "jquery.min.js");
	copy_and_overwrite(searchPath + "jquery.jqplot.css", exportFiles + "jquery.jqplot.css");
	copy_and_overwrite(searchPath + (ui->themeSelection->currentText() == "Light" ? "light.css" : "sand.css"),
			   exportFiles + "theme.css");
}
コード例 #5
0
QString TemplateLayout::generate()
{
	int progress = 0;
	int totalWork = getTotalWork(PrintOptions);
	QString templateName;

	QString htmlContent;
	m_engine = new Grantlee::Engine(this);

	QSharedPointer<Grantlee::FileSystemTemplateLoader> m_templateLoader =
		QSharedPointer<Grantlee::FileSystemTemplateLoader>(new Grantlee::FileSystemTemplateLoader());
	m_templateLoader->setTemplateDirs(QStringList() << getSubsurfaceDataPath("printing_templates"));
	m_engine->addTemplateLoader(m_templateLoader);

	Grantlee::registerMetaType<Dive>();
	Grantlee::registerMetaType<template_options>();
	Grantlee::registerMetaType<print_options>();

	QVariantHash mapping;
	QVariantList diveList;

	struct dive *dive;
	int i;
	for_each_dive (i, dive) {
		//TODO check for exporting selected dives only
		if (!dive->selected && PrintOptions->print_selected)
			continue;
		Dive d(dive);
		diveList.append(QVariant::fromValue(d));
		progress++;
		emit progressUpdated(progress * 100.0 / totalWork);
	}
	mapping.insert("dives", diveList);
	mapping.insert("template_options", QVariant::fromValue(*templateOptions));
	mapping.insert("print_options", QVariant::fromValue(*PrintOptions));

	Grantlee::Context c(mapping);

	if (PrintOptions->p_template == print_options::ONE_DIVE) {
		templateName = "one_dive.html";
	} else if (PrintOptions->p_template == print_options::TWO_DIVE) {
		templateName = "two_dives.html";
	} else if (PrintOptions->p_template == print_options::CUSTOM) {
		templateName = "custom.html";
	}
	Grantlee::Template t = m_engine->loadByName(templateName);
	if (!t || t->error()) {
		qDebug() << "Can't load template";
		return htmlContent;
	}

	htmlContent = t->render(&c);

	if (t->error()) {
		qDebug() << "Can't render template";
		return htmlContent;
	}
	return htmlContent;
}
コード例 #6
0
ファイル: printoptions.cpp プロジェクト: ngdmcc/subsurface
void PrintOptions::on_exportButton_clicked()
{
	QString filename = QFileDialog::getSaveFileName(this, tr("Export template files as"), "",
							tr("HTML files (*.html)"));
	if (filename.isEmpty())
		return;
	QFile::copy(getSubsurfaceDataPath("printing_templates") + QDir::separator() + getSelectedTemplate(), filename);
}
コード例 #7
0
ファイル: models.cpp プロジェクト: atdotde/subsurface
LanguageModel::LanguageModel(QObject *parent) : QAbstractListModel(parent)
{
	QDir d(getSubsurfaceDataPath("translations"));
	Q_FOREACH (const QString &s, d.entryList()) {
		if (s.startsWith("subsurface_") && s.endsWith(".qm")) {
			languages.push_back((s == "subsurface_source.qm") ? "English" : s);
		}
	}
}
コード例 #8
0
QString TemplateLayout::readTemplate(QString template_name)
{
	QFile qfile(getSubsurfaceDataPath("printing_templates") + QDir::separator() + template_name);
	if (qfile.open(QFile::ReadOnly | QFile::Text)) {
		QTextStream in(&qfile);
		return in.readAll();
	}
	return "";
}
コード例 #9
0
void TemplateLayout::writeTemplate(QString template_name, QString grantlee_template)
{
	QFile qfile(getSubsurfaceDataPath("printing_templates") + QDir::separator() + template_name);
	if (qfile.open(QFile::ReadWrite | QFile::Text)) {
		qfile.write(grantlee_template.toUtf8().data());
		qfile.resize(qfile.pos());
		qfile.close();
	}
}
コード例 #10
0
ファイル: globe.cpp プロジェクト: 20150/subsurface
GlobeGPS::GlobeGPS(QWidget *parent) : MarbleWidget(parent),
	loadedDives(0),
	messageWidget(new KMessageWidget(this)),
	fixZoomTimer(new QTimer(this)),
	needResetZoom(false),
	editingDiveLocation(false),
	doubleClick(false)
{
#ifdef MARBLE_SUBSURFACE_BRANCH
	// we need to make sure this gets called after the command line arguments have
	// been processed but before we initialize the rest of Marble
	Marble::MarbleDebug::setEnabled(verbose);
#endif
	currentZoomLevel = -1;
	// check if Google Sat Maps are installed
	// if not, check if they are in a known location
	MapThemeManager mtm;
	QStringList list = mtm.mapThemeIds();
	QString subsurfaceDataPath;
	QDir marble;
	if (!list.contains("earth/googlesat/googlesat.dgml")) {
		subsurfaceDataPath = getSubsurfaceDataPath("marbledata");
		if (subsurfaceDataPath.size()) {
			MarbleDirs::setMarbleDataPath(subsurfaceDataPath);
		} else {
			subsurfaceDataPath = getSubsurfaceDataPath("data");
			if (subsurfaceDataPath.size())
				MarbleDirs::setMarbleDataPath(subsurfaceDataPath);
		}
	}
	messageWidget->setCloseButtonVisible(false);
	messageWidget->setHidden(true);

	setMapThemeId("earth/googlesat/googlesat.dgml");
	//setMapThemeId("earth/openstreetmap/openstreetmap.dgml");
	setProjection(Marble::Spherical);

	setAnimationsEnabled(true);
	Q_FOREACH (AbstractFloatItem *i, floatItems()) {
		i->setVisible(false);
	}
コード例 #11
0
ファイル: templatelayout.cpp プロジェクト: ngdmcc/subsurface
void find_all_templates()
{
	grantlee_templates.clear();
	grantlee_statistics_templates.clear();
	QDir dir(getSubsurfaceDataPath("printing_templates"));
	QFileInfoList list = dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot);
	foreach (QFileInfo finfo, list) {
		QString filename = finfo.fileName();
		if (filename.at(filename.size() - 1) != '~') {
			grantlee_templates.append(finfo.fileName());
		}
	}
コード例 #12
0
ファイル: usermanual.cpp プロジェクト: yubing84/subsurface
UserManual::UserManual(QWidget *parent) : QMainWindow(parent),
	ui(new Ui::UserManual)
{
	ui->setupUi(this);

	QShortcut *closeKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this);
	connect(closeKey, SIGNAL(activated()), this, SLOT(close()));
	QShortcut *quitKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this);
	connect(quitKey, SIGNAL(activated()), parent, SLOT(close()));

	QAction *actionShowSearch = new QAction(this);
	actionShowSearch->setShortcut(Qt::CTRL + Qt::Key_F);
	actionShowSearch->setShortcutContext(Qt::WindowShortcut);
	addAction(actionShowSearch);

	QAction *actionHideSearch = new QAction(this);
	actionHideSearch->setShortcut(Qt::Key_Escape);
	actionHideSearch->setShortcutContext(Qt::WindowShortcut);
	addAction(actionHideSearch);

	setWindowTitle(tr("User Manual"));

	ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
	QString searchPath = getSubsurfaceDataPath("Documentation");
	if (searchPath.size()) {
		// look for localized versions of the manual first
		QString lang = uiLanguage(NULL);
		QString prefix = searchPath.append("/user-manual");
		QFile manual(prefix + "_" + lang + ".html");
		if (!manual.exists())
			manual.setFileName(prefix + "_" + lang.left(2) + ".html");
		if (!manual.exists())
			manual.setFileName(prefix + ".html");
		if (!manual.exists()) {
			ui->webView->setHtml(tr("Cannot find the Subsurface manual"));
		} else {
			QString urlString = QString("file:///") + manual.fileName();
			QUrl url(urlString, QUrl::TolerantMode);
			ui->webView->setUrl(url);
		}
	} else {
		ui->webView->setHtml(tr("Cannot find the Subsurface manual"));
	}
	ui->searchPanel->setParent(this);
	ui->searchPanel->hide();

	connect(actionShowSearch, SIGNAL(triggered(bool)), this, SLOT(showSearchPanel()));
	connect(actionHideSearch, SIGNAL(triggered(bool)), this, SLOT(hideSearchPanel()));
	connect(ui->webView, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClickedSlot(QUrl)));
	connect(ui->searchEdit, SIGNAL(textChanged(QString)), this, SLOT(searchTextChanged(QString)));
	connect(ui->findNext, SIGNAL(clicked()), this, SLOT(searchNext()));
	connect(ui->findPrev, SIGNAL(clicked()), this, SLOT(searchPrev()));
}
コード例 #13
0
ファイル: printoptions.cpp プロジェクト: ngdmcc/subsurface
void PrintOptions::on_importButton_clicked()
{
	QString filename = QFileDialog::getOpenFileName(this, tr("Import template file"), "",
							tr("HTML files (*.html)"));
	if (filename.isEmpty())
		return;
	QFileInfo fileInfo(filename);
	QFile::copy(filename, getSubsurfaceDataPath("printing_templates") + QDir::separator() + fileInfo.fileName());
	printOptions->p_template = fileInfo.fileName();
	find_all_templates();
	setup();
}
コード例 #14
0
ファイル: mainwindow.cpp プロジェクト: 1nv4d3r5/subsurface
void MainWindow::on_actionUserManual_triggered()
{
	if(!helpView){
		helpView = new QTextBrowser();
	}
	QString searchPath = getSubsurfaceDataPath("Documentation");
	if (searchPath != "") {
		QUrl url(searchPath.append("/user-manual.html"));
		helpView->setSource(url);
	} else {
		helpView->setText(tr("Cannot find the Subsurface manual"));
	}
	helpView->show();
}
コード例 #15
0
ファイル: printoptions.cpp プロジェクト: ngdmcc/subsurface
void PrintOptions::on_deleteButton_clicked()
{
	QString templateName = getSelectedTemplate();
	QMessageBox msgBox;
	msgBox.setText("This action cannot be undone!");
	msgBox.setInformativeText("Delete '" + templateName + "' template?");
	msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
	msgBox.setDefaultButton(QMessageBox::Cancel);
	if (msgBox.exec() == QMessageBox::Ok) {
		QFile f(getSubsurfaceDataPath("printing_templates") + QDir::separator() + templateName);
		f.remove();
		find_all_templates();
		setup();
	}
}
コード例 #16
0
void exportHtmlInitLogic(const QString &filename, struct htmlExportSetting &hes)
{
	QString photosDirectory;
	QFile file(filename);
	QFileInfo info(file);
	QDir mainDir = info.absoluteDir();
	mainDir.mkdir(file.fileName() + "_files");
	QString exportFiles = file.fileName() + "_files";

	QString json_dive_data = exportFiles + QDir::separator() + "file.js";
	QString json_settings = exportFiles + QDir::separator() + "settings.js";
	QString translation = exportFiles + QDir::separator() + "translation.js";
	QString stat_file = exportFiles + QDir::separator() + "stat.js";
	exportFiles += "/";

	if (hes.exportPhotos) {
		photosDirectory = exportFiles + QDir::separator() + "photos" + QDir::separator();
		mainDir.mkdir(photosDirectory);
	}


	exportHTMLsettings(json_settings, hes);
	exportHTMLstatistics(stat_file, hes);
	export_translation(qPrintable(translation));

	export_HTML(qPrintable(json_dive_data), qPrintable(photosDirectory), hes.selectedOnly, hes.listOnly);

	QString searchPath = getSubsurfaceDataPath("theme");
	if (searchPath.isEmpty()) {
		report_error(qPrintable(gettextFromC::tr("Cannot find a folder called 'theme' in the standard locations")));
		return;
	}

	searchPath += QDir::separator();

	file_copy_and_overwrite(searchPath + "dive_export.html", filename);
	file_copy_and_overwrite(searchPath + "list_lib.js", exportFiles + "list_lib.js");
	file_copy_and_overwrite(searchPath + "poster.png", exportFiles + "poster.png");
	file_copy_and_overwrite(searchPath + "jqplot.highlighter.min.js", exportFiles + "jqplot.highlighter.min.js");
	file_copy_and_overwrite(searchPath + "jquery.jqplot.min.js", exportFiles + "jquery.jqplot.min.js");
	file_copy_and_overwrite(searchPath + "jqplot.canvasAxisTickRenderer.min.js", exportFiles + "jqplot.canvasAxisTickRenderer.min.js");
	file_copy_and_overwrite(searchPath + "jqplot.canvasTextRenderer.min.js", exportFiles + "jqplot.canvasTextRenderer.min.js");
	file_copy_and_overwrite(searchPath + "jquery.min.js", exportFiles + "jquery.min.js");
	file_copy_and_overwrite(searchPath + "jquery.jqplot.css", exportFiles + "jquery.jqplot.css");
	file_copy_and_overwrite(searchPath + hes.themeFile, exportFiles + "theme.css");
}
コード例 #17
0
ファイル: globe.cpp プロジェクト: levisjani/subsurface
GlobeGPS::GlobeGPS(QWidget* parent) : MarbleWidget(parent), loadedDives(0)
{
	// check if Google Sat Maps are installed
	// if not, check if they are in a known location
	MapThemeManager mtm;
	QStringList list = mtm.mapThemeIds();
	QString theme, subsurfaceDataPath;
	QDir marble;
	bool foundGoogleMap = false;
	Q_FOREACH(theme, list)
		if (theme == "earth/googlesat/googlesat.dgml")
			foundGoogleMap = true;
	if (!foundGoogleMap) {
		subsurfaceDataPath = getSubsurfaceDataPath("marbledata");
		if (subsurfaceDataPath != "")
			MarbleDirs::setMarbleDataPath(subsurfaceDataPath);
	}
	messageWidget = new KMessageWidget(this);
	messageWidget->setCloseButtonVisible(false);
	messageWidget->setHidden(true);

	setMapThemeId("earth/googlesat/googlesat.dgml");
	//setMapThemeId("earth/openstreetmap/openstreetmap.dgml");
	setProjection(Marble::Spherical);

	setAnimationsEnabled(true);
	setShowClouds(false);
	setShowBorders(false);
	setShowPlaces(true);
	setShowCrosshairs(false);
	setShowGrid(false);
	setShowOverviewMap(false);
	setShowScaleBar(true);
	setShowCompass(false);
	connect(this, SIGNAL(mouseClickGeoPosition(qreal, qreal, GeoDataCoordinates::Unit)),
			this, SLOT(mouseClicked(qreal, qreal, GeoDataCoordinates::Unit)));

	setMinimumHeight(0);
	setMinimumWidth(0);
	editingDiveCoords = 0;
	fixZoomTimer = new QTimer();
	connect(fixZoomTimer, SIGNAL(timeout()), this, SLOT(fixZoom()));
	fixZoomTimer->setSingleShot(true);
}
コード例 #18
0
ファイル: usermanual.cpp プロジェクト: danilocesar/subsurface
UserManual::UserManual(QWidget *parent) :
	QMainWindow(parent),
	ui(new Ui::UserManual)
{
	ui->setupUi(this);

	QAction *actionShowSearch = new QAction(this);
	actionShowSearch->setShortcut(Qt::CTRL + Qt::Key_F);
	actionShowSearch->setShortcutContext(Qt::WindowShortcut);
	addAction(actionShowSearch);

	QAction *actionHideSearch = new QAction(this);
	actionHideSearch->setShortcut(Qt::Key_Escape);
	actionHideSearch->setShortcutContext(Qt::WindowShortcut);
	addAction(actionHideSearch);

	setWindowTitle(tr("User Manual"));

	ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
	QString searchPath = getSubsurfaceDataPath("Documentation");
	if (searchPath != "") {
		QUrl url(searchPath.append("/user-manual.html"));
		ui->webView->setUrl(url);
	} else {
		ui->webView->setHtml(tr("Cannot find the Subsurface manual"));
	}
	ui->searchPanel->setParent(this);
	ui->searchPanel->hide();

	connect(actionShowSearch, SIGNAL(triggered(bool)), this, SLOT(showSearchPanel()));
	connect(actionHideSearch, SIGNAL(triggered(bool)), this, SLOT(hideSearchPanel()));
	connect(ui->webView, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClickedSlot(QUrl)));
	connect(ui->searchEdit, SIGNAL(textChanged(QString)), this, SLOT(searchTextChanged(QString)));
	connect(ui->findNext, SIGNAL(clicked()), this, SLOT(searchNext()));
	connect(ui->findPrev, SIGNAL(clicked()), this, SLOT(searchPrev()));
}
コード例 #19
0
ファイル: templatelayout.cpp プロジェクト: ngdmcc/subsurface
}

void find_all_templates()
{
	grantlee_templates.clear();
	grantlee_statistics_templates.clear();
	QDir dir(getSubsurfaceDataPath("printing_templates"));
	QFileInfoList list = dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot);
	foreach (QFileInfo finfo, list) {
		QString filename = finfo.fileName();
		if (filename.at(filename.size() - 1) != '~') {
			grantlee_templates.append(finfo.fileName());
		}
	}
	// find statistics templates
	dir.setPath(getSubsurfaceDataPath("printing_templates") + QDir::separator() + "statistics");
	list = dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot);
	foreach (QFileInfo finfo, list) {
		QString filename = finfo.fileName();
		if (filename.at(filename.size() - 1) != '~') {
			grantlee_statistics_templates.append(finfo.fileName());
		}
	}
}

TemplateLayout::TemplateLayout(print_options *PrintOptions, template_options *templateOptions) :
	m_engine(NULL)
{
	this->PrintOptions = PrintOptions;
	this->templateOptions = templateOptions;
}
コード例 #20
0
ファイル: qt-gui.cpp プロジェクト: Exhora/subsurface
void init_ui(int *argcp, char ***argvp)
{
	QVariant v;

	application = new QApplication(*argcp, *argvp);

	// tell Qt to use system proxies
	// note: on Linux, "system" == "environment variables"
	QNetworkProxyFactory::setUseSystemConfiguration(true);

#if QT_VERSION < 0x050000
	// ask QString in Qt 4 to interpret all char* as UTF-8,
	// like Qt 5 does.
	// 106 is "UTF-8", this is faster than lookup by name
	// [http://www.iana.org/assignments/character-sets/character-sets.xml]
	QTextCodec::setCodecForCStrings(QTextCodec::codecForMib(106));
#endif
	QCoreApplication::setOrganizationName("Subsurface");
	QCoreApplication::setOrganizationDomain("subsurface.hohndel.org");
	QCoreApplication::setApplicationName("Subsurface");
	xslt_path = strdup(getSubsurfaceDataPath("xslt").toAscii().data());

	QLocale loc;
	QString uiLang = loc.uiLanguages().first();
	// there's a stupid Qt bug on MacOS where uiLanguages doesn't give us the country info
	if (!uiLang.contains('-') && uiLang != loc.bcp47Name()) {
		QLocale loc2(loc.bcp47Name());
		loc = loc2;
		uiLang = loc2.uiLanguages().first();
	}

	// we don't have translations for English - if we don't check for this
	// Qt will proceed to load the second language in preference order - not what we want
	// on Linux this tends to be en-US, but on the Mac it's just en
	if (!uiLang.startsWith("en")) {
		qtTranslator = new QTranslator;
		if (qtTranslator->load(loc,"qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
			application->installTranslator(qtTranslator);
		} else {
			qDebug() << "can't find Qt localization for locale" << uiLang <<
				    "searching in" << QLibraryInfo::location(QLibraryInfo::TranslationsPath);
		}
		ssrfTranslator = new QTranslator;
		if (ssrfTranslator->load(loc,"subsurface", "_") ||
				ssrfTranslator->load(loc,"subsurface", "_", getSubsurfaceDataPath("translations")) ||
				ssrfTranslator->load(loc,"subsurface", "_", getSubsurfaceDataPath("../translations"))) {
			application->installTranslator(ssrfTranslator);
		} else {
			qDebug() << "can't find Subsurface localization for locale" << uiLang;
		}
	}

	QSettings s;
	s.beginGroup("GeneralSettings");
	prefs.default_filename = getSetting(s, "default_filename");
	s.endGroup();
	s.beginGroup("DiveComputer");
	default_dive_computer_vendor = getSetting(s, "dive_computer_vendor");
	default_dive_computer_product = getSetting(s,"dive_computer_product");
	default_dive_computer_device = getSetting(s, "dive_computer_device");
	s.endGroup();

	window = new MainWindow();
	window->show();
	if (existing_filename && existing_filename[0] != '\0')
		window->setTitle(MWTF_FILENAME);
	else
		window->setTitle(MWTF_DEFAULT);

	return;
}