#include <QDir>
#include <QEventLoop>
#include <QFileOpenEvent>
+#include <QFileInfo>
#include <QHash>
#include <QIcon>
#include <QImageReader>
#include <QPixmapCache>
#include <QRegExp>
#include <QSessionManager>
+#include <QSettings>
#include <QSocketNotifier>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
}
+void GuiApplication::clearSession()
+{
+ QSettings settings;
+ settings.clear();
+}
+
+
docstring GuiApplication::iconName(FuncRequest const & f, bool unknown)
{
return qstring_to_ucs4(lyx::frontend::iconName(f, unknown));
lyx::execBatchCommands();
}
+
QAbstractItemModel * GuiApplication::languageModel()
{
if (d->language_model_)
{ "toolbarset", ui_toolbarset }
};
- // Ensure that a file is read only once (prevents include loops)
- static QStringList uifiles;
- if (uifiles.contains(name)) {
- if (!include) {
- // We are reading again the top uifile so reset the safeguard:
- uifiles.clear();
- d->menus_.reset();
- d->toolbars_.reset();
- } else {
- LYXERR(Debug::INIT, "UI file '" << name << "' has been read already. "
- << "Is this an include loop?");
- return false;
- }
- }
-
LYXERR(Debug::INIT, "About to read " << name << "...");
FileName ui_path;
return false;
}
- uifiles.push_back(name);
+
+ // Ensure that a file is read only once (prevents include loops)
+ static QStringList uifiles;
+ QString const uifile = toqstr(ui_path.absFilename());
+ if (uifiles.contains(uifile)) {
+ if (!include) {
+ // We are reading again the top uifile so reset the safeguard:
+ uifiles.clear();
+ d->menus_.reset();
+ d->toolbars_.reset();
+ } else {
+ LYXERR(Debug::INIT, "UI file '" << name << "' has been read already. "
+ << "Is this an include loop?");
+ return false;
+ }
+ }
+ uifiles.push_back(uifile);
LYXERR(Debug::INIT, "Found " << name << " in " << ui_path);
+
Lexer lex(uitags);
lex.setFile(ui_path);
if (!lex.isOK()) {
break;
}
}
+
+ if (include)
+ return true;
+
+ QSettings settings;
+ settings.beginGroup("ui_files");
+ bool touched = false;
+ for (int i = 0; i != uifiles.size(); ++i) {
+ QFileInfo fi(uifiles[i]);
+ QDateTime const date_value = fi.lastModified();
+ QString const name_key = QString::number(i);
+ qDebug() << "File read " << i << " " << uifiles[i] << " " << date_value.toString("hh:mm:ss.zzz");
+ qDebug() << "File saved " << name_key << " " << settings.value(name_key).toString()
+ << " " << settings.value(name_key + "/date").toDateTime().toString("hh:mm:ss.zzz");
+
+ if (!settings.contains(name_key)
+ || settings.value(name_key).toString() != uifiles[i]
+ || settings.value(name_key + "/date").toDateTime() != date_value) {
+ touched = true;
+ settings.setValue(name_key, uifiles[i]);
+ settings.setValue(name_key + "/date", date_value);
+ }
+ }
+ settings.endGroup();
+ if (touched)
+ settings.remove("views");
+
return true;
}
initToolbars();
// This enables to clear session data if any.
QSettings settings;
- settings.clear();
+ settings.remove("views");
}
void GuiView::saveLayout() const
{
QSettings settings;
- QString const key = "view-" + QString::number(id_);
+ QString const key = "views/" + QString::number(id_);
#ifdef Q_WS_X11
settings.setValue(key + "/pos", pos());
settings.setValue(key + "/size", size());
bool GuiView::restoreLayout()
{
QSettings settings;
- QString const key = "view-" + QString::number(id_);
+ QString const key = "views/" + QString::number(id_);
QString const icon_key = key + "/icon_size";
if (!settings.contains(icon_key))
return false;
if (!restoreGeometry(settings.value(key + "/geometry").toByteArray()))
setGeometry(50, 50, 690, 510);
#endif
+ // Make sure layout is correctly oriented.
+ setLayoutDirection(qApp->layoutDirection());
+
// Allow the toc and view-source dock widget to be restored if needed.
Dialog * tmp;
if ((tmp = findOrBuild("toc", true)))