#include "GuiCompare.h"
+#include "GuiApplication.h"
+
#include "Buffer.h"
#include "BufferView.h"
#include "BufferList.h"
#include "buffer_funcs.h"
+#include "ColorCache.h"
#include "Compare.h"
#include "FuncRequest.h"
#include "GuiView.h"
}
-int GuiCompare::run()
+int GuiCompare::run(bool blocking_mode)
{
progressBar->setValue(0);
return 0;
dest_buffer_->changed(true);
- dest_buffer_->markDirty();
+ if (blocking_mode)
+ //blocking mode is infinitive and we don't want diff autosave
+ //if user decides to kill ther running lyx instance
+ dest_buffer_->markClean();
+ else
+ dest_buffer_->markDirty();
+
// get the options from the dialog
CompareOptions options;
options.settings_from_new = newSettingsRB->isChecked();
+ options.author = authorCO->currentIndex();
// init the compare object and start it
+
compare_ = new Compare(new_buffer_, old_buffer_, dest_buffer_, options);
+
connect(compare_, SIGNAL(error()), this, SLOT(error()));
- connect(compare_, SIGNAL(finished(bool)), this, SLOT(finished(bool)));
+ // Only connect the finished() method to the signal if we're *not* in blocking_mode
+ // (i.e. we want to make it possible for caller to block for the results)
+ if (! blocking_mode) {
+ connect(compare_, SIGNAL(finished(bool)), this, SLOT(finished(bool)));
+ }
connect(compare_, SIGNAL(progress(int)), this, SLOT(progress(int)));
connect(compare_, SIGNAL(progressMax(int)), this, SLOT(progressMax(int)));
connect(compare_, SIGNAL(statusMessage(QString)),
this, SLOT(setStatusMessage(QString)));
compare_->start(QThread::LowPriority);
+
return 1;
}
{
//just for the sake of parsing arguments
FuncRequest cmd(LFUN_UNKNOWN_ACTION, par);
- if (cmd.getArg(0) == "run") {
+ if (cmd.getArg(0) == "run" || cmd.getArg(0) == "run-blocking") {
oldFileCB->setEditText(toqstr(cmd.getArg(1)));
newFileCB->setEditText(toqstr(cmd.getArg(2)));
- slotOK();
+
+ if (cmd.getArg(0) == "run" ) {
+ // Run asynchronously
+ slotOK();
+ }
+ else {
+ // Run synchronously
+ enableControls(false);
+
+ if (! run(true)) {
+ error();
+ return false;
+ }
+
+ // Wait for the Compare function to process in a thread
+ compare_->wait();
+
+ finished(false);
+ //Hiding dialog does not work as intended through finished routine, because showView
+ //is triggered after initialiseParams returns true. So we return false, warning will
+ //show on the terminal though.
+ return false;
+ }
}
progressBar->setValue(0);
progressBar->setEnabled(false);
progressBar->setMaximum(1);
+ // If empty fill the author combobox with the current and the comparison
+ // author and their respective colors
+ if (authorCO->count() == 0) {
+ authorCO->clear();
+ QPixmap colorIcon(32, 32);
+ colorIcon.fill(guiApp->colorCache().get(
+ Color(Color_changedtext_workarea_author1)));
+ authorCO->addItem(colorIcon, qt_("Current Author"));
+ colorIcon.fill(guiApp->colorCache().get(
+ Color(Color_changedtext_workarea_comparison)));
+ authorCO->addItem(colorIcon, qt_("Document Comparison"));
+ }
+
return true;
}
-Dialog * createGuiCompare(GuiView & lv) { return new GuiCompare(lv); }
-
} // namespace frontend
} // namespace lyx