1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

LP-245 config: save/restore last selected panel

This commit is contained in:
Philippe Renon 2016-09-16 08:53:45 +02:00 committed by Philippe Renon
parent 5b2fe8b350
commit 841468519e
4 changed files with 34 additions and 4 deletions

View File

@ -25,8 +25,11 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "configgadget.h"
#include "configgadgetwidget.h"
#include "../uavobjectwidgetutils/configtaskwidget.h"
ConfigGadget::ConfigGadget(QString classId, ConfigGadgetWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent), m_widget(widget)
{}
@ -40,3 +43,13 @@ void ConfigGadget::loadConfiguration(IUAVGadgetConfiguration *config)
{
Q_UNUSED(config);
}
void ConfigGadget::saveState(QSettings *settings)
{
m_widget->saveState(settings);
}
void ConfigGadget::restoreState(QSettings *settings)
{
m_widget->restoreState(settings);
}

View File

@ -28,14 +28,10 @@
#define CONFIGGADGET_H
#include <coreplugin/iuavgadget.h>
#include "../uavobjectwidgetutils/configtaskwidget.h"
class IUAVGadget;
// class QList<int>;
class QWidget;
class QString;
class ConfigGadgetWidget;
class Ui_ConfigGadget;
using namespace Core;
@ -49,8 +45,12 @@ public:
{
return (QWidget *)m_widget;
}
void loadConfiguration(IUAVGadgetConfiguration *config);
void saveState(QSettings *settings);
void restoreState(QSettings *settings);
private:
ConfigGadgetWidget *m_widget;
};

View File

@ -53,6 +53,7 @@
#include <QWidget>
#include <QVBoxLayout>
#include <QMessageBox>
#include <QSettings>
#include <QDebug>
#define OPLINK_TIMEOUT 2000
@ -171,6 +172,18 @@ void ConfigGadgetWidget::startInputWizard()
inputWidget->startInputWizard();
}
void ConfigGadgetWidget::saveState(QSettings *settings)
{
settings->setValue("currentIndex", stackWidget->currentIndex());
}
void ConfigGadgetWidget::restoreState(QSettings *settings)
{
int index = settings->value("currentIndex", 0).toInt();
stackWidget->setCurrentIndex(index);
}
void ConfigGadgetWidget::resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event);

View File

@ -31,6 +31,7 @@
#include <QWidget>
class QTextBrowser;
class QSettings;
class MyTabbedStackWidget;
class ConfigGadgetWidget : public QWidget {
@ -44,6 +45,9 @@ public:
void startInputWizard();
void saveState(QSettings *settings);
void restoreState(QSettings *settings);
protected:
void resizeEvent(QResizeEvent *event);