]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiCompare.cpp
Do not compute caret geometry when we are not ready to do so.
[lyx.git] / src / frontends / qt4 / GuiCompare.cpp
index b78f63514990a3baac33b6b138ab3f53b78cc59a..4ea7f3578440668e2a052a964f5b50d553db86f9 100644 (file)
@@ -62,9 +62,9 @@ GuiCompare::GuiCompare(GuiView & lv)
                this, SLOT(changeAdaptor()));
 
        newSettingsRB->setChecked(true);
+       trackingCB->setChecked(true);
 
-       progressBar->setValue(0);
-       progressBar->setEnabled(false);
+       closePB->setCursor(Qt::ArrowCursor);
 
        bc().setPolicy(ButtonPolicy::OkApplyCancelPolicy);
        bc().setOK(okPB);
@@ -78,7 +78,7 @@ GuiCompare::~GuiCompare()
 
 void GuiCompare::closeEvent(QCloseEvent *)
 {
-       slotCancel();   
+       slotCancel();
 }
 
 
@@ -114,10 +114,10 @@ void GuiCompare::updateContents()
                newFileCB->addItem(filename);
                oldFileCB->addItem(filename);
        }
-       if (lyxview().documentBufferView())
-               newFileCB->setEditText(toqstr(buffer().absFileName()));
-       else
+       if (!restore_filename1.isEmpty())
                newFileCB->setEditText(restore_filename1);
+       else if (lyxview().documentBufferView())
+               newFileCB->setEditText(toqstr(buffer().absFileName()));
 
        if (!restore_filename2.isEmpty())
                oldFileCB->setEditText(restore_filename2);
@@ -154,24 +154,28 @@ QString GuiCompare::browse(QString const & in_name) const
        QString const title = qt_("Select document");
 
        QStringList const & filters = fileFilters(qt_("LyX Documents (*.lyx)"));
-       
+
        QString filename;
        if (lyxview().documentBufferView()) {
-               QString path = bufferFilepath();
-               filename = browseRelFile(in_name, path, title, filters, false, 
+               QString path = bufferFilePath();
+               filename = browseRelToParent(in_name, path, title, filters, false,
                        qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
        } else {
                QString path = toqstr(lyxrc.document_path);
-               QString rel_filename = browseRelFile(in_name, path, title, filters, false, 
+               QString rel_filename = browseRelToParent(in_name, path, title, filters, false,
                        qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
                filename = makeAbsPath(rel_filename, path);
        }
-       return filename;        
+       return filename;
 }
 
 
-void GuiCompare::enableControls(bool enable) const
+void GuiCompare::enableControls(bool enable)
 {
+       // Set the hourglass cursor for the dialog, but
+       // never for the cancel button.
+       setCursor(enable ? Qt::ArrowCursor : Qt::WaitCursor);
+
        newFileLA->setEnabled(enable);
        newFilePB->setEnabled(enable);
        newFileCB->setEnabled(enable);
@@ -192,7 +196,6 @@ void GuiCompare::enableControls(bool enable) const
 void GuiCompare::error()
 {
        Alert::error(_("Error"), _("Error while comparing documents."));
-       window_title_ = windowTitle();
        finished(true);
 }
 
@@ -204,13 +207,12 @@ void GuiCompare::finished(bool aborted)
                delete compare_;
                compare_ = 0;
        }
-       
+
        if (aborted) {
                if (dest_buffer_) {
                        dest_buffer_->markClean();
                        theBufferList().release(dest_buffer_);
                }
-               setWindowTitle(window_title_);
                progressBar->setValue(0);
                statusBar->showMessage(qt_("Aborted"), 5000);
        } else {
@@ -219,6 +221,10 @@ void GuiCompare::finished(bool aborted)
                if (dest_buffer_) {
                        dispatch(FuncRequest(LFUN_BUFFER_SWITCH,
                                dest_buffer_->absFileName()));
+                       if (trackingCB->isChecked()) {
+                               dispatch(FuncRequest(LFUN_CHANGES_OUTPUT));
+                               dispatch(FuncRequest(LFUN_CHANGES_TRACK));
+                       }
                }
                statusBar->showMessage(qt_("Finished"), 5000);
        }
@@ -235,7 +241,6 @@ void GuiCompare::progressMax(int max) const
 {
        progressBar->setMaximum(max);
 }
-       
 
 
 void GuiCompare::setStatusMessage(QString msg)
@@ -255,8 +260,6 @@ void GuiCompare::slotOK()
 void GuiCompare::slotCancel()
 {
        if (compare_ && compare_->isRunning()) {
-               window_title_ = windowTitle();
-               setWindowTitle(window_title_ + " " + qt_("(cancelling)"));
                statusBar->showMessage(qt_("Aborting process..."));
                compare_->abort();
        } else {
@@ -273,7 +276,7 @@ Buffer const * GuiCompare::bufferFromFileName(string const & file) const
        if (FileName::isAbsolute(file))
                fname.set(file);
        else if (lyxview().documentBufferView())
-               fname = support::makeAbsPath(file, fromqstr(bufferFilepath()));
+               fname = support::makeAbsPath(file, fromqstr(bufferFilePath()));
 
        if (fname.empty()
                        || (!fname.exists() && !theBufferList().getBuffer(fname))) {
@@ -317,6 +320,22 @@ int GuiCompare::run()
        return 1;
 }
 
+bool GuiCompare::initialiseParams(std::string const &par)
+{
+       //just for the sake of parsing arguments
+       FuncRequest cmd(LFUN_UNKNOWN_ACTION, par);
+       if (cmd.getArg(0) == "run") {
+               oldFileCB->setEditText(toqstr(cmd.getArg(1)));
+               newFileCB->setEditText(toqstr(cmd.getArg(2)));
+               slotOK();
+       }
+
+       progressBar->setValue(0);
+       progressBar->setEnabled(false);
+       progressBar->setMaximum(1);
+
+       return true;
+}
 
 Dialog * createGuiCompare(GuiView & lv) { return new GuiCompare(lv); }