mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 10:18:50 +00:00
Transfer geometry related session code from LyX::newLyXView() to GuiView::setGeometry().
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21606 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
9c928fba07
commit
e5eabfe067
53
src/LyX.cpp
53
src/LyX.cpp
@ -56,7 +56,6 @@
|
|||||||
#include "support/filetools.h"
|
#include "support/filetools.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
#include "support/lyxlib.h"
|
#include "support/lyxlib.h"
|
||||||
#include "support/convert.h"
|
|
||||||
#include "support/ExceptionMessage.h"
|
#include "support/ExceptionMessage.h"
|
||||||
#include "support/os.h"
|
#include "support/os.h"
|
||||||
#include "support/Package.h"
|
#include "support/Package.h"
|
||||||
@ -712,58 +711,8 @@ LyXView * LyX::newLyXView()
|
|||||||
if (!lyx::use_gui)
|
if (!lyx::use_gui)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// FIXME: transfer all this geometry stuff to the frontend.
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
// FIXME: 0 means GuiView::NotMaximized by default!
|
|
||||||
int maximized = 0;
|
|
||||||
// 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().sessionInfo().load("WindowWidth");
|
|
||||||
if (!val.empty())
|
|
||||||
width = convert<unsigned int>(val);
|
|
||||||
val = session().sessionInfo().load("WindowHeight");
|
|
||||||
if (!val.empty())
|
|
||||||
height = convert<unsigned int>(val);
|
|
||||||
val = session().sessionInfo().load("WindowMaximized");
|
|
||||||
if (!val.empty())
|
|
||||||
maximized = convert<int>(val);
|
|
||||||
val = session().sessionInfo().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().sessionInfo().load("WindowPosX");
|
|
||||||
if (!val.empty())
|
|
||||||
posx = convert<int>(val);
|
|
||||||
val = session().sessionInfo().load("WindowPosY");
|
|
||||||
if (!val.empty())
|
|
||||||
posy = convert<int>(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!geometryArg.empty())
|
|
||||||
{
|
|
||||||
width = 0;
|
|
||||||
height = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// create the main window
|
// create the main window
|
||||||
LyXView * view = &pimpl_->application_->createView(width, height,
|
LyXView * view = &pimpl_->application_->createView(geometryArg);
|
||||||
posx, posy, maximized, iconSizeXY, geometryArg);
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -214,9 +214,7 @@ public:
|
|||||||
virtual void unregisterSocketCallback(int fd) = 0;
|
virtual void unregisterSocketCallback(int fd) = 0;
|
||||||
|
|
||||||
/// Create the main window with given geometry settings.
|
/// Create the main window with given geometry settings.
|
||||||
virtual LyXView & createView(unsigned int width, unsigned int height,
|
virtual LyXView & createView(std::string const & geometryArg) = 0;
|
||||||
int posx, int posy, int maximized,
|
|
||||||
unsigned int iconSizeXY, const std::string & geometryArg) = 0;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
LyXView const * currentView() const { return current_view_; }
|
LyXView const * currentView() const { return current_view_; }
|
||||||
|
@ -194,21 +194,14 @@ GuiApplication::~GuiApplication()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LyXView & GuiApplication::createView(unsigned int width,
|
LyXView & GuiApplication::createView(string const & geometryArg)
|
||||||
unsigned int height,
|
|
||||||
int posx, int posy,
|
|
||||||
int maximized,
|
|
||||||
unsigned int iconSizeXY,
|
|
||||||
const std::string & geometryArg)
|
|
||||||
{
|
{
|
||||||
int const id = gui_.createRegisteredView();
|
int const id = gui_.createRegisteredView();
|
||||||
GuiView & view = static_cast<GuiView &>(gui_.view(id));
|
GuiView & view = static_cast<GuiView &>(gui_.view(id));
|
||||||
theLyXFunc().setLyXView(&view);
|
theLyXFunc().setLyXView(&view);
|
||||||
|
|
||||||
view.init();
|
view.init();
|
||||||
view.setGeometry(width, height, posx, posy, GuiView::Maximized(maximized),
|
view.setGeometry(geometryArg);
|
||||||
iconSizeXY, geometryArg);
|
|
||||||
|
|
||||||
view.setFocus();
|
view.setFocus();
|
||||||
|
|
||||||
setCurrentView(view);
|
setCurrentView(view);
|
||||||
|
@ -70,10 +70,7 @@ public:
|
|||||||
virtual void updateColor(ColorCode col);
|
virtual void updateColor(ColorCode col);
|
||||||
virtual void registerSocketCallback(int fd, SocketCallback func);
|
virtual void registerSocketCallback(int fd, SocketCallback func);
|
||||||
void unregisterSocketCallback(int fd);
|
void unregisterSocketCallback(int fd);
|
||||||
/// Create the main window with given geometry settings.
|
LyXView & createView(std::string const & geometryArg);
|
||||||
LyXView & createView(unsigned int width, unsigned int height,
|
|
||||||
int posx, int posy, int maximized,
|
|
||||||
unsigned int iconSizeXY, const std::string & geometryArg);
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/// Methods inherited from \c QApplication class
|
/// Methods inherited from \c QApplication class
|
||||||
|
@ -494,13 +494,69 @@ void GuiView::saveGeometry()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiView::setGeometry(unsigned int width,
|
void GuiView::setGeometry(string const & geometryArg)
|
||||||
unsigned int height,
|
|
||||||
int posx, int posy,
|
|
||||||
GuiView::Maximized maximized,
|
|
||||||
unsigned int iconSizeXY,
|
|
||||||
const string & 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)
|
// use last value (not at startup)
|
||||||
if (d.lastIconSize != 0)
|
if (d.lastIconSize != 0)
|
||||||
setIconSize(d.lastIconSize);
|
setIconSize(d.lastIconSize);
|
||||||
|
@ -67,13 +67,7 @@ public:
|
|||||||
CompletelyMaximized
|
CompletelyMaximized
|
||||||
};
|
};
|
||||||
///
|
///
|
||||||
virtual void setGeometry(
|
virtual void setGeometry(std::string const & geometryArg);
|
||||||
unsigned int width,
|
|
||||||
unsigned int height,
|
|
||||||
int posx, int posy,
|
|
||||||
Maximized maximized,
|
|
||||||
unsigned int iconSizeXY,
|
|
||||||
const std::string & geometryArg);
|
|
||||||
/// save the geometry state in the session manager.
|
/// save the geometry state in the session manager.
|
||||||
virtual void saveGeometry();
|
virtual void saveGeometry();
|
||||||
virtual void setBusy(bool);
|
virtual void setBusy(bool);
|
||||||
|
Loading…
Reference in New Issue
Block a user