Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFR] Wallaby version 9 #4

Merged
merged 11 commits into from
Jan 28, 2016
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ set(INCLUDE ${CMAKE_SOURCE_DIR}/include/botui)
set(RC ${CMAKE_SOURCE_DIR}/rc)
set(SRC ${CMAKE_SOURCE_DIR}/src)
set(UI ${CMAKE_SOURCE_DIR}/ui)
set(TS ${CMAKE_SOURCE_DIR}/ts)

set(DBUS ${CMAKE_SOURCE_DIR}/dbus)

Expand Down Expand Up @@ -52,7 +53,7 @@ endif()
file(GLOB INCLUDES ${INCLUDE}/*.h ${DEVICE_DIR}/include/*.h)
file(GLOB SOURCES ${SRC}/*.cpp ${DEVICE_DIR}/src/*.cpp)
file(GLOB UIS ${UI}/*)

file(GLOB TS_FILES ${TS}/*.ts)

set(UI ${UIS})

Expand All @@ -76,13 +77,15 @@ if(NOT qt5)
QT4_WRAP_CPP(SRCS_CXX ${MOC_SRCS} OPTIONS -DQT_VERSION=0x040000)
QT4_WRAP_UI(SRCS_CXX ${UI})
QT4_ADD_RESOURCES(SRCS_CXX ${QRC_FILES})
QT4_ADD_TRANSLATION(QM_FILES ${TS_FILES})
else()
# set(CMAKE_AUTOMOC ON)
set(MOC_SRCS ${INCLUDES})
set(SRCS_CXX ${SOURCES})
qt5_wrap_cpp(SRCS_CXX ${MOC_SRCS} OPTIONS -DQT_VERSION=0x050000 -UQT_DBUS_LIB)
qt5_wrap_ui(SRCS_CXX ${UI})
qt5_add_resources(SRCS_CXX ${QRC_FILES})
qt5_add_translation(QM_FILES ${TS_FILES})
endif()

add_definitions(-Wall)
Expand All @@ -96,9 +99,9 @@ ELSEIF(WIN32)
ENDIF()

if(WIN32)
add_executable(botui WIN32 ${SRCS_CXX})
add_executable(botui WIN32 ${SRCS_CXX} ${QM_FILES})
else()
add_executable(botui ${SRCS_CXX})
add_executable(botui ${SRCS_CXX} ${QM_FILES})
endif()

add_definitions(-O3)
Expand All @@ -118,3 +121,4 @@ endif()


install(TARGETS botui DESTINATION bin)
install(FILES ${QM_FILES} DESTINATION "/etc/botui/locale")
3 changes: 3 additions & 0 deletions src/CombinedMotorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ CombinedMotorWidget::CombinedMotorWidget(Device *device, QWidget *parent)

connect(ui->tabs, SIGNAL(currentChanged(int)), SLOT(stop()));

// TODO: remove this once position mode works
ui->tabs->removeTab(2);

connect(ui->go, SIGNAL(clicked()), SLOT(go()));

QTimer *timer = new QTimer(this);
Expand Down
5 changes: 4 additions & 1 deletion src/HomeWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ HomeWidget::HomeWidget(Device *device, QWidget *parent)
connect(ui->fileManager, SIGNAL(clicked()), SLOT(fileManager()));
connect(ui->motorsSensors, SIGNAL(clicked()), SLOT(motorsSensors()));
connect(ui->settings, SIGNAL(clicked()), SLOT(settings()));


// TODO: fix fileManager and then remove this line
ui->fileManager->setVisible(false);

// QAction *lock = menuBar()->addAction(UiStandards::lockString());
// connect(lock, SIGNAL(triggered()), SLOT(lock()));
QAction *about = menuBar()->addAction(tr("About"));
Expand Down
6 changes: 6 additions & 0 deletions src/LanguageWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "LocaleModel.h"

#include <QSettings>
#include <QDebug>
#include <unistd.h>

LanguageWidget::LanguageWidget(Device *device, QWidget *const parent)
Expand All @@ -16,6 +17,7 @@ LanguageWidget::LanguageWidget(Device *device, QWidget *const parent)
LocaleModel *localeModel = new LocaleModel(this);
ui->languages->setModel(localeModel);

// Set current index to current locale
const QString currLocale = QSettings().value("locale", "en").toString();
for(int i = 0; i < ui->languages->count(); ++i) {
if(localeModel->locale(localeModel->index(i, 0)).bcp47Name() != currLocale) continue;
Expand All @@ -32,11 +34,15 @@ LanguageWidget::~LanguageWidget()

void LanguageWidget::currentIndexChanged(int index)
{
// Create QLocale for selected locale
if(index < 0) return;
LocaleModel *const model = qobject_cast<LocaleModel *>(ui->languages->model());
const QLocale locale = model->locale(ui->languages->model()->index(index, 0));

// Update global locale setting
QSettings settings;
settings.setValue("locale", locale.bcp47Name());
qDebug() << "Set locale to " << locale.bcp47Name();
settings.sync();
sync();
}
11 changes: 6 additions & 5 deletions src/LocaleModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ class LocaleItem : public QStandardItem
LocaleModel::LocaleModel(QObject *const parent)
: QStandardItemModel(parent)
{
QDir locales("/etc/botui/locale");
Q_FOREACH(const QFileInfo &localeFile, locales.entryInfoList(QDir::NoDot | QDir::NoDotDot | QDir::Files)) {
const QString name = localeFile.baseName();
const int underline = name.indexOf("_");
const QDir localeDir("/etc/botui/locale");
Q_FOREACH(const QFileInfo &localeFile, localeDir.entryInfoList(QDir::NoDot | QDir::NoDotDot | QDir::Files)) {
const QString fileName = localeFile.baseName();
const int underline = fileName.indexOf("_");
if(!underline) continue;
appendRow(new LocaleItem(QLocale(name.mid(underline + 1))));
const QString localeName = fileName.mid(underline + 1);
appendRow(new LocaleItem(QLocale(localeName)));
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/MotorsSensorsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ MotorsSensorsWidget::MotorsSensorsWidget(Device *device, QWidget *parent)
connect(ui->camera, SIGNAL(clicked()), SLOT(camera()));
connect(ui->pidTuner, SIGNAL(clicked()), SLOT(pidTuner()));
connect(ui->depth, SIGNAL(clicked()), SLOT(depth()));

// TODO: remove these once the widgets work on the Wallaby
ui->camera->setVisible(false);
ui->pidTuner->setVisible(false);
ui->depth->setVisible(false);
}

MotorsSensorsWidget::~MotorsSensorsWidget()
Expand Down
2 changes: 1 addition & 1 deletion src/SensorListWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ SensorListWidget::SensorListWidget(Device *device, QWidget *parent)

QTimer *timer = new QTimer(this);
_model->connect(timer, SIGNAL(timeout()), SLOT(update()));
timer->start(50); // 20 FPS
timer->start(200); // 5 FPS
}

SensorListWidget::~SensorListWidget()
Expand Down
13 changes: 8 additions & 5 deletions src/SensorsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,17 @@ double SensorsWidget::value(const int &i) const
{
double val = rawValue(i);

if(i < 8) val = val / 512.0 - 1.0;
else if(i < 12) val = val / 32768.0;
#ifdef WALLABY
else if(i < 19) val = val / 512.0;
if(i < 6) val = val / 2048.0 - 1.0;
else if(i < 10) val = val / 32768.0;
else if(i < 19) val = val / 2046.0;
else val = 0.0;
#else
if(i < 8) val = val / 512.0 - 1.0;
else if(i < 12) val = val / 32768.0;
else if(i < 15) val = val / 512.0;
#endif
else val = 0.0;

#endif

return val;
}
8 changes: 8 additions & 0 deletions src/SettingsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ SettingsWidget::SettingsWidget(Device *device, QWidget *parent)
connect(ui->gui, SIGNAL(clicked()), SLOT(gui()));
connect(ui->calibrate, SIGNAL(clicked()), SLOT(calibrate()));
connect(ui->language, SIGNAL(clicked()), SLOT(language()));

//TODO show buttons once the widgets are fixed
ui->network->setVisible(false);
ui->channels->setVisible(false);
ui->comm->setVisible(false);
ui->keyboard->setVisible(false);
ui->mouse->setVisible(false);
ui->programSettings->setVisible(false);
}

SettingsWidget::~SettingsWidget()
Expand Down
8 changes: 6 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ int main(int argc, char* argv[])
QApplication app(argc, argv);

QTranslator translator;
const QString trFile = "link_" + QSettings().value("locale", "en").toString().left(2);
if(trFile != "en" && translator.load(trFile, "/etc/botui/locale/"))
const QString trFile = "botui_" + QSettings().value("locale", "en").toString().left(2);
qDebug() << "Trying to use translation file " << trFile;
if(trFile != "botui_en" && translator.load(trFile, "/etc/botui/locale/"))
{
qDebug() << "Successfully loaded translation file " << trFile;
app.installTranslator(&translator);
}

QDir::setCurrent(QApplication::applicationDirPath());
qmlRegisterType<BusyIndicator>("ZapBsComponents", 1, 0, "BusyIndicator");
Expand Down
File renamed without changes.
File renamed without changes.
82 changes: 4 additions & 78 deletions ui/LanguageWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
<string>About</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>6</number>
</property>
Expand Down Expand Up @@ -50,84 +47,13 @@
</layout>
</item>
<item>
<widget class="QTextEdit" name="textEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>75</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="0">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="0">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>237</red>
<green>237</green>
<blue>237</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="acceptDrops">
<bool>false</bool>
<widget class="QLabel" name="noteLabel">
<property name="text">
<string>Note: System must be restarted to apply changes.</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="undoRedoEnabled">
<bool>false</bool>
</property>
<property name="readOnly">
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="html">
<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:'.Lucida Grande UI'; font-size:13pt; 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;Note: Link must be restarted for changes to take effect.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::NoTextInteraction</set>
</property>
</widget>
</item>
<item>
Expand Down