summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-04-13 20:44:02 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-04-13 20:44:02 -0700
commitf5c958ad73db696e473aaa35e144f4c9d8ae24de (patch)
treeef693cc0bbcaea533d007132897c32a7f9e8ea98
parent14e133321f4ac2cff9eb0b84ba9687e5d42e3e46 (diff)
downloadsubsurface-f5c958ad73db696e473aaa35e144f4c9d8ae24de.tar.gz
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>
-rw-r--r--Makefile6
-rw-r--r--qt-gui.cpp5
-rw-r--r--qt-ui/addcylinderdialog.cpp6
-rw-r--r--qt-ui/addcylinderdialog.h6
-rw-r--r--qt-ui/divelistview.cpp6
-rw-r--r--qt-ui/divelistview.h6
-rw-r--r--qt-ui/divetripmodel.cpp17
-rw-r--r--qt-ui/divetripmodel.h6
-rw-r--r--qt-ui/maintab.cpp7
-rw-r--r--qt-ui/maintab.h6
-rw-r--r--qt-ui/mainwindow.cpp15
-rw-r--r--qt-ui/mainwindow.h6
-rw-r--r--qt-ui/models.cpp25
-rw-r--r--qt-ui/models.h6
-rw-r--r--qt-ui/plotareascene.cpp6
-rw-r--r--qt-ui/plotareascene.h6
16 files changed, 113 insertions, 22 deletions
diff --git a/Makefile b/Makefile
index 8bbd26fb7..e33d92053 100644
--- a/Makefile
+++ b/Makefile
@@ -110,8 +110,10 @@ else
QT_MODULES = QtGui
QT_CORE = QtCore
endif
+
+# we need GLIB2CFLAGS for gettext
+QTCXXFLAGS = $(shell $(PKGCONFIG) --cflags $(QT_MODULES)) $(GLIB2CFLAGS)
LIBQT = $(shell $(PKGCONFIG) --libs $(QT_MODULES))
-QTCXXFLAGS = $(shell $(PKGCONFIG) --cflags $(QT_MODULES))
LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0)
LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERINCLUDES)
@@ -303,7 +305,7 @@ $(INFOPLIST): $(INFOPLISTINPUT)
# Transifex merge the translations
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 pull -af
diff --git a/qt-gui.cpp b/qt-gui.cpp
index 745457763..1621317c2 100644
--- a/qt-gui.cpp
+++ b/qt-gui.cpp
@@ -25,6 +25,7 @@
#include "version.h"
#include "libdivecomputer.h"
#include "qt-ui/mainwindow.h"
+#include "qt-ui/common.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk-pixbuf/gdk-pixdata.h>
@@ -1784,7 +1785,7 @@ void MainWindow::setCurrentFileName(const QString &fileName)
if (fileName == m_currentFileName) return;
m_currentFileName = fileName;
- QString title = tr("Subsurface");
+ QString title = Qtr_("Subsurface");
if (!m_currentFileName.isEmpty()) {
QFileInfo fileInfo(m_currentFileName);
title += " - " + fileInfo.fileName();
@@ -1797,7 +1798,7 @@ void MainWindow::on_actionOpen_triggered()
QString defaultFileName = QString::fromUtf8(prefs.default_filename);
QFileInfo fileInfo(defaultFileName);
- QFileDialog dialog(this, tr("Open File"), fileInfo.path());
+ QFileDialog dialog(this, Qtr_("Open File"), fileInfo.path());
dialog.setFileMode(QFileDialog::ExistingFile);
dialog.selectFile(defaultFileName);
dialog.setNameFilters(fileNameFilters());
diff --git a/qt-ui/addcylinderdialog.cpp b/qt-ui/addcylinderdialog.cpp
index 6f2294a25..043f29907 100644
--- a/qt-ui/addcylinderdialog.cpp
+++ b/qt-ui/addcylinderdialog.cpp
@@ -1,3 +1,9 @@
+/*
+ * addcylinderdialog.cpp
+ *
+ * classes for the add cylinder dialog of Subsurface
+ *
+ */
#include "addcylinderdialog.h"
#include "ui_addcylinderdialog.h"
#include <QComboBox>
diff --git a/qt-ui/addcylinderdialog.h b/qt-ui/addcylinderdialog.h
index b32494c05..652f7b362 100644
--- a/qt-ui/addcylinderdialog.h
+++ b/qt-ui/addcylinderdialog.h
@@ -1,3 +1,9 @@
+/*
+ * addcylinderdialog.h
+ *
+ * header file for the add cylinder dialog of Subsurface
+ *
+ */
#ifndef ADDCYLINDERDIALOG_H
#define ADDCYLINDERDIALOG_H
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index eafbdd384..a8b1eff05 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -1,3 +1,9 @@
+/*
+ * divelistview.cpp
+ *
+ * classes for the divelist of Subsurface
+ *
+ */
#include "divelistview.h"
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent)
diff --git a/qt-ui/divelistview.h b/qt-ui/divelistview.h
index 3ac123a14..be9774c5c 100644
--- a/qt-ui/divelistview.h
+++ b/qt-ui/divelistview.h
@@ -1,3 +1,9 @@
+/*
+ * divelistview.h
+ *
+ * header file for the dive list of Subsurface
+ *
+ */
#ifndef DIVELISTVIEW_H
#define DIVELISTVIEW_H
diff --git a/qt-ui/divetripmodel.cpp b/qt-ui/divetripmodel.cpp
index a03603bcf..0a2944d8b 100644
--- a/qt-ui/divetripmodel.cpp
+++ b/qt-ui/divetripmodel.cpp
@@ -1,3 +1,10 @@
+/*
+ * divetripmodel.cpp
+ *
+ * classes for the dive trip list in Subsurface
+ */
+
+#include "common.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 (section == DIVE_NUMBER) {
- return tr("Dive number");
+ return Qtr_("Dive number");
} else if (section == DIVE_DATE_TIME) {
- return tr("Date");
+ return Qtr_("Date");
} else if (section == DIVE_DURATION) {
- return tr("Duration");
+ return Qtr_("Duration");
} else if (section == DIVE_DEPTH) {
- return tr("Depth");
+ return Qtr_("Depth");
} else if (section == DIVE_LOCATION) {
- return tr("Location");
+ return Qtr_("Location");
}
}
return QVariant();
diff --git a/qt-ui/divetripmodel.h b/qt-ui/divetripmodel.h
index 8c8a829e2..ad1815798 100644
--- a/qt-ui/divetripmodel.h
+++ b/qt-ui/divetripmodel.h
@@ -1,3 +1,9 @@
+/*
+ * divetripmodel.h
+ *
+ * header file for the divetrip model of Subsurface
+ *
+ */
#ifndef DIVETRIPMODEL_H
#define DIVETRIPMODEL_H
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index b957fd1c7..72d8dfebc 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -1,3 +1,10 @@
+/*
+ * maintab.cpp
+ *
+ * classes for the "notebook" area of the main window of Subsurface
+ *
+ */
+#include "common.h"
#include "maintab.h"
#include "ui_maintab.h"
#include "addcylinderdialog.h"
diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h
index 0e9f285ac..44815fafc 100644
--- a/qt-ui/maintab.h
+++ b/qt-ui/maintab.h
@@ -1,3 +1,9 @@
+/*
+ * maintab.h
+ *
+ * header file for the main tab of Subsurface
+ *
+ */
#ifndef MAINTAB_H
#define MAINTAB_H
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index fdc823d9c..d1cde044a 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -1,3 +1,10 @@
+/*
+ * mainwindow.cpp
+ *
+ * classes for the main UI window in Subsurface
+ */
+
+#include "common.h"
#include "mainwindow.h"
#include "ui_mainwindow.h"
@@ -53,7 +60,7 @@ void MainWindow::on_actionNew_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()){
return;
}
@@ -283,10 +290,10 @@ QString MainWindow::filter()
bool MainWindow::askSaveChanges()
{
- QString message = ! existing_filename ? tr("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);
+ QString message = ! existing_filename ? Qtr_("You have unsaved changes\nWould you like to save those before closing the datafile?")
+ : 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.
// file_save(NULL,NULL);
return true;
diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
index 34acf2b67..43ebde7f5 100644
--- a/qt-ui/mainwindow.h
+++ b/qt-ui/mainwindow.h
@@ -1,3 +1,9 @@
+/*
+ * mainwindow.h
+ *
+ * header file for the main window of Subsurface
+ *
+ */
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index dac1c7215..a341c0c70 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -1,3 +1,10 @@
+/*
+ * models.cpp
+ *
+ * classes for the equipment models of Subsurface
+ *
+ */
+#include "common.h"
#include "models.h"
#include "../dive.h"
@@ -15,25 +22,25 @@ QVariant CylindersModel::headerData(int section, Qt::Orientation orientation, in
if (role == Qt::DisplayRole) {
switch(section) {
case TYPE:
- ret = tr("Type");
+ ret = Qtr_("Type");
break;
case SIZE:
- ret = tr("Size");
+ ret = Qtr_("Size");
break;
case MAXPRESS:
- ret = tr("MaxPress");
+ ret = Qtr_("MaxPress");
break;
case START:
- ret = tr("Start");
+ ret = Qtr_("Start");
break;
case END:
- ret = tr("End");
+ ret = Qtr_("End");
break;
case O2:
- ret = tr("O2%");
+ ret = Qtr_("O2%");
break;
case HE:
- ret = tr("He%");
+ ret = Qtr_("He%");
break;
}
}
@@ -157,10 +164,10 @@ QVariant WeightModel::headerData(int section, Qt::Orientation orientation, int r
switch(section){
case TYPE:
- ret = tr("Type");
+ ret = Qtr_("Type");
break;
case WEIGHT:
- ret = tr("Weight");
+ ret = Qtr_("Weight");
break;
}
return ret;
diff --git a/qt-ui/models.h b/qt-ui/models.h
index 0d0c7b41d..697096f92 100644
--- a/qt-ui/models.h
+++ b/qt-ui/models.h
@@ -1,3 +1,9 @@
+/*
+ * models.h
+ *
+ * header file for the equipment models of Subsurface
+ *
+ */
#ifndef MODELS_H
#define MODELS_H
diff --git a/qt-ui/plotareascene.cpp b/qt-ui/plotareascene.cpp
index e69de29bb..a728040f5 100644
--- a/qt-ui/plotareascene.cpp
+++ b/qt-ui/plotareascene.cpp
@@ -0,0 +1,6 @@
+/*
+ * plotareascene.cpp
+ *
+ * classes for profile plot area scene of Subsurface
+ *
+ */
diff --git a/qt-ui/plotareascene.h b/qt-ui/plotareascene.h
index e69de29bb..a5b07d1be 100644
--- a/qt-ui/plotareascene.h
+++ b/qt-ui/plotareascene.h
@@ -0,0 +1,6 @@
+/*
+ * plotareascene.h
+ *
+ * header file for the profile plot area scene of Subsurface
+ *
+ */