Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

Commit 2f480ac5 authored by Frédéric Larue's avatar Frédéric Larue
Browse files

Mechanism to save/restore the current UI state modified.

parent 9ef93dbe
......@@ -51,103 +51,22 @@ UIMainWindow::~UIMainWindow()
bool UIMainWindow::saveUISettings() const
{
std::ofstream file;
file.open( "ui_settings.xml", std::ios_base::out | std::ios_base::trunc );
if( !file.good() )
return false;
file << "<UISETTINGS>" << std::endl;
QRect g = normalGeometry();
file << " <MAINWINDOW "
<< "Maximized=\"" << std::boolalpha << isMaximized() << "\" "
<< "X=\"" << g.x() << "\" "
<< "Y=\"" << g.y() << "\" "
<< "W=\"" << g.width() << "\" "
<< "H=\"" << g.height() << "\""
<< "/>" << std::endl;
g = ui->dockProjectManager->geometry();
file << " <DOCK Name=\"" << ui->dockProjectManager->windowTitle().toStdString() << "\" "
<< "Floating=\"" << std::boolalpha << ui->dockProjectManager->isFloating() << "\" "
<< "X=\"" << g.x() << "\" "
<< "Y=\"" << g.y() << "\" "
<< "W=\"" << g.width() << "\" "
<< "H=\"" << g.height() << "\""
<< "/>" << std::endl;
g = ui->dockTools->geometry();
file << " <DOCK Name=\"" << ui->dockTools->windowTitle().toStdString() << "\" "
<< "Floating=\"" << std::boolalpha << ui->dockTools->isFloating() << "\" "
<< "X=\"" << g.x() << "\" "
<< "Y=\"" << g.y() << "\" "
<< "W=\"" << g.width() << "\" "
<< "H=\"" << g.height() << "\""
<< "/>" << std::endl;
for( auto r : m_RecentProjects )
file << " <RECENT Path=\"" << r->text().toStdString() << "\"/>" << std::endl;
file << "</UISETTINGS>" << std::endl;
return file.good();
QSettings settings( QSettings::IniFormat, QSettings::UserScope, "ExRealis", "Settings" );
settings.setValue( "geometry", saveGeometry() );
settings.setValue( "windowState", saveState() );
return true;
}
bool UIMainWindow::loadUISettings()
{
QFile xmlFile( "ui_settings.xml" );
if( !xmlFile.open( QIODevice::ReadOnly ) )
return false;
QSettings settings( QSettings::IniFormat, QSettings::UserScope, "ExRealis", "Settings" );
QXmlStreamReader xmlParser( &xmlFile );
while( xmlParser.readNext() != QXmlStreamReader::StartElement );
if( xmlParser.name() != "UISETTINGS" )
if( settings.value("geometry").toByteArray().isEmpty() || settings.value("windowState").toByteArray().isEmpty() )
return false;
int recentCount = 0;
QStringList recent;
do
{
if( xmlParser.readNext() == QXmlStreamReader::StartElement )
{
QXmlStreamAttributes attrib = xmlParser.attributes();
if( xmlParser.name() == "MAINWINDOW" )
{
setGeometry(
attrib.value("X").toInt(),
attrib.value("Y").toInt(),
attrib.value("W").toInt(),
attrib.value("H").toInt()
);
if( attrib.value("Maximized") == "true" )
setWindowState( windowState() | Qt::WindowMaximized );
}
else if( xmlParser.name() == "DOCK" )
{
QDockWidget *dock = (attrib.value("Name")==ui->dockTools->windowTitle())? ui->dockTools : ui->dockProjectManager;
dock->setFloating( attrib.value("Floating") == "true" );
dock->setGeometry(
attrib.value("X").toInt(),
attrib.value("Y").toInt(),
attrib.value("W").toInt(),
attrib.value("H").toInt()
);
}
else if( xmlParser.name() == "RECENT" )
{
recent.push_front( attrib.value("Path").toString() );
}
}
} while( !xmlParser.atEnd() );
for( auto r : recent )
updateRecentListEntry( r );
restoreGeometry( settings.value("geometry").toByteArray() );
restoreState( settings.value("windowState").toByteArray() );
return true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment