@@ -23,8 +23,8 @@ void FileManager::newFile() {
2323
2424void FileManager::openFile () {
2525 QString filePath =
26- QFileDialog::getOpenFileName (m_window, " Open Mind Map" , QString (),
27- " YMind Files (*.ymind);;JSON Files (*.json);;All Files (*)" );
26+ QFileDialog::getOpenFileName (m_window, tr ( " Open Mind Map" ) , QString (),
27+ tr ( " YMind Files (*.ymind);;JSON Files (*.json);;All Files (*)" ) );
2828 if (filePath.isEmpty ())
2929 return ;
3030
@@ -39,7 +39,7 @@ void FileManager::openFile() {
3939 auto * scene = m_tabManager->currentScene ();
4040 auto * view = m_tabManager->currentView ();
4141 if (!scene->loadFromFile (filePath)) {
42- QMessageBox::warning (m_window, " YMind" , " Could not open file:\n " + filePath);
42+ QMessageBox::warning (m_window, " YMind" , tr ( " Could not open file:\n %1 " ). arg ( filePath) );
4343 return ;
4444 }
4545 m_tabManager->setCurrentFilePath (filePath);
@@ -55,7 +55,7 @@ void FileManager::openFile() {
5555 view->setScene (scene);
5656
5757 if (!scene->loadFromFile (filePath)) {
58- QMessageBox::warning (m_window, " YMind" , " Could not open file:\n " + filePath);
58+ QMessageBox::warning (m_window, " YMind" , tr ( " Could not open file:\n %1 " ). arg ( filePath) );
5959 delete scene;
6060 delete view;
6161 return ;
@@ -80,7 +80,7 @@ void FileManager::saveFile() {
8080 QString path = m_tabManager->currentFilePath ();
8181
8282 if (!scene->saveToFile (path)) {
83- QMessageBox::warning (m_window, " YMind" , " Could not save file:\n " + path);
83+ QMessageBox::warning (m_window, " YMind" , tr ( " Could not save file:\n %1 " ). arg ( path) );
8484 }
8585
8686 int cur = m_tabManager->currentIndex ();
@@ -92,8 +92,8 @@ void FileManager::saveFile() {
9292
9393void FileManager::saveFileAs () {
9494 QString filePath =
95- QFileDialog::getSaveFileName (m_window, " Save Mind Map" , QString (),
96- " YMind Files (*.ymind);;JSON Files (*.json);;All Files (*)" );
95+ QFileDialog::getSaveFileName (m_window, tr ( " Save Mind Map" ) , QString (),
96+ tr ( " YMind Files (*.ymind);;JSON Files (*.json);;All Files (*)" ) );
9797 if (filePath.isEmpty ())
9898 return ;
9999
@@ -102,7 +102,7 @@ void FileManager::saveFileAs() {
102102
103103 auto * scene = m_tabManager->currentScene ();
104104 if (!scene->saveToFile (filePath)) {
105- QMessageBox::warning (m_window, " YMind" , " Could not save file:\n " + filePath);
105+ QMessageBox::warning (m_window, " YMind" , tr ( " Could not save file:\n %1 " ). arg ( filePath) );
106106 return ;
107107 }
108108
@@ -130,15 +130,15 @@ void FileManager::doExport(const QString& dialogTitle, const QString& filter,
130130
131131 if (!exporter (filePath)) {
132132 QMessageBox::warning (m_window, " YMind" ,
133- QString (" Could not export %1:\n %2" ).arg (errorLabel, filePath));
133+ tr (" Could not export %1:\n %2" ).arg (errorLabel, filePath));
134134 return ;
135135 }
136136 if (auto * mw = qobject_cast<QMainWindow*>(m_window))
137- mw->statusBar ()->showMessage (" Exported to " + filePath, 3000 );
137+ mw->statusBar ()->showMessage (tr ( " Exported to %1 " ). arg ( filePath) , 3000 );
138138}
139139
140140void FileManager::exportAsText () {
141- doExport (" Export as Text" , " Text Files (*.txt);;All Files (*)" , " .txt" ,
141+ doExport (tr ( " Export as Text" ), tr ( " Text Files (*.txt);;All Files (*)" ) , " .txt" ,
142142 [this ](const QString& path) {
143143 QFile file (path);
144144 if (!file.open (QIODevice::WriteOnly | QIODevice::Text))
@@ -147,11 +147,11 @@ void FileManager::exportAsText() {
147147 file.close ();
148148 return true ;
149149 },
150- " file" );
150+ tr ( " file" ) );
151151}
152152
153153void FileManager::exportAsMarkdown () {
154- doExport (" Export as Markdown" , " Markdown Files (*.md);;All Files (*)" , " .md" ,
154+ doExport (tr ( " Export as Markdown" ), tr ( " Markdown Files (*.md);;All Files (*)" ) , " .md" ,
155155 [this ](const QString& path) {
156156 QFile file (path);
157157 if (!file.open (QIODevice::WriteOnly | QIODevice::Text))
@@ -160,42 +160,42 @@ void FileManager::exportAsMarkdown() {
160160 file.close ();
161161 return true ;
162162 },
163- " file" );
163+ tr ( " file" ) );
164164}
165165
166166void FileManager::exportAsPng () {
167- doExport (" Export as PNG" , " PNG Images (*.png);;All Files (*)" , " .png" ,
167+ doExport (tr ( " Export as PNG" ), tr ( " PNG Images (*.png);;All Files (*)" ) , " .png" ,
168168 [this ](const QString& path) {
169169 return m_tabManager->currentScene ()->exportToPng (path);
170170 },
171171 " PNG" );
172172}
173173
174174void FileManager::exportAsSvg () {
175- doExport (" Export as SVG" , " SVG Files (*.svg);;All Files (*)" , " .svg" ,
175+ doExport (tr ( " Export as SVG" ), tr ( " SVG Files (*.svg);;All Files (*)" ) , " .svg" ,
176176 [this ](const QString& path) {
177177 return m_tabManager->currentScene ()->exportToSvg (path);
178178 },
179179 " SVG" );
180180}
181181
182182void FileManager::exportAsPdf () {
183- doExport (" Export as PDF" , " PDF Files (*.pdf);;All Files (*)" , " .pdf" ,
183+ doExport (tr ( " Export as PDF" ), tr ( " PDF Files (*.pdf);;All Files (*)" ) , " .pdf" ,
184184 [this ](const QString& path) {
185185 return m_tabManager->currentScene ()->exportToPdf (path);
186186 },
187187 " PDF" );
188188}
189189
190190void FileManager::importFromText () {
191- QString filePath = QFileDialog::getOpenFileName (m_window, " Import from Text" , QString (),
192- " Text Files (*.txt);;All Files (*)" );
191+ QString filePath = QFileDialog::getOpenFileName (m_window, tr ( " Import from Text" ) , QString (),
192+ tr ( " Text Files (*.txt);;All Files (*)" ) );
193193 if (filePath.isEmpty ())
194194 return ;
195195
196196 QFile file (filePath);
197197 if (!file.open (QIODevice::ReadOnly | QIODevice::Text)) {
198- QMessageBox::warning (m_window, " YMind" , " Could not read file:\n " + filePath);
198+ QMessageBox::warning (m_window, " YMind" , tr ( " Could not read file:\n %1 " ). arg ( filePath) );
199199 return ;
200200 }
201201 QString text = QString::fromUtf8 (file.readAll ());
@@ -206,7 +206,8 @@ void FileManager::importFromText() {
206206 auto * scene = m_tabManager->currentScene ();
207207 auto * view = m_tabManager->currentView ();
208208 if (!scene->importFromText (text)) {
209- QMessageBox::warning (m_window, " YMind" , " Could not parse text file:\n " + filePath);
209+ QMessageBox::warning (m_window, " YMind" ,
210+ tr (" Could not parse text file:\n %1" ).arg (filePath));
210211 return ;
211212 }
212213 m_tabManager->setCurrentFilePath (QString ());
@@ -221,7 +222,8 @@ void FileManager::importFromText() {
221222 view->setScene (scene);
222223
223224 if (!scene->importFromText (text)) {
224- QMessageBox::warning (m_window, " YMind" , " Could not parse text file:\n " + filePath);
225+ QMessageBox::warning (m_window, " YMind" ,
226+ tr (" Could not parse text file:\n %1" ).arg (filePath));
225227 delete scene;
226228 delete view;
227229 return ;
@@ -236,5 +238,5 @@ void FileManager::importFromText() {
236238 }
237239
238240 if (auto * mw = qobject_cast<QMainWindow*>(m_window))
239- mw->statusBar ()->showMessage (" Imported from " + filePath, 3000 );
241+ mw->statusBar ()->showMessage (tr ( " Imported from %1 " ). arg ( filePath) , 3000 );
240242}
0 commit comments