mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Do some caching of window title and related UI
This should avoid performance problems related to the window update machinery.
Moreover this fixes a crash introduced by 82808fea
when closing a file.
Note that GuiWorkArea::Private already had a read_only_ member, but it
was unused.
Also rename LyXVC::vcname() to LyXVC::vcstatus() since it now contains
directly the UI string to be shown.
This commit is contained in:
parent
a4e7114d98
commit
6cb05ce8bb
@ -41,9 +41,14 @@ LyXVC::LyXVC()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string LyXVC::vcname() const
|
docstring LyXVC::vcstatus() const
|
||||||
{
|
{
|
||||||
return vcs->vcname();
|
if (!vcs)
|
||||||
|
return docstring();
|
||||||
|
if (locking())
|
||||||
|
return bformat(_("%1$s lock"), from_ascii(vcs->vcname()));
|
||||||
|
else
|
||||||
|
return from_ascii(vcs->vcname());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#ifndef LYX_VC_H
|
#ifndef LYX_VC_H
|
||||||
#define LYX_VC_H
|
#define LYX_VC_H
|
||||||
|
|
||||||
|
#include "support/docstring.h"
|
||||||
#include "support/unique_ptr.h"
|
#include "support/unique_ptr.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -48,8 +49,8 @@ public:
|
|||||||
};
|
};
|
||||||
///
|
///
|
||||||
LyXVC();
|
LyXVC();
|
||||||
/// Name of the underlying VCS
|
/// Status of the underlying VCS
|
||||||
std::string vcname() const;
|
docstring vcstatus() const;
|
||||||
/// Is \p fn under version control?
|
/// Is \p fn under version control?
|
||||||
static bool fileInVC(support::FileName const & fn);
|
static bool fileInVC(support::FileName const & fn);
|
||||||
/** Not a good name perhaps. This function should be called whenever
|
/** Not a good name perhaps. This function should be called whenever
|
||||||
|
@ -1182,12 +1182,7 @@ void GuiView::updateWindowTitle(GuiWorkArea * wa)
|
|||||||
|
|
||||||
if (buf.lyxvc().inUse()) {
|
if (buf.lyxvc().inUse()) {
|
||||||
version_control_->show();
|
version_control_->show();
|
||||||
if (buf.lyxvc().locking())
|
version_control_->setText(toqstr(buf.lyxvc().vcstatus()));
|
||||||
version_control_->setText(
|
|
||||||
toqstr(bformat(_("%1$s lock"),
|
|
||||||
from_ascii(buf.lyxvc().vcname()))));
|
|
||||||
else
|
|
||||||
version_control_->setText(toqstr(buf.lyxvc().vcname()));
|
|
||||||
} else
|
} else
|
||||||
version_control_->hide();
|
version_control_->hide();
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,6 @@
|
|||||||
#include "support/convert.h"
|
#include "support/convert.h"
|
||||||
#include "support/debug.h"
|
#include "support/debug.h"
|
||||||
#include "support/gettext.h"
|
#include "support/gettext.h"
|
||||||
#include "support/FileName.h"
|
|
||||||
#include "support/lassert.h"
|
#include "support/lassert.h"
|
||||||
#include "support/TempFile.h"
|
#include "support/TempFile.h"
|
||||||
|
|
||||||
@ -247,11 +246,12 @@ SyntheticMouseEvent::SyntheticMouseEvent()
|
|||||||
|
|
||||||
|
|
||||||
GuiWorkArea::Private::Private(GuiWorkArea * parent)
|
GuiWorkArea::Private::Private(GuiWorkArea * parent)
|
||||||
: p(parent), screen_(0), buffer_view_(0), read_only_(false), lyx_view_(0),
|
: p(parent), screen_(0), buffer_view_(0), lyx_view_(0),
|
||||||
cursor_visible_(false), cursor_(0),
|
cursor_visible_(false), cursor_(0),
|
||||||
need_resize_(false), schedule_redraw_(false), preedit_lines_(1),
|
need_resize_(false), schedule_redraw_(false), preedit_lines_(1),
|
||||||
pixel_ratio_(1.0),
|
pixel_ratio_(1.0),
|
||||||
completer_(new GuiCompleter(p, p)), dialog_mode_(false)
|
completer_(new GuiCompleter(p, p)), dialog_mode_(false),
|
||||||
|
read_only_(false), clean_(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1388,8 +1388,15 @@ QVariant GuiWorkArea::inputMethodQuery(Qt::InputMethodQuery query) const
|
|||||||
|
|
||||||
void GuiWorkArea::updateWindowTitle()
|
void GuiWorkArea::updateWindowTitle()
|
||||||
{
|
{
|
||||||
d->lyx_view_->updateWindowTitle(this);
|
Buffer const & buf = bufferView().buffer();
|
||||||
titleChanged(this);
|
if (buf.fileName() != d->file_name_ || buf.isReadonly() != d->read_only_
|
||||||
|
|| buf.lyxvc().vcstatus() != d->vc_status_ || buf.isClean() != d->clean_) {
|
||||||
|
d->file_name_ = buf.fileName();
|
||||||
|
d->read_only_ = buf.isReadonly();
|
||||||
|
d->vc_status_ = buf.lyxvc().vcstatus();
|
||||||
|
d->clean_ = buf.isClean();
|
||||||
|
titleChanged(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
#include "LyXRC.h"
|
#include "LyXRC.h"
|
||||||
|
|
||||||
|
#include "support/FileName.h"
|
||||||
#include "support/Timeout.h"
|
#include "support/Timeout.h"
|
||||||
|
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
@ -150,8 +151,6 @@ struct GuiWorkArea::Private
|
|||||||
QPaintDevice * screen_;
|
QPaintDevice * screen_;
|
||||||
///
|
///
|
||||||
BufferView * buffer_view_;
|
BufferView * buffer_view_;
|
||||||
/// Read only Buffer status cache.
|
|
||||||
bool read_only_;
|
|
||||||
///
|
///
|
||||||
GuiView * lyx_view_;
|
GuiView * lyx_view_;
|
||||||
/// is the cursor currently displayed
|
/// is the cursor currently displayed
|
||||||
@ -187,6 +186,17 @@ struct GuiWorkArea::Private
|
|||||||
/// when the menu is actually shown (after releasing on Windows)
|
/// when the menu is actually shown (after releasing on Windows)
|
||||||
/// and after the DEPM has done its job.
|
/// and after the DEPM has done its job.
|
||||||
std::string context_menu_name_;
|
std::string context_menu_name_;
|
||||||
|
|
||||||
|
/// stuff related to window title
|
||||||
|
///
|
||||||
|
support::FileName file_name_;
|
||||||
|
///
|
||||||
|
bool read_only_;
|
||||||
|
///
|
||||||
|
docstring vc_status_;
|
||||||
|
///
|
||||||
|
bool clean_;
|
||||||
|
|
||||||
}; // GuiWorkArea
|
}; // GuiWorkArea
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
Loading…
Reference in New Issue
Block a user