Properly reset windows geometry and state
This commit is contained in:
@@ -94,6 +94,8 @@ downloadDialog_forWait(NULL)
|
|||||||
this, SLOT(setActiveSubWindow(QWidget*)));
|
this, SLOT(setActiveSubWindow(QWidget*)));
|
||||||
|
|
||||||
MaxRecentFiles=MAX_RECENT;
|
MaxRecentFiles=MAX_RECENT;
|
||||||
|
QSettings settings("companion", "companion");
|
||||||
|
restoreGeometry(settings.value("mainWindowGeometry").toByteArray());
|
||||||
createActions();
|
createActions();
|
||||||
createMenus();
|
createMenus();
|
||||||
createToolBars();
|
createToolBars();
|
||||||
@@ -115,7 +117,6 @@ downloadDialog_forWait(NULL)
|
|||||||
|
|
||||||
// give time to the splash to disappear and main window to open before starting updates
|
// give time to the splash to disappear and main window to open before starting updates
|
||||||
int updateDelay = 1000;
|
int updateDelay = 1000;
|
||||||
QSettings settings("companion", "companion");
|
|
||||||
bool showSplash = settings.value("show_splash", true).toBool();
|
bool showSplash = settings.value("show_splash", true).toBool();
|
||||||
if (showSplash)
|
if (showSplash)
|
||||||
updateDelay += (SPLASH_TIME*1000);
|
updateDelay += (SPLASH_TIME*1000);
|
||||||
@@ -609,11 +610,13 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
|
|||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent *event)
|
void MainWindow::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
|
QSettings settings("companion", "companion");
|
||||||
|
settings.setValue("mainWindowGeometry", saveGeometry());
|
||||||
|
settings.setValue("mainWindowState", saveState());
|
||||||
mdiArea->closeAllSubWindows();
|
mdiArea->closeAllSubWindows();
|
||||||
if (mdiArea->currentSubWindow()) {
|
if (mdiArea->currentSubWindow()) {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
} else {
|
} else {
|
||||||
writeSettings();
|
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1876,6 +1879,7 @@ QMenu *MainWindow::createProfilesMenu()
|
|||||||
void MainWindow::createToolBars()
|
void MainWindow::createToolBars()
|
||||||
{
|
{
|
||||||
fileToolBar = addToolBar(tr("File"));
|
fileToolBar = addToolBar(tr("File"));
|
||||||
|
fileToolBar->setObjectName("File");
|
||||||
fileToolBar->addAction(newAct);
|
fileToolBar->addAction(newAct);
|
||||||
fileToolBar->addAction(openAct);
|
fileToolBar->addAction(openAct);
|
||||||
QToolButton * recentToolButton = new QToolButton;
|
QToolButton * recentToolButton = new QToolButton;
|
||||||
@@ -1913,6 +1917,7 @@ void MainWindow::createToolBars()
|
|||||||
fileToolBar->addAction(compareAct);
|
fileToolBar->addAction(compareAct);
|
||||||
|
|
||||||
editToolBar = addToolBar(tr("Edit"));
|
editToolBar = addToolBar(tr("Edit"));
|
||||||
|
editToolBar->setObjectName("Edit");
|
||||||
editToolBar->addAction(cutAct);
|
editToolBar->addAction(cutAct);
|
||||||
editToolBar->addAction(copyAct);
|
editToolBar->addAction(copyAct);
|
||||||
editToolBar->addAction(pasteAct);
|
editToolBar->addAction(pasteAct);
|
||||||
@@ -1920,6 +1925,7 @@ void MainWindow::createToolBars()
|
|||||||
|
|
||||||
burnToolBar = new QToolBar(tr("Write"));
|
burnToolBar = new QToolBar(tr("Write"));
|
||||||
addToolBar( Qt::LeftToolBarArea, burnToolBar );
|
addToolBar( Qt::LeftToolBarArea, burnToolBar );
|
||||||
|
burnToolBar->setObjectName("Write");
|
||||||
burnToolBar->addAction(burnToAct);
|
burnToolBar->addAction(burnToAct);
|
||||||
burnToolBar->addAction(burnFromAct);
|
burnToolBar->addAction(burnFromAct);
|
||||||
burnToolBar->addSeparator();
|
burnToolBar->addSeparator();
|
||||||
@@ -1932,6 +1938,7 @@ void MainWindow::createToolBars()
|
|||||||
burnToolBar->addAction(burnConfigAct);
|
burnToolBar->addAction(burnConfigAct);
|
||||||
|
|
||||||
helpToolBar = addToolBar(tr("Help"));
|
helpToolBar = addToolBar(tr("Help"));
|
||||||
|
helpToolBar->setObjectName("Help");
|
||||||
helpToolBar->addAction(checkForUpdatesAct);
|
helpToolBar->addAction(checkForUpdatesAct);
|
||||||
helpToolBar->addAction(aboutAct);
|
helpToolBar->addAction(aboutAct);
|
||||||
}
|
}
|
||||||
@@ -1944,10 +1951,7 @@ void MainWindow::createStatusBar()
|
|||||||
void MainWindow::readSettings()
|
void MainWindow::readSettings()
|
||||||
{
|
{
|
||||||
QSettings settings("companion", "companion");
|
QSettings settings("companion", "companion");
|
||||||
bool maximized = settings.value("maximized", false).toBool();
|
restoreState(settings.value("mainWindowState").toByteArray());
|
||||||
QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
|
|
||||||
QSize size = settings.value("size", QSize(400, 400)).toSize();
|
|
||||||
|
|
||||||
checkCompanion9x = settings.value("startup_check_companion9x", true).toBool();
|
checkCompanion9x = settings.value("startup_check_companion9x", true).toBool();
|
||||||
checkFW = settings.value("startup_check_fw", true).toBool();
|
checkFW = settings.value("startup_check_fw", true).toBool();
|
||||||
MaxRecentFiles =settings.value("history_size",10).toInt();
|
MaxRecentFiles =settings.value("history_size",10).toInt();
|
||||||
@@ -1960,23 +1964,6 @@ void MainWindow::readSettings()
|
|||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
if (maximized) {
|
|
||||||
setWindowState(Qt::WindowMaximized);
|
|
||||||
} else {
|
|
||||||
move(pos);
|
|
||||||
resize(size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::writeSettings()
|
|
||||||
{
|
|
||||||
QSettings settings("companion", "companion");
|
|
||||||
|
|
||||||
settings.setValue("maximized", isMaximized());
|
|
||||||
if(!isMaximized()) {
|
|
||||||
settings.setValue("pos", pos());
|
|
||||||
settings.setValue("size", size());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MdiChild *MainWindow::activeMdiChild()
|
MdiChild *MainWindow::activeMdiChild()
|
||||||
|
|||||||
@@ -134,7 +134,6 @@ private:
|
|||||||
void createToolBars();
|
void createToolBars();
|
||||||
void createStatusBar();
|
void createStatusBar();
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void writeSettings();
|
|
||||||
void updateRecentFileActions();
|
void updateRecentFileActions();
|
||||||
void updateProfilesActions();
|
void updateProfilesActions();
|
||||||
int getFileType(const QString &fullFileName);
|
int getFileType(const QString &fullFileName);
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ ModelEdit::ModelEdit(RadioData & radioData, int modelId, bool openWizard, bool i
|
|||||||
generalSettings(generalSettings)
|
generalSettings(generalSettings)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
QSettings settings("companion", "companion");
|
||||||
|
restoreGeometry(settings.value("modelEditGeometry").toByteArray());
|
||||||
addTab(new Setup(this, model), tr("Setup"));
|
addTab(new Setup(this, model), tr("Setup"));
|
||||||
addTab(new HeliPanel(this, model), tr("Heli"));
|
addTab(new HeliPanel(this, model), tr("Heli"));
|
||||||
addTab(new FlightModes(this, model, radioData.generalSettings), tr("Flight Modes"));
|
addTab(new FlightModes(this, model, radioData.generalSettings), tr("Flight Modes"));
|
||||||
@@ -40,6 +42,12 @@ ModelEdit::~ModelEdit()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModelEdit::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
QSettings settings("companion", "companion");
|
||||||
|
settings.setValue("modelEditGeometry", saveGeometry());
|
||||||
|
}
|
||||||
|
|
||||||
class VerticalScrollArea : public QScrollArea
|
class VerticalScrollArea : public QScrollArea
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ class ModelEdit : public QDialog
|
|||||||
public:
|
public:
|
||||||
explicit ModelEdit(RadioData & radioData, int modelId , bool openWizard =false, bool inNew =false, QWidget *parent = 0);
|
explicit ModelEdit(RadioData & radioData, int modelId , bool openWizard =false, bool inNew =false, QWidget *parent = 0);
|
||||||
~ModelEdit();
|
~ModelEdit();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void modified();
|
void modified();
|
||||||
|
|||||||
Reference in New Issue
Block a user