mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Add Qtr_ macros that uses gettext in a tr() compatible manner
This should wrap gettext nicely and replace the "_()" macros we use in C code. Also added comments to the top of all the new files. Suggested-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									14e133321f
								
							
						
					
					
						commit
						f5c958ad73
					
				
					 16 changed files with 113 additions and 22 deletions
				
			
		
							
								
								
									
										6
									
								
								Makefile
									
										
									
									
									
								
							
							
						
						
									
										6
									
								
								Makefile
									
										
									
									
									
								
							|  | @ -110,8 +110,10 @@ else | ||||||
| 	QT_MODULES = QtGui | 	QT_MODULES = QtGui | ||||||
| 	QT_CORE = QtCore | 	QT_CORE = QtCore | ||||||
| endif | endif | ||||||
|  | 
 | ||||||
|  | # we need GLIB2CFLAGS for gettext
 | ||||||
|  | QTCXXFLAGS = $(shell $(PKGCONFIG) --cflags $(QT_MODULES)) $(GLIB2CFLAGS) | ||||||
| LIBQT = $(shell $(PKGCONFIG) --libs $(QT_MODULES)) | LIBQT = $(shell $(PKGCONFIG) --libs $(QT_MODULES)) | ||||||
| QTCXXFLAGS = $(shell $(PKGCONFIG) --cflags $(QT_MODULES)) |  | ||||||
| 
 | 
 | ||||||
| LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0) | LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0) | ||||||
| LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERINCLUDES) | LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERINCLUDES) | ||||||
|  | @ -303,7 +305,7 @@ $(INFOPLIST): $(INFOPLISTINPUT) | ||||||
| 
 | 
 | ||||||
| # Transifex merge the translations
 | # Transifex merge the translations
 | ||||||
| update-po-files: | update-po-files: | ||||||
| 	xgettext -o po/subsurface-new.pot -s -k_ -kN_ --keyword=C_:1c,2  --add-comments="++GETTEXT" *.c | 	xgettext -o po/subsurface-new.pot -s -k_ -kN_ -kQtr_ --keyword=C_:1c,2  --add-comments="++GETTEXT" *.c qt-ui/*.cpp | ||||||
| 	tx push -s | 	tx push -s | ||||||
| 	tx pull -af | 	tx pull -af | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -25,6 +25,7 @@ | ||||||
| #include "version.h" | #include "version.h" | ||||||
| #include "libdivecomputer.h" | #include "libdivecomputer.h" | ||||||
| #include "qt-ui/mainwindow.h" | #include "qt-ui/mainwindow.h" | ||||||
|  | #include "qt-ui/common.h" | ||||||
| 
 | 
 | ||||||
| #include <gdk-pixbuf/gdk-pixbuf.h> | #include <gdk-pixbuf/gdk-pixbuf.h> | ||||||
| #include <gdk-pixbuf/gdk-pixdata.h> | #include <gdk-pixbuf/gdk-pixdata.h> | ||||||
|  | @ -1784,7 +1785,7 @@ void MainWindow::setCurrentFileName(const QString &fileName) | ||||||
| 	if (fileName == m_currentFileName) return; | 	if (fileName == m_currentFileName) return; | ||||||
| 	m_currentFileName = fileName; | 	m_currentFileName = fileName; | ||||||
| 
 | 
 | ||||||
| 	QString title = tr("Subsurface"); | 	QString title = Qtr_("Subsurface"); | ||||||
| 	if (!m_currentFileName.isEmpty()) { | 	if (!m_currentFileName.isEmpty()) { | ||||||
| 		QFileInfo fileInfo(m_currentFileName); | 		QFileInfo fileInfo(m_currentFileName); | ||||||
| 		title += " - " + fileInfo.fileName(); | 		title += " - " + fileInfo.fileName(); | ||||||
|  | @ -1797,7 +1798,7 @@ void MainWindow::on_actionOpen_triggered() | ||||||
| 	QString defaultFileName = QString::fromUtf8(prefs.default_filename); | 	QString defaultFileName = QString::fromUtf8(prefs.default_filename); | ||||||
| 	QFileInfo fileInfo(defaultFileName); | 	QFileInfo fileInfo(defaultFileName); | ||||||
| 
 | 
 | ||||||
| 	QFileDialog dialog(this, tr("Open File"), fileInfo.path()); | 	QFileDialog dialog(this, Qtr_("Open File"), fileInfo.path()); | ||||||
| 	dialog.setFileMode(QFileDialog::ExistingFile); | 	dialog.setFileMode(QFileDialog::ExistingFile); | ||||||
| 	dialog.selectFile(defaultFileName); | 	dialog.selectFile(defaultFileName); | ||||||
| 	dialog.setNameFilters(fileNameFilters()); | 	dialog.setNameFilters(fileNameFilters()); | ||||||
|  |  | ||||||
|  | @ -1,3 +1,9 @@ | ||||||
|  | /*
 | ||||||
|  |  * addcylinderdialog.cpp | ||||||
|  |  * | ||||||
|  |  * classes for the add cylinder dialog of Subsurface | ||||||
|  |  * | ||||||
|  |  */ | ||||||
| #include "addcylinderdialog.h" | #include "addcylinderdialog.h" | ||||||
| #include "ui_addcylinderdialog.h" | #include "ui_addcylinderdialog.h" | ||||||
| #include <QComboBox> | #include <QComboBox> | ||||||
|  |  | ||||||
|  | @ -1,3 +1,9 @@ | ||||||
|  | /*
 | ||||||
|  |  * addcylinderdialog.h | ||||||
|  |  * | ||||||
|  |  * header file for the add cylinder dialog of Subsurface | ||||||
|  |  * | ||||||
|  |  */ | ||||||
| #ifndef ADDCYLINDERDIALOG_H | #ifndef ADDCYLINDERDIALOG_H | ||||||
| #define ADDCYLINDERDIALOG_H | #define ADDCYLINDERDIALOG_H | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,3 +1,9 @@ | ||||||
|  | /*
 | ||||||
|  |  * divelistview.cpp | ||||||
|  |  * | ||||||
|  |  * classes for the divelist of Subsurface | ||||||
|  |  * | ||||||
|  |  */ | ||||||
| #include "divelistview.h" | #include "divelistview.h" | ||||||
| 
 | 
 | ||||||
| DiveListView::DiveListView(QWidget *parent) : QTreeView(parent) | DiveListView::DiveListView(QWidget *parent) : QTreeView(parent) | ||||||
|  |  | ||||||
|  | @ -1,3 +1,9 @@ | ||||||
|  | /*
 | ||||||
|  |  * divelistview.h | ||||||
|  |  * | ||||||
|  |  * header file for the dive list of Subsurface | ||||||
|  |  * | ||||||
|  |  */ | ||||||
| #ifndef DIVELISTVIEW_H | #ifndef DIVELISTVIEW_H | ||||||
| #define DIVELISTVIEW_H | #define DIVELISTVIEW_H | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,3 +1,10 @@ | ||||||
|  | /*
 | ||||||
|  |  * divetripmodel.cpp | ||||||
|  |  * | ||||||
|  |  * classes for the dive trip list in Subsurface | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | #include "common.h" | ||||||
| #include "divetripmodel.h" | #include "divetripmodel.h" | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -63,15 +70,15 @@ QVariant DiveTripModel::headerData(int section, Qt::Orientation orientation, int | ||||||
| { | { | ||||||
| 	if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { | 	if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { | ||||||
| 		if (section == DIVE_NUMBER) { | 		if (section == DIVE_NUMBER) { | ||||||
| 			return tr("Dive number"); | 			return Qtr_("Dive number"); | ||||||
| 		} else if (section == DIVE_DATE_TIME) { | 		} else if (section == DIVE_DATE_TIME) { | ||||||
| 			return tr("Date"); | 			return Qtr_("Date"); | ||||||
| 		} else if (section == DIVE_DURATION) { | 		} else if (section == DIVE_DURATION) { | ||||||
| 			return tr("Duration"); | 			return Qtr_("Duration"); | ||||||
| 		} else if (section == DIVE_DEPTH) { | 		} else if (section == DIVE_DEPTH) { | ||||||
| 			return tr("Depth"); | 			return Qtr_("Depth"); | ||||||
| 		} else if (section == DIVE_LOCATION) { | 		} else if (section == DIVE_LOCATION) { | ||||||
| 			return tr("Location"); | 			return Qtr_("Location"); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	return QVariant(); | 	return QVariant(); | ||||||
|  |  | ||||||
|  | @ -1,3 +1,9 @@ | ||||||
|  | /*
 | ||||||
|  |  * divetripmodel.h | ||||||
|  |  * | ||||||
|  |  * header file for the divetrip model of Subsurface | ||||||
|  |  * | ||||||
|  |  */ | ||||||
| #ifndef DIVETRIPMODEL_H | #ifndef DIVETRIPMODEL_H | ||||||
| #define DIVETRIPMODEL_H | #define DIVETRIPMODEL_H | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,3 +1,10 @@ | ||||||
|  | /*
 | ||||||
|  |  * maintab.cpp | ||||||
|  |  * | ||||||
|  |  * classes for the "notebook" area of the main window of Subsurface | ||||||
|  |  * | ||||||
|  |  */ | ||||||
|  | #include "common.h" | ||||||
| #include "maintab.h" | #include "maintab.h" | ||||||
| #include "ui_maintab.h" | #include "ui_maintab.h" | ||||||
| #include "addcylinderdialog.h" | #include "addcylinderdialog.h" | ||||||
|  |  | ||||||
|  | @ -1,3 +1,9 @@ | ||||||
|  | /*
 | ||||||
|  |  * maintab.h | ||||||
|  |  * | ||||||
|  |  * header file for the main tab of Subsurface | ||||||
|  |  * | ||||||
|  |  */ | ||||||
| #ifndef MAINTAB_H | #ifndef MAINTAB_H | ||||||
| #define MAINTAB_H | #define MAINTAB_H | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,3 +1,10 @@ | ||||||
|  | /*
 | ||||||
|  |  * mainwindow.cpp | ||||||
|  |  * | ||||||
|  |  * classes for the main UI window in Subsurface | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | #include "common.h" | ||||||
| #include "mainwindow.h" | #include "mainwindow.h" | ||||||
| #include "ui_mainwindow.h" | #include "ui_mainwindow.h" | ||||||
| 
 | 
 | ||||||
|  | @ -53,7 +60,7 @@ void MainWindow::on_actionNew_triggered() | ||||||
| 
 | 
 | ||||||
| void MainWindow::on_actionOpen_triggered() | void MainWindow::on_actionOpen_triggered() | ||||||
| { | { | ||||||
| 	QString filename = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::homePath(), filter()); | 	QString filename = QFileDialog::getOpenFileName(this, Qtr_("Open File"), QDir::homePath(), filter()); | ||||||
| 	if (filename.isEmpty()){ | 	if (filename.isEmpty()){ | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
|  | @ -283,10 +290,10 @@ QString MainWindow::filter() | ||||||
| 
 | 
 | ||||||
| bool MainWindow::askSaveChanges() | bool MainWindow::askSaveChanges() | ||||||
| { | { | ||||||
| 	QString message = ! existing_filename ? tr("You have unsaved changes\nWould you like to save those before closing the datafile?") | 	QString message = ! existing_filename ? Qtr_("You have unsaved changes\nWould you like to save those before closing the datafile?") | ||||||
| 		:    tr("You have unsaved changes to file: %1 \nWould you like to save those before closing the datafile?").arg(existing_filename); | 		:    Qtr_("You have unsaved changes to file: %1 \nWould you like to save those before closing the datafile?").arg(existing_filename); | ||||||
| 
 | 
 | ||||||
| 	if (QMessageBox::question(this,  tr("Save Changes?"), message) == QMessageBox::Ok){ | 	if (QMessageBox::question(this,  Qtr_("Save Changes?"), message) == QMessageBox::Ok){ | ||||||
| 		// WARNING: Port.
 | 		// WARNING: Port.
 | ||||||
| 		//		file_save(NULL,NULL);
 | 		//		file_save(NULL,NULL);
 | ||||||
| 		return true; | 		return true; | ||||||
|  |  | ||||||
|  | @ -1,3 +1,9 @@ | ||||||
|  | /*
 | ||||||
|  |  * mainwindow.h | ||||||
|  |  * | ||||||
|  |  * header file for the main window of Subsurface | ||||||
|  |  * | ||||||
|  |  */ | ||||||
| #ifndef MAINWINDOW_H | #ifndef MAINWINDOW_H | ||||||
| #define MAINWINDOW_H | #define MAINWINDOW_H | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,3 +1,10 @@ | ||||||
|  | /*
 | ||||||
|  |  * models.cpp | ||||||
|  |  * | ||||||
|  |  * classes for the equipment models of Subsurface | ||||||
|  |  * | ||||||
|  |  */ | ||||||
|  | #include "common.h" | ||||||
| #include "models.h" | #include "models.h" | ||||||
| #include "../dive.h" | #include "../dive.h" | ||||||
| 
 | 
 | ||||||
|  | @ -15,25 +22,25 @@ QVariant CylindersModel::headerData(int section, Qt::Orientation orientation, in | ||||||
| 	if (role == Qt::DisplayRole) { | 	if (role == Qt::DisplayRole) { | ||||||
| 		switch(section) { | 		switch(section) { | ||||||
| 		case TYPE: | 		case TYPE: | ||||||
| 			ret = tr("Type"); | 			ret = Qtr_("Type"); | ||||||
| 			break; | 			break; | ||||||
| 		case SIZE: | 		case SIZE: | ||||||
| 			ret = tr("Size"); | 			ret = Qtr_("Size"); | ||||||
| 			break; | 			break; | ||||||
| 		case MAXPRESS: | 		case MAXPRESS: | ||||||
| 			ret = tr("MaxPress"); | 			ret = Qtr_("MaxPress"); | ||||||
| 			break; | 			break; | ||||||
| 		case START: | 		case START: | ||||||
| 			ret = tr("Start"); | 			ret = Qtr_("Start"); | ||||||
| 			break; | 			break; | ||||||
| 		case END: | 		case END: | ||||||
| 			ret = tr("End"); | 			ret = Qtr_("End"); | ||||||
| 			break; | 			break; | ||||||
| 		case O2: | 		case O2: | ||||||
| 			ret = tr("O2%"); | 			ret = Qtr_("O2%"); | ||||||
| 			break; | 			break; | ||||||
| 		case HE: | 		case HE: | ||||||
| 			ret = tr("He%"); | 			ret = Qtr_("He%"); | ||||||
| 			break; | 			break; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | @ -157,10 +164,10 @@ QVariant WeightModel::headerData(int section, Qt::Orientation orientation, int r | ||||||
| 
 | 
 | ||||||
| 	switch(section){ | 	switch(section){ | ||||||
| 	case TYPE: | 	case TYPE: | ||||||
| 		ret = tr("Type"); | 		ret = Qtr_("Type"); | ||||||
| 		break; | 		break; | ||||||
| 	case WEIGHT: | 	case WEIGHT: | ||||||
| 		ret = tr("Weight"); | 		ret = Qtr_("Weight"); | ||||||
| 		break; | 		break; | ||||||
| 	} | 	} | ||||||
| 	return ret; | 	return ret; | ||||||
|  |  | ||||||
|  | @ -1,3 +1,9 @@ | ||||||
|  | /*
 | ||||||
|  |  * models.h | ||||||
|  |  * | ||||||
|  |  * header file for the equipment models of Subsurface | ||||||
|  |  * | ||||||
|  |  */ | ||||||
| #ifndef MODELS_H | #ifndef MODELS_H | ||||||
| #define MODELS_H | #define MODELS_H | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -0,0 +1,6 @@ | ||||||
|  | /*
 | ||||||
|  |  * plotareascene.cpp | ||||||
|  |  * | ||||||
|  |  * classes for profile plot area scene of Subsurface | ||||||
|  |  * | ||||||
|  |  */ | ||||||
|  | @ -0,0 +1,6 @@ | ||||||
|  | /*
 | ||||||
|  |  * plotareascene.h | ||||||
|  |  * | ||||||
|  |  * header file for the profile plot area scene of Subsurface | ||||||
|  |  * | ||||||
|  |  */ | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue