#include "Dialog.h"
#include "GuiView.h"
+#include "qt_helpers.h"
#include "Buffer.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
#include "LyXFunc.h"
-#include "support/Debug.h"
+#include "support/debug.h"
+
+#include <QSettings>
+#include <QString>
+
+#include "support/assert.h"
#include <string>
using namespace std;
+using namespace lyx::support;
namespace lyx {
namespace frontend {
-Dialog::Dialog(GuiView & lv, std::string const & name)
- : name_(name), lyxview_(&lv)
+Dialog::Dialog(GuiView & lv, QString const & name, QString const & title)
+ : name_(name), title_(title), lyxview_(&lv)
{}
{}
-std::string const & Dialog::name() const
-{
- return name_;
-}
-
bool Dialog::canApply() const
{
- FuncRequest const fr(getLfun(), from_ascii(name_));
+ FuncRequest const fr(getLfun(), fromqstr(name_));
FuncStatus const fs(getStatus(fr));
return fs.enabled();
}
void Dialog::updateDialog() const
{
- dispatch(FuncRequest(LFUN_DIALOG_UPDATE, from_ascii(name_)));
+ dispatch(FuncRequest(LFUN_DIALOG_UPDATE, fromqstr(name_)));
}
void Dialog::disconnect() const
{
- lyxview_->disconnectDialog(name_);
+ lyxview_->disconnectDialog(fromqstr(name_));
}
}
-std::string const Dialog::bufferFilepath() const
+QString Dialog::bufferFilepath() const
{
- return buffer().filePath();
+ return toqstr(buffer().filePath());
}
Buffer & Dialog::buffer()
{
- BOOST_ASSERT(lyxview_->buffer());
+ LASSERT(lyxview_->buffer(), /**/);
return *lyxview_->buffer();
}
Buffer const & Dialog::buffer() const
{
- BOOST_ASSERT(lyxview_->buffer());
+ LASSERT(lyxview_->buffer(), /**/);
return *lyxview_->buffer();
}
return;
if (!initialiseParams(data)) {
- LYXERR0("Dialog \"" << name()
+ LYXERR0("Dialog \"" << fromqstr(name())
<< "\" failed to translate the data string passed to show()");
return;
}
return;
if (!initialiseParams(data)) {
- LYXERR0("Dialog \"" << name()
+ LYXERR0("Dialog \"" << fromqstr(name())
<< "\" could not be initialized");
return;
}
void Dialog::showView()
{
- updateView(); // make sure its up-to-date
+ // Make sure the dialog is up-to-date.
+ updateView();
+ // Make sure the dialog controls are correctly enabled/disabled with
+ // readonly status.
+ checkStatus();
if (exitEarly())
return;
QWidget * w = asQWidget();
+ w->setWindowTitle(title_);
+
QSize const hint = w->sizeHint();
if (hint.height() >= 0 && hint.width() >= 0)
w->setMinimumSize(hint);
enableView(false);
}
+
+QString Dialog::sessionKey() const
+{
+ return "view-" + QString::number(lyxview_->id())
+ + "/" + name();
+}
+
+
+void Dialog::saveSession() const
+{
+ QSettings settings;
+ settings.setValue(sessionKey() + "/geometry", asQWidget()->saveGeometry());
+}
+
+
+void Dialog::restoreSession()
+{
+ QSettings settings;
+ asQWidget()->restoreGeometry(
+ settings.value(sessionKey() + "/geometry").toByteArray());
+}
+
} // namespace frontend
} // namespace lyx