mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-09-19 22:40:26 +00:00
Use QSettings for session management of windows geometry. This commit also removes the possibility to fix the window dimensions in the RC file. Instead we have now a single check box for enabling/disabling geometry session management.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21625 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
55217e352c
commit
e73f8040fe
@ -2521,9 +2521,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
|
||||
case LyXRC::RC_SCREEN_FONT_SIZES:
|
||||
case LyXRC::RC_SCREEN_FONT_TYPEWRITER:
|
||||
case LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
|
||||
case LyXRC::RC_SCREEN_GEOMETRY_HEIGHT:
|
||||
case LyXRC::RC_SCREEN_GEOMETRY_WIDTH:
|
||||
case LyXRC::RC_SCREEN_GEOMETRY_XYSAVED:
|
||||
case LyXRC::RC_GEOMETRY_SESSION:
|
||||
case LyXRC::RC_SCREEN_ZOOM:
|
||||
case LyXRC::RC_SERVERPIPE:
|
||||
case LyXRC::RC_SET_COLOR:
|
||||
|
@ -67,6 +67,7 @@ namespace {
|
||||
// when adding something to this array keep it sorted!
|
||||
keyword_item lyxrcTags[] = {
|
||||
{ "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
|
||||
{ "\\allow_geometry_session", LyXRC::RC_GEOMETRY_SESSION },
|
||||
{ "\\alternate_language", LyXRC::RC_ALT_LANG },
|
||||
{ "\\auto_number", LyXRC::RC_AUTO_NUMBER },
|
||||
{ "\\auto_region_delete", LyXRC::RC_AUTOREGIONDELETE },
|
||||
@ -146,9 +147,6 @@ keyword_item lyxrcTags[] = {
|
||||
{ "\\screen_font_sizes", LyXRC::RC_SCREEN_FONT_SIZES },
|
||||
{ "\\screen_font_typewriter", LyXRC::RC_SCREEN_FONT_TYPEWRITER },
|
||||
{ "\\screen_font_typewriter_foundry", LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY },
|
||||
{ "\\screen_geometry_height", LyXRC::RC_SCREEN_GEOMETRY_HEIGHT },
|
||||
{ "\\screen_geometry_width", LyXRC::RC_SCREEN_GEOMETRY_WIDTH },
|
||||
{ "\\screen_geometry_xysaved", LyXRC::RC_SCREEN_GEOMETRY_XYSAVED },
|
||||
{ "\\screen_zoom", LyXRC::RC_SCREEN_ZOOM },
|
||||
{ "\\serverpipe", LyXRC::RC_SERVERPIPE },
|
||||
{ "\\set_color", LyXRC::RC_SET_COLOR },
|
||||
@ -222,9 +220,7 @@ void LyXRC::setDefaults() {
|
||||
dpi = 75;
|
||||
// Because a screen typically is wider than a piece of paper:
|
||||
zoom = 150;
|
||||
geometry_width = 0;
|
||||
geometry_height = 0;
|
||||
geometry_xysaved = true;
|
||||
allow_geometry_session = true;
|
||||
// Default LaTeX font size:
|
||||
font_sizes[FONT_SIZE_TINY] = "5.0";
|
||||
font_sizes[FONT_SIZE_SCRIPT] = "7.0";
|
||||
@ -641,21 +637,9 @@ int LyXRC::read(Lexer & lexrc)
|
||||
}
|
||||
break;
|
||||
|
||||
case RC_SCREEN_GEOMETRY_HEIGHT:
|
||||
case RC_GEOMETRY_SESSION:
|
||||
if (lexrc.next()) {
|
||||
geometry_height = lexrc.getInteger();
|
||||
}
|
||||
break;
|
||||
|
||||
case RC_SCREEN_GEOMETRY_WIDTH:
|
||||
if (lexrc.next()) {
|
||||
geometry_width = lexrc.getInteger();
|
||||
}
|
||||
break;
|
||||
|
||||
case RC_SCREEN_GEOMETRY_XYSAVED:
|
||||
if (lexrc.next()) {
|
||||
geometry_xysaved = lexrc.getBool();
|
||||
allow_geometry_session = lexrc.getBool();
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1573,26 +1557,10 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
|
||||
}
|
||||
if (tag != RC_LAST)
|
||||
break;
|
||||
case RC_SCREEN_GEOMETRY_HEIGHT:
|
||||
case RC_GEOMETRY_SESSION:
|
||||
if (ignore_system_lyxrc ||
|
||||
geometry_height != system_lyxrc.geometry_height) {
|
||||
os << "\\screen_geometry_height " << geometry_height
|
||||
<< '\n';
|
||||
}
|
||||
if (tag != RC_LAST)
|
||||
break;
|
||||
case RC_SCREEN_GEOMETRY_WIDTH:
|
||||
if (ignore_system_lyxrc ||
|
||||
geometry_width != system_lyxrc.geometry_width) {
|
||||
os << "\\screen_geometry_width " << geometry_width
|
||||
<< '\n';
|
||||
}
|
||||
if (tag != RC_LAST)
|
||||
break;
|
||||
case RC_SCREEN_GEOMETRY_XYSAVED:
|
||||
if (ignore_system_lyxrc ||
|
||||
geometry_xysaved != system_lyxrc.geometry_xysaved) {
|
||||
os << "\\screen_geometry_xysaved " << convert<string>(geometry_xysaved)
|
||||
allow_geometry_session != system_lyxrc.allow_geometry_session) {
|
||||
os << "\\allow_geometry_session " << convert<string>(allow_geometry_session)
|
||||
<< '\n';
|
||||
}
|
||||
if (tag != RC_LAST)
|
||||
@ -2647,13 +2615,8 @@ string const LyXRC::getDescription(LyXRCTags tag)
|
||||
str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper.");
|
||||
break;
|
||||
|
||||
case RC_SCREEN_GEOMETRY_HEIGHT:
|
||||
case RC_SCREEN_GEOMETRY_WIDTH:
|
||||
str = _("Specify geometry of the main view in width x height (values from last session will not be used if non-zero values are specified).");
|
||||
break;
|
||||
|
||||
case RC_SCREEN_GEOMETRY_XYSAVED:
|
||||
str = _("Allow session manager to save and restore windows position.");
|
||||
case RC_GEOMETRY_SESSION:
|
||||
str = _("Allow session manager to save and restore windows geometry.");
|
||||
break;
|
||||
|
||||
case RC_SERVERPIPE:
|
||||
|
13
src/LyXRC.h
13
src/LyXRC.h
@ -118,9 +118,7 @@ public:
|
||||
RC_SCREEN_FONT_SIZES,
|
||||
RC_SCREEN_FONT_TYPEWRITER,
|
||||
RC_SCREEN_FONT_TYPEWRITER_FOUNDRY,
|
||||
RC_SCREEN_GEOMETRY_HEIGHT,
|
||||
RC_SCREEN_GEOMETRY_WIDTH,
|
||||
RC_SCREEN_GEOMETRY_XYSAVED,
|
||||
RC_GEOMETRY_SESSION,
|
||||
RC_SCREEN_ZOOM,
|
||||
RC_SERVERPIPE,
|
||||
RC_SET_COLOR,
|
||||
@ -247,12 +245,9 @@ public:
|
||||
bool make_backup;
|
||||
/// A directory for storing backup files
|
||||
std::string backupdir_path;
|
||||
/// Width of MainWindow. if 0, value from last session will be used
|
||||
int geometry_width;
|
||||
/// Height of MainWindow, if 0, value from last session will be used
|
||||
int geometry_height;
|
||||
/// Whether or not save/restore windows position as session info
|
||||
bool geometry_xysaved;
|
||||
/// Whether or not save/restore session information
|
||||
/// like windows position and geometry.
|
||||
bool allow_geometry_session;
|
||||
/// Zoom factor for screen fonts
|
||||
unsigned int zoom;
|
||||
/// Screen font sizes in points for each font size
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include <QLocale>
|
||||
#include <QLibraryInfo>
|
||||
#include <QPixmapCache>
|
||||
#include <QRegExp>
|
||||
#include <QSessionManager>
|
||||
#include <QSocketNotifier>
|
||||
#include <QTextCodec>
|
||||
@ -201,7 +202,21 @@ LyXView & GuiApplication::createView(string const & geometryArg)
|
||||
theLyXFunc().setLyXView(&view);
|
||||
|
||||
view.init();
|
||||
view.setGeometry(geometryArg);
|
||||
view.show();
|
||||
if (!geometryArg.empty())
|
||||
{
|
||||
#ifdef Q_WS_WIN
|
||||
int x, y;
|
||||
int w, h;
|
||||
QRegExp re( "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ ]*(?:([+-][0-9]*)([+-][0-9]*)){0,1}" );
|
||||
re.indexIn(toqstr(geometryArg.c_str()));
|
||||
w = re.cap(1).toInt();
|
||||
h = re.cap(2).toInt();
|
||||
x = re.cap(3).toInt();
|
||||
y = re.cap(4).toInt();
|
||||
view.setGeometry(x, y, w, h);
|
||||
#endif
|
||||
}
|
||||
view.setFocus();
|
||||
|
||||
setCurrentView(view);
|
||||
|
@ -1609,13 +1609,7 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form, QWidget * parent)
|
||||
this, SIGNAL(changed()));
|
||||
connect(loadSessionCB, SIGNAL(clicked()),
|
||||
this, SIGNAL(changed()));
|
||||
connect(loadWindowSizeCB, SIGNAL(clicked()),
|
||||
this, SIGNAL(changed()));
|
||||
connect(loadWindowLocationCB, SIGNAL(clicked()),
|
||||
this, SIGNAL(changed()));
|
||||
connect(windowWidthSB, SIGNAL(valueChanged(int)),
|
||||
this, SIGNAL(changed()));
|
||||
connect(windowHeightSB, SIGNAL(valueChanged(int)),
|
||||
connect(allowGeometrySessionCB, SIGNAL(clicked()),
|
||||
this, SIGNAL(changed()));
|
||||
connect(cursorFollowsCB, SIGNAL(clicked()),
|
||||
this, SIGNAL(changed()));
|
||||
@ -1638,14 +1632,7 @@ void PrefUserInterface::apply(LyXRC & rc) const
|
||||
rc.ui_file = internal_path(fromqstr(uiFileED->text()));
|
||||
rc.use_lastfilepos = restoreCursorCB->isChecked();
|
||||
rc.load_session = loadSessionCB->isChecked();
|
||||
if (loadWindowSizeCB->isChecked()) {
|
||||
rc.geometry_width = 0;
|
||||
rc.geometry_height = 0;
|
||||
} else {
|
||||
rc.geometry_width = windowWidthSB->value();
|
||||
rc.geometry_height = windowHeightSB->value();
|
||||
}
|
||||
rc.geometry_xysaved = loadWindowLocationCB->isChecked();
|
||||
rc.allow_geometry_session = allowGeometrySessionCB->isChecked();
|
||||
rc.cursor_follows_scrollbar = cursorFollowsCB->isChecked();
|
||||
rc.sort_layouts = sortEnvironmentsCB->isChecked();
|
||||
rc.autosave = autoSaveSB->value() * 60;
|
||||
@ -1660,13 +1647,7 @@ void PrefUserInterface::update(LyXRC const & rc)
|
||||
uiFileED->setText(toqstr(external_path(rc.ui_file)));
|
||||
restoreCursorCB->setChecked(rc.use_lastfilepos);
|
||||
loadSessionCB->setChecked(rc.load_session);
|
||||
bool loadWindowSize = rc.geometry_width == 0 && rc.geometry_height == 0;
|
||||
loadWindowSizeCB->setChecked(loadWindowSize);
|
||||
if (!loadWindowSize) {
|
||||
windowWidthSB->setValue(rc.geometry_width);
|
||||
windowHeightSB->setValue(rc.geometry_height);
|
||||
}
|
||||
loadWindowLocationCB->setChecked(rc.geometry_xysaved);
|
||||
allowGeometrySessionCB->setChecked(rc.allow_geometry_session);
|
||||
cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar);
|
||||
sortEnvironmentsCB->setChecked(rc.sort_layouts);
|
||||
// convert to minutes
|
||||
@ -1693,15 +1674,6 @@ void PrefUserInterface::select_ui()
|
||||
}
|
||||
|
||||
|
||||
void PrefUserInterface::on_loadWindowSizeCB_toggled(bool loadwindowsize)
|
||||
{
|
||||
windowWidthLA->setDisabled(loadwindowsize);
|
||||
windowHeightLA->setDisabled(loadwindowsize);
|
||||
windowWidthSB->setDisabled(loadwindowsize);
|
||||
windowHeightSB->setDisabled(loadwindowsize);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PrefShortcuts
|
||||
|
@ -343,8 +343,6 @@ public:
|
||||
|
||||
public Q_SLOTS:
|
||||
void select_ui();
|
||||
void on_loadWindowSizeCB_toggled(bool);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -52,7 +52,6 @@
|
||||
#include "LyXRC.h"
|
||||
#include "MenuBackend.h"
|
||||
#include "Paragraph.h"
|
||||
#include "Session.h"
|
||||
#include "TextClass.h"
|
||||
#include "Text.h"
|
||||
#include "ToolbarBackend.h"
|
||||
@ -73,6 +72,8 @@
|
||||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
#include <QPushButton>
|
||||
#include <QSettings>
|
||||
#include <QShowEvent>
|
||||
#include <QSplitter>
|
||||
#include <QStackedWidget>
|
||||
#include <QStatusBar>
|
||||
@ -368,6 +369,25 @@ void GuiView::init()
|
||||
}
|
||||
|
||||
|
||||
void GuiView::showEvent(QShowEvent * e)
|
||||
{
|
||||
if (lyxrc.allow_geometry_session) {
|
||||
QSettings settings;
|
||||
QString const key = "view-" + QString::number(id());
|
||||
if (!restoreGeometry(settings.value(key + "/geometry").toByteArray()))
|
||||
setGeometry(50, 50, 690, 510);
|
||||
setIconSize(settings.value(key + "/icon_size").toSize());
|
||||
} else
|
||||
setGeometry(50, 50, 690, 510);
|
||||
|
||||
if (d.splitter_->count() == 0)
|
||||
// No work area, switch to the background widget.
|
||||
d.setBackground();
|
||||
|
||||
QMainWindow::showEvent(e);
|
||||
}
|
||||
|
||||
|
||||
void GuiView::closeEvent(QCloseEvent * close_event)
|
||||
{
|
||||
// we may have been called through the close window button
|
||||
@ -384,6 +404,14 @@ void GuiView::closeEvent(QCloseEvent * close_event)
|
||||
// Make sure the timer time out will not trigger a statusbar update.
|
||||
statusbar_timer_.stop();
|
||||
|
||||
if (lyxrc.allow_geometry_session) {
|
||||
QSettings settings;
|
||||
QString const key = "view-" + QString::number(id());
|
||||
settings.setValue(key + "/geometry", saveGeometry());
|
||||
settings.setValue(key + "/icon_size", iconSize());
|
||||
d.toolbars_->saveToolbarInfo();
|
||||
}
|
||||
|
||||
theApp()->gui().unregisterView(id());
|
||||
if (!theApp()->gui().viewIds().empty()) {
|
||||
// Just close the window and do nothing else if this is not the
|
||||
@ -396,7 +424,6 @@ void GuiView::closeEvent(QCloseEvent * close_event)
|
||||
|
||||
// this is the place where we leave the frontend.
|
||||
// it is the only point at which we start quitting.
|
||||
saveGeometry();
|
||||
close_event->accept();
|
||||
// quit the event loop
|
||||
qApp->quit();
|
||||
@ -430,232 +457,6 @@ void GuiView::dropEvent(QDropEvent* event)
|
||||
}
|
||||
|
||||
|
||||
void GuiView::saveGeometry()
|
||||
{
|
||||
static bool done = false;
|
||||
if (done)
|
||||
return;
|
||||
else
|
||||
done = true;
|
||||
|
||||
// FIXME:
|
||||
// change the ifdef to 'geometry = normalGeometry();' only
|
||||
// when Trolltech has fixed the broken normalGeometry on X11:
|
||||
// http://www.trolltech.com/developer/task-tracker/index_html?id=119684+&method=entry
|
||||
// Then also the moveEvent, resizeEvent, and the
|
||||
// code for floatingGeometry_ can be removed;
|
||||
// adjust GuiView::setGeometry()
|
||||
|
||||
QRect normal_geometry;
|
||||
Maximized maximized;
|
||||
#ifdef Q_WS_WIN
|
||||
normal_geometry = normalGeometry();
|
||||
if (isMaximized()) {
|
||||
maximized = CompletelyMaximized;
|
||||
} else {
|
||||
maximized = NotMaximized;
|
||||
}
|
||||
#else
|
||||
normal_geometry = updateFloatingGeometry();
|
||||
|
||||
QDesktopWidget& dw = *qApp->desktop();
|
||||
QRect desk = dw.availableGeometry(dw.primaryScreen());
|
||||
// Qt bug on Linux: load completely maximized, vert max. save-> frameGeometry().height() is wrong
|
||||
if (isMaximized() && desk.width() <= frameGeometry().width() && desk.height() <= frameGeometry().height()) {
|
||||
maximized = CompletelyMaximized;
|
||||
// maximizing does not work when the window is allready hor. or vert. maximized
|
||||
// Tested only on KDE
|
||||
int dh = frameGeometry().height() - height();
|
||||
if (desk.height() <= normal_geometry.height() + dh)
|
||||
normal_geometry.setHeight(normal_geometry.height() - 1);
|
||||
int dw = frameGeometry().width() - width();
|
||||
if (desk.width() <= normal_geometry.width() + dw)
|
||||
normal_geometry.setWidth(normal_geometry.width() - 1);
|
||||
} else if (desk.height() <= frameGeometry().height()) {
|
||||
maximized = VerticallyMaximized;
|
||||
} else if (desk.width() <= frameGeometry().width()) {
|
||||
maximized = HorizontallyMaximized;
|
||||
} else {
|
||||
maximized = NotMaximized;
|
||||
}
|
||||
#endif
|
||||
|
||||
// save windows size and position
|
||||
SessionInfoSection & info = LyX::ref().session().sessionInfo();
|
||||
info.save("WindowWidth", convert<string>(normal_geometry.width()));
|
||||
info.save("WindowHeight", convert<string>(normal_geometry.height()));
|
||||
info.save("WindowMaximized", convert<string>(int(maximized)));
|
||||
info.save("IconSizeXY", convert<string>(iconSize().width()));
|
||||
if (lyxrc.geometry_xysaved) {
|
||||
info.save("WindowPosX", convert<string>(normal_geometry.x() + d.posx_offset));
|
||||
info.save("WindowPosY", convert<string>(normal_geometry.y() + d.posy_offset));
|
||||
}
|
||||
d.toolbars_->saveToolbarInfo();
|
||||
}
|
||||
|
||||
|
||||
void GuiView::setGeometry(string const & geometryArg)
|
||||
{
|
||||
// *******************************************
|
||||
// Beginning of the session handling stuff
|
||||
|
||||
//FIXME: Instead of the stuff below, we should use QSettings:
|
||||
/*
|
||||
QSettings settings;
|
||||
QString key = "view " + QString::number(id) + "/geometry";
|
||||
view.restoreGeometry(settings.value(key).toByteArray());
|
||||
*/
|
||||
|
||||
// determine windows size and position, from lyxrc and/or session
|
||||
// initial geometry
|
||||
unsigned int width = 690;
|
||||
unsigned int height = 510;
|
||||
// default icon size, will be overwritten by stored session value
|
||||
unsigned int iconSizeXY = 0;
|
||||
Maximized maximized = NotMaximized;
|
||||
SessionInfoSection & session = LyX::ref().session().sessionInfo();
|
||||
|
||||
// first try lyxrc
|
||||
if (lyxrc.geometry_width != 0 && lyxrc.geometry_height != 0 ) {
|
||||
width = lyxrc.geometry_width;
|
||||
height = lyxrc.geometry_height;
|
||||
}
|
||||
// if lyxrc returns (0,0), then use session info
|
||||
else {
|
||||
string val = session.load("WindowWidth");
|
||||
if (!val.empty())
|
||||
width = convert<unsigned int>(val);
|
||||
val = session.load("WindowHeight");
|
||||
if (!val.empty())
|
||||
height = convert<unsigned int>(val);
|
||||
val = session.load("WindowMaximized");
|
||||
if (!val.empty())
|
||||
maximized = GuiView::Maximized(convert<int>(val));
|
||||
val = session.load("IconSizeXY");
|
||||
if (!val.empty())
|
||||
iconSizeXY = convert<unsigned int>(val);
|
||||
}
|
||||
|
||||
// if user wants to restore window position
|
||||
int posx = -1;
|
||||
int posy = -1;
|
||||
if (lyxrc.geometry_xysaved) {
|
||||
string val = session.load("WindowPosX");
|
||||
if (!val.empty())
|
||||
posx = convert<int>(val);
|
||||
val = session.load("WindowPosY");
|
||||
if (!val.empty())
|
||||
posy = convert<int>(val);
|
||||
}
|
||||
|
||||
if (!geometryArg.empty())
|
||||
{
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
|
||||
// End of the sesssion handling stuff
|
||||
// *******************************************
|
||||
|
||||
// use last value (not at startup)
|
||||
if (d.lastIconSize != 0)
|
||||
setIconSize(d.lastIconSize);
|
||||
else if (iconSizeXY != 0)
|
||||
setIconSize(iconSizeXY);
|
||||
else
|
||||
setIconSize(d.normalIconSize);
|
||||
|
||||
// only true when the -geometry option was NOT used
|
||||
if (width != 0 && height != 0) {
|
||||
if (posx != -1 && posy != -1) {
|
||||
// if there are startup positioning problems:
|
||||
// http://doc.trolltech.com/4.2/qdesktopwidget.html
|
||||
QDesktopWidget& dw = *qApp->desktop();
|
||||
if (dw.isVirtualDesktop()) {
|
||||
if(!dw.geometry().contains(posx, posy)) {
|
||||
posx = 50;
|
||||
posy = 50;
|
||||
}
|
||||
} else {
|
||||
// Which system doesn't use a virtual desktop?
|
||||
// TODO save also last screen number and check if it is still availabe.
|
||||
}
|
||||
#ifdef Q_WS_WIN
|
||||
// FIXME: use setGeometry only when Trolltech has fixed the qt4/X11 bug
|
||||
QWidget::setGeometry(posx, posy, width, height);
|
||||
#else
|
||||
resize(width, height);
|
||||
move(posx, posy);
|
||||
#endif
|
||||
} else {
|
||||
resize(width, height);
|
||||
}
|
||||
|
||||
// remember original size
|
||||
floatingGeometry_ = QRect(posx, posy, width, height);
|
||||
|
||||
if (maximized != NotMaximized) {
|
||||
if (maximized == CompletelyMaximized) {
|
||||
setWindowState(Qt::WindowMaximized);
|
||||
} else {
|
||||
#ifndef Q_WS_WIN
|
||||
// TODO How to set by the window manager?
|
||||
// setWindowState(Qt::WindowVerticallyMaximized);
|
||||
// is not possible
|
||||
QDesktopWidget& dw = *qApp->desktop();
|
||||
QRect desk = dw.availableGeometry(dw.primaryScreen());
|
||||
if (maximized == VerticallyMaximized)
|
||||
resize(width, desk.height());
|
||||
if (maximized == HorizontallyMaximized)
|
||||
resize(desk.width(), height);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: move this code into parse_geometry() (LyX.cpp)
|
||||
#ifdef Q_WS_WIN
|
||||
int x, y;
|
||||
int w, h;
|
||||
QRegExp re( "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ ]*(?:([+-][0-9]*)([+-][0-9]*)){0,1}" );
|
||||
re.indexIn(toqstr(geometryArg.c_str()));
|
||||
w = re.cap(1).toInt();
|
||||
h = re.cap(2).toInt();
|
||||
x = re.cap(3).toInt();
|
||||
y = re.cap(4).toInt();
|
||||
QWidget::setGeometry( x, y, w, h );
|
||||
#else
|
||||
// silence warning
|
||||
(void)geometryArg;
|
||||
#endif
|
||||
}
|
||||
|
||||
d.setBackground();
|
||||
|
||||
show();
|
||||
|
||||
// after show geometry() has changed (Qt bug?)
|
||||
// we compensate the drift when storing the position
|
||||
d.posx_offset = 0;
|
||||
d.posy_offset = 0;
|
||||
if (width != 0 && height != 0)
|
||||
if (posx != -1 && posy != -1) {
|
||||
#ifdef Q_WS_WIN
|
||||
d.posx_offset = posx - normalGeometry().x();
|
||||
d.posy_offset = posy - normalGeometry().y();
|
||||
#else
|
||||
#ifndef Q_WS_MACX
|
||||
if (maximized == NotMaximized) {
|
||||
d.posx_offset = posx - geometry().x();
|
||||
d.posy_offset = posy - geometry().y();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GuiView::message(docstring const & str)
|
||||
{
|
||||
statusBar()->showMessage(toqstr(str));
|
||||
@ -664,28 +465,21 @@ void GuiView::message(docstring const & str)
|
||||
}
|
||||
|
||||
|
||||
void GuiView::setIconSize(unsigned int size)
|
||||
{
|
||||
d.lastIconSize = size;
|
||||
QMainWindow::setIconSize(QSize(size, size));
|
||||
}
|
||||
|
||||
|
||||
void GuiView::smallSizedIcons()
|
||||
{
|
||||
setIconSize(d.smallIconSize);
|
||||
setIconSize(QSize(d.smallIconSize, d.smallIconSize));
|
||||
}
|
||||
|
||||
|
||||
void GuiView::normalSizedIcons()
|
||||
{
|
||||
setIconSize(d.normalIconSize);
|
||||
setIconSize(QSize(d.normalIconSize, d.normalIconSize));
|
||||
}
|
||||
|
||||
|
||||
void GuiView::bigSizedIcons()
|
||||
{
|
||||
setIconSize(d.bigIconSize);
|
||||
setIconSize(QSize(d.bigIconSize, d.bigIconSize));
|
||||
}
|
||||
|
||||
|
||||
@ -746,30 +540,6 @@ bool GuiView::hasFocus() const
|
||||
}
|
||||
|
||||
|
||||
QRect GuiView::updateFloatingGeometry()
|
||||
{
|
||||
QDesktopWidget& dw = *qApp->desktop();
|
||||
QRect desk = dw.availableGeometry(dw.primaryScreen());
|
||||
// remember only non-maximized sizes
|
||||
if (!isMaximized() && desk.width() > frameGeometry().width() && desk.height() > frameGeometry().height()) {
|
||||
floatingGeometry_ = QRect(x(), y(), width(), height());
|
||||
}
|
||||
return floatingGeometry_;
|
||||
}
|
||||
|
||||
|
||||
void GuiView::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
updateFloatingGeometry();
|
||||
}
|
||||
|
||||
|
||||
void GuiView::moveEvent(QMoveEvent *)
|
||||
{
|
||||
updateFloatingGeometry();
|
||||
}
|
||||
|
||||
|
||||
bool GuiView::event(QEvent * e)
|
||||
{
|
||||
switch (e->type())
|
||||
|
@ -24,6 +24,7 @@ class QCloseEvent;
|
||||
class QDragEnterEvent;
|
||||
class QDropEvent;
|
||||
class QMenu;
|
||||
class QShowEvent;
|
||||
|
||||
|
||||
namespace lyx {
|
||||
@ -59,18 +60,8 @@ public:
|
||||
virtual void init();
|
||||
virtual void close();
|
||||
virtual void setFocus();
|
||||
|
||||
enum Maximized {
|
||||
NotMaximized = 0, // LyX::newLyXView() relies on this to be zero!
|
||||
VerticallyMaximized,
|
||||
HorizontallyMaximized,
|
||||
CompletelyMaximized
|
||||
};
|
||||
///
|
||||
virtual void setGeometry(std::string const & geometryArg);
|
||||
/// save the geometry state in the session manager.
|
||||
virtual void saveGeometry();
|
||||
virtual void setBusy(bool);
|
||||
|
||||
/// add toolbar, if newline==true, add a toolbar break before the toolbar
|
||||
GuiToolbar * makeToolbar(ToolbarInfo const & tbinfo, bool newline);
|
||||
virtual void updateStatusBar();
|
||||
@ -185,19 +176,13 @@ private:
|
||||
///
|
||||
void dropEvent(QDropEvent * ev);
|
||||
/// make sure we quit cleanly
|
||||
virtual void closeEvent(QCloseEvent * e);
|
||||
void closeEvent(QCloseEvent * e);
|
||||
///
|
||||
virtual void resizeEvent(QResizeEvent * e);
|
||||
///
|
||||
virtual void moveEvent(QMoveEvent * e);
|
||||
void showEvent(QShowEvent *);
|
||||
|
||||
/// in order to catch Tab key press.
|
||||
bool event(QEvent * e);
|
||||
bool focusNextPrevChild(bool);
|
||||
///
|
||||
QRect updateFloatingGeometry();
|
||||
///
|
||||
void setIconSize(unsigned int size);
|
||||
|
||||
///
|
||||
struct GuiViewPrivate;
|
||||
@ -209,9 +194,6 @@ private:
|
||||
/// are we quitting by the menu?
|
||||
bool quitting_by_menu_;
|
||||
|
||||
///
|
||||
QRect floatingGeometry_;
|
||||
|
||||
struct ToolbarSize {
|
||||
int top_width;
|
||||
int bottom_width;
|
||||
|
@ -27,196 +27,6 @@
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="uiFileLA" >
|
||||
<property name="text" >
|
||||
<string>&User interface file:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>uiFileED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLineEdit" name="uiFileED" />
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<widget class="QPushButton" name="uiFilePB" >
|
||||
<property name="text" >
|
||||
<string>Bro&wse...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3" >
|
||||
<widget class="QGroupBox" name="GeometryGB" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title" >
|
||||
<string>Session</string>
|
||||
</property>
|
||||
<property name="flat" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="2" >
|
||||
<widget class="QCheckBox" name="loadWindowSizeCB" >
|
||||
<property name="text" >
|
||||
<string>Save/restore window size, or use fixed size</string>
|
||||
</property>
|
||||
<property name="checked" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="0" >
|
||||
<widget class="QCheckBox" name="loadSessionCB" >
|
||||
<property name="text" >
|
||||
<string>Load opened files from last session</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<widget class="QCheckBox" name="restoreCursorCB" >
|
||||
<property name="text" >
|
||||
<string>Restore cursor positions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QCheckBox" name="loadWindowLocationCB" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Restore to cursor position when the file was last closed</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Save/restore window position</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="windowWidthLA" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Width</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="windowWidthSB" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<number>9999</number>
|
||||
</property>
|
||||
<property name="minimum" >
|
||||
<number>200</number>
|
||||
</property>
|
||||
<property name="singleStep" >
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="windowHeightLA" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Height</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="windowHeightSB" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<number>9999</number>
|
||||
</property>
|
||||
<property name="minimum" >
|
||||
<number>200</number>
|
||||
</property>
|
||||
<property name="singleStep" >
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3" >
|
||||
<widget class="QGroupBox" name="documentsGB" >
|
||||
<property name="title" >
|
||||
@ -312,13 +122,18 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3" >
|
||||
<widget class="QGroupBox" name="scrollGB" >
|
||||
<property name="title" >
|
||||
<string>Editing</string>
|
||||
<item row="1" column="0" colspan="2" >
|
||||
<widget class="QGroupBox" name="GeometryGB" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>0</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
<property name="title" >
|
||||
<string>Session</string>
|
||||
</property>
|
||||
<property name="flat" >
|
||||
<bool>true</bool>
|
||||
@ -331,22 +146,48 @@
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QCheckBox" name="cursorFollowsCB" >
|
||||
<widget class="QCheckBox" name="allowGeometrySessionCB" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Restore to cursor position when the file was last closed</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Cursor follows &scrollbar</string>
|
||||
<string>Allow saving/restoring of windows geometry</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QCheckBox" name="loadSessionCB" >
|
||||
<property name="text" >
|
||||
<string>Load opened files from last session</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QCheckBox" name="sortEnvironmentsCB" >
|
||||
<widget class="QCheckBox" name="restoreCursorCB" >
|
||||
<property name="text" >
|
||||
<string>Sort &Environments alphabetically</string>
|
||||
<string>Restore cursor positions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3" >
|
||||
<widget class="QGroupBox" name="pixmapCacheGB" >
|
||||
<property name="title" >
|
||||
@ -381,28 +222,67 @@ p, li { white-space: pre-wrap; }
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
<item row="3" column="0" colspan="3" >
|
||||
<widget class="QGroupBox" name="scrollGB" >
|
||||
<property name="title" >
|
||||
<string>Editing</string>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</spacer>
|
||||
<property name="flat" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QCheckBox" name="cursorFollowsCB" >
|
||||
<property name="text" >
|
||||
<string>Cursor follows &scrollbar</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QCheckBox" name="sortEnvironmentsCB" >
|
||||
<property name="text" >
|
||||
<string>Sort &Environments alphabetically</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<widget class="QPushButton" name="uiFilePB" >
|
||||
<property name="text" >
|
||||
<string>Bro&wse...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLineEdit" name="uiFileED" />
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="uiFileLA" >
|
||||
<property name="text" >
|
||||
<string>&User interface file:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>uiFileED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>uiFileED</tabstop>
|
||||
<tabstop>uiFilePB</tabstop>
|
||||
<tabstop>loadWindowSizeCB</tabstop>
|
||||
<tabstop>windowWidthSB</tabstop>
|
||||
<tabstop>windowHeightSB</tabstop>
|
||||
<tabstop>loadWindowLocationCB</tabstop>
|
||||
<tabstop>allowGeometrySessionCB</tabstop>
|
||||
<tabstop>restoreCursorCB</tabstop>
|
||||
<tabstop>loadSessionCB</tabstop>
|
||||
<tabstop>autoSaveCB</tabstop>
|
||||
|
Loading…
Reference in New Issue
Block a user