diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | src/Makefile.am | 18 | ||||
-rw-r--r-- | src/dgedit.cc | 17 | ||||
-rw-r--r-- | src/filelist.cc | 13 | ||||
-rw-r--r-- | src/mainwindow.cc | 53 | ||||
-rw-r--r-- | src/selectioneditor.cc | 12 | ||||
-rw-r--r-- | src/ts/dgedit_da.ts | 204 | ||||
-rw-r--r-- | src/volumefader.cc | 6 |
8 files changed, 283 insertions, 43 deletions
@@ -23,4 +23,5 @@ src/qrc_*.cc stamp-h1 src/presets.ini moc_*.cpp -qrc_*.cpp
\ No newline at end of file +qrc_*.cpp +*.qm
\ No newline at end of file diff --git a/src/Makefile.am b/src/Makefile.am index b7fb48d..0c37d01 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,9 +5,13 @@ bin_PROGRAMS = dgedit dgedit_LDADD = $(SNDFILE_LIBS) $(QT_LIBS) $(AO_LIBS) \ $(shell ../tools/MocList o ) qrc_dgedit.o -dgedit_CXXFLAGS = $(SNDFILE_CXXFLAGS) $(QT_CFLAGS) $(AO_CFLAGS) +dgedit_CXXFLAGS = $(SNDFILE_CXXFLAGS) $(QT_CFLAGS) $(AO_CFLAGS) \ + -DLOCALEDIR='"$(localedir)"' AM_CXXFLAGS = $(QT_CFLAGS) +dgedit_TRANLATIONS = \ + ts/dgedit_da.ts + dgedit_SOURCES = \ dgedit.cc \ audioextractor.cc \ @@ -25,6 +29,7 @@ dgedit_SOURCES = \ samplesorter.cc \ selection.cc \ selectioneditor.cc \ + session.cc \ volumefader.cc \ zoomslider.cc @@ -44,6 +49,7 @@ EXTRA_DIST = \ samplesorter.h \ selection.h \ selectioneditor.h \ + session.h \ sleep.h \ volumefader.h \ zoomslider.h \ @@ -72,3 +78,13 @@ qrc_%.cc: %.qrc # command for creating .res file from .rc on Win32 %.res: %.rc rc $< + +%.ts: $(dgedit_SOURCES) + QT_SELECT=qt5 lupdate $(dgedit_SOURCES) -ts $@ + +%.qm: %.ts + QT_SELECT=qt5 lrelease $< + +dgeditdir = $(localedir) +dgedit_DATA = $(dgedit_TRANLATIONS:.ts=.qm) +BUILT_SOURCES = $(dgedit_TRANLATIONS) diff --git a/src/dgedit.cc b/src/dgedit.cc index d590bc6..c511150 100644 --- a/src/dgedit.cc +++ b/src/dgedit.cc @@ -25,6 +25,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include <QApplication> +#include <QLocale> +#include <QTranslator> + +#include <iostream> #include "mainwindow.h" @@ -32,6 +36,19 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); + QTranslator translator; + QString locale = QLocale().name().section('_', 0, 0); + if(!locale.isEmpty() && locale != "C") + { + QString file = LOCALEDIR"/dgedit_" + locale + ".qm"; + std::cout << file.toStdString() << std::endl; + if(QFile::exists(file)) + { + translator.load(file); + app.installTranslator(&translator); + } + } + MainWindow wnd; wnd.show(); diff --git a/src/filelist.cc b/src/filelist.cc index 6cad785..0f9b1cf 100644 --- a/src/filelist.cc +++ b/src/filelist.cc @@ -47,8 +47,9 @@ FileList::FileList() void FileList::addFiles() { - QStringList files = QFileDialog::getOpenFileNames(this, tr("Open file"), - path, tr("Audio Files (*.wav)")); + QStringList files = + QFileDialog::getOpenFileNames(this, tr("Open file"), + path, tr("Audio Files (*.wav)")); QStringList::Iterator i = files.begin(); while(i != files.end()) { @@ -92,16 +93,16 @@ void FileList::createMenus() { menu = new QMenu(); - setMasterAction = new QAction("Set as Master (dbl-click)", this); + setMasterAction = new QAction(tr("Set as Master (dbl-click)"), this); connect(setMasterAction, SIGNAL(triggered()), this, SLOT(setMaster())); - editAction = new QAction("Edit name", this); + editAction = new QAction(tr("Edit name"), this); connect(editAction, SIGNAL(triggered()), this, SLOT(editName())); - removeAction = new QAction("Remove", this); + removeAction = new QAction(tr("Remove"), this); connect(removeAction, SIGNAL(triggered()), this, SLOT(removeFile())); - removeAllAction = new QAction("Remove all", this); + removeAllAction = new QAction(tr("Remove all"), this); connect(removeAllAction, SIGNAL(triggered()), this, SLOT(removeAllFiles())); menu->addAction(setMasterAction); diff --git a/src/mainwindow.cc b/src/mainwindow.cc index 81beae0..69e4398 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -85,7 +85,7 @@ MainWindow::MainWindow() //canvas = new Canvas(this); canvaswidget = new CanvasWidget(this); - QToolBar* toolbar = addToolBar("Tools"); + QToolBar* toolbar = addToolBar(tr("Tools")); listen = new CanvasToolListen(canvaswidget->canvas, player); addTool(toolbar, canvaswidget->canvas, listen); threshold = new CanvasToolThreshold(canvaswidget->canvas); @@ -102,8 +102,8 @@ MainWindow::MainWindow() canvaswidget->canvas, SLOT(update())); addTool(toolbar, canvaswidget->canvas, tool_selections); - QMenu* fileMenu = menuBar()->addMenu("&File"); - QAction* act_quit = new QAction("&Quit", this); + QMenu* fileMenu = menuBar()->addMenu(tr("&File")); + QAction* act_quit = new QAction(tr("&Quit"), this); fileMenu->addAction(act_quit); connect(act_quit, SIGNAL(triggered()), this, SLOT(close())); @@ -145,7 +145,7 @@ MainWindow::MainWindow() connect(&selections, SIGNAL(activeChanged(sel_id_t)), sorter, SLOT(relayout())); - QPushButton* btn_playsamples = new QPushButton("Play samples"); + QPushButton* btn_playsamples = new QPushButton(tr("Play samples")); connect(btn_playsamples, SIGNAL(clicked()), this, SLOT(playSamples())); sb_playsamples = new QScrollBar(Qt::Horizontal); @@ -176,10 +176,10 @@ MainWindow::MainWindow() //dockWidget->widget()->layout()->addWidget(presets); tabs = new QTabWidget(this); - tabs->addTab(createFilesTab(), "Files"); - generateTabId = tabs->addTab(createGenerateTab(), "Generate"); - tabs->addTab(createEditTab(), "Edit"); - tabs->addTab(createExportTab(), "Export"); + tabs->addTab(createFilesTab(), tr("Files")); + generateTabId = tabs->addTab(createGenerateTab(), tr("Generate")); + tabs->addTab(createEditTab(), tr("Edit")); + tabs->addTab(createExportTab(), tr("Export")); connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int))); tabChanged(tabs->currentIndex()); @@ -222,7 +222,7 @@ MainWindow::MainWindow() // presets->addItem(presetname, v); //} - statusBar()->showMessage("Ready"); + statusBar()->showMessage(tr("Ready")); } MainWindow::~MainWindow() @@ -243,9 +243,9 @@ QWidget* MainWindow::createFilesTab() QVBoxLayout* l = new QVBoxLayout(); w->setLayout(l); - l->addWidget(new QLabel("Files: (double-click to set as master)")); + l->addWidget(new QLabel(tr("Files: (double-click to set as master)"))); QPushButton* loadbtn = new QPushButton(); - loadbtn->setText("Add files..."); + loadbtn->setText(tr("Add files...")); l->addWidget(loadbtn); filelist = new FileList(); @@ -312,7 +312,7 @@ QWidget* MainWindow::createGenerateTab() QHBoxLayout* btns = new QHBoxLayout(); QPushButton* autosel = new QPushButton(); - autosel->setText("Generate"); + autosel->setText(tr("Generate")); connect(autosel, SIGNAL(clicked()), tool_selections, SLOT(clearSelections())); connect(autosel, SIGNAL(clicked()), @@ -324,7 +324,7 @@ QWidget* MainWindow::createGenerateTab() tool_selections, SLOT(autoCreateSelectionsPreview())); QPushButton* clearsel = new QPushButton(); - clearsel->setText("Clear"); + clearsel->setText(tr("Clear")); connect(clearsel, SIGNAL(clicked()), tool_selections, SLOT(clearSelections())); @@ -333,35 +333,35 @@ QWidget* MainWindow::createGenerateTab() l->addLayout(btns); - slider_attacklength = createAttribute(w, "Attack length:", 10, 1000); + slider_attacklength = createAttribute(w, tr("Attack length:"), 10, 1000); connect(slider_attacklength, SIGNAL(valueChanged(int)), sorter, SLOT(setAttackLength(int))); connect(slider_attacklength, SIGNAL(valueChanged(int)), tool_selections, SLOT(autoCreateSelectionsPreview())); slider_attacklength->setValue(300); - slider_spread = createAttribute(w, "Power spread:", 1, 2000); + slider_spread = createAttribute(w, tr("Power spread:"), 1, 2000); connect(slider_spread, SIGNAL(valueChanged(int)), sorter, SLOT(setSpreadFactor(int))); connect(slider_spread, SIGNAL(valueChanged(int)), tool_selections, SLOT(autoCreateSelectionsPreview())); slider_spread->setValue(1000); - slider_hold = createAttribute(w, "Minimum size (samples):", 0, 200000); + slider_hold = createAttribute(w, tr("Minimum size (samples):"), 0, 200000); connect(slider_hold, SIGNAL(valueChanged(int)), tool_selections, SLOT(holdChanged(int))); connect(slider_hold, SIGNAL(valueChanged(int)), tool_selections, SLOT(autoCreateSelectionsPreview())); slider_hold->setValue(100); - slider_falloff = createAttribute(w, "Falloff:", 10, 5000); + slider_falloff = createAttribute(w, tr("Falloff:"), 10, 5000); connect(slider_falloff, SIGNAL(valueChanged(int)), tool_selections, SLOT(noiseFloorChanged(int))); connect(slider_falloff, SIGNAL(valueChanged(int)), tool_selections, SLOT(autoCreateSelectionsPreview())); slider_falloff->setValue(300); - slider_fadelength = createAttribute(w, "Fadelength:", 0, 2000); + slider_fadelength = createAttribute(w, tr("Fadelength:"), 0, 2000); connect(slider_fadelength, SIGNAL(valueChanged(int)), tool_selections, SLOT(fadeoutChanged(int))); connect(slider_fadelength, SIGNAL(valueChanged(int)), @@ -379,26 +379,26 @@ QWidget* MainWindow::createExportTab() QVBoxLayout* l = new QVBoxLayout(); w->setLayout(l); - l->addWidget(new QLabel("Prefix:")); + l->addWidget(new QLabel(tr("Prefix:"))); prefix = new QLineEdit(); connect(prefix, SIGNAL(textChanged(const QString &)), extractor, SLOT(setOutputPrefix(const QString &))); l->addWidget(prefix); - l->addWidget(new QLabel("Export path:")); + l->addWidget(new QLabel(tr("Export path:"))); QHBoxLayout* lo_exportp = new QHBoxLayout(); lineed_exportp = new QLineEdit(); connect(lineed_exportp, SIGNAL(textChanged(const QString &)), extractor, SLOT(setExportPath(const QString &))); lo_exportp->addWidget(lineed_exportp); - QPushButton* btn_browse = new QPushButton("..."); + QPushButton* btn_browse = new QPushButton(tr("...")); connect(btn_browse, SIGNAL(clicked()), this, SLOT(browse())); lo_exportp->addWidget(btn_browse); l->addLayout(lo_exportp); QPushButton* exportsel = new QPushButton(); - exportsel->setText("Export"); + exportsel->setText(tr("Export")); connect(exportsel, SIGNAL(clicked()), this, SLOT(doExport())); l->addWidget(exportsel); @@ -535,7 +535,7 @@ void MainWindow::doExport() void MainWindow::loadFile(QString filename) { setCursor(Qt::WaitCursor); - statusBar()->showMessage("Loading..."); + statusBar()->showMessage(tr("Loading...")); qApp->processEvents(); sorter->setWavData(NULL, 0); @@ -546,7 +546,7 @@ void MainWindow::loadFile(QString filename) sorter->setWavData(canvaswidget->canvas->data, canvaswidget->canvas->size); player.setPcmData(canvaswidget->canvas->data, canvaswidget->canvas->size); - statusBar()->showMessage("Ready"); + statusBar()->showMessage(tr("Ready")); setCursor(Qt::ArrowCursor); } @@ -562,7 +562,8 @@ void MainWindow::setPreset(int index) void MainWindow::browse() { - QString path = QFileDialog::getExistingDirectory(this, "Select export path", - lineed_exportp->text()); + QString path = + QFileDialog::getExistingDirectory(this, tr("Select export path"), + lineed_exportp->text()); lineed_exportp->setText(path); } diff --git a/src/selectioneditor.cc b/src/selectioneditor.cc index 71a1195..98c6161 100644 --- a/src/selectioneditor.cc +++ b/src/selectioneditor.cc @@ -54,12 +54,12 @@ SelectionEditor::SelectionEditor(Selections &s) setLayout(new QVBoxLayout()); - from = createWidget("From:", this); - to = createWidget("To:", this); - fadein = createWidget("FadeIn:", this); - fadeout = createWidget("FadeOut:", this); - energy = createWidget("Energy:", this); - name = createWidget("Name:", this); + from = createWidget(tr("From:"), this); + to = createWidget(tr("To:"), this); + fadein = createWidget(tr("FadeIn:"), this); + fadeout = createWidget(tr("FadeOut:"), this); + energy = createWidget(tr("Energy:"), this); + name = createWidget(tr("Name:"), this); ((QHBoxLayout*)layout())->addStretch(); } diff --git a/src/ts/dgedit_da.ts b/src/ts/dgedit_da.ts new file mode 100644 index 0000000..220bf09 --- /dev/null +++ b/src/ts/dgedit_da.ts @@ -0,0 +1,204 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="da_DK"> +<context> + <name>FileList</name> + <message> + <location filename="../filelist.cc" line="51"/> + <source>Open file</source> + <translation>Åbn fil</translation> + </message> + <message> + <location filename="../filelist.cc" line="52"/> + <source>Audio Files (*.wav)</source> + <translation>Lyd filer (*.wav)</translation> + </message> + <message> + <location filename="../filelist.cc" line="96"/> + <source>Set as Master (dbl-click)</source> + <translation>Vælg hovedkanal (dbl klik)</translation> + </message> + <message> + <location filename="../filelist.cc" line="99"/> + <source>Edit name</source> + <translation>Redigér navn</translation> + </message> + <message> + <location filename="../filelist.cc" line="102"/> + <source>Remove</source> + <translation>Fjern</translation> + </message> + <message> + <location filename="../filelist.cc" line="105"/> + <source>Remove all</source> + <translation>Fjern alle</translation> + </message> +</context> +<context> + <name>MainWindow</name> + <message> + <location filename="../mainwindow.cc" line="88"/> + <source>Tools</source> + <translation>Værktøjer</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="105"/> + <source>&File</source> + <translation>&Filer</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="106"/> + <source>&Quit</source> + <translation>&Afslut</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="148"/> + <source>Play samples</source> + <translation>Afspil lydbidder</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="166"/> + <source>Dock Widget</source> + <translation>Dock vindue</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="179"/> + <source>Files</source> + <translation>Filer</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="181"/> + <source>Edit</source> + <translation>Redigér</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="182"/> + <location filename="../mainwindow.cc" line="401"/> + <source>Export</source> + <translation>Eksportér</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="225"/> + <location filename="../mainwindow.cc" line="549"/> + <source>Ready</source> + <translation>Klar</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="246"/> + <source>Files: (double-click to set as master)</source> + <translation>Filer: (dobbeltklik for at vælge som hovedkanal)</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="248"/> + <source>Add files...</source> + <translation>Tilføj filer...</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="180"/> + <location filename="../mainwindow.cc" line="315"/> + <source>Generate</source> + <translation>Generér</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="327"/> + <source>Clear</source> + <translation>Ryd</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="336"/> + <source>Attack length:</source> + <translation>Attack længde:</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="343"/> + <source>Power spread:</source> + <translation>Energi spredning:</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="350"/> + <source>Minimum size (samples):</source> + <translation>Minimum størrelse (samples):</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="357"/> + <source>Falloff:</source> + <translation>Falloff:</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="364"/> + <source>Fadelength:</source> + <translation>Fadelængde:</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="382"/> + <source>Prefix:</source> + <translation>Prefix:</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="388"/> + <source>Export path:</source> + <translation>Eksporteringssti:</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="394"/> + <source>...</source> + <translation>...</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="538"/> + <source>Loading...</source> + <translation>Indlæser...</translation> + </message> + <message> + <location filename="../mainwindow.cc" line="566"/> + <source>Select export path</source> + <translation>Vælg eksporteringssti</translation> + </message> +</context> +<context> + <name>SelectionEditor</name> + <message> + <location filename="../selectioneditor.cc" line="57"/> + <source>From:</source> + <translation>Fra:</translation> + </message> + <message> + <location filename="../selectioneditor.cc" line="58"/> + <source>To:</source> + <translation>Til:</translation> + </message> + <message> + <location filename="../selectioneditor.cc" line="59"/> + <source>FadeIn:</source> + <translation>FadeIn:</translation> + </message> + <message> + <location filename="../selectioneditor.cc" line="60"/> + <source>FadeOut:</source> + <translation>FadeOut:</translation> + </message> + <message> + <location filename="../selectioneditor.cc" line="61"/> + <source>Energy:</source> + <translation>Energi:</translation> + </message> + <message> + <location filename="../selectioneditor.cc" line="62"/> + <source>Name:</source> + <translation>Navn:</translation> + </message> +</context> +<context> + <name>VolumeFader</name> + <message> + <location filename="../volumefader.cc" line="73"/> + <source>Peak </source> + <translation>Peak </translation> + </message> + <message> + <location filename="../volumefader.cc" line="97"/> + <source>Gain %1 dB</source> + <translation>Forstærkning %1 dB</translation> + </message> +</context> +</TS> diff --git a/src/volumefader.cc b/src/volumefader.cc index 9d3e15a..7982896 100644 --- a/src/volumefader.cc +++ b/src/volumefader.cc @@ -70,7 +70,7 @@ void VolumeFader::updatePeakDb(double db) void VolumeFader::updatePeakPower(double newpeak) { peak = (newpeak * (1.0 - P) + peak * P); - volumepeak->setText("Peak " + QString::number(peak, 'f', 5)); + volumepeak->setText(tr("Peak ") + QString::number(peak, 'f', 5)); handleValueChanged(); } @@ -94,6 +94,6 @@ void VolumeFader::handleValueChanged() emit volumeChangedDb(db); emit volumeChangedPower(power); - volume->setText("Gain " + QString::number(volslider->value() / SCALAR) + - " dB"); + volume->setText(tr("Gain %1 dB").arg(QString::number(volslider->value() / + SCALAR))); } |