diff --git a/.vscode/settings.json b/.vscode/settings.json
index d9a640a1..db5c224a 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -2,6 +2,11 @@
"C_Cpp.errorSquiggles": "Disabled",
"files.associations": {
"chrono": "cpp",
- "variant": "cpp"
+ "variant": "cpp",
+ "*.tcc": "cpp",
+ "list": "cpp",
+ "array": "cpp",
+ "string_view": "cpp",
+ "string": "cpp"
}
}
\ No newline at end of file
diff --git a/dbus/CMakeLists.txt b/dbus/CMakeLists.txt
index 3a799358..cd768210 100644
--- a/dbus/CMakeLists.txt
+++ b/dbus/CMakeLists.txt
@@ -7,6 +7,7 @@ set(NETWORK_MANAGER_INTERFACES
org.freedesktop.NetworkManager.Settings
org.freedesktop.NetworkManager.AccessPoint
org.freedesktop.NetworkManager.IP4Config
+ org.freedesktop.NetworkManager.Connection.Active
org.freedesktop.NetworkManager
)
diff --git a/dbus/org.freedesktop.NetworkManager.Connection.Active.xml b/dbus/org.freedesktop.NetworkManager.Connection.Active.xml
new file mode 100644
index 00000000..54e3dd80
--- /dev/null
+++ b/dbus/org.freedesktop.NetworkManager.Connection.Active.xml
@@ -0,0 +1,173 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/include/botui/NetworkManager.h b/include/botui/NetworkManager.h
index a881c1ea..c5392f78 100644
--- a/include/botui/NetworkManager.h
+++ b/include/botui/NetworkManager.h
@@ -60,6 +60,10 @@ Q_OBJECT
QString ip4Address() const;
Connection createAPConfig() const ;
+
+ QString currentActiveConnectionName() const;
+
+ bool isActiveConnectionOn() const;
public slots:
bool turnOn();
diff --git a/include/botui/NetworkSettingsWidget.h b/include/botui/NetworkSettingsWidget.h
index 6ae0bcbd..a3a561ff 100644
--- a/include/botui/NetworkSettingsWidget.h
+++ b/include/botui/NetworkSettingsWidget.h
@@ -30,11 +30,7 @@ public slots:
void connect();
void manage();
void updateInformation();
- void enableAP();
- void disableAP();
- void enableAPControls();
- void disableAPControls();
- void disableAPControlsTemporarily();
+
private slots:
diff --git a/include/botui/RootController.h b/include/botui/RootController.h
index 0cfe8731..485aba74 100644
--- a/include/botui/RootController.h
+++ b/include/botui/RootController.h
@@ -7,59 +7,65 @@
#include
#include
#include
-
+#include "NetworkSettingsWidget.h"
#include "Singleton.h"
class RootController : public QObject, public Singleton
{
-Q_OBJECT
-Q_PROPERTY(bool dismissable READ isDismissable WRITE setDismissable)
-Q_PROPERTY(unsigned int depth READ depth)
+ Q_OBJECT
+ Q_PROPERTY(bool dismissable READ isDismissable WRITE setDismissable)
+ Q_PROPERTY(unsigned int depth READ depth)
public:
RootController();
-
+
const unsigned int depth() const;
-
+
void setDismissable(bool dismissable);
bool isDismissable() const;
-
- void setFullscreen(const bool fullscreen);
- bool isFullscreen() const;
-
- template
+
+ void setFullscreen(const bool fullscreen);
+ bool isFullscreen() const;
+
+ template
void dismissUntil()
{
- while(depth() > 1 && !dynamic_cast(m_stack.top())) m_stack.pop();
+ while (depth() > 1 && !dynamic_cast(m_stack.top()))
+ m_stack.pop();
}
-
- template
+
+ template
bool containsWidget()
{
QStack::ConstIterator it = m_stack.begin();
- for(; it != m_stack.end(); ++it) {
- if(dynamic_cast(*it)) return true;
+ for (; it != m_stack.end(); ++it)
+ {
+ if (dynamic_cast(*it))
+ return true;
}
return false;
}
-
+
public slots:
- void presentQml(const QUrl& url);
+ void presentQml(const QUrl &url);
int presentDialog(QDialog *dialog);
void presentWidget(QWidget *widget, bool owns = true);
-
+
void dismissWidget();
void dismissAllWidgets();
-
- void minimize();
-
+ void findNetworkSettingsWidget() const;
+ void addNetworkSettingsStack(NetworkSettingsWidget *networkWidget) ;
+ void minimize();
+ void printStack();
+ void getNetworkSettingsWidget();
+
private:
void constrain(QWidget *widget);
void present(QWidget *widget);
-
+
QMap m_ownership;
QStack m_stack;
bool m_dismissable;
- bool m_fullscreen;
+ bool m_fullscreen;
};
#endif
diff --git a/src/AboutWidget.cpp b/src/AboutWidget.cpp
index 5e3e7ec1..abf99bfe 100644
--- a/src/AboutWidget.cpp
+++ b/src/AboutWidget.cpp
@@ -12,7 +12,8 @@ AboutWidget::AboutWidget(Device *device, QWidget *parent)
ui(new Ui::AboutWidget)
{
ui->setupUi(this);
-
+// Setup the UI
+ performStandardSetup(tr("About"));
// Version Number
ui->version->setText("Version 27.0 (Quark)");
@@ -22,11 +23,6 @@ AboutWidget::AboutWidget(Device *device, QWidget *parent)
const QString serial = device->serial();
ui->deviceName->setText("Wombat-" + serial);
-
- //QDBusObjectPath ip4Config = m_device.ip4Config();
- qDebug() << "IP Address: " << NetworkManager::ref().ip4Address();
-
-
// Check if eth0 is active (/sys/class/net/eth0/carrier will output 1 if eth0 is active and 0 if it is not)
QProcess proc;
proc.start("cat /sys/class/net/eth0/carrier");
@@ -62,8 +58,7 @@ AboutWidget::AboutWidget(Device *device, QWidget *parent)
ui->ssid->setText(ssid);
ui->password->setText(password);
}
- // Setup the UI
- performStandardSetup(tr("About"));
+
}
AboutWidget::~AboutWidget()
diff --git a/src/AdvancedSettingsWidget.cpp b/src/AdvancedSettingsWidget.cpp
index 673b63be..c812e9bc 100644
--- a/src/AdvancedSettingsWidget.cpp
+++ b/src/AdvancedSettingsWidget.cpp
@@ -29,7 +29,7 @@ AdvancedSettingsWidget::AdvancedSettingsWidget(Device *device, QWidget *parent)
#else
ui->network->setEnabled(true);
#endif
-
+
connect(ui->network, SIGNAL(clicked()), SLOT(network()));
connect(ui->factory, SIGNAL(clicked()), SLOT(factory()));
connect(ui->gui, SIGNAL(clicked()), SLOT(gui()));
@@ -45,7 +45,7 @@ AdvancedSettingsWidget::~AdvancedSettingsWidget()
void AdvancedSettingsWidget::network()
{
#ifdef NETWORK_ENABLED
- RootController::ref().presentWidget(new NetworkSettingsWidget(device()));
+ RootController::ref().getNetworkSettingsWidget();
#endif
}
diff --git a/src/HomeWidget.cpp b/src/HomeWidget.cpp
index 3dcd8379..9e15a361 100644
--- a/src/HomeWidget.cpp
+++ b/src/HomeWidget.cpp
@@ -74,6 +74,7 @@ void HomeWidget::settings()
void HomeWidget::about()
{
RootController::ref().presentWidget(new AboutWidget(device()));
+ RootController::ref().printStack();
}
void HomeWidget::shutDown()
diff --git a/src/NetworkManager.cpp b/src/NetworkManager.cpp
index 778e1aa0..231550e0 100644
--- a/src/NetworkManager.cpp
+++ b/src/NetworkManager.cpp
@@ -8,6 +8,7 @@
#include "org_freedesktop_NetworkManager_Device_Wireless.h"
#include "org_freedesktop_NetworkManager_Settings.h"
#include "org_freedesktop_NetworkManager_Settings_Connection.h"
+#include "org_freedesktop_NetworkManager_Connection_Active.h"
#include "org_freedesktop_NetworkManager_IP4Config.h"
#include
@@ -391,6 +392,28 @@ Network NetworkManager::active() const
return createAccessPoint(m_wifi->activeAccessPoint());
}
+bool NetworkManager::isActiveConnectionOn() const
+{
+ bool activeConnOn;
+ if (m_device->activeConnection().path() != "/") // if there is an Active Connection path (i.e. not "/")
+ {
+ activeConnOn = true;
+ }
+ return activeConnOn;
+}
+
+QString NetworkManager::currentActiveConnectionName() const
+{
+ QDBusObjectPath activePath = m_device->activeConnection(); // Device's current active connection
+
+ OrgFreedesktopNetworkManagerConnectionActiveInterface activeConnObj(
+ NM_SERVICE,
+ activePath.path(),
+ QDBusConnection::systemBus());
+
+ return activeConnObj.id();
+}
+
NetworkList NetworkManager::accessPoints() const
{
if (!m_wifi)
@@ -446,7 +469,7 @@ QString NetworkManager::ip4Address() const
ip4Con.path(),
QDBusConnection::systemBus());
- QList> ip4conf = ip4Object.addressData();
+ QList> ip4conf = ip4Object.addressData();
ipAddr = ip4conf.value(0).value("address").toString();
return ipAddr;
}
@@ -467,7 +490,7 @@ NetworkManager::NetworkManager()
NM_SERVICE,
NM_OBJECT "/Settings",
QDBusConnection::systemBus());
-
+
QDBusPendingReply> reply = m_nm->GetDevices();
if (reply.isError())
diff --git a/src/NetworkSettingsWidget.cpp b/src/NetworkSettingsWidget.cpp
index b2b8eb19..55b4c96b 100644
--- a/src/NetworkSettingsWidget.cpp
+++ b/src/NetworkSettingsWidget.cpp
@@ -25,14 +25,12 @@ NetworkSettingsWidget::NetworkSettingsWidget(Device *device, QWidget *parent)
ui->setupUi(this);
performStandardSetup(tr("Network Settings"));
+
enableCoolOffTimer = new QTimer(this);
enableCoolOffTimer->setSingleShot(true);
QObject::connect(enableCoolOffTimer, SIGNAL(timeout()), SLOT(enableAPControls()));
- // ui->turnOn->setVisible(false);
- // ui->turnOff->setVisible(false);
ui->ConnectButton->setEnabled(false);
- //ui->ConnectButton->setIcon(QPixmap(":/tango/network-wireless-encrypted.svg"));
QObject::connect(ui->ConnectButton, SIGNAL(clicked()), SLOT(connect()));
QObject::connect(ui->ManageButton, SIGNAL(clicked()), SLOT(manage()));
@@ -101,42 +99,6 @@ void NetworkSettingsWidget::manage() // Forget or add network to history
RootController::ref().presentWidget(new ManageNetworksWidget(device()));
}
-void NetworkSettingsWidget::enableAP()
-{
- disableAPControlsTemporarily();
- NetworkManager::ref().enableAP();
- // ui->turnOn->hide();
- // ui->turnOff->show();
-}
-
-void NetworkSettingsWidget::disableAP()
-{
- disableAPControlsTemporarily();
- NetworkManager::ref().disableAP();
- // ui->turnOn->show();
- // ui->turnOff->hide();
-}
-
-void NetworkSettingsWidget::enableAPControls()
-{
- // ui->turnOn->setEnabled(true);
- // ui->turnOff->setEnabled(true);
-}
-
-void NetworkSettingsWidget::disableAPControls()
-{
- // ui->turnOn->setEnabled(false);
- // ui->turnOff->setEnabled(false);
-}
-
-void NetworkSettingsWidget::disableAPControlsTemporarily()
-{
- // ui->turnOn->setEnabled(false);
- // ui->turnOff->setEnabled(false);
-
- enableCoolOffTimer->start(20000);
-}
-
void NetworkSettingsWidget::updateInformation()
{
const bool on = NetworkManager::ref().isOn(); //
@@ -144,19 +106,28 @@ void NetworkSettingsWidget::updateInformation()
const QString id = device()->id();
const QString serial = device()->serial();
- if (!id.isEmpty())
+ // if (!id.isEmpty())
+ // {
+ // const QString password = SystemUtils::sha256(id).left(6) + "00";
+ // const QString ssid = serial + "-wombat";
+ // ui->ssid->setText(ssid);
+ // ui->password->setText(password);
+ // }
+
+ if (NetworkManager::ref().isActiveConnectionOn() == true) // if there's an active connection
{
- const QString password = SystemUtils::sha256(id).left(6) + "00";
- const QString ssid = serial + "-wombat";
- ui->ssid->setText(ssid);
- ui->password->setText(password);
+ if (ui->connectionModeSelect->currentText() == "Client Mode") // if Wombat in client mode
+ {
+ ui->ssid->setText(NetworkManager::ref().currentActiveConnectionName());
+ ui->ip->setText(NetworkManager::ref().ip4Address());
+
+ }
}
-
Network active = NetworkManager::ref().active();
// ui->ssid->setText(active.ssid());
ui->security->setText(active.securityString());
- const QString ip = NetworkManager::ref().ipAddress();
- ui->ip->setText(ip.isEmpty() ? tr("No IP") : ip);
+ // const QString ip = NetworkManager::ref().ipAddress();
+ // ui->ip->setText(ip.isEmpty() ? tr("No IP") : ip);
}
void NetworkSettingsWidget::stateChanged(const NetworkManager::State &newState, const NetworkManager::State &oldState)
diff --git a/src/RootController.cpp b/src/RootController.cpp
index 32538d7e..58524cf2 100644
--- a/src/RootController.cpp
+++ b/src/RootController.cpp
@@ -15,7 +15,7 @@ RootController::RootController()
{
}
-void RootController::presentQml(const QUrl& url)
+void RootController::presentQml(const QUrl &url)
{
DeclarativeView *view = new DeclarativeView(url);
view->setAutoReload(DEVELOPER_MODE);
@@ -27,50 +27,108 @@ void RootController::presentQml(const QUrl& url)
int RootController::presentDialog(QDialog *dialog)
{
setDismissable(false);
- //presentWidget(dialog, false);
+ // presentWidget(dialog, false);
const int ret = dialog->exec();
setDismissable(true);
- //dismissWidget();
+ // dismissWidget();
return ret;
}
+void RootController::findNetworkSettingsWidget() const
+{
+}
+
+void RootController::addNetworkSettingsStack(NetworkSettingsWidget *networkWidget)
+{
+ m_stack.push(networkWidget);
+}
+
+void RootController::getNetworkSettingsWidget()
+{
+ QWidget *prev = m_stack.size() ? m_stack.top() : 0;
+ printStack();
+ foreach (QWidget *widge, m_stack)
+ {
+
+ if (widge->objectName() == "NetworkSettingsWidget")
+ {
+ constrain(widge);
+ widge->move(prev->pos());
+ present(widge);
+ }
+ }
+}
+void RootController::printStack()
+{
+ foreach (QWidget *widge, m_stack)
+ {
+ qDebug() << widge << " Name: " << widge->objectName();
+ }
+}
void RootController::presentWidget(QWidget *widget, bool owns)
{
- for(int i = 0; i < m_stack.size(); ++i) {
- if(m_stack.at(i) == widget) m_stack.remove(i);
+ for (int i = 0; i < m_stack.size(); ++i)
+ {
+ if (m_stack.at(i) == widget)
+ m_stack.remove(i);
}
m_ownership[widget] = owns;
QWidget *prev = m_stack.size() ? m_stack.top() : 0;
m_stack.push(widget);
- constrain(widget);
- if(prev) widget->move(prev->pos());
+ constrain(widget); // constrain size of widget
+ if (prev)
+ widget->move(prev->pos());
present(widget);
- if(prev) prev->hide();
+ if (prev)
+ prev->hide();
}
void RootController::dismissWidget()
{
- if(!m_dismissable) return;
- QWidget *widget = m_stack.pop();
- QWidget *next = m_stack.size() ? m_stack.top() : 0;
- if(next) next->move(widget->pos());
-
- present(next);
+ if (!m_dismissable)
+ return;
+ // QWidget *widget = m_stack.pop();
+
+ QWidget *widget = m_stack.top(); // reference to top of stack
- widget->hide();
- if(m_ownership.value(widget)) widget->deleteLater();
- m_ownership.remove(widget);
+ if (widget->objectName() == "NetworkSettingsWidget")
+ {
+ widget->hide();
+ }
+ else
+ {
+ widget = m_stack.pop();
+ qDebug() << "Trying to dismiss Widget: " << widget->objectName();
+ QWidget *next = m_stack.size() ? m_stack.top() : 0;
+ qDebug() << "Next Widget is:" << next->objectName();
+ if (next)
+ next->move(widget->pos());
+
+ if(next->objectName() != "NetworkSettingsWidget")
+ {
+ present(next);
+ }
+
+ widget->hide();
+ if (m_ownership.value(widget))
+ widget->deleteLater();
+ m_ownership.remove(widget);
+ }
}
void RootController::dismissAllWidgets()
{
- if(!m_dismissable) return;
- while(m_stack.size() > 1) dismissWidget();
+ if (!m_dismissable)
+ return;
+ while (m_stack.size() > 2) //Remaining: HomeWidget and NetworkSettingsWidget
+ dismissWidget();
+ printStack();
+ present(m_stack.at(0));
}
void RootController::minimize()
{
- m_stack.top()->showMinimized();
+ m_stack.top()->showMinimized();
}
const unsigned int RootController::depth() const
@@ -90,12 +148,12 @@ bool RootController::isDismissable() const
void RootController::setFullscreen(const bool fullscreen)
{
- m_fullscreen = fullscreen;
+ m_fullscreen = fullscreen;
}
bool RootController::isFullscreen() const
{
- return m_fullscreen;
+ return m_fullscreen;
}
void RootController::constrain(QWidget *widget)
@@ -106,12 +164,13 @@ void RootController::constrain(QWidget *widget)
void RootController::present(QWidget *widget)
{
- if(!widget) return;
-
- if(m_fullscreen)
- widget->showFullScreen();
- else
- widget->show();
-
+ if (!widget)
+ return;
+
+ if (m_fullscreen)
+ widget->showFullScreen();
+ else
+ widget->show();
+
widget->raise();
}
diff --git a/src/main.cpp b/src/main.cpp
index 6b008380..da6e833d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -12,7 +12,7 @@
#include "KovanSerialBridge.h"
#include "CursorManager.h"
#include "SettingsProvider.h"
-
+#include "NetworkSettingsWidget.h"
#include
#include
@@ -57,8 +57,11 @@ int main(int argc, char* argv[])
const bool fullscreen = settings && settings->value("fullscreen", true).toBool();
RootController::ref().setFullscreen(fullscreen);
//GuiSettingsWidget::updateStyle(&device);
-
+
RootController::ref().presentWidget(new HomeWidget(&device));
+ NetworkSettingsWidget *networkWidget = new NetworkSettingsWidget(&device);
+ RootController::ref().addNetworkSettingsStack(networkWidget);
+ RootController::ref().printStack();
return app.exec();
}
diff --git a/ui/NetworkSettingsWidget.ui b/ui/NetworkSettingsWidget.ui
index a3a955d7..5e7ba96f 100644
--- a/ui/NetworkSettingsWidget.ui
+++ b/ui/NetworkSettingsWidget.ui
@@ -250,7 +250,7 @@
- kovanet
+
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter