1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

GCS/core+plugins: Changes to options pages to make them more uniform.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@695 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
ephy 2010-06-01 08:07:53 +00:00 committed by ephy
parent a2beb49257
commit 4a974de1b5
32 changed files with 1024 additions and 964 deletions

View File

@ -196,7 +196,7 @@ void QxtBasicSTDLoggerEngine::writeToStdErr(const QString &level, const QList<QV
if (!out.isNull())
{
if (count != 0) *errstream << padding;
*errstream << out.toString() << '\n';
*errstream << out.toString();// << '\n';
}
count++;
}
@ -228,7 +228,7 @@ void QxtBasicSTDLoggerEngine::writeToStdOut(const QString& level, const QList<QV
if (!out.isNull())
{
if (count != 0) *outstream << padding;
*outstream << out.toString() << '\n';
*outstream << out.toString();// << '\n';
}
count++;
}

View File

@ -29,7 +29,7 @@
namespace qmapcontrol
{
GoogleSatMapAdapter::GoogleSatMapAdapter()
: TileMapAdapter("khm.google.com", "/kh?v=51&x=%2&s=&y=%3&z=%1", 256, 0, 17)
: TileMapAdapter("khm.google.com", "/kh?v=58&x=%2&s=&y=%3&z=%1", 256, 0, 17)
{
}

View File

@ -110,7 +110,7 @@ PathChooser::PathChooser(QWidget *parent) :
connect(m_d->m_lineEdit, SIGNAL(validChanged(bool)), this, SIGNAL(validChanged(bool)));
connect(m_d->m_lineEdit, SIGNAL(editingFinished()), this, SIGNAL(editingFinished()));
m_d->m_lineEdit->setMinimumWidth(200);
m_d->m_lineEdit->setMinimumWidth(50);
m_d->m_hLayout->addWidget(m_d->m_lineEdit);
m_d->m_hLayout->setSizeConstraint(QLayout::SetMinimumSize);

View File

@ -53,7 +53,10 @@ using namespace Core::Internal;
SettingsDialog::SettingsDialog(QWidget *parent, const QString &categoryId,
const QString &pageId)
: QDialog(parent), m_applied(false)
: QDialog(parent),
m_applied(false),
m_windowWidth(0),
m_windowHeight(0)
{
setupUi(this);
#ifdef Q_OS_MAC
@ -67,7 +70,11 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &categoryId,
QSettings *settings = ICore::instance()->settings();
initialCategory = settings->value("General/LastPreferenceCategory", QVariant(QString())).toString();
initialPage = settings->value("General/LastPreferencePage", QVariant(QString())).toString();
m_windowWidth = settings->value("General/SettingsWindowWidth", 0).toInt();
m_windowHeight = settings->value("General/SettingsWindowHeight", 0).toInt();
}
if (m_windowWidth > 0 && m_windowHeight > 0)
resize(m_windowWidth, m_windowHeight);
buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));
@ -77,6 +84,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &categoryId,
connect(this, SIGNAL(settingsDialogShown(Core::Internal::SettingsDialog*)), m_instanceManager, SLOT(settingsDialogShown(Core::Internal::SettingsDialog*)));
connect(this, SIGNAL(settingsDialogRemoved()), m_instanceManager, SLOT(settingsDialogRemoved()));
splitter->setCollapsible(0, false);
splitter->setCollapsible(1, false);
pageTree->header()->setVisible(false);
@ -250,5 +258,7 @@ void SettingsDialog::done(int val)
QSettings *settings = ICore::instance()->settings();
settings->setValue("General/LastPreferenceCategory", m_currentCategory);
settings->setValue("General/LastPreferencePage", m_currentPage);
settings->setValue("General/SettingsWindowWidth", this->width());
settings->setValue("General/SettingsWindowHeight", this->height());
QDialog::done(val);
}

View File

@ -78,6 +78,8 @@ private:
bool m_applied;
QString m_currentCategory;
QString m_currentPage;
int m_windowWidth;
int m_windowHeight;
};
} // namespace Internal

View File

@ -162,6 +162,12 @@ void FancyTabBar::leaveEvent(QEvent *e)
}
}
void FancyTabBar::updateTabNameIcon(int index, const QIcon &icon, const QString &label)
{
m_tabs[index].icon = icon;
m_tabs[index].text = label;
}
QSize FancyTabBar::sizeHint() const
{
QSize sh = tabSizeHint();
@ -359,6 +365,13 @@ void FancyTabWidget::removeTab(int index)
m_tabBar->removeTab(index);
}
void FancyTabWidget::updateTabNameIcon(int index, const QIcon &icon, const QString &label)
{
m_tabBar->updateTabNameIcon(index, icon, label);
m_tabBar->repaint();
}
void FancyTabWidget::setBackgroundBrush(const QBrush &brush)
{
QPalette pal = m_tabBar->palette();

View File

@ -78,6 +78,7 @@ public:
void removeTab(int index) {
m_tabs.removeAt(index);
}
void updateTabNameIcon(int index, const QIcon &icon, const QString &label);
void setCurrentIndex(int index);
int currentIndex() const { return m_currentIndex; }
@ -123,6 +124,7 @@ public:
void insertCornerWidget(int pos, QWidget *widget);
int cornerWidgetCount() const;
void setTabToolTip(int index, const QString &toolTip);
void updateTabNameIcon(int index, const QIcon &icon, const QString &label);
void paintEvent(QPaintEvent *event);

View File

@ -16,187 +16,183 @@
<property name="title">
<string>General settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="colorLabel">
<property name="text">
<string>User &amp;interface color:</string>
</property>
<property name="buddy">
<cstring>colorButton</cstring>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Utils::QtColorButton" name="colorButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
<property name="alphaAllowed">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="resetButton">
<property name="toolTip">
<string>Reset to default</string>
</property>
<property name="text">
<string>R</string>
</property>
<property name="icon">
<iconset resource="core.qrc">
<normaloff>:/core/images/reset.png</normaloff>:/core/images/reset.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="terminalLabel">
<property name="text">
<string>Terminal:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="terminalLabel">
<property name="text">
<string>Terminal:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="terminalEdit"/>
</item>
<item>
<widget class="QToolButton" name="resetTerminalButton">
<property name="toolTip">
<string>Reset to default</string>
</property>
<property name="text">
<string>R</string>
</property>
<property name="icon">
<iconset resource="core.qrc">
<normaloff>:/core/images/reset.png</normaloff>:/core/images/reset.png</iconset>
</property>
</widget>
</item>
</layout>
<item row="7" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>External editor:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>External editor:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="externalEditorEdit"/>
</item>
<item>
<widget class="QToolButton" name="resetEditorButton">
<property name="toolTip">
<string>Reset to default</string>
</property>
<property name="text">
<string>R</string>
</property>
<property name="icon">
<iconset resource="core.qrc">
<normaloff>:/core/images/reset.png</normaloff>:/core/images/reset.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="helpExternalEditorButton">
<property name="text">
<string>?</string>
</property>
</widget>
</item>
</layout>
<item row="9" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>When files are externally modified:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>When files are externally modified:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="reloadBehavior">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>Always ask</string>
<item row="1" column="1">
<widget class="QLineEdit" name="terminalEdit"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="colorLabel">
<property name="text">
<string>User interface color:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="resetTerminalButton">
<property name="toolTip">
<string>Reset to default</string>
</property>
<property name="text">
<string>R</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/core/images/reset.png</normaloff>:/core/images/reset.png</iconset>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="externalEditorEdit"/>
</item>
<item row="7" column="2">
<widget class="QToolButton" name="resetEditorButton">
<property name="toolTip">
<string>Reset to default</string>
</property>
<property name="text">
<string>R</string>
</property>
<property name="icon">
<iconset>
<normaloff>:/core/images/reset.png</normaloff>:/core/images/reset.png</iconset>
</property>
</widget>
</item>
<item row="7" column="3">
<widget class="QToolButton" name="helpExternalEditorButton">
<property name="text">
<string>?</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="QToolButton" name="resetButton">
<property name="toolTip">
<string>Reset to default</string>
</property>
</item>
<item>
<property name="text">
<string>Reload all modified files</string>
<string>R</string>
</property>
</item>
<item>
<property name="text">
<string>Ignore modifications</string>
<property name="icon">
<iconset>
<normaloff>:/core/images/reset.png</normaloff>:/core/images/reset.png</iconset>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="Utils::QtColorButton" name="colorButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
<property name="alphaAllowed" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="9" column="1">
<widget class="QWidget" name="widget_2" native="true">
<layout class="QGridLayout" name="gridLayout_3">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QComboBox" name="reloadBehavior">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>Always ask</string>
</property>
</item>
<item>
<property name="text">
<string>Reload all modified files</string>
</property>
</item>
<item>
<property name="text">
<string>Ignore modifications</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>132</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
@ -220,11 +216,9 @@
<customwidget>
<class>Utils::QtColorButton</class>
<extends>QToolButton</extends>
<header location="global">utils/qtcolorbutton.h</header>
<header>utils/qtcolorbutton.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="core.qrc"/>
</resources>
<resources/>
<connections/>
</ui>

View File

@ -175,6 +175,14 @@ void ModeManager::updateModeToolTip()
}
}
void ModeManager::updateModeNameIcon(IMode *mode, const QIcon &icon, const QString &label)
{
int index = indexOf(mode->uniqueModeName());
if (index < 0)
return;
m_modeStack->updateTabNameIcon(index, icon, label);
}
void ModeManager::aboutToRemoveObject(QObject *obj)
{
IMode *mode = Aggregation::query<IMode>(obj);

View File

@ -39,6 +39,7 @@
QT_BEGIN_NAMESPACE
class QSignalMapper;
class QMenu;
class QIcon;
QT_END_NAMESPACE
namespace Core {
@ -67,6 +68,7 @@ public:
void addAction(Command *command, int priority, QMenu *menu = 0);
void addWidget(QWidget *widget);
void updateModeNameIcon(IMode *mode, const QIcon &icon, const QString &label);
signals:
void currentModeAboutToChange(Core::IMode *mode);

View File

@ -87,11 +87,21 @@ QString UAVGadgetMode::name() const
return m_name;
}
void UAVGadgetMode::setName(QString name)
{
m_name = name;
}
QIcon UAVGadgetMode::icon() const
{
return m_icon;
}
void UAVGadgetMode::setIcon(QIcon icon)
{
m_icon = icon;
}
int UAVGadgetMode::priority() const
{
return m_priority;

View File

@ -63,6 +63,8 @@ public:
const char* uniqueModeName() const;
QList<int> context() const;
UAVGadgetManager* uavGadgetManager() const { return m_uavGadgetManager; }
void setName(QString name);
void setIcon(QIcon icon);
private slots:
void grabUAVGadgetManager(Core::IMode *mode);

View File

@ -57,22 +57,6 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Maximum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="deleteButton">
<property name="sizePolicy">

View File

@ -27,6 +27,8 @@
#include "workspacesettings.h"
#include <coreplugin/icore.h>
#include <coreplugin/modemanager.h>
#include <coreplugin/uavgadgetmode.h>
#include <QtCore/QSettings>
#include "ui_workspacesettings.h"
@ -73,7 +75,10 @@ QWidget *WorkspaceSettings::createPage(QWidget *parent)
m_page = new Ui::WorkspaceSettings();
QWidget *w = new QWidget(parent);
m_page->setupUi(w);
// Read workspaces from settings
m_page->numberOfWorkspacesSpinBox->setMaximum(MAX_WORKSPACES);
m_modeManager = Core::ICore::instance()->modeManager();
m_settings = Core::ICore::instance()->settings();
m_settings->beginGroup(QLatin1String("Workspace"));
const int numberOfWorkspaces = m_settings->value(QLatin1String("NumberOfWorkspaces"), 2).toInt();
@ -89,26 +94,26 @@ QWidget *WorkspaceSettings::createPage(QWidget *parent)
if (i <= numberOfWorkspaces)
m_page->workspaceComboBox->addItem(QIcon(iconName), name);
}
m_page->iconPathChooser->setExpectedKind(Utils::PathChooser::File);
m_page->iconPathChooser->setPromptDialogFilter(tr("Images (*.png *.jpg *.bmp *.xpm)"));
m_page->iconPathChooser->setPromptDialogTitle(tr("Choose icon"));
m_settings->endGroup();
connect(m_page->workspaceComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectWorkspace(int)));
connect(m_page->numberOfWorkspacesSpinBox, SIGNAL(valueChanged(int)), this, SLOT(numberOfWorkspacesChanged(int)));
connect(m_page->nameEdit, SIGNAL(textEdited(QString)), this, SLOT(textEdited(QString)));
connect(m_page->iconPathChooser, SIGNAL(browsingFinished()), this, SLOT(iconChanged()));
m_currentIndex = 0;
QString iconName = m_iconNames.at(m_currentIndex);
m_page->iconEdit->setText(iconName);
m_page->iconLabel->setPixmap(QIcon(iconName).pixmap(16, 16));
m_page->nameEdit->setText(m_names.at(m_currentIndex));
selectWorkspace(m_currentIndex);
return w;
}
void WorkspaceSettings::apply()
{
m_iconNames.replace(m_currentIndex, m_page->iconEdit->text());
m_names.replace(m_currentIndex, m_page->nameEdit->text());
selectWorkspace(m_currentIndex, true);
m_settings->beginGroup(QLatin1String("Workspace"));
m_settings->setValue(QLatin1String("NumberOfWorkspaces"), m_page->numberOfWorkspacesSpinBox->value());
@ -118,6 +123,11 @@ void WorkspaceSettings::apply()
QString defaultIconName = "Icon" + numberString;
m_settings->setValue(defaultName, m_names.at(i-1));
m_settings->setValue(defaultIconName, m_iconNames.at(i-1));
QString modeName = "Mode" + numberString;
Core::Internal::UAVGadgetMode *mode = qobject_cast<Core::Internal::UAVGadgetMode*>(m_modeManager->mode(modeName));
if (mode) {
m_modeManager->updateModeNameIcon(mode, QIcon(m_iconNames.at(i-1)), m_names.at(i-1));
}
}
m_settings->endGroup();
@ -133,6 +143,12 @@ void WorkspaceSettings::textEdited(QString name)
m_page->workspaceComboBox->setItemText(m_currentIndex, m_page->nameEdit->text());
}
void WorkspaceSettings::iconChanged()
{
QString iconName = m_page->iconPathChooser->path();
m_page->workspaceComboBox->setItemIcon(m_currentIndex, QIcon(iconName));
}
void WorkspaceSettings::numberOfWorkspacesChanged(int value)
{
int count = m_page->workspaceComboBox->count();
@ -147,18 +163,19 @@ void WorkspaceSettings::numberOfWorkspacesChanged(int value)
}
}
void WorkspaceSettings::selectWorkspace(int index)
void WorkspaceSettings::selectWorkspace(int index, bool store)
{
// write old values of workspace not shown anymore
m_iconNames.replace(m_currentIndex, m_page->iconEdit->text());
m_names.replace(m_currentIndex, m_page->nameEdit->text());
m_page->workspaceComboBox->setItemIcon(m_currentIndex, QIcon(m_page->iconEdit->text()));
m_page->workspaceComboBox->setItemText(m_currentIndex, m_page->nameEdit->text());
if (store || (index != m_currentIndex)) {
// write old values of workspace not shown anymore
m_iconNames.replace(m_currentIndex, m_page->iconPathChooser->path());
m_names.replace(m_currentIndex, m_page->nameEdit->text());
m_page->workspaceComboBox->setItemIcon(m_currentIndex, QIcon(m_page->iconPathChooser->path()));
m_page->workspaceComboBox->setItemText(m_currentIndex, m_page->nameEdit->text());
}
// display current workspace
// display current workspace
QString iconName = m_iconNames.at(index);
m_page->iconEdit->setText(iconName);
m_page->iconLabel->setPixmap(QIcon(iconName).pixmap(16, 16));
m_page->iconPathChooser->setPath(iconName);
m_page->nameEdit->setText(m_names.at(index));
m_currentIndex = index;
}

View File

@ -36,6 +36,8 @@ class QSettings;
namespace Core {
class ModeManager;
namespace Internal {
namespace Ui {
@ -62,12 +64,14 @@ public:
signals:
public slots:
void selectWorkspace(int index);
void selectWorkspace(int index, bool store = false);
void numberOfWorkspacesChanged(int value);
void textEdited(QString string);
void iconChanged();
private:
Ui::WorkspaceSettings *m_page;
QSettings *m_settings;
ModeManager *m_modeManager;
QStringList m_iconNames;
QStringList m_names;
int m_currentIndex;

View File

@ -7,11 +7,11 @@
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<height>320</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -19,182 +19,166 @@
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>371</width>
<height>101</height>
</rect>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Workspaces</string>
</property>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>331</width>
<height>31</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Number of workspaces:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="numberOfWorkspacesSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="value">
<number>2</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_2">
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<width>331</width>
<height>31</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QComboBox" name="workspaceComboBox"/>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<zorder>horizontalLayoutWidget</zorder>
<zorder>horizontalLayoutWidget_2</zorder>
<zorder>horizontalLayoutWidget_3</zorder>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>10</x>
<y>120</y>
<width>371</width>
<height>111</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Details</string>
</property>
<widget class="QWidget" name="horizontalLayoutWidget_3">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>331</width>
<height>31</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Icon:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="iconEdit"/>
</item>
<item>
<widget class="QLabel" name="iconLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="chooseIconButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Choose</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_4">
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<width>331</width>
<height>41</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="nameEdit"/>
</item>
</layout>
</widget>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>20</x>
<y>240</y>
<width>311</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>&lt;b&gt;Note:&lt;/b&gt; A restart is needed for changes to take effect.</string>
</property>
</widget>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Workspaces</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Number of workspaces:</string>
</property>
</widget>
</item>
<item row="0" column="4">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Change details of workspace:</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="workspaceComboBox"/>
</item>
<item row="0" column="2">
<widget class="QSpinBox" name="numberOfWorkspacesSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="value">
<number>2</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Details</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Icon:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Utils::PathChooser" name="iconPathChooser" native="true"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="nameEdit"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="1">
<widget class="QLabel" name="label_4">
<property name="toolTip">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Note:&lt;/span&gt; A restart is needed for changes to number of workspaces to take effect.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Note:&lt;/span&gt; A restart is needed for changes to number of workspaces to take effect.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Utils::PathChooser</class>
<extends>QWidget</extends>
<header>utils/pathchooser.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -45,52 +45,29 @@ QWidget *HITLOptionsPage::createPage(QWidget *parent)
m_optionsPage = new Ui::HITLOptionsPage();
QWidget* optionsPageWidget = new QWidget;
m_optionsPage->setupUi(optionsPageWidget);
connect(m_optionsPage->loadFileBin, SIGNAL(clicked()), this, SLOT(onLoadFileBinClicked()));
connect(m_optionsPage->loadFileData, SIGNAL(clicked()), this, SLOT(onLoadFileDataClicked()));
m_optionsPage->executablePathChooser->setExpectedKind(Utils::PathChooser::File);
m_optionsPage->executablePathChooser->setPromptDialogTitle(tr("Choose FlightGear executable"));
m_optionsPage->dataDirectoryPathChooser->setExpectedKind(Utils::PathChooser::Directory);
m_optionsPage->dataDirectoryPathChooser->setPromptDialogTitle(tr("Choose FlightGear data directory"));
// Restore the contents from the settings:
m_optionsPage->fgPathBin->setText(m_config->fgPathBin());
m_optionsPage->fgPathData->setText(m_config->fgPathData());
m_optionsPage->executablePathChooser->setPath(m_config->fgPathBin());
m_optionsPage->dataDirectoryPathChooser->setPath(m_config->fgPathData());
m_optionsPage->fgManualControl->setChecked(m_config->fgManualControl());
return optionsPageWidget;
}
void HITLOptionsPage::apply()
{
m_config->setFGPathBin( m_optionsPage->fgPathBin->text());
m_config->setFGPathData( m_optionsPage->fgPathData->text());
m_config->setFGPathBin( m_optionsPage->executablePathChooser->path());
m_config->setFGPathData( m_optionsPage->dataDirectoryPathChooser->path());
m_config->setFGManualControl( m_optionsPage->fgManualControl->isChecked());
}
void HITLOptionsPage::finish()
{
disconnect(this);
delete m_optionsPage;
}
void HITLOptionsPage::onLoadFileBinClicked()
{
QFileDialog::Options options;
QString selectedFilter;
QString fileName = QFileDialog::getOpenFileName(qobject_cast<QWidget*>(this),
tr("QFileDialog::getOpenFileName()"),
m_optionsPage->fgPathBin->text(),
tr("All Files (*)"),
&selectedFilter,
options);
if (!fileName.isEmpty()) m_optionsPage->fgPathBin->setText(fileName);
}
void HITLOptionsPage::onLoadFileDataClicked()
{
QFileDialog::Options options;
QString selectedFilter;
QString fileName = QFileDialog::getExistingDirectory(qobject_cast<QWidget*>(this),
tr("Open Directory"),
m_optionsPage->fgPathData->text(),
QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks);
if (!fileName.isEmpty()) m_optionsPage->fgPathData->setText(fileName);
}

View File

@ -1,162 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>HITLOptionsPage</class>
<widget class="QWidget" name="HITLOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>675</width>
<height>300</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>-1</x>
<y>-1</y>
<width>481</width>
<height>339</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0">
<property name="spacing">
<number>10</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>FlightGear Executable</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fgPathBin">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="loadFileBin">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>FlightGear Data Directory</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fgPathData"/>
</item>
<item>
<widget class="QPushButton" name="loadFileData">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item>
<widget class="QCheckBox" name="fgManualControl">
<property name="text">
<string>Manual aircraft control (can be used when hardware is not available)</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>HITLOptionsPage</class>
<widget class="QWidget" name="HITLOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>320</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>FlightGear executable:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>FlightGear data directory:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Utils::PathChooser" name="executablePathChooser" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Utils::PathChooser" name="dataDirectoryPathChooser" native="true"/>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="fgManualControl">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Manual aircraft control (can be used when hardware is not available)</string>
</property>
<property name="text">
<string>Manual aircraft control (can be used when hardware is not available)</string>
</property>
</widget>
</item>
<item row="4" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>182</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Utils::PathChooser</class>
<extends>QWidget</extends>
<header>utils/pathchooser.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -17,3 +17,4 @@ SOURCES += mapplugin.cpp \
mapgadgetwidget.cpp \
mapgadgetoptionspage.cpp
OTHER_FILES += MapGadget.pluginspec
FORMS += mapgadgetoptionspage.ui

View File

@ -34,6 +34,8 @@
#include <QtGui/QHBoxLayout>
#include <QtGui/QVBoxLayout>
#include "ui_mapgadgetoptionspage.h"
MapGadgetOptionsPage::MapGadgetOptionsPage(MapGadgetConfiguration *config, QObject *parent) :
IOptionsPage(parent),
@ -43,80 +45,30 @@ MapGadgetOptionsPage::MapGadgetOptionsPage(MapGadgetConfiguration *config, QObje
QWidget *MapGadgetOptionsPage::createPage(QWidget *parent)
{
QWidget *widget = new QWidget;
QVBoxLayout *vl = new QVBoxLayout();
widget->setLayout(vl);
m_page = new Ui::MapGadgetOptionsPage();
QWidget *w = new QWidget(parent);
m_page->setupUi(w);
QHBoxLayout *providerLayout = new QHBoxLayout();
QWidget *mp = new QWidget;
mp->setLayout(providerLayout);
QWidget *label = new QLabel("Map Provider:");
m_providerComboBox = new QComboBox();
m_providerComboBox->addItem("OpenStreetMap");
m_providerComboBox->addItem("Google");
m_providerComboBox->addItem("Google Sat");
// m_providerComboBox->addItem("Yahoo");
providerLayout->addWidget(label);
providerLayout->addWidget(m_providerComboBox);
QHBoxLayout *zoomLayout = new QHBoxLayout();
QWidget *x = new QWidget;
x->setLayout(zoomLayout);
label = new QLabel("Default zoom:");
m_zoomSpin = new QSpinBox();
m_zoomSpin->setMaximum(18);
zoomLayout->addWidget(label);
zoomLayout->addWidget(m_zoomSpin);
QHBoxLayout *latLayout = new QHBoxLayout();
QWidget *y = new QWidget;
y->setLayout(latLayout);
label = new QLabel("Default latitude:");
m_latSpin = new QDoubleSpinBox();
m_latSpin->setDecimals(8);
m_latSpin->setMinimum(-90);
m_latSpin->setMaximum(90);
latLayout->addWidget(label);
latLayout->addWidget(m_latSpin);
QHBoxLayout *longLayout = new QHBoxLayout();
QWidget *z = new QWidget;
z->setLayout(longLayout);
label = new QLabel("Default longitude:");
m_longSpin = new QDoubleSpinBox();
m_longSpin->setDecimals(8);
m_longSpin->setMinimum(-180);
m_longSpin->setMaximum(180);
longLayout->addWidget(label);
longLayout->addWidget(m_longSpin);
QSpacerItem *spacer = new QSpacerItem(100, 100, QSizePolicy::Expanding, QSizePolicy::Expanding);
vl->addWidget(mp);
vl->addWidget(x);
vl->addWidget(y);
vl->addWidget(z);
vl->addSpacerItem(spacer);
int index = m_providerComboBox->findText(m_config->mapProvider());
int index = m_page->providerComboBox->findText(m_config->mapProvider());
index = (index >= 0) ? index : 0;
m_providerComboBox->setCurrentIndex(index);
m_zoomSpin->setValue(m_config->zoom());
m_latSpin->setValue(m_config->latitude());
m_longSpin->setValue(m_config->longitude());
m_page->providerComboBox->setCurrentIndex(index);
m_page->zoomSpinBox->setValue(m_config->zoom());
m_page->latitudeSpinBox->setValue(m_config->latitude());
m_page->longitudeSpinBox->setValue(m_config->longitude());
return widget;
return w;
}
void MapGadgetOptionsPage::apply()
{
m_config->setMapProvider(m_providerComboBox->currentText());
m_config->setZoom(m_zoomSpin->value());
m_config->setLatitude(m_latSpin->value());
m_config->setLongitude(m_longSpin->value());
m_config->setMapProvider(m_page->providerComboBox->currentText());
m_config->setZoom(m_page->zoomSpinBox->value());
m_config->setLatitude(m_page->latitudeSpinBox->value());
m_config->setLongitude(m_page->longitudeSpinBox->value());
}
void MapGadgetOptionsPage::finish()
{
delete m_page;
}

View File

@ -30,13 +30,15 @@
#include "coreplugin/dialogs/ioptionspage.h"
namespace Core {
class IUAVGadgetConfiguration;
}
class MapGadgetConfiguration;
class QComboBox;
class QSpinBox;
class QDoubleSpinBox;
namespace Core {
class IUAVGadgetConfiguration;
}
namespace Ui {
class MapGadgetOptionsPage;
}
using namespace Core;
@ -55,11 +57,7 @@ signals:
public slots:
private:
MapGadgetConfiguration *m_config;
QComboBox *m_providerComboBox;
QSpinBox *m_zoomSpin;
QDoubleSpinBox *m_latSpin;
QDoubleSpinBox *m_longSpin;
Ui::MapGadgetOptionsPage *m_page;
};
#endif // MAPGADGETOPTIONSPAGE_H

View File

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MapGadgetOptionsPage</class>
<widget class="QWidget" name="MapGadgetOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Map provider:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="providerComboBox">
<item>
<property name="text">
<string>OpenStreetMap</string>
</property>
</item>
<item>
<property name="text">
<string>Google</string>
</property>
</item>
<item>
<property name="text">
<string>Google Sat</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Default zoom:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="zoomSpinBox">
<property name="maximum">
<number>18</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Default latitude:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="latitudeSpinBox">
<property name="decimals">
<number>8</number>
</property>
<property name="minimum">
<double>-90.000000000000000</double>
</property>
<property name="maximum">
<double>90.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Default longitude:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="longitudeSpinBox">
<property name="decimals">
<number>8</number>
</property>
<property name="minimum">
<double>-180.000000000000000</double>
</property>
<property name="maximum">
<double>180.000000000000000</double>
</property>
</widget>
</item>
<item row="4" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,20 +1,21 @@
TEMPLATE = lib
TARGET = ModelViewGadget
include(../../openpilotgcsplugin.pri)
include(../../plugins/coreplugin/coreplugin.pri)
include(../../libs/glc_lib/glc_lib.pri)
include(modelview_dependencies.pri)
INCLUDEPATH += ../../libs/glc_lib/install/include/GLC_lib
HEADERS += modelviewplugin.h \
modelviewgadgetconfiguration.h \
modelviewgadget.h \
modelviewgadgetwidget.h \
modelviewgadgetfactory.h \
modelviewgadgetoptionspage.h
SOURCES += modelviewplugin.cpp \
modelviewgadgetconfiguration.cpp \
modelviewgadget.cpp \
modelviewgadgetfactory.cpp \
modelviewgadgetwidget.cpp \
modelviewgadgetoptionspage.cpp
OTHER_FILES += ModelViewGadget.pluginspec
TEMPLATE = lib
TARGET = ModelViewGadget
include(../../openpilotgcsplugin.pri)
include(../../plugins/coreplugin/coreplugin.pri)
include(../../libs/glc_lib/glc_lib.pri)
include(modelview_dependencies.pri)
INCLUDEPATH += ../../libs/glc_lib/install/include/GLC_lib
HEADERS += modelviewplugin.h \
modelviewgadgetconfiguration.h \
modelviewgadget.h \
modelviewgadgetwidget.h \
modelviewgadgetfactory.h \
modelviewgadgetoptionspage.h
SOURCES += modelviewplugin.cpp \
modelviewgadgetconfiguration.cpp \
modelviewgadget.cpp \
modelviewgadgetfactory.cpp \
modelviewgadgetwidget.cpp \
modelviewgadgetoptionspage.cpp
OTHER_FILES += ModelViewGadget.pluginspec
FORMS += modelviewoptionspage.ui

View File

@ -28,6 +28,8 @@
#include "modelviewgadgetoptionspage.h"
#include "modelviewgadgetconfiguration.h"
#include "ui_modelviewoptionspage.h"
ModelViewGadgetOptionsPage::ModelViewGadgetOptionsPage(ModelViewGadgetConfiguration *config, QObject *parent) :
IOptionsPage(parent),
@ -37,60 +39,32 @@ ModelViewGadgetOptionsPage::ModelViewGadgetOptionsPage(ModelViewGadgetConfigurat
QWidget *ModelViewGadgetOptionsPage::createPage(QWidget *parent)
{
QWidget *widget = new QWidget;
QVBoxLayout *vl = new QVBoxLayout();
widget->setLayout(vl);
m_page = new Ui::ModelViewOptionsPage();
QWidget *w = new QWidget(parent);
m_page->setupUi(w);
QWidget *label = new QLabel("3D Object File:");
vl->addWidget(label);
m_acFileLabel = new QLabel(m_config->acFilename());
QWidget* acPushbutton = new QPushButton("Change model");
vl->addWidget(m_acFileLabel);
vl->addWidget(acPushbutton);
m_page->modelPathChooser->setExpectedKind(Utils::PathChooser::File);
m_page->modelPathChooser->setPromptDialogFilter(tr("3D model (*.dae *.3ds)"));
m_page->modelPathChooser->setPromptDialogTitle(tr("Choose 3D model"));
m_page->backgroundPathChooser->setExpectedKind(Utils::PathChooser::File);
m_page->backgroundPathChooser->setPromptDialogFilter(tr("Images (*.png *.jpg *.bmp *.xpm)"));
m_page->backgroundPathChooser->setPromptDialogTitle(tr("Choose background image"));
QSpacerItem *spacer = new QSpacerItem(100, 100, QSizePolicy::Expanding, QSizePolicy::Expanding);
vl->addSpacerItem(spacer);
label = new QLabel("Background image file:");
vl->addWidget(label);
m_bgFileLabel = new QLabel(m_config->bgFilename());
QWidget* bgPushbutton = new QPushButton("Change background");
vl->addWidget(m_bgFileLabel);
vl->addWidget(bgPushbutton);
m_page->modelPathChooser->setPath(m_config->acFilename());
m_page->backgroundPathChooser->setPath(m_config->bgFilename());
QSpacerItem *spacer2 = new QSpacerItem(100, 100, QSizePolicy::Expanding, QSizePolicy::Expanding);
vl->addSpacerItem(spacer2);
connect(acPushbutton, SIGNAL(clicked()), this, SLOT(changeAC()) );
connect(bgPushbutton, SIGNAL(clicked()), this, SLOT(changeBG()) );
return widget;
return w;
}
void ModelViewGadgetOptionsPage::apply()
{
//m_config->setAcFilename(m_acFileName->selectedFiles());
//m_config->setBgFilename(m_bgFileName->selectedFiles());
m_config->setAcFilename(m_page->modelPathChooser->path());
m_config->setBgFilename(m_page->backgroundPathChooser->path());
}
void ModelViewGadgetOptionsPage::finish()
{
delete m_page;
}
void ModelViewGadgetOptionsPage::changeAC()
{
QString ac = QFileDialog::getOpenFileName(qobject_cast<QWidget*>(this),
tr("Model 3D File"), "../artwork/", tr("3D File (*.dae *.3ds)") );
m_config->setAcFilename(ac);
m_acFileLabel->setText(ac);
}
void ModelViewGadgetOptionsPage::changeBG()
{
QString bg = QFileDialog::getOpenFileName(qobject_cast<QWidget*>(this),
tr("Background Image File"), "../artwork", tr("Image Files (*.png *.jpg *.bmp)") );
m_config->setBgFilename(bg);
m_bgFileLabel->setText(bg);
}

View File

@ -35,11 +35,14 @@
#include <QtGui/QHBoxLayout>
#include <QtGui/QVBoxLayout>
namespace Core {
class IUAVGadgetConfiguration;
}
class ModelViewGadgetConfiguration;
class QFileDialog;
namespace Core {
class IUAVGadgetConfiguration;
}
namespace Ui {
class ModelViewOptionsPage;
}
using namespace Core;
@ -62,13 +65,10 @@ signals:
public slots:
private slots:
void changeAC();
void changeBG();
private:
ModelViewGadgetConfiguration *m_config;
QLabel *m_acFileLabel;
QLabel *m_bgFileLabel;
Ui::ModelViewOptionsPage *m_page;
};
#endif // MODELVIEWGADGETOPTIONSPAGE_H

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ModelViewOptionsPage</class>
<widget class="QWidget" name="ModelViewOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>3D model:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Background image:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Utils::PathChooser" name="backgroundPathChooser" native="true"/>
</item>
<item row="0" column="1">
<widget class="Utils::PathChooser" name="modelPathChooser" native="true"/>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Utils::PathChooser</class>
<extends>QWidget</extends>
<header>utils/pathchooser.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -50,9 +50,10 @@ QWidget *SystemHealthGadgetOptionsPage::createPage(QWidget *parent)
options_page->setupUi(optionsPageWidget);
// Restore the contents from the settings:
options_page->svgSourceFile->setText(m_config->getSystemFile());
connect(options_page->loadFile, SIGNAL(clicked()), this, SLOT(on_loadFile_clicked()));
options_page->svgFilePathChooser->setExpectedKind(Utils::PathChooser::File);
options_page->svgFilePathChooser->setPromptDialogFilter(tr("SVG image (*.svg)"));
options_page->svgFilePathChooser->setPromptDialogTitle(tr("Choose SVG image"));
options_page->svgFilePathChooser->setPath(m_config->getSystemFile());
return optionsPageWidget;
}
@ -64,30 +65,11 @@ QWidget *SystemHealthGadgetOptionsPage::createPage(QWidget *parent)
*/
void SystemHealthGadgetOptionsPage::apply()
{
m_config->setSystemFile(options_page->svgSourceFile->text());
}
/**
Opens an open file dialog.
*/
void SystemHealthGadgetOptionsPage::on_loadFile_clicked()
{
QFileDialog::Options options;
QString selectedFilter;
QString fileName = QFileDialog::getOpenFileName(qobject_cast<QWidget*>(this),
tr("QFileDialog::getOpenFileName()"),
options_page->svgSourceFile->text(),
tr("All Files (*);;SVG Files (*.svg)"),
&selectedFilter,
options);
if (!fileName.isEmpty()) options_page->svgSourceFile->setText(fileName);
m_config->setSystemFile(options_page->svgFilePathChooser->path());
}
void SystemHealthGadgetOptionsPage::finish()
{
delete options_page;
}

View File

@ -1,109 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SystemHealthGadgetOptionsPage</class>
<widget class="QWidget" name="SystemHealthGadgetOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>486</width>
<height>300</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>-1</x>
<y>-1</y>
<width>481</width>
<height>339</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0">
<property name="spacing">
<number>10</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Subsystem SVG:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="svgSourceFile"/>
</item>
<item>
<widget class="QPushButton" name="loadFile">
<property name="text">
<string>Load file...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SystemHealthGadgetOptionsPage</class>
<widget class="QWidget" name="SystemHealthGadgetOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>486</width>
<height>300</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Subsystem SVG:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Utils::PathChooser" name="svgFilePathChooser" native="true"/>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Utils::PathChooser</class>
<extends>QWidget</extends>
<header>utils/pathchooser.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -23,4 +23,5 @@ SOURCES += browserplugin.cpp \
browseritemdelegate.cpp \
fieldtreeitem.cpp
OTHER_FILES += UAVObjectBrowser.pluginspec
FORMS += uavobjectbrowser.ui
FORMS += uavobjectbrowser.ui \
uavobjectbrowseroptionspage.ui

View File

@ -34,6 +34,8 @@
#include <QtGui/QVBoxLayout>
#include <QtGui/QColorDialog>
#include "ui_uavobjectbrowseroptionspage.h"
UAVObjectBrowserOptionsPage::UAVObjectBrowserOptionsPage(UAVObjectBrowserConfiguration *config, QObject *parent) :
IOptionsPage(parent),
@ -43,103 +45,26 @@ UAVObjectBrowserOptionsPage::UAVObjectBrowserOptionsPage(UAVObjectBrowserConfigu
QWidget *UAVObjectBrowserOptionsPage::createPage(QWidget *parent)
{
QWidget *widget = new QWidget;
QVBoxLayout *vl = new QVBoxLayout();
widget->setLayout(vl);
m_page = new Ui::UAVObjectBrowserOptionsPage();
QWidget *w = new QWidget(parent);
m_page->setupUi(w);
QHBoxLayout *recentColorLayout = new QHBoxLayout();
QWidget *ru = new QWidget;
ru->setLayout(recentColorLayout);
QWidget *label = new QLabel(tr("Recently updated highlight color:"));
QHBoxLayout *rubLayout = new QHBoxLayout();
QWidget *rub = new QWidget;
rub->setLayout(rubLayout);
m_ruLabel = new QLabel(" ");
m_ruLabel->setMinimumWidth(40);
m_ruButton = new QPushButton(tr("Choose"));
rubLayout->addWidget(m_ruLabel);
rubLayout->addWidget(m_ruButton);
recentColorLayout->addWidget(label);
recentColorLayout->addWidget(rub);
m_page->recentlyUpdatedButton->setColor(m_config->recentlyUpdatedColor());
m_page->manuallyChangedButton->setColor(m_config->manuallyChangedColor());
m_page->recentlyUpdatedTimeoutSpinBox->setValue(m_config->recentlyUpdatedTimeout());
QHBoxLayout *manualColorLayout = new QHBoxLayout();
QWidget *mc = new QWidget;
mc->setLayout(manualColorLayout);
label = new QLabel(tr("Manually changed color:"));
QHBoxLayout *mcbLayout = new QHBoxLayout();
QWidget *mcb = new QWidget;
mcb->setLayout(mcbLayout);
m_mcLabel = new QLabel(" ");
m_mcLabel->setMinimumWidth(40);
m_mcButton = new QPushButton(tr("Choose"));
mcbLayout->addWidget(m_mcLabel);
mcbLayout->addWidget(m_mcButton);
manualColorLayout->addWidget(label);
manualColorLayout->addWidget(mcb);
QHBoxLayout *timeoutLayout = new QHBoxLayout();
QWidget *x = new QWidget;
x->setLayout(timeoutLayout);
label = new QLabel("Recently updated highlight timeout (ms):");
m_timeoutSpin = new QSpinBox();
m_timeoutSpin->setSingleStep(100);
m_timeoutSpin->setMaximum(1000000000);
timeoutLayout->addWidget(label);
timeoutLayout->addWidget(m_timeoutSpin);
QSpacerItem *spacer = new QSpacerItem(100, 100, QSizePolicy::Expanding, QSizePolicy::Expanding);
vl->addWidget(ru);
vl->addWidget(mc);
vl->addWidget(x);
vl->addSpacerItem(spacer);
m_ruColor = m_config->recentlyUpdatedColor();
QString s = QString("background-color: %1").arg(m_ruColor.name());
m_ruLabel->setStyleSheet(s);
m_mcColor = m_config->manuallyChangedColor();
s = QString("background-color: %1").arg(m_mcColor.name());
m_mcLabel->setStyleSheet(s);
m_timeoutSpin->setValue(m_config->recentlyUpdatedTimeout());
connect(m_ruButton, SIGNAL(clicked()), this, SLOT(ruButtonClicked()));
connect(m_mcButton, SIGNAL(clicked()), this, SLOT(mcButtonClicked()));
return widget;
return w;
}
void UAVObjectBrowserOptionsPage::apply()
{
m_config->setRecentlyUpdatedColor(m_ruColor);
m_config->setManuallyChangedColor(m_mcColor);
m_config->setRecentlyUpdatedTimeout(m_timeoutSpin->value());
m_config->setRecentlyUpdatedColor(m_page->recentlyUpdatedButton->color());
m_config->setManuallyChangedColor(m_page->manuallyChangedButton->color());
m_config->setRecentlyUpdatedTimeout(m_page->recentlyUpdatedTimeoutSpinBox->value());
}
void UAVObjectBrowserOptionsPage::finish()
{
disconnect(m_ruButton, SIGNAL(clicked()), this, SLOT(ruButtonClicked()));
disconnect(m_mcButton, SIGNAL(clicked()), this, SLOT(mcButtonClicked()));
delete m_ruButton;
delete m_mcButton;
delete m_ruLabel;
delete m_mcLabel;
delete m_timeoutSpin;
delete m_page;
}
void UAVObjectBrowserOptionsPage::ruButtonClicked()
{
QColor c = QColorDialog::getColor(m_ruColor);
m_ruColor = c.isValid() ? c : m_ruColor;
QString s = QString("background-color: %1").arg(m_ruColor.name());
m_ruLabel->setStyleSheet(s);
}
void UAVObjectBrowserOptionsPage::mcButtonClicked()
{
QColor c = QColorDialog::getColor(m_mcColor);
m_mcColor = c.isValid() ? c : m_mcColor;
QString s = QString("background-color: %1").arg(m_mcColor.name());
m_mcLabel->setStyleSheet(s);
}

View File

@ -30,6 +30,8 @@
#include "coreplugin/dialogs/ioptionspage.h"
#include <QtGui/QColor>
#include <utils/qtcolorbutton.h>
namespace Core {
class IUAVGadgetConfiguration;
@ -41,6 +43,10 @@ class QSpinBox;
using namespace Core;
namespace Ui {
class UAVObjectBrowserOptionsPage;
}
class UAVObjectBrowserOptionsPage : public IOptionsPage
{
Q_OBJECT
@ -54,18 +60,9 @@ public:
signals:
private slots:
void ruButtonClicked();
void mcButtonClicked();
private:
UAVObjectBrowserConfiguration *m_config;
QColor m_ruColor;
QColor m_mcColor;
QLabel *m_ruLabel;
QLabel *m_mcLabel;
QPushButton *m_ruButton;
QPushButton *m_mcButton;
QSpinBox *m_timeoutSpin;
Ui::UAVObjectBrowserOptionsPage *m_page;
};
#endif // UAVOBJECTBROWSEROPTIONSPAGE_H

View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>UAVObjectBrowserOptionsPage</class>
<widget class="QWidget" name="UAVObjectBrowserOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Recently updated color:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Manually changed color:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Recently updated timeout (ms):</string>
</property>
</widget>
</item>
<item row="2" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="Utils::QtColorButton" name="recentlyUpdatedButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="Utils::QtColorButton" name="manuallyChangedButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QSpinBox" name="recentlyUpdatedTimeoutSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>100000000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Utils::QtColorButton</class>
<extends>QToolButton</extends>
<header>utils/qtcolorbutton.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>