34 #define WEBQUERY_ENABLE
42 #ifdef WEBQUERY_ENABLE
59 #include <ktoolbarpopupaction.h>
61 #include <kstatusbar.h>
64 #if QT_VERSION >= 0x040400
65 #include <kfadewidgeteffect.h>
69 #include <kio/netaccess.h>
71 #include <kactioncollection.h>
72 #include <kstandardaction.h>
73 #include <kstandardshortcut.h>
74 #include <kxmlguifactory.h>
77 #include <kactioncategory.h>
79 #include <kinputdialog.h>
81 #include <kfiledialog.h>
82 #include <kmessagebox.h>
85 #include <QActionGroup>
87 #include <QMdiSubWindow>
93 #include <threadweaver/ThreadWeaver.h>
101 , _project(
Project::instance())
105 , _spellcheckStartUndoIndex(0)
106 , _spellcheckStop(false)
107 , m_currentIsApproved(true)
108 , m_currentIsUntr(true)
109 , m_fullPathShown(false)
110 , m_doReplaceCalled(false)
114 , m_syncViewSecondary(0)
120 setAcceptDrops(
true);
121 setCentralWidget(m_view);
128 connect(m_view, SIGNAL(signalChanged(uint)),
this, SLOT(msgStrChanged())); msgStrChanged();
130 connect(m_view->
tabBar(),SIGNAL(currentChanged(
int)),
this,SLOT(switchForm(
int)));
135 connect(
this, SIGNAL(
fileOpened()),
this, SLOT(indexWordsForCompletion()),Qt::QueuedConnection);
137 connect (m_catalog,SIGNAL(signalFileAutoSaveFailed(QString)),
this,SLOT(fileAutoSaveFailedWarning(QString)));
145 void EditorTab::initLater()
158 ids.removeAll(m_dbusId);
162 void EditorTab::setupStatusBar()
170 connect(m_catalog,SIGNAL(signalNumberOfFuzziesChanged()),
this,SLOT(numberOfFuzziesChanged()));
171 connect(m_catalog,SIGNAL(signalNumberOfEmptyChanged()),
this,SLOT(numberOfUntranslatedChanged()));
176 QString text=i18nc(
"@info:status message entries\n'fuzzy' in gettext terminology",
"Not ready: %1", count);
178 text+=i18nc(
"percentages in statusbar",
" (%1%)",
int(100.0*count/total));
184 QString text=i18nc(
"@info:status message entries",
"Untranslated: %1", count);
186 text+=i18nc(
"percentages in statusbar",
" (%1%)",
int(100.0*count/total));
190 void EditorTab::numberOfFuzziesChanged()
195 void EditorTab::numberOfUntranslatedChanged()
200 void EditorTab::setupActions()
205 setXMLFile(
"editorui.rc");
208 KActionCollection* ac=actionCollection();
209 KActionCategory* actionCategory;
211 KActionCategory* file=
new KActionCategory(i18nc(
"@title actions category",
"File"), ac);;
212 KActionCategory* nav=
new KActionCategory(i18nc(
"@title actions category",
"Navigation"), ac);
213 KActionCategory* edit=
new KActionCategory(i18nc(
"@title actions category",
"Editing"), ac);
214 KActionCategory* sync1=
new KActionCategory(i18n(
"Synchronization 1"), ac);
215 KActionCategory* sync2=
new KActionCategory(i18n(
"Synchronization 2"), ac);
216 KActionCategory* tm=
new KActionCategory(i18n(
"Translation Memory"), ac);
217 KActionCategory* glossary=
new KActionCategory(i18nc(
"@title actions category",
"Glossary"), actionCollection());
218 KActionCategory* tools=
new KActionCategory(i18nc(
"@title actions category",
"Tools"), actionCollection());
241 altaction=tm->addAction(QString(
"alttrans_insert_%1").arg(i));
242 altaction->setShortcut(Qt::ALT+altlist[i]);
243 altaction->setText(i18nc(
"@action:inmenu",
"Insert alternate translation # %1",i));
244 altactions[i]=altaction;
247 m_altTransView =
new AltTransView(
this,m_catalog,altactions);
248 addDockWidget(Qt::BottomDockWidgetArea, m_altTransView);
249 actionCollection()->addAction( QLatin1String(
"showmsgiddiff_action"), m_altTransView->toggleViewAction() );
251 connect (m_altTransView,SIGNAL(textInsertRequested(QString)),m_view,SLOT(insertTerm(QString)));
252 connect (m_altTransView,SIGNAL(refreshRequested()),m_view,SLOT(
gotoEntry()),Qt::QueuedConnection);
253 connect (m_catalog,SIGNAL(signalFileLoaded()),m_altTransView,SLOT(fileLoaded()));
255 m_syncView =
new MergeView(
this,m_catalog,
true);
256 addDockWidget(Qt::BottomDockWidgetArea, m_syncView);
257 sync1->addAction( QLatin1String(
"showmergeview_action"), m_syncView->toggleViewAction() );
259 connect (m_catalog,SIGNAL(signalFileLoaded()),m_syncView,SLOT(cleanup()));
263 m_syncViewSecondary =
new MergeView(
this,m_catalog,
false);
264 addDockWidget(Qt::BottomDockWidgetArea, m_syncViewSecondary);
265 sync2->addAction( QLatin1String(
"showmergeviewsecondary_action"), m_syncViewSecondary->toggleViewAction() );
267 connect (m_catalog,SIGNAL(signalFileLoaded()),m_syncViewSecondary,SLOT(cleanup()));
268 connect (m_catalog,SIGNAL(signalFileLoaded(KUrl)),m_syncViewSecondary,SLOT(
mergeOpen(KUrl)),Qt::QueuedConnection);
272 m_transUnitsView =
new CatalogView(
this,m_catalog);
273 addDockWidget(Qt::LeftDockWidgetArea, m_transUnitsView);
274 actionCollection()->addAction( QLatin1String(
"showcatalogtreeview_action"), m_transUnitsView->toggleViewAction() );
277 connect (m_transUnitsView,SIGNAL(escaped()),
this,SLOT(
setProperFocus()));
278 connect (m_syncView,SIGNAL(mergeCatalogPointerChanged(
MergeCatalog*)),
279 m_transUnitsView, SLOT(setMergeCatalogPointer(
MergeCatalog*)));
282 addDockWidget(Qt::LeftDockWidgetArea, m_notesView);
283 actionCollection()->addAction( QLatin1String(
"showmsgctxt_action"), m_notesView->toggleViewAction() );
284 connect(m_catalog,SIGNAL(signalFileLoaded()),m_notesView,SLOT(cleanup()));
285 connect(m_notesView,SIGNAL(
srcFileOpenRequested(QString,
int)),
this,SLOT(dispatchSrcFileOpenRequest(QString,
int)));
286 connect(m_view, SIGNAL(signalChanged(uint)), m_notesView, SLOT(removeErrorNotes()));
287 connect(m_notesView,SIGNAL(escaped()),
this,SLOT(
setProperFocus()));
289 action=edit->addAction(QLatin1String(
"edit_addnote"),m_notesView,SLOT(addNoteUI()));
291 action->setText(i18nc(
"@action:inmenu",
"Add a note"));
311 tmaction=tm->addAction(QString(
"tmquery_insert_%1").arg(i));
312 tmaction->setShortcut(Qt::CTRL+tmlist[i]);
313 tmaction->setText(i18nc(
"@action:inmenu",
"Insert TM suggestion # %1",i));
314 tmactions[i]=tmaction;
317 addDockWidget(Qt::BottomDockWidgetArea, _tmView);
318 tm->addAction( QLatin1String(
"showtmqueryview_action"), _tmView->toggleViewAction() );
319 connect (_tmView,SIGNAL(refreshRequested()),m_view,SLOT(
gotoEntry()),Qt::QueuedConnection);
320 connect (_tmView,SIGNAL(refreshRequested()),
this,SLOT(msgStrChanged()),Qt::QueuedConnection);
321 connect (_tmView,SIGNAL(textInsertRequested(QString)),m_view,SLOT(insertTerm(QString)));
357 gaction=glossary->addAction(QString(
"glossary_insert_%1").arg(i));
358 gaction->setShortcut(Qt::CTRL+glist[i]);
359 gaction->setText(i18nc(
"@action:inmenu",
"Insert # %1 term translation",i));
364 addDockWidget(Qt::BottomDockWidgetArea, _glossaryView);
365 glossary->addAction( QLatin1String(
"showglossaryview_action"), _glossaryView->toggleViewAction() );
367 connect (_glossaryView,SIGNAL(termInsertRequested(QString)),m_view,SLOT(insertTerm(QString)));
369 gaction = glossary->addAction(
"glossary_define",
this,SLOT(defineNewTerm()));
370 gaction->setText(i18nc(
"@action:inmenu",
"Define new term"));
371 _glossaryView->addAction(gaction);
372 _glossaryView->setContextMenuPolicy( Qt::ActionsContextMenu);
376 addDockWidget(Qt::BottomDockWidgetArea, binUnitsView);
377 edit->addAction( QLatin1String(
"showbinunitsview_action"), binUnitsView->toggleViewAction() );
378 connect(m_view,SIGNAL(binaryUnitSelectRequested(QString)),binUnitsView,SLOT(selectUnit(QString)));
401 wqaction=actionCollection()->addAction(QString(
"webquery_insert_%1").arg(i));
402 wqaction->setShortcut(Qt::CTRL+Qt::ALT+wqlist[i]);
404 wqaction->setText(i18nc(
"@action:inmenu",
"Insert WebQuery result # %1",i));
405 wqactions[i]=wqaction;
408 addDockWidget(Qt::BottomDockWidgetArea, _webQueryView);
409 actionCollection()->addAction( QLatin1String(
"showwebqueryview_action"), _webQueryView->toggleViewAction() );
411 connect (_webQueryView,SIGNAL(textInsertRequested(QString)),m_view,SLOT(insertTerm(QString)));
423 action=file->addAction(KStandardAction::Save,
this, SLOT(
saveFile()));
424 action->setEnabled(
false);
425 connect (m_catalog,SIGNAL(cleanChanged(
bool)),action,SLOT(setDisabled(
bool)));
426 connect (m_catalog,SIGNAL(cleanChanged(
bool)),
this,SLOT(setModificationSign(
bool)));
427 file->addAction(KStandardAction::SaveAs,
this, SLOT(
saveFileAs()));
434 action = actionCategory->addAction(
"file_phases");
435 action->setText(i18nc(
"@action:inmenu",
"Phases..."));
436 connect(action, SIGNAL(triggered()), SLOT(openPhasesWindow()));
438 #define ADD_ACTION_ICON(_name,_text,_shortcut,_icon)\
439 action = actionCategory->addAction(_name);\
440 action->setText(_text);\
441 action->setShortcuts(KStandardShortcut::shortcut(KStandardShortcut::_shortcut));\
442 action->setIcon(KIcon(_icon));
444 #define ADD_ACTION_SHORTCUT_ICON(_name,_text,_shortcut,_icon)\
445 action = actionCategory->addAction(_name);\
446 action->setText(_text);\
447 action->setShortcut(QKeySequence( _shortcut ));\
448 action->setIcon(KIcon(_icon));
450 #define ADD_ACTION_SHORTCUT(_name,_text,_shortcut)\
451 action = actionCategory->addAction(_name);\
452 action->setText(_text);\
453 action->setShortcut(QKeySequence( _shortcut ));\
458 action=edit->addAction(KStandardAction::Undo,
this,SLOT(undo()));
459 connect(m_view->
viewPort(),SIGNAL(undoRequested()),
this,SLOT(undo()));
460 connect(m_catalog,SIGNAL(canUndoChanged(
bool)),action,SLOT(setEnabled(
bool)) );
461 action->setEnabled(
false);
463 action=edit->addAction(KStandardAction::Redo,
this,SLOT(redo()));
464 connect(m_view->
viewPort(),SIGNAL(redoRequested()),
this,SLOT(redo()));
465 connect(m_catalog,SIGNAL(canRedoChanged(
bool)),action,SLOT(setEnabled(
bool)) );
466 action->setEnabled(
false);
468 action=nav->addAction(KStandardAction::Find,
this,SLOT(find()));
469 action=nav->addAction(KStandardAction::FindNext,
this,SLOT(findNext()));
470 action=nav->addAction(KStandardAction::FindPrev,
this,SLOT(findPrev()));
471 action->setText(i18nc(
"@action:inmenu",
"Change searching direction"));
472 action=edit->addAction(KStandardAction::Replace,
this,SLOT(replace()));
474 connect(m_view,SIGNAL(findRequested()),
this,SLOT(find()));
475 connect(m_view,SIGNAL(findNextRequested()),
this,SLOT(findNext()));
476 connect(m_view,SIGNAL(replaceRequested()),
this,SLOT(replace()));
480 action = actionCategory->addAction(
"edit_approve",
new KToolBarPopupAction(KIcon(
"approved"),i18nc(
"@option:check whether message is marked as translated/reviewed/approved (depending on your role)",
"Approved"),
this));
481 action->setShortcut(QKeySequence( Qt::CTRL+Qt::Key_U ));
482 action->setCheckable(
true);
483 connect(action, SIGNAL(triggered()), m_view,SLOT(toggleApprovement()));
487 m_approveAction=action;
488 connect(
Project::local(), SIGNAL(configChanged()), SLOT(setApproveActionTitle()));
489 connect(m_catalog, SIGNAL(activePhaseChanged()), SLOT(setApproveActionTitle()));
490 setApproveActionTitle();
491 connect(action->menu(), SIGNAL(aboutToShow()),
this,SLOT(showStatesMenu()));
492 connect(action->menu(), SIGNAL(triggered(QAction*)),
this,SLOT(setState(QAction*)));
495 action = actionCategory->addAction(
"edit_approve_go_fuzzyUntr");
496 action->setText(i18nc(
"@action:inmenu",
"Approve and go to next"));
497 connect(action, SIGNAL(triggered()), SLOT(toggleApprovementGotoNextFuzzyUntr()));
500 action = actionCategory->addAction(
"edit_nonequiv",m_view,SLOT(setEquivTrans(
bool)));
501 action->setText(i18nc(
"@action:inmenu",
"Equivalent translation"));
502 action->setCheckable(
true);
506 int copyShortcut=Qt::CTRL+Qt::Key_Space;
507 QString systemLang=KGlobal::locale()->language();
508 if (KDE_ISUNLIKELY( systemLang.startsWith(
"ko")
509 || systemLang.startsWith(
"ja")
510 || systemLang.startsWith(
"zh")
512 copyShortcut=Qt::ALT+Qt::Key_Space;
513 ADD_ACTION_SHORTCUT_ICON(
"edit_msgid2msgstr",i18nc(
"@action:inmenu",
"Copy source to target"),copyShortcut,
"msgid2msgstr")
514 connect(action, SIGNAL(triggered(
bool)), m_view->viewPort(),SLOT(source2target()));
516 ADD_ACTION_SHORTCUT("edit_unwrap-target",i18nc("@action:inmenu","Unwrap target"),Qt::CTRL+Qt::Key_I)
517 connect(action, SIGNAL(triggered(
bool)), m_view,SLOT(unwrap()));
520 action->setShortcut(Qt::CTRL+Qt::Key_D);
521 action->
setText(i18nc("@action:inmenu","Clear"));
523 action=edit->addAction("edit_completion",m_view,SIGNAL(doExplicitCompletion()));
524 action->setShortcut(Qt::CTRL+Qt::ALT+Qt::Key_Space);
525 action->
setText(i18nc("@action:inmenu","Completion"));
527 action=edit->addAction("edit_tagmenu",m_view->viewPort(),SLOT(tagMenu()));
528 action->setShortcut(Qt::CTRL+Qt::Key_T);
531 action=edit->addAction("edit_tagimmediate",m_view->viewPort(),SLOT(tagImmediate()));
532 action->setShortcut(Qt::CTRL+Qt::Key_M);
535 action=edit->addAction("edit_spellreplace",m_view->viewPort(),SLOT(spellReplace()));
536 action->setShortcut(Qt::CTRL+Qt::Key_Equal);
537 action->
setText(i18nc("@action:inmenu","Replace with best spellcheck suggestion"));
544 action=nav->addAction(KStandardAction::Next,this, SLOT(
gotoNext()));
545 action->
setText(i18nc("@action:inmenu entry","&Next"));
547 connect(m_view->viewPort(),SIGNAL(gotoNextRequested()),this,SLOT(gotoNext()));
549 action=nav->addAction(KStandardAction::Prior,this, SLOT(
gotoPrev()));
550 action->
setText(i18nc("@action:inmenu entry","&Previous"));
552 connect(m_view->viewPort(),SIGNAL(gotoPrevRequested()),this,SLOT(gotoPrev()));
554 action=nav->addAction(KStandardAction::FirstPage,this, SLOT(
gotoFirst()));
555 connect(m_view->viewPort(),SIGNAL(gotoFirstRequested()),this,SLOT(gotoFirst()));
556 action->
setText(i18nc("@action:inmenu","&First Entry"));
557 action->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_Home));
560 action=nav->addAction(KStandardAction::LastPage,this, SLOT(
gotoLast()));
561 connect(m_view->viewPort(),SIGNAL(gotoLastRequested()),this,SLOT(gotoLast()));
562 action->
setText(i18nc("@action:inmenu","&Last Entry"));
563 action->setShortcut(QKeySequence(Qt::CTRL+Qt::ALT+Qt::Key_End));
566 action=nav->addAction(KStandardAction::GotoPage,this, SLOT(gotoEntry()));
567 action->setShortcut(Qt::CTRL+Qt::Key_G);
568 action->
setText(i18nc("@action:inmenu","Entry by number"));
570 ADD_ACTION_SHORTCUT_ICON("go_prev_fuzzy",i18nc("@action:inmenu\n'not ready' means 'fuzzy' in gettext terminology","Previous non-empty but not ready"),Qt::CTRL+Qt::Key_PageUp,"prevfuzzy")
571 connect( action, SIGNAL(triggered(
bool)), this, SLOT(gotoPrevFuzzy()) );
572 connect( m_view->viewPort(), SIGNAL(gotoPrevFuzzyRequested()), this, SLOT(gotoPrevFuzzy()) );
575 ADD_ACTION_SHORTCUT_ICON("go_next_fuzzy",i18nc("@action:inmenu\n'not ready' means 'fuzzy' in gettext terminology","Next non-empty but not ready"),Qt::CTRL+Qt::Key_PageDown,"nextfuzzy")
576 connect( action, SIGNAL(triggered(
bool)), this, SLOT(gotoNextFuzzy()) );
577 connect( m_view->viewPort(), SIGNAL(gotoNextFuzzyRequested()), this, SLOT(gotoNextFuzzy()) );
580 ADD_ACTION_SHORTCUT_ICON("go_prev_untrans",i18nc("@action:inmenu","Previous untranslated"),Qt::ALT+Qt::Key_PageUp,"prevuntranslated")
581 connect( action, SIGNAL(triggered(
bool)), this, SLOT(gotoPrevUntranslated()));
582 connect( m_view->viewPort(), SIGNAL(gotoPrevUntranslatedRequested()), this, SLOT(gotoPrevUntranslated()) );
585 ADD_ACTION_SHORTCUT_ICON("go_next_untrans",i18nc("@action:inmenu","Next untranslated"),Qt::ALT+Qt::Key_PageDown,"nextuntranslated")
586 connect( action, SIGNAL(triggered(
bool)), this, SLOT(gotoNextUntranslated()));
587 connect( m_view->viewPort(), SIGNAL(gotoNextUntranslatedRequested()), this, SLOT(gotoNextUntranslated()) );
590 ADD_ACTION_SHORTCUT_ICON("go_prev_fuzzyUntr",i18nc("@action:inmenu\n'not ready' means 'fuzzy' in gettext terminology","Previous not ready"),Qt::CTRL+Qt::SHIFT+Qt::Key_PageUp,"prevfuzzyuntrans")
591 connect( action, SIGNAL(triggered(
bool)), this, SLOT(gotoPrevFuzzyUntr()) );
592 connect( m_view->viewPort(), SIGNAL(gotoPrevFuzzyUntrRequested()), this, SLOT(gotoPrevFuzzyUntr()) );
595 ADD_ACTION_SHORTCUT_ICON("go_next_fuzzyUntr",i18nc("@action:inmenu\n'not ready' means 'fuzzy' in gettext terminology","Next not ready"),Qt::CTRL+Qt::SHIFT+Qt::Key_PageDown,"nextfuzzyuntrans")
596 connect( action, SIGNAL(triggered(
bool)), this, SLOT(gotoNextFuzzyUntr()) );
597 connect( m_view->viewPort(), SIGNAL(gotoNextFuzzyUntrRequested()), this, SLOT(gotoNextFuzzyUntr()) );
600 action=nav->addAction("go_focus_earch_line",m_transUnitsView, SLOT(setFocus()));
601 action->setShortcut(Qt::CTRL+Qt::Key_L);
602 action->
setText(i18nc("@action:inmenu","Focus the search line of Translation Units view"));
606 action=nav->addAction(KStandardAction::AddBookmark,m_view,SLOT(toggleBookmark(
bool)));
608 action->
setText(i18nc("@option:check","Bookmark message"));
609 action->setCheckable(true);
613 action=nav->addAction("bookmark_prior",this,SLOT(gotoPrevBookmark()));
614 action->
setText(i18nc("@action:inmenu","Previous bookmark"));
617 action=nav->addAction("bookmark_next",this,SLOT(gotoNextBookmark()));
618 action->
setText(i18nc("@action:inmenu","Next bookmark"));
622 edit->addAction(KStandardAction::Spelling,this,SLOT(spellcheck()));
626 ADD_ACTION_SHORTCUT("tools_tm_batch",i18nc("@action:inmenu","Fill in all exact suggestions"),Qt::CTRL+Qt::ALT+Qt::Key_B)
627 connect( action, SIGNAL(triggered(
bool)), _tmView, SLOT(slotBatchTranslate()) );
630 ADD_ACTION_SHORTCUT("tools_tm_batch_fuzzy",i18nc("@action:inmenu","Fill in all exact suggestions and mark as fuzzy"),Qt::CTRL+Qt::ALT+Qt::Key_N)
631 connect( action, SIGNAL(triggered(
bool)), _tmView, SLOT(slotBatchTranslateFuzzy()) );
633 actionCategory=tools;
634 ADD_ACTION_SHORTCUT("tools_wordcount",i18nc("@action:inmenu","Word count"),Qt::CTRL+Qt::ALT+Qt::Key_C)
635 connect( action, SIGNAL(triggered(
bool)), this, SLOT(displayWordCount()) );
638 action = sync1->addAction("merge_open",m_syncView,SLOT(
mergeOpen()));
639 action->
setText(i18nc("@action:inmenu","Open file for sync/merge"));
640 action->setStatusTip(i18nc("@info:status","Open catalog to be merged into the current one / replicate base file changes to"));
641 action->setToolTip(action->statusTip());
642 action->setWhatsThis(action->statusTip());
643 m_syncView->addAction(action);
645 action = sync1->addAction("merge_prev",m_syncView,SLOT(gotoPrevChanged()));
646 action->
setText(i18nc("@action:inmenu","Previous different"));
647 action->setStatusTip(i18nc("@info:status","Previous entry which is translated differently in the file being merged, including empty translations in merge source"));
648 action->setToolTip(action->statusTip());
649 action->setWhatsThis(action->statusTip());
650 action->setShortcut(Qt::ALT+Qt::Key_Up);
651 connect( m_syncView, SIGNAL(signalPriorChangedAvailable(
bool)),action,SLOT(setEnabled(
bool)) );
652 m_syncView->addAction(action);
654 action = sync1->addAction("merge_next",m_syncView,SLOT(gotoNextChanged()));
655 action->
setText(i18nc("@action:inmenu","Next different"));
656 action->setStatusTip(i18nc("@info:status","Next entry which is translated differently in the file being merged, including empty translations in merge source"));
657 action->setToolTip(action->statusTip());
658 action->setWhatsThis(action->statusTip());
659 action->setShortcut(Qt::ALT+Qt::Key_Down);
660 connect( m_syncView, SIGNAL(signalNextChangedAvailable(
bool)),action,SLOT(setEnabled(
bool)) );
661 m_syncView->addAction(action);
663 action = sync1->addAction("merge_nextapproved",m_syncView,SLOT(gotoNextChangedApproved()));
664 action->
setText(i18nc("@action:inmenu","Next different approved"));
665 action->setShortcut(Qt::ALT+Qt::META+Qt::Key_Down);
666 connect( m_syncView, SIGNAL(signalNextChangedAvailable(
bool)),action,SLOT(setEnabled(
bool)) );
667 m_syncView->addAction(action);
669 action = sync1->addAction("merge_accept",m_syncView,SLOT(mergeAccept()));
670 action->
setText(i18nc("@action:inmenu","Copy from merging source"));
671 action->setShortcut(Qt::ALT+Qt::Key_Return);
673 m_syncView->addAction(action);
675 action = sync1->addAction("merge_acceptnew",m_syncView,SLOT(mergeAcceptAllForEmpty()));
676 action->
setText(i18nc("@action:inmenu","Copy all new translations"));
677 action->setStatusTip(i18nc("@info:status","This changes only empty and non-ready entries in base file"));
678 action->setToolTip(action->statusTip());
679 action->setWhatsThis(action->statusTip());
680 action->setShortcut(Qt::CTRL+Qt::ALT+Qt::Key_A);
681 m_syncView->addAction(action);
684 action = sync1->addAction("merge_back",m_syncView,SLOT(mergeBack()));
685 action->
setText(i18nc("@action:inmenu","Copy to merging source"));
686 action->setShortcut(Qt::CTRL+Qt::ALT+Qt::Key_Return);
687 m_syncView->addAction(action);
691 action = sync2->addAction("mergesecondary_open",m_syncViewSecondary,SLOT(mergeOpen()));
692 action->
setText(i18nc("@action:inmenu","Open file for secondary sync"));
693 action->setStatusTip(i18nc("@info:status","Open catalog to be merged into the current one / replicate base file changes to"));
694 action->setToolTip(action->statusTip());
695 action->setWhatsThis(action->statusTip());
696 m_syncViewSecondary->addAction(action);
698 action = sync2->addAction("mergesecondary_prev",m_syncViewSecondary,SLOT(gotoPrevChanged()));
699 action->
setText(i18nc("@action:inmenu","Previous different"));
700 action->setStatusTip(i18nc("@info:status","Previous entry which is translated differently in the file being merged, including empty translations in merge source"));
701 action->setToolTip(action->statusTip());
702 action->setWhatsThis(action->statusTip());
703 connect( m_syncViewSecondary, SIGNAL(signalPriorChangedAvailable(
bool)),action,SLOT(setEnabled(
bool)) );
704 m_syncViewSecondary->addAction(action);
706 action = sync2->addAction("mergesecondary_next",m_syncViewSecondary,SLOT(gotoNextChanged()));
707 action->
setText(i18nc("@action:inmenu","Next different"));
708 action->setStatusTip(i18nc("@info:status","Next entry which is translated differently in the file being merged, including empty translations in merge source"));
709 action->setToolTip(action->statusTip());
710 action->setWhatsThis(action->statusTip());
711 connect( m_syncViewSecondary, SIGNAL(signalNextChangedAvailable(
bool)),action,SLOT(setEnabled(
bool)) );
712 m_syncViewSecondary->addAction(action);
714 action = sync2->addAction("mergesecondary_accept",m_syncViewSecondary,SLOT(mergeAccept()));
715 action->
setText(i18nc("@action:inmenu","Copy from merging source"));
717 m_syncViewSecondary->addAction(action);
719 action = sync2->addAction("mergesecondary_acceptnew",m_syncViewSecondary,SLOT(mergeAcceptAllForEmpty()));
720 action->
setText(i18nc("@action:inmenu","Copy all new translations"));
721 action->setStatusTip(i18nc("@info:status","This changes only empty entries"));
722 action->setToolTip(action->statusTip());
723 action->setWhatsThis(action->statusTip());
724 m_syncViewSecondary->addAction(action);
726 action = sync2->addAction("mergesecondary_back",m_syncViewSecondary,SLOT(mergeBack()));
727 action->
setText(i18nc("@action:inmenu","Copy to merging source"));
728 m_syncViewSecondary->addAction(action);
734 m_view->setProperFocus();
739 if (m_transUnitsView->isFloating())
740 m_transUnitsView->hide();
746 if (m_transUnitsView->isFloating())
747 m_transUnitsView->show();
752 if (m_catalog->
autoSaveRecovered()) title+=
' '+i18nc(
"editor tab name",
"(recovered)");
753 setWindowTitle(title+
" [*]");
754 setWindowModified(modified);
759 m_fullPathShown=fullPathShown;
762 setModificationSign(m_catalog->isClean());
766 void EditorTab::updateCaptionPath()
768 KUrl url=m_catalog->
url();
769 if (!url.isLocalFile() || !_project->
isLoaded())
770 _captionPath=url.pathOrUrl();
775 _captionPath=KUrl::relativePath(
776 KUrl(_project->
path()).directory()
778 if (_captionPath.contains(
"../.."))
779 _captionPath=url.toLocalFile();
780 else if (_captionPath.startsWith(
"./"))
781 _captionPath=_captionPath.mid(2);
784 _captionPath=url.fileName();
791 if (!m_catalog->isClean())
794 i18nc(
"@info",
"The document contains unsaved changes.\n"
795 "Do you want to save your changes or discard them?"),i18nc(
"@title:window",
"Warning"),
796 KStandardGuiItem::save(),KStandardGuiItem::discard())
799 case KMessageBox::Yes:
if (!
saveFile())
return false;
800 case KMessageBox::Cancel:
return false;
803 if (baseUrl.isEmpty())
804 baseUrl=m_catalog->
url();
818 QString path=url.toLocalFile();
820 if (QFile::exists(path) || QFile::exists(path=path+
't'))
829 QApplication::setOverrideCursor(Qt::WaitCursor);
832 bool wasOpen=!m_catalog->
isEmpty();
837 QApplication::restoreOverrideCursor();
842 numberOfUntranslatedChanged();
843 numberOfFuzziesChanged();
845 m_currentPos.
entry=-1;
853 if (url.isLocalFile() && !_project->
isLoaded())
857 QDir dir(url.directory());
858 QStringList proj(
"*.ktp");
859 proj.append(
"*.lokalize");
860 dir.setNameFilters(proj);
861 while (--i && !dir.isRoot() && !_project->
isLoaded())
863 if (dir.entryList().isEmpty()) dir.cdUp();
864 else _project->
load(dir.absoluteFilePath(dir.entryList().first()));
872 _project->
setDesirablePath(url.directory(KUrl::AppendTrailingSlash)+
"index.lokalize");
881 setModificationSign(m_catalog->isClean());
891 if (errorLine>0) KMessageBox::error(
this, i18nc(
"@info",
"Error opening the file <filename>%1</filename>, line: %2",url.pathOrUrl(),errorLine) );
892 else KMessageBox::error(
this, i18nc(
"@info",
"Error opening the file <filename>%1</filename>",url.pathOrUrl()) );
899 KUrl url=KFileDialog::getSaveUrl(m_catalog->
url(),m_catalog->
mimetype(),
this);
900 if (url.isEmpty())
return false;
909 setModificationSign(
true);
914 if ( KMessageBox::Continue==KMessageBox::warningContinueCancel(
this,
915 i18nc(
"@info",
"Error saving the file <filename>%1</filename>\n"
916 "Do you want to save to another file or cancel?", m_catalog->
url().pathOrUrl()),
917 i18nc(
"@title",
"Error"),KStandardGuiItem::save())
923 void EditorTab::fileAutoSaveFailedWarning(
const QString& fileName)
925 KMessageBox::information(
this, i18nc(
"@info",
"Could not perform file autosaving.\n"
926 "The target file was <filename>%1</filename>.", fileName) );
933 state.
url=m_catalog->
url();
943 if (m_catalog->isClean())
return true;
946 switch (KMessageBox::warningYesNoCancel(
this,
947 i18nc(
"@info",
"The document contains unsaved changes.\n"
948 "Do you want to save your changes or discard them?"),i18nc(
"@title:window",
"Warning"),
949 KStandardGuiItem::save(),KStandardGuiItem::discard()))
951 case KMessageBox::Yes:
return saveFile();
952 case KMessageBox::No:
return true;
953 default:
return false;
958 void EditorTab::undo()
960 gotoEntry(m_catalog->
undo(),0);
964 void EditorTab::redo()
973 pos.
entry=KInputDialog::getInteger(
974 i18nc(
"@title",
"Jump to Entry"),
975 i18nc(
"@label:spinbox",
"Enter entry number:"),
1054 void EditorTab::msgStrChanged()
1056 bool isUntr=m_catalog->
msgstr(m_currentPos).isEmpty();
1058 if (isUntr==m_currentIsUntr && isApproved==m_currentIsApproved)
1062 if (isUntr) msg=i18nc(
"@info:status",
"Untranslated");
1063 else if (isApproved)msg=i18nc(
"@info:status 'non-fuzzy' in gettext terminology",
"Ready");
1064 else msg=i18nc(
"@info:status 'fuzzy' in gettext terminology",
"Needs review");
1071 m_currentIsUntr=isUntr;
1075 void EditorTab::switchForm(
int newForm)
1077 if (m_currentPos.
form==newForm)
return;
1143 void EditorTab::gotoPrevFuzzy()
1153 void EditorTab::gotoNextFuzzy()
1163 void EditorTab::gotoPrevUntranslated()
1173 void EditorTab::gotoNextUntranslated()
1183 void EditorTab::gotoPrevFuzzyUntr()
1190 pos.
entry=fu>un?fu:un;
1191 if ( pos.
entry == -1)
1197 bool EditorTab::gotoNextFuzzyUntr(
const DocPosition& p)
1205 if ( (fu == -1) && (un == -1) )
1208 if (fu == -1) fu=un;
1209 else if (un == -1) un=fu;
1211 pos.
entry=fu<un?fu:un;
1217 void EditorTab::toggleApprovementGotoNextFuzzyUntr()
1221 if (!gotoNextFuzzyUntr())
1225 void EditorTab::setApproveActionTitle()
1227 const char*
const titles[]={
1228 I18N_NOOP2(
"@option:check trans-unit state",
"Translated"),
1229 I18N_NOOP2(
"@option:check trans-unit state",
"Signed-off"),
1230 I18N_NOOP2(
"@option:check trans-unit state",
"Approved")
1232 const char*
const helpText[]={
1233 I18N_NOOP2(
"@info:tooltip",
"Translation is done (although still may need a review)"),
1234 I18N_NOOP2(
"@info:tooltip",
"Translation received positive review"),
1235 I18N_NOOP2(
"@info:tooltip",
"Entry is fully localized (i.e. final)")
1241 m_approveAction->setText(i18nc(
"@option:check trans-unit state",titles[role]));
1242 m_approveAction->setToolTip(i18nc(
"@info:tooltip",helpText[role]));
1245 void EditorTab::showStatesMenu()
1247 m_approveAction->menu()->clear();
1250 QAction* a=m_approveAction->menu()->addAction(i18nc(
"@info:status 'fuzzy' in gettext terminology",
"Needs review"));
1251 a->setData(QVariant(-1));
1252 a->setCheckable(
true);
1253 a->setChecked(!m_catalog->
isApproved(m_currentPos));
1255 a=m_approveAction->menu()->addAction(i18nc(
"@info:status 'non-fuzzy' in gettext terminology",
"Ready"));
1256 a->setData(QVariant(-2));
1257 a->setCheckable(
true);
1258 a->setChecked(m_catalog->
isApproved(m_currentPos));
1268 QAction* a=m_approveAction->menu()->addAction(i18n(states[i]));
1269 a->setData(QVariant(i));
1270 a->setCheckable(
true);
1271 a->setChecked(state==i);
1274 m_approveAction->menu()->addSeparator();
1278 void EditorTab::setState(QAction* a)
1285 m_approveAction->menu()->clear();
1288 void EditorTab::openPhasesWindow()
1294 void EditorTab::gotoPrevBookmark()
1304 void EditorTab::gotoNextBookmark()
1329 if (QMdiSubWindow* sw=qobject_cast<QMdiSubWindow*>(parent()))
1331 if (sw->mdiArea()->currentSubWindow()!=sw)
1334 LokalizeSubwindowBase2::paintEvent(event);
1337 void EditorTab::indexWordsForCompletion()
1343 void EditorTab::defineNewTerm()
1348 en=m_catalog->
msgid(m_currentPos).toLower();
1351 if (target.isEmpty())
1352 target=m_catalog->
msgstr(m_currentPos).toLower();
1360 KUrl mergeFile=m_syncView->
url();
1366 if (!mergeFile.isEmpty())
1370 void EditorTab::dispatchSrcFileOpenRequest(
const QString& srcPath,
int line)
1372 m_srcFileOpenRequestAccepted=
false;
1374 if (!m_srcFileOpenRequestAccepted)
1375 KMessageBox::information(
this, i18nc(
"@info",
"Cannot open source files: no scripts to do so are currently loaded. "
1376 "Refer to the Lokalize handbook for script examples and how to plug them into your project.") );
1381 #include "editoradaptor.h"
1382 QList<int> EditorTab::ids;
1391 while(i<ids.size()&&i==ids.at(i))
1395 QDBusConnection::sessionBus().registerObject(
"/ThisIsWhatYouWant/Editor/" + QString::number(m_dbusId),
this);
1397 return "/ThisIsWhatYouWant/Editor/" + QString::number(m_dbusId);
1435 if (m_currentPos==pos)
1442 #include "editortab.moc"
PersonRole role() const
Get Role.
void gotoEntry(const DocPosition &, int selection=0)
QString selectionInSource() const
void addAlternateTranslation(int entry, const QString &, bool temp=true)
Q_SCRIPTABLE void gotoFirst()
void gotoEntry(DocPosition pos=DocPosition(), int selection=0)
Q_SCRIPTABLE QString targetLangCode()
EditorTab(QWidget *parent, bool valid=true)
void addNote(DocPosition, const QString &text)
CatalogString targetWithTags(const DocPosition &pos) const
void signalApprovedEntryDisplayed(bool)
int prevBookmarkIndex(uint index) const
int prevUntranslatedIndex(uint index) const
QString targetLangCode() const
ThreadWeaver::Weaver * weaver()
void mergeOpen(KUrl url=KUrl())
void insert(int, const QString &)
Q_SCRIPTABLE bool saveFile(const KUrl &url=KUrl())
int numberOfPluralForms() const
#define ADD_ACTION_SHORTCUT_ICON(_name, _text, _shortcut, _icon)
bool isApproved(TargetState state, ProjectLocal::PersonRole role)
void setState(TargetState)
unlike other views, we keep data like catalog pointer in our child view: ui_queryControl contains our...
Q_SCRIPTABLE QString currentEntryId()
bool switchNext(Catalog *&catalog, DocPosition &pos, int parts)
static Project * instance()
void signalEntryWithMergeDisplayed(bool, const DocPosition &)
void setProperCaption(QString, bool)
static CompletionStorage * instance()
ProjectLocal::PersonRole activePhaseRole() const
void signalEquivTranslatedEntryDisplayed(bool)
virtual const DocPosition & redo()
Q_SCRIPTABLE void srcFileOpenRequested(const QString &srcPath, int line)
void signalLastDisplayed(bool)
static ProjectLocal * local()
#define ID_STATUS_CURRENT
void signalNextFuzzyOrUntrAvailable(bool)
#define ALTTRANS_SHORTCUTS
int lastUntranslatedIndex() const
int loadFromUrl(const KUrl &url, const KUrl &saidUrl=KUrl(), int *fileSize=0)
Q_SCRIPTABLE void attachAlternateTranslationFile(const QString &path)
void setActivePhase(const QString &phase, ProjectLocal::PersonRole role=ProjectLocal::Approver)
Q_SCRIPTABLE void setDesirablePath(const QString &path)
bool isEmpty(uint index) const
Q_SCRIPTABLE void gotoLast()
Q_SCRIPTABLE void addEntryNote(int entry, const QString ¬e)
int firstUntranslatedIndex() const
#define ADD_ACTION_SHORTCUT(_name, _text, _shortcut)
void signalFirstDisplayed(bool)
GlossaryNS::GlossaryWindow * defineNewTerm(QString en=QString(), QString target=QString())
This struct represents a position in a catalog.
void mergeOpen(KUrl url=KUrl())
Q_SCRIPTABLE void gotoNextUnfiltered()
void signalNewEntryDisplayed(const DocPosition &)
Singleton object that represents project.
virtual const DocPosition & undo()
Q_SCRIPTABLE int entryCount()
QString selectionInTarget() const
bool removeTargetSubstring(Catalog *catalog, DocPosition pos, int delStart, int delLen)
Q_SCRIPTABLE void setEntryFilteredOut(int entry, bool filteredOut)
void paintEvent(QPaintEvent *event)
void setText(QDomElement element, QString text)
void reflectNonApprovedCount(int count, int total)
Q_SCRIPTABLE void addTemporaryEntryNote(int entry, const QString ¬e)
static QString content(QDomElement elem, ContentEditingData *data=0)
walks through XLIFF XML and performs actions depending on ContentEditingData:
int firstFuzzyIndex() const
void scanCatalog(Catalog *)
Q_SCRIPTABLE void setEntriesFilteredOut(bool filteredOut)
bool isBookmarked(uint index) const
Q_SCRIPTABLE void fileOpened()
Q_SCRIPTABLE void gotoLastUnfiltered()
Q_SCRIPTABLE QString entrySource(int entry, int form)
Q_SCRIPTABLE void entryDisplayed()
Q_SCRIPTABLE QString desirablePath() const
void addTemporaryEntryNote(int entry, const QString &text)
bool isPlural(uint index) const
void signalNextBookmarkAvailable(bool)
Q_SCRIPTABLE void gotoFirstUnfiltered()
Q_SCRIPTABLE void gotoNext()
int nextBookmarkIndex(uint index) const
static const char *const states[]
void signalPriorFuzzyAvailable(bool)
Q_SCRIPTABLE void fileAboutToBeClosed()
void tmLookupRequested(DocPosition::Part, const QString &)
Q_SCRIPTABLE QString selectionInSource()
void reflectUntranslatedCount(int count, int total)
Q_SCRIPTABLE bool saveFileAs()
Q_SCRIPTABLE QString entryTarget(int entry, int form)
void setFullPathShown(bool)
int nextFuzzyIndex(uint index) const
int firstBookmarkIndex() const
static SettingsController * instance()
void signalPriorFuzzyOrUntrAvailable(bool)
This is the main view class for Lokalize Editor.
void load(const QString &file)
Q_SCRIPTABLE int entryPluralFormCount(int entry)
int nextUntranslatedIndex(uint index) const
void signalPriorBookmarkAvailable(bool)
int lastFuzzyIndex() const
void signalPriorUntranslatedAvailable(bool)
#define WEBQUERY_SHORTCUTS
QString msgid(const DocPosition &) const
Q_SCRIPTABLE void reloadFile()
data structure used to pass info about inline elements a XLIFF tag is represented by a TAGRANGE_IMAGE...
void insertCatalogString(Catalog *catalog, DocPosition pos, const CatalogString &catStr, int start)
#define ID_STATUS_ISFUZZY
void signalNextFuzzyAvailable(bool)
void signalBookmarkDisplayed(bool)
StatusBarProxy statusBarItems
void gotoEntry(DocPosition pos, int selection=0)
Q_SCRIPTABLE QString currentFile()
int lastBookmarkIndex() const
Q_SCRIPTABLE void gotoPrev()
CatalogString sourceWithTags(const DocPosition &pos) const
QString id(const DocPosition &pos) const
Q_SCRIPTABLE void fileSaved(const QString &path)
bool isApproved(uint index) const
int numberOfEntries() const
Q_SCRIPTABLE QString selectionInTarget()
Q_SCRIPTABLE bool entryReady(int entry)
int numberOfNonApproved() const
static QString supportedMimeFilters
This class represents a catalog It uses CatalogStorage interface to work with catalogs in different f...
TargetState state(const DocPosition &pos) const
QString sourceLangCode() const
int prevFuzzyIndex(uint index) const
void setEntryFilteredOut(int entry, bool filteredOut)
static const char *const * states()
Q_SCRIPTABLE QByteArray currentFileContents()
bool isEquivTrans(const DocPosition &) const
Q_SCRIPTABLE QString sourceLangCode()
Q_SCRIPTABLE void gotoPrevUnfiltered()
void fileOpenRequested(const KUrl &path, const QString &str, const QString &ctxt)
virtual QString msgstr(const DocPosition &) const
void setEntriesFilteredOut(bool filteredOut=false)
bool fileOpen(KUrl url=KUrl(), KUrl baseUrl=KUrl(), bool silent=false)
#define ID_STATUS_UNTRANS
#define GLOSSARY_SHORTCUTS
void signalNextUntranslatedAvailable(bool)
int numberOfUntranslated() const
Q_SCRIPTABLE void addTemporaryAlternateTranslation(int entry, const QString &translation)
bool switchPrev(Catalog *&catalog, DocPosition &pos, int parts)
Q_SCRIPTABLE void setEntryTarget(int entry, int form, const QString &content)
Q_SCRIPTABLE void addAlternateTranslation(int entry, const QString &translation)
void attachAltTransFile(const QString &)