diff --git a/src/editortab.cpp b/src/editortab.cpp --- a/src/editortab.cpp +++ b/src/editortab.cpp @@ -209,6 +209,7 @@ //(via QTimer::singleShot) go to initLater() setXMLFile(QStringLiteral("editorui.rc")); + setUpdatedXMLFile(); QAction *action; KActionCollection* ac = actionCollection(); @@ -220,8 +221,8 @@ KActionCategory* sync1 = new KActionCategory(i18n("Synchronization 1"), ac); KActionCategory* sync2 = new KActionCategory(i18n("Synchronization 2"), ac); KActionCategory* tm = new KActionCategory(i18n("Translation Memory"), ac); - KActionCategory* glossary = new KActionCategory(i18nc("@title actions category", "Glossary"), actionCollection()); - //KActionCategory* tools=new KActionCategory(i18nc("@title actions category","Tools"), actionCollection()); + KActionCategory* glossary = new KActionCategory(i18nc("@title actions category", "Glossary"), ac); + //KActionCategory* tools=new KActionCategory(i18nc("@title actions category","Tools"), ac); #ifndef Q_OS_DARWIN QLocale::Language systemLang = QLocale::system().language(); @@ -253,7 +254,7 @@ m_altTransView = new AltTransView(this, m_catalog, altactions); addDockWidget(Qt::BottomDockWidgetArea, m_altTransView); - actionCollection()->addAction(QStringLiteral("showmsgiddiff_action"), m_altTransView->toggleViewAction()); + ac->addAction(QStringLiteral("showmsgiddiff_action"), m_altTransView->toggleViewAction()); connect(this, QOverload::of(&EditorTab::signalNewEntryDisplayed), m_altTransView, QOverload::of(&AltTransView::slotNewEntryDisplayed)); connect(m_altTransView, &AltTransView::textInsertRequested, m_view, &EditorView::insertTerm); connect(m_altTransView, &AltTransView::refreshRequested, m_view, QOverload<>::of(&EditorView::gotoEntry), Qt::QueuedConnection); @@ -276,15 +277,15 @@ m_transUnitsView = new CatalogView(this, m_catalog); addDockWidget(Qt::LeftDockWidgetArea, m_transUnitsView); - actionCollection()->addAction(QStringLiteral("showcatalogtreeview_action"), m_transUnitsView->toggleViewAction()); + ac->addAction(QStringLiteral("showcatalogtreeview_action"), m_transUnitsView->toggleViewAction()); connect(this, QOverload::of(&EditorTab::signalNewEntryDisplayed), m_transUnitsView, QOverload::of(&CatalogView::slotNewEntryDisplayed)); connect(m_transUnitsView, &CatalogView::gotoEntry, this, QOverload::of(&EditorTab::gotoEntry)); connect(m_transUnitsView, &CatalogView::escaped, this, &EditorTab::setProperFocus); connect(m_syncView, &MergeView::mergeCatalogPointerChanged, m_transUnitsView, &CatalogView::setMergeCatalogPointer); m_notesView = new MsgCtxtView(this, m_catalog); addDockWidget(Qt::LeftDockWidgetArea, m_notesView); - actionCollection()->addAction(QStringLiteral("showmsgctxt_action"), m_notesView->toggleViewAction()); + ac->addAction(QStringLiteral("showmsgctxt_action"), m_notesView->toggleViewAction()); connect(m_catalog, QOverload<>::of(&Catalog::signalFileLoaded), m_notesView, &MsgCtxtView::cleanup); connect(m_notesView, &MsgCtxtView::srcFileOpenRequested, this, &EditorTab::dispatchSrcFileOpenRequest); connect(m_view, &EditorView::signalChanged, m_notesView, &MsgCtxtView::removeErrorNotes); @@ -408,15 +409,15 @@ QAction* wqaction; for (i = 0; i < WEBQUERY_SHORTCUTS; ++i) { // action->setVisible(false); - wqaction = actionCollection()->addAction(QString("webquery_insert_%1").arg(i)); + wqaction = ac->addAction(QString("webquery_insert_%1").arg(i)); wqaction->setShortcut(Qt::CTRL + Qt::ALT + wqlist[i]); //wqaction->setShortcut(Qt::META+wqlist[i]); wqaction->setText(i18nc("@action:inmenu", "Insert WebQuery result #%1", i)); wqactions[i] = wqaction; } WebQueryView* _webQueryView = new WebQueryView(this, m_catalog, wqactions); addDockWidget(Qt::BottomDockWidgetArea, _webQueryView); - actionCollection()->addAction(QStringLiteral("showwebqueryview_action"), _webQueryView->toggleViewAction()); + ac->addAction(QStringLiteral("showwebqueryview_action"), _webQueryView->toggleViewAction()); connect(this, &EditorTab::signalNewEntryDisplayed, _webQueryView, SLOT(slotNewEntryDisplayed(DocPosition))); connect(_webQueryView, SIGNAL(textInsertRequested(QString)), m_view, SLOT(insertTerm(QString))); #endif @@ -757,7 +758,6 @@ action = sync2->addAction(QStringLiteral("mergesecondary_back"), m_syncViewSecondary, SLOT(mergeBack())); action->setText(i18nc("@action:inmenu", "Copy to merging source")); m_syncViewSecondary->addAction(action); - } void EditorTab::setProperFocus() diff --git a/src/lokalizemainwindow.cpp b/src/lokalizemainwindow.cpp --- a/src/lokalizemainwindow.cpp +++ b/src/lokalizemainwindow.cpp @@ -189,6 +189,8 @@ */ } LokalizeSubwindowBase* editor = static_cast(w->widget()); + + editor->reloadUpdatedXML(); if (qobject_cast(editor)) { EditorTab* w = static_cast(editor); w->setProperFocus(); @@ -454,15 +456,16 @@ //all operations that can be done after initial setup //(via QTimer::singleShot) go to initLater() - QTime aaa; aaa.start(); + QTime aaa; + aaa.start(); setStandardToolBarMenuEnabled(true); QAction *action; KActionCollection* ac = actionCollection(); KActionCategory* actionCategory; KActionCategory* file = new KActionCategory(i18nc("@title actions category", "File"), ac); - //KActionCategory* config=new KActionCategory(i18nc("@title actions category","Configuration"), ac); + //KActionCategory* config=new KActionCategory(i18nc("@title actions category","Settings"), ac); KActionCategory* glossary = new KActionCategory(i18nc("@title actions category", "Glossary"), ac); KActionCategory* tm = new KActionCategory(i18nc("@title actions category", "Translation Memory"), ac); KActionCategory* proj = new KActionCategory(i18nc("@title actions category", "Project"), ac); @@ -479,7 +482,7 @@ //Settings SettingsController* sc = SettingsController::instance(); - KStandardAction::preferences(sc, SLOT(showSettingsDialog()), ac); + KStandardAction::preferences(sc, &SettingsController::showSettingsDialog, ac); #define ADD_ACTION_SHORTCUT(_name,_text,_shortcut)\ action = actionCategory->addAction(QStringLiteral(_name));\ diff --git a/src/lokalizesubwindowbase.h b/src/lokalizesubwindowbase.h --- a/src/lokalizesubwindowbase.h +++ b/src/lokalizesubwindowbase.h @@ -26,6 +26,9 @@ #include #include +#include +#include +#include #include "actionproxy.h" @@ -47,6 +50,8 @@ emit aboutToBeClosed(); } virtual KXMLGUIClient* guiClient() = 0; + virtual void reloadUpdatedXML() = 0; + virtual void setUpdatedXMLFile() = 0; //interface for LokalizeMainWindow virtual void hideDocks() = 0; @@ -69,6 +74,8 @@ //QHash supportedActions; StatusBarProxy statusBarItems; +protected: + QDateTime lastXMLUpdate; }; /** @@ -84,6 +91,26 @@ { return (KXMLGUIClient*)this; } + + void setUpdatedXMLFile() + { + QString localXml = guiClient()->localXMLFile(); + if (QFile::exists(localXml)) { + lastXMLUpdate = QFileInfo(localXml).lastModified(); + } + } + + void reloadUpdatedXML() + { + QString localXml = guiClient()->localXMLFile(); + if (QFile::exists(localXml)) { + QDateTime newXMLUpdate = QFileInfo(localXml).lastModified(); + if (newXMLUpdate > lastXMLUpdate) { + lastXMLUpdate = newXMLUpdate; + guiClient()->reloadXML(); + } + } + } }; #else #include diff --git a/src/project/projecttab.cpp b/src/project/projecttab.cpp --- a/src/project/projecttab.cpp +++ b/src/project/projecttab.cpp @@ -137,6 +137,7 @@ statusBar->insertWidget(ID_STATUS_PROGRESS, m_progressBar, 1); setXMLFile(QStringLiteral("projectmanagerui.rc"), true); + setUpdatedXMLFile(); //QAction* action = KStandardAction::find(Project::instance(),SLOT(showTM()),actionCollection()); #define ADD_ACTION_SHORTCUT_ICON(_name,_text,_shortcut,_icon)\ diff --git a/src/tm/tmtab.cpp b/src/tm/tmtab.cpp --- a/src/tm/tmtab.cpp +++ b/src/tm/tmtab.cpp @@ -488,6 +488,7 @@ statusBarItems.insert(i, QString()); setXMLFile(QStringLiteral("translationmemoryrui.rc"), true); + setUpdatedXMLFile(); dbusObjectPath();