mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 19:07:45 +00:00
Better session management for the source panel.
We now remember the previous GUI values across sessions.
This commit is contained in:
parent
ba3e6cb2d2
commit
120c99ae60
@ -33,6 +33,7 @@
|
|||||||
#include <boost/crc.hpp>
|
#include <boost/crc.hpp>
|
||||||
|
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
|
#include <QComboBox>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QTextCursor>
|
#include <QTextCursor>
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
@ -56,13 +57,15 @@ ViewSourceWidget::ViewSourceWidget()
|
|||||||
connect(autoUpdateCB, SIGNAL(toggled(bool)),
|
connect(autoUpdateCB, SIGNAL(toggled(bool)),
|
||||||
updatePB, SLOT(setDisabled(bool)));
|
updatePB, SLOT(setDisabled(bool)));
|
||||||
connect(autoUpdateCB, SIGNAL(toggled(bool)),
|
connect(autoUpdateCB, SIGNAL(toggled(bool)),
|
||||||
this, SLOT(updateViewNow()));
|
this, SLOT(contentsChanged()));
|
||||||
connect(masterPerspectiveCB, SIGNAL(toggled(bool)),
|
connect(masterPerspectiveCB, SIGNAL(toggled(bool)),
|
||||||
this, SLOT(updateViewNow()));
|
this, SLOT(contentsChanged()));
|
||||||
connect(updatePB, SIGNAL(clicked()),
|
connect(updatePB, SIGNAL(clicked()),
|
||||||
this, SLOT(updateViewNow()));
|
this, SLOT(updateViewNow()));
|
||||||
connect(outputFormatCO, SIGNAL(activated(int)),
|
connect(outputFormatCO, SIGNAL(activated(int)),
|
||||||
this, SLOT(setViewFormat()));
|
this, SLOT(setViewFormat(int)));
|
||||||
|
connect(outputFormatCO, SIGNAL(activated(int)),
|
||||||
|
this, SLOT(contentsChanged()));
|
||||||
|
|
||||||
// setting the update timer
|
// setting the update timer
|
||||||
update_timer_->setSingleShot(true);
|
update_timer_->setSingleShot(true);
|
||||||
@ -149,11 +152,10 @@ void ViewSourceWidget::contentsChanged()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ViewSourceWidget::setViewFormat()
|
void ViewSourceWidget::setViewFormat(int const index)
|
||||||
{
|
{
|
||||||
view_format_ = outputFormatCO->itemData(
|
outputFormatCO->setCurrentIndex(index);
|
||||||
outputFormatCO->currentIndex()).toString();
|
view_format_ = outputFormatCO->itemData(index).toString();
|
||||||
updateViewNow();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -244,7 +246,7 @@ void ViewSourceWidget::updateDefaultFormat()
|
|||||||
if (qformat == view_format_)
|
if (qformat == view_format_)
|
||||||
index = outputFormatCO->count() -1;
|
index = outputFormatCO->count() -1;
|
||||||
}
|
}
|
||||||
outputFormatCO->setCurrentIndex(index);
|
setViewFormat(index);
|
||||||
|
|
||||||
outputFormatCO->blockSignals(false);
|
outputFormatCO->blockSignals(false);
|
||||||
}
|
}
|
||||||
@ -262,6 +264,35 @@ void ViewSourceWidget::resizeEvent (QResizeEvent * event)
|
|||||||
QWidget::resizeEvent(event);
|
QWidget::resizeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewSourceWidget::saveSession(QString const & session_key) const
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
settings.setValue(session_key + "/output", view_format_);
|
||||||
|
settings.setValue(session_key + "/contents", contentsCO->currentIndex());
|
||||||
|
settings.setValue(session_key + "/autoupdate", autoUpdateCB->isChecked());
|
||||||
|
settings.setValue(session_key + "/masterview",
|
||||||
|
masterPerspectiveCB->isChecked());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ViewSourceWidget::restoreSession(QString const & session_key)
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
view_format_ = settings.value(session_key + "/output", 0).toString();
|
||||||
|
contentsCO->setCurrentIndex(settings
|
||||||
|
.value(session_key + "/contents", 0)
|
||||||
|
.toInt());
|
||||||
|
masterPerspectiveCB->setChecked(settings
|
||||||
|
.value(session_key + "/masterview", false)
|
||||||
|
.toBool());
|
||||||
|
bool const checked = settings
|
||||||
|
.value(session_key + "/autoupdate", true)
|
||||||
|
.toBool();
|
||||||
|
autoUpdateCB->setChecked(checked);
|
||||||
|
if (checked)
|
||||||
|
updateView();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GuiViewSource::GuiViewSource(GuiView & parent,
|
GuiViewSource::GuiViewSource(GuiView & parent,
|
||||||
Qt::DockWidgetArea area, Qt::WindowFlags flags)
|
Qt::DockWidgetArea area, Qt::WindowFlags flags)
|
||||||
@ -294,7 +325,7 @@ void GuiViewSource::enableView(bool enable)
|
|||||||
widget_->updateDefaultFormat();
|
widget_->updateDefaultFormat();
|
||||||
if (!enable)
|
if (!enable)
|
||||||
// In the opposite case, updateView() will be called anyway.
|
// In the opposite case, updateView() will be called anyway.
|
||||||
widget_->updateView();
|
widget_->contentsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -323,26 +354,14 @@ QString GuiViewSource::title() const
|
|||||||
void GuiViewSource::saveSession() const
|
void GuiViewSource::saveSession() const
|
||||||
{
|
{
|
||||||
Dialog::saveSession();
|
Dialog::saveSession();
|
||||||
QSettings settings;
|
widget_->saveSession(sessionKey());
|
||||||
// see below
|
|
||||||
// settings.setValue(
|
|
||||||
// sessionKey() + "/output", widget_->contentsCO->currentIndex());
|
|
||||||
settings.setValue(
|
|
||||||
sessionKey() + "/autoupdate", widget_->autoUpdateCB->isChecked());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiViewSource::restoreSession()
|
void GuiViewSource::restoreSession()
|
||||||
{
|
{
|
||||||
DockView::restoreSession();
|
DockView::restoreSession();
|
||||||
// FIXME: Full source updating is too slow to be done at startup.
|
widget_->restoreSession(sessionKey());
|
||||||
//widget_->outputCO-setCurrentIndex(
|
|
||||||
// settings.value(sessionKey() + "/output", false).toInt());
|
|
||||||
widget_->contentsCO->setCurrentIndex(0);
|
|
||||||
QSettings settings;
|
|
||||||
widget_->autoUpdateCB->setChecked(
|
|
||||||
settings.value(sessionKey() + "/autoupdate", true).toBool());
|
|
||||||
widget_->updateView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,6 +38,10 @@ public:
|
|||||||
ViewSourceWidget();
|
ViewSourceWidget();
|
||||||
///
|
///
|
||||||
void setBufferView(BufferView const * bv);
|
void setBufferView(BufferView const * bv);
|
||||||
|
///
|
||||||
|
void saveSession(QString const & session_key) const;
|
||||||
|
///
|
||||||
|
void restoreSession(QString const & session_key);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
///
|
///
|
||||||
@ -49,8 +53,8 @@ public Q_SLOTS:
|
|||||||
/// schedule an update now
|
/// schedule an update now
|
||||||
void updateViewNow();
|
void updateViewNow();
|
||||||
///
|
///
|
||||||
void setViewFormat();
|
void setViewFormat(int const index);
|
||||||
///
|
//
|
||||||
void updateDefaultFormat();
|
void updateDefaultFormat();
|
||||||
///
|
///
|
||||||
void contentsChanged();
|
void contentsChanged();
|
||||||
|
Loading…
Reference in New Issue
Block a user