[lokalize] src: Add new ways to launch pology on file(s)

Simon Depiets null at kde.org
Sat Sep 29 12:02:22 BST 2018


Git commit 52b94d0b6c41cb7e77ef64fcf9b32e403522b436 by Simon Depiets.
Committed on 29/09/2018 at 11:02.
Pushed by sdepiets into branch 'master'.

Add new ways to launch pology on file(s)

Summary:
Pology is a great tool but is not easily accessible from Lokalize currently, you need to launch a command line or configure a script, which is cumbersome and complicated in user space. After adding a line by line feature a few weeks ago, this review focuses on the file level :

- Launch the Pology "-s lokalize" command on file, files or folders from the Project Overview : this will open problematic messages in different tabs.
{F6285626}
- Launch the Pology "-s lokalize" command from within the file (Ctrl+Alt+P) : this will filter on problematic messages directly from within the file.
{F6285627}

The next step I see would be displaying pology statistics in the TM file, I'm open to your ideas for a better integration. I'm also counting on you to pass the message to your respective communities and update their documentation for the usage of pology.

As the agreement seems to be that syntax checks shall be handle externally, I will close the following bugs :
FEATURE: 342614
FEATURE: 342615
FEATURE: 65061
FEATURE: 198872
GUI:

Reviewers: #localization, aacid, adrianchavesfernandez, huftis, mlaurent

Reviewed By: mlaurent

Subscribers: mlaurent

Tags: #localization

Differential Revision: https://phabricator.kde.org/D15759

M  +1    -1    src/CMakeLists.txt
M  +45   -8    src/editortab.cpp
M  +7    -0    src/editortab.h
M  +2    -1    src/editorui.rc
M  +4    -4    src/filesearch/filesearchtab.cpp
M  +9    -9    src/lokalizemainwindow.cpp
M  +4    -4    src/msgctxtview.cpp
M  +11   -0    src/prefs/lokalize.kcfg
M  +7    -6    src/prefs/prefs.cpp
A  +83   -0    src/prefs/prefs_pology.ui
D  +0    -64   src/project/prefs_project_pology.ui
M  +0    -6    src/project/projectlocal.kcfg
M  +53   -5    src/project/projecttab.cpp
M  +7    -0    src/project/projecttab.h
M  +5    -5    src/tm/tmtab.cpp

https://commits.kde.org/lokalize/52b94d0b6c41cb7e77ef64fcf9b32e403522b436

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index cfc8aae..ed02c24 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -130,9 +130,9 @@ ki18n_wrap_ui(lokalize_SRCS
     prefs/prefs_editor.ui
     prefs/prefs_appearance.ui
     prefs/prefs_tm.ui
+    prefs/prefs_pology.ui
     project/prefs_project_advanced.ui
     project/prefs_project_local.ui
-    project/prefs_project_pology.ui
     project/prefs_projectmain.ui
     glossary/termedit.ui
     filesearch/filesearchoptions.ui
diff --git a/src/editortab.cpp b/src/editortab.cpp
index 8308295..6680346 100644
--- a/src/editortab.cpp
+++ b/src/editortab.cpp
@@ -57,19 +57,20 @@
 
 #include "project.h"
 #include "prefs.h"
+#include "prefs_lokalize.h"
 #include "languagelistmodel.h"
 
 #ifndef NOKDE
-#include <ktoolbarpopupaction.h>
-#include <kactioncollection.h>
-#include <kstandardaction.h>
-#include <kstandardshortcut.h>
-#include <kxmlguifactory.h>
-#include <kactioncategory.h>
+#include <KToolBarPopupAction>
+#include <KActionCollection>
+#include <KStandardAction>
+#include <KStandardShortcut>
+#include <KXMLGUIFactory>
+#include <KActionCategory>
 #endif
 
-#include <kmessagebox.h>
-#include <klocalizedstring.h>
+#include <KMessageBox>
+#include <KLocalizedString>
 
 #include <QDesktopServices>
 #include <QIcon>
@@ -92,6 +93,7 @@ EditorTab::EditorTab(QWidget* parent, bool valid)
     , m_project(Project::instance())
     , m_catalog(new Catalog(this))
     , m_view(new EditorView(this, m_catalog/*,new keyEventHandler(this,m_catalog)*/))
+    , m_pologyProcessInProgress(false)
 #ifndef NOKDE
     , m_sonnetDialog(0)
     , m_spellcheckStartUndoIndex(0)
@@ -462,6 +464,10 @@ void EditorTab::setupActions()
     ADD_ACTION_SHORTCUT("file_cleartarget", i18nc("@action:inmenu", "Clear all translated entries"), Qt::CTRL + Qt::ALT + Qt::Key_D)
     connect(action, &QAction::triggered, this, &EditorTab::clearTranslatedEntries);
 
+    ADD_ACTION_SHORTCUT("file_pology", i18nc("@action:inmenu", "Launch the Pology command on this file"), Qt::CTRL + Qt::ALT + Qt::Key_P)
+    action->setEnabled(Settings::self()->pologyEnabled());
+    connect(action, &QAction::triggered, this, &EditorTab::launchPology);
+
     ADD_ACTION_SHORTCUT("file_xliff2odf", i18nc("@action:inmenu", "Merge translation into OpenDocument"), Qt::CTRL + Qt::Key_Backslash)
     connect(action, &QAction::triggered, this, &EditorTab::mergeIntoOpenDocument);
     connect(this, &EditorTab::xliffFileOpened, action, &QAction::setVisible);
@@ -1395,6 +1401,37 @@ void EditorTab::indexWordsForCompletion()
     CompletionStorage::instance()->scanCatalog(m_catalog);
 }
 
+void EditorTab::launchPology()
+{
+    if (!m_pologyProcessInProgress) {
+        QString command = Settings::self()->pologyCommandFile().replace(QStringLiteral("%f"), QStringLiteral("\"") + currentFilePath() + QStringLiteral("\""));
+        m_pologyProcess = new KProcess;
+        m_pologyProcess->setOutputChannelMode(KProcess::SeparateChannels);
+        qCWarning(LOKALIZE_LOG) << "Launching pology command: " << command;
+        connect(m_pologyProcess, QOverload<int, QProcess::ExitStatus>::of(&KProcess::finished),
+                this, &EditorTab::pologyHasFinished);
+        m_pologyProcess->setShellCommand(command);
+        m_pologyProcessInProgress = true;
+        m_pologyProcess->start();
+    } else {
+        KMessageBox::error(this, i18n("A Pology check is already in progress."), i18n("Pology error"));
+    }
+}
+
+void EditorTab::pologyHasFinished(int exitCode, QProcess::ExitStatus exitStatus)
+{
+    const QString pologyError = m_pologyProcess->readAllStandardError();
+    if (exitStatus == QProcess::CrashExit) {
+        KMessageBox::error(this, i18n("The Pology check has crashed unexpectedly:\n%1", pologyError), i18n("Pology error"));
+    } else if (exitCode == 0) {
+        KMessageBox::information(this, i18n("The Pology check has succeeded."), i18n("Pology success"));
+    } else {
+        KMessageBox::error(this, i18n("The Pology check has returned an error:\n%1", pologyError), i18n("Pology error"));
+    }
+    m_pologyProcess->deleteLater();
+    m_pologyProcessInProgress = false;
+}
+
 void EditorTab::clearTranslatedEntries()
 {
     switch (KMessageBox::warningYesNoCancel(this,
diff --git a/src/editortab.h b/src/editortab.h
index a501181..e6bb210 100644
--- a/src/editortab.h
+++ b/src/editortab.h
@@ -32,6 +32,7 @@
 #include "lokalizesubwindowbase.h"
 
 #include <QHash>
+#include <KProcess>
 
 #ifndef NOKDE
 namespace Sonnet
@@ -292,6 +293,7 @@ private slots:
 
     void displayWordCount();
     void clearTranslatedEntries();
+    void launchPology();
 
     void openPhasesWindow();
 
@@ -305,6 +307,8 @@ private slots:
 
     void fileAutoSaveFailedWarning(const QString&);
 
+    void pologyHasFinished(int exitCode, QProcess::ExitStatus exitStatus);
+
 protected:
     void paintEvent(QPaintEvent* event);
 
@@ -325,6 +329,9 @@ private:
     QAction* m_approveAction;
     QAction* m_stateAction; //is = m_approveAction ifndef NOKDE
 
+    KProcess* m_pologyProcess;
+    bool m_pologyProcessInProgress;
+
     DocPosition m_currentPos;
     DocPosition _searchingPos; //for find/replace
     DocPosition _replacingPos;
diff --git a/src/editorui.rc b/src/editorui.rc
index f7e4f68..59dde0c 100644
--- a/src/editorui.rc
+++ b/src/editorui.rc
@@ -1,5 +1,5 @@
 <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<kpartgui name="Editor" version="13">
+<kpartgui name="Editor" version="14">
 <MenuBar>
   <Menu name="file"><text>&File</text>
     <Action name="file_new"/>
@@ -22,6 +22,7 @@
     <Action name="file_mail"/>
     <MergeLocal name="mail_merge"/>
     <Separator/>
+    <Action name="file_pology"/>
     <Action name="file_cleartarget"/>
     <Action name="file_phases"/>
     <Action name="file_wordcount"/>
diff --git a/src/filesearch/filesearchtab.cpp b/src/filesearch/filesearchtab.cpp
index 610f1d4..b010844 100644
--- a/src/filesearch/filesearchtab.cpp
+++ b/src/filesearch/filesearchtab.cpp
@@ -54,12 +54,12 @@
 #include <QBoxLayout>
 #include <QThreadPool>
 
-#include <klocalizedstring.h>
+#include <KLocalizedString>
 
 #ifndef NOKDE
-#include <kactioncategory.h>
-#include <kcolorscheme.h>
-#include <kxmlguifactory.h>
+#include <KActionCategory>
+#include <KColorScheme>
+#include <KXMLGUIFactory>
 #endif
 
 static QStringList doScanRecursive(const QDir& dir);
diff --git a/src/lokalizemainwindow.cpp b/src/lokalizemainwindow.cpp
index aafbbeb..9adc114 100644
--- a/src/lokalizemainwindow.cpp
+++ b/src/lokalizemainwindow.cpp
@@ -44,15 +44,15 @@
 
 #include "multieditoradaptor.h"
 
-#include <klocalizedstring.h>
-#include <kmessagebox.h>
-#include <knotification.h>
-#include <kactioncollection.h>
-#include <kactioncategory.h>
-#include <kstandardaction.h>
-#include <kstandardshortcut.h>
-#include <krecentfilesaction.h>
-#include <kxmlguifactory.h>
+#include <KLocalizedString>
+#include <KMessageBox>
+#include <KNotification>
+#include <KActionCollection>
+#include <KActionCategory>
+#include <KStandardAction>
+#include <KStandardShortcut>
+#include <KRecentFilesAction>
+#include <KXMLGUIFactory>
 #include <kross/core/action.h>
 
 
diff --git a/src/msgctxtview.cpp b/src/msgctxtview.cpp
index 1f3a712..7063a3a 100644
--- a/src/msgctxtview.cpp
+++ b/src/msgctxtview.cpp
@@ -167,9 +167,9 @@ void MsgCtxtView::process()
 }
 void MsgCtxtView::pology()
 {
-    if (Project::instance()->local()->pologyEnabled() && m_pologyProcessInProgress == 0) {
-        QString command = Project::instance()->local()->pologyCommandEntry();
-        command = command.replace(QStringLiteral("%u"), QString::number(m_entry.entry + 1)).replace(QStringLiteral("%f"), m_catalog->url()).replace(QStringLiteral("\n"), QStringLiteral(" "));
+    if (Settings::self()->pologyEnabled() && m_pologyProcessInProgress == 0) {
+        QString command = Settings::self()->pologyCommandEntry();
+        command = command.replace(QStringLiteral("%u"), QString::number(m_entry.entry + 1)).replace(QStringLiteral("%f"),  QStringLiteral("\"") + m_catalog->url() + QStringLiteral("\"")).replace(QStringLiteral("\n"), QStringLiteral(" "));
         m_pologyProcess = new KProcess;
         m_pologyProcess->setShellCommand(command);
         m_pologyProcess->setOutputChannelMode(KProcess::SeparateChannels);
@@ -183,7 +183,7 @@ void MsgCtxtView::pology()
         m_pologyData = QStringLiteral("[pology] ");
         m_pologyProcessInProgress = m_entry.entry + 1;
         m_pologyProcess->start();
-    } else if (Project::instance()->local()->pologyEnabled() && m_pologyProcessInProgress > 0) {
+    } else if (Settings::self()->pologyEnabled() && m_pologyProcessInProgress > 0) {
         QTimer::singleShot(1000, this, &MsgCtxtView::pology);
     }
 }
diff --git a/src/prefs/lokalize.kcfg b/src/prefs/lokalize.kcfg
index ec3768e..9cb64b0 100644
--- a/src/prefs/lokalize.kcfg
+++ b/src/prefs/lokalize.kcfg
@@ -132,4 +132,15 @@
         <default>false</default>
     </entry>
   </group>
+  <group name="Pology">
+    <entry name="PologyEnabled" type="Bool">
+        <default>false</default>
+    </entry>
+    <entry name="PologyCommandEntry" type="String">
+        <default>posieve -u %u check-rules %f</default>
+    </entry>
+    <entry name="PologyCommandFile" type="String">
+        <default>posieve -s lokalize check-rules %f</default>
+    </entry>
+  </group>
 </kcfg>
diff --git a/src/prefs/prefs.cpp b/src/prefs/prefs.cpp
index 9eee7b2..a24cfd5 100644
--- a/src/prefs/prefs.cpp
+++ b/src/prefs/prefs.cpp
@@ -36,11 +36,11 @@
 #include "ui_prefs_editor.h"
 #include "ui_prefs_general.h"
 #include "ui_prefs_appearance.h"
+#include "ui_prefs_pology.h"
 #include "ui_prefs_tm.h"
 #include "ui_prefs_projectmain.h"
 #include "ui_prefs_project_advanced.h"
 #include "ui_prefs_project_local.h"
-#include "ui_prefs_project_pology.h"
 
 
 #include <klocalizedstring.h>
@@ -138,6 +138,12 @@ void SettingsController::showSettingsDialog()
     ui_prefs_tm.setupUi(w);
     dialog->addPage(w, i18nc("@title:tab", "Translation Memory"), "configure");
 
+//Pology
+    w = new QWidget(dialog);
+    Ui_prefs_pology ui_prefs_pology;
+    ui_prefs_pology.setupUi(w);
+    dialog->addPage(w, i18nc("@title:tab", "Pology"), "preferences-desktop-filetype-association");
+
     connect(dialog, &KConfigDialog::settingsChanged, this, &SettingsController::generalSettingsChanged);
 
 
@@ -335,11 +341,6 @@ void SettingsController::projectConfigure()
     ui_prefs_project_local.setupUi(w);
     dialog->addPage(w, Project::local(), i18nc("@title:tab", "Personal"), "preferences-desktop-user");
 
-    w = new QWidget(dialog);
-    Ui_prefs_project_pology ui_prefs_project_pology;
-    ui_prefs_project_pology.setupUi(w);
-    dialog->addPage(w, Project::local(), i18nc("@title:tab", "Pology"), "preferences-desktop-filetype-association");
-
     connect(dialog, &KConfigDialog::settingsChanged, Project::instance(), &Project::reinit);
     connect(dialog, &KConfigDialog::settingsChanged, Project::instance(), &Project::save, Qt::QueuedConnection);
     connect(dialog, &KConfigDialog::settingsChanged, TM::DBFilesModel::instance(), &TM::DBFilesModel::updateProjectTmIndex);
diff --git a/src/prefs/prefs_pology.ui b/src/prefs/prefs_pology.ui
new file mode 100644
index 0000000..4092f2c
--- /dev/null
+++ b/src/prefs/prefs_pology.ui
@@ -0,0 +1,83 @@
+<ui version="4.0" >
+ <class>prefs_pology</class>
+ <widget class="QWidget" name="prefs_pology" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>611</width>
+    <height>439</height>
+   </rect>
+  </property>
+  <layout class="QVBoxLayout" >
+   <item>
+    <layout class="QFormLayout" name="formLayout" >
+     <property name="fieldGrowthPolicy" >
+      <enum>QFormLayout::ExpandingFieldsGrow</enum>
+     </property>
+     <item row="0" column="0">
+      <widget class="QCheckBox" name="kcfg_PologyEnabled">
+       <property name="text">
+        <string>Enable Pology verification</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="0" colspan="2">
+      <widget class="QLabel" name="textLabel3_0">
+       <property name="text">
+        <string comment="@label:textbox">The Pology command to run in order to check a single entry. Use the following placeholders in order to set-up the commands: %u is the entry number, %f is the file name. For instance: posieve -u %u check-rules %f</string>
+       </property>
+       <property name="wordWrap">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="0" colspan="2">
+      <widget class="QPlainTextEdit" name="kcfg_PologyCommandEntry">
+       <property name="maximumSize">
+        <size>
+         <width>611</width>
+         <height>100</height>
+        </size>
+       </property>
+       <property name="toolTip">
+        <string>The Pology command to run in order to check a single entry.</string>
+       </property>
+       <property name="whatsThis">
+        <string>Please enter here the Pology command to be run in order to check a single entry</string>
+       </property>
+      </widget>
+     </item>
+     <item row="3" column="0" colspan="2">
+      <widget class="QLabel" name="textLabel4_0">
+       <property name="text">
+        <string comment="@label:textbox">The Pology command to run in order to check a whole file. This command should include "-s lokalize", placeholder %f is the file name. For instance: posieve -s lokalize check-rules %f</string>
+       </property>
+       <property name="wordWrap">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item row="4" column="0" colspan="2">
+      <widget class="QPlainTextEdit" name="kcfg_PologyCommandFile">
+       <property name="maximumSize">
+        <size>
+         <width>611</width>
+         <height>100</height>
+        </size>
+       </property>
+       <property name="toolTip">
+        <string>The Pology command to run in order to check a whole file.</string>
+       </property>
+       <property name="whatsThis">
+        <string>Please enter here the Pology command to be run in order to check a whole file</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/project/prefs_project_pology.ui b/src/project/prefs_project_pology.ui
deleted file mode 100644
index bfc5b88..0000000
--- a/src/project/prefs_project_pology.ui
+++ /dev/null
@@ -1,64 +0,0 @@
-<ui version="4.0" >
- <class>prefs_project_pology</class>
- <widget class="QWidget" name="prefs_project_pology" >
-  <property name="geometry" >
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>611</width>
-    <height>439</height>
-   </rect>
-  </property>
-  <layout class="QVBoxLayout" >
-   <item>
-    <layout class="QFormLayout" name="formLayout" >
-     <property name="fieldGrowthPolicy" >
-      <enum>QFormLayout::ExpandingFieldsGrow</enum>
-     </property>
-     <item row="0" column="0">
-       <widget class="QCheckBox" name="kcfg_PologyEnabled">
-         <property name="text">
-           <string>Enable Pology verification</string>
-         </property>
-       </widget>
-    </item>
-    <item row="1" column="0">
-    <widget class="QLabel" name="textLabel1_0">
-     <property name="text">
-      <string comment="@label:textbox">Pology command at entry level:</string>
-     </property>
-     <property name="wordWrap">
-      <bool>false</bool>
-     </property>
-     <property name="buddy">
-      <cstring>kcfg_PologyCommandEntry</cstring>
-     </property>
-    </widget>
-    </item>
-    <item row="1" column="1">
-        <widget class="QPlainTextEdit" name="kcfg_PologyCommandEntry">
-        <property name="toolTip">
-        <string>The Pology command to run in order to check a single entry</string>
-        </property>
-        <property name="whatsThis">
-        <string>Please enter here the Pology command to be run in order to check a single entry</string>
-        </property>
-        </widget>
-    </item>
-    <item row="2" column="0" colspan="2">
-    <widget class="QLabel" name="textLabel3_0">
-     <property name="text">
-      <string comment="@label:textbox">Use the following placeholders in order to set-up the commands: %u is the entry number, %f is the file name. For instance: python /home/translator/i18n/pology/scripts/posieve.py -u %u check_rules %f</string>
-     </property>
-     <property name="wordWrap">
-      <bool>true</bool>
-     </property>
-    </widget>
-    </item>
-    </layout>
-   </item>
-  </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/src/project/projectlocal.kcfg b/src/project/projectlocal.kcfg
index 997265a..f7461ca 100644
--- a/src/project/projectlocal.kcfg
+++ b/src/project/projectlocal.kcfg
@@ -21,10 +21,4 @@
       <default>true</default>
     </entry>
   </group>
-  <group name="Pology">
-    <entry name="PologyEnabled" type="Bool">
-        <default>false</default>
-    </entry>
-    <entry name="PologyCommandEntry" type="String"></entry>
-  </group>
 </kcfg>
diff --git a/src/project/projecttab.cpp b/src/project/projecttab.cpp
index aa92d57..8e40e52 100644
--- a/src/project/projecttab.cpp
+++ b/src/project/projecttab.cpp
@@ -26,13 +26,17 @@
 #include "projectwidget.h"
 #include "tmscanapi.h"
 #include "prefs.h"
+#include "prefs_lokalize.h"
 #include "catalog.h"
+#include "lokalize_debug.h"
 
-#include <klocalizedstring.h>
-#include <kactioncategory.h>
-#include <kactioncollection.h>
-#include <kstandardaction.h>
-#include <kxmlguifactory.h>
+#include <KLocalizedString>
+#include <KActionCategory>
+#include <KActionCollection>
+#include <KStandardAction>
+#include <KXMLGUIFactory>
+#include <KProcess>
+#include <KMessageBox>
 
 #include <QLineEdit>
 #include <QIcon>
@@ -51,6 +55,7 @@ ProjectTab::ProjectTab(QWidget *parent)
     : LokalizeSubwindowBase2(parent)
     , m_browser(new ProjectWidget(this))
     , m_filterEdit(new QLineEdit(this))
+    , m_pologyProcessInProgress(false)
     , m_legacyUnitsCount(-1)
     , m_currentUnitsCount(0)
 
@@ -261,6 +266,9 @@ void ProjectTab::contextMenuEvent(QContextMenuEvent *event)
     menu->addAction(i18nc("@action:inmenu", "Add to translation memory"), this, SLOT(scanFilesToTM()));
 
     menu->addAction(i18nc("@action:inmenu", "Search in files"), this, SLOT(searchInFiles()));
+    if (Settings::self()->pologyEnabled()) {
+        menu->addAction(i18nc("@action:inmenu", "Launch Pology on files"), this, &ProjectTab::pologyOnFiles);
+    }
     if (QDir(Project::instance()->templatesRoot()).exists())
         menu->addAction(i18nc("@action:inmenu", "Search in files (including templates)"), this, SLOT(searchInFilesInclTempl()));
 
@@ -296,6 +304,46 @@ void ProjectTab::searchInFiles(bool templ)
     emit searchRequested(files);
 }
 
+void ProjectTab::pologyOnFiles()
+{
+    if (!m_pologyProcessInProgress) {
+        QStringList files = m_browser->selectedItems();
+        QString templatesRoot = Project::instance()->templatesRoot();
+        QString filesAsString;
+        int i = files.size();
+        while (--i >= 0) {
+            if (files.at(i).endsWith(QStringLiteral(".po")))
+                filesAsString += QStringLiteral("\"") + files.at(i) + QStringLiteral("\" ");
+        }
+
+        QString command = Settings::self()->pologyCommandFile().replace(QStringLiteral("%f"), filesAsString);
+        m_pologyProcess = new KProcess;
+        m_pologyProcess->setOutputChannelMode(KProcess::SeparateChannels);
+        qCWarning(LOKALIZE_LOG) << "Launching pology command: " << command;
+        connect(m_pologyProcess, QOverload<int, QProcess::ExitStatus>::of(&KProcess::finished),
+                this, &ProjectTab::pologyHasFinished);
+        m_pologyProcess->setShellCommand(command);
+        m_pologyProcessInProgress = true;
+        m_pologyProcess->start();
+    } else {
+        KMessageBox::error(this, i18n("A Pology check is already in progress."), i18n("Pology error"));
+    }
+}
+
+void ProjectTab::pologyHasFinished(int exitCode, QProcess::ExitStatus exitStatus)
+{
+    const QString pologyError = m_pologyProcess->readAllStandardError();
+    if (exitStatus == QProcess::CrashExit) {
+        KMessageBox::error(this, i18n("The Pology check has crashed unexpectedly:\n%1", pologyError), i18n("Pology error"));
+    } else if (exitCode == 0) {
+        KMessageBox::information(this, i18n("The Pology check has succeeded"), i18n("Pology success"));
+    } else {
+        KMessageBox::error(this, i18n("The Pology check has returned an error:\n%1", pologyError), i18n("Pology error"));
+    }
+    m_pologyProcess->deleteLater();
+    m_pologyProcessInProgress = false;
+}
+
 void ProjectTab::searchInFilesInclTempl()
 {
     searchInFiles(true);
diff --git a/src/project/projecttab.h b/src/project/projecttab.h
index 1e08cc3..23d452c 100644
--- a/src/project/projecttab.h
+++ b/src/project/projecttab.h
@@ -27,6 +27,7 @@
 #include "lokalizesubwindowbase.h"
 
 #include <KMainWindow>
+#include <KProcess>
 
 #include <KXMLGUIClient>
 
@@ -89,6 +90,7 @@ private slots:
     void setFilterRegExp();
     void setFocus();
     void scanFilesToTM();
+    void pologyOnFiles();
     void searchInFiles(bool templ = false);
     void searchInFilesInclTempl();
     void openFile();
@@ -111,6 +113,8 @@ private slots:
     void updateStatusBar(int fuzzy = 0, int translated = 0, int untranslated = 0, bool done = false);
     void initStatusBarProgress();
 
+    void pologyHasFinished(int exitCode, QProcess::ExitStatus exitStatus);
+
 private:
     ProjectWidget* m_browser;
     QLineEdit* m_filterEdit;
@@ -118,6 +122,9 @@ private:
 
     QStackedLayout *m_stackedLayout;
 
+    KProcess* m_pologyProcess;
+    bool m_pologyProcessInProgress;
+
     int m_legacyUnitsCount, m_currentUnitsCount;
 };
 
diff --git a/src/tm/tmtab.cpp b/src/tm/tmtab.cpp
index fba868d..baa838f 100644
--- a/src/tm/tmtab.cpp
+++ b/src/tm/tmtab.cpp
@@ -54,11 +54,11 @@
 #include <QTextCodec>
 
 #ifndef NOKDE
-#include <kactioncategory.h>
-#include <kcolorscheme.h>
-#include <kxmlguifactory.h>
-#include <klocalizedstring.h>
-#include <kmessagebox.h>
+#include <KActionCategory>
+#include <KColorScheme>
+#include <KXMLGUIFactory>
+#include <KLocalizedString>
+#include <KMessageBox>
 #endif
 
 #if defined(Q_OS_WIN) && defined(QStringLiteral)


More information about the kde-doc-english mailing list