Changeset View
Changeset View
Standalone View
Standalone View
kcm/kcm.cpp
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | 70 | { | |||
---|---|---|---|---|---|
72 | m_ui->setupUi(mainWidget); | 72 | m_ui->setupUi(mainWidget); | ||
73 | 73 | | |||
74 | KDeclarative::KDeclarative kdeclarative; | 74 | KDeclarative::KDeclarative kdeclarative; | ||
75 | kdeclarative.setDeclarativeEngine(m_ui->connectionView->engine()); | 75 | kdeclarative.setDeclarativeEngine(m_ui->connectionView->engine()); | ||
76 | kdeclarative.setTranslationDomain(QStringLiteral(TRANSLATION_DOMAIN)); | 76 | kdeclarative.setTranslationDomain(QStringLiteral(TRANSLATION_DOMAIN)); | ||
77 | kdeclarative.setupEngine(m_ui->connectionView->engine()); | 77 | kdeclarative.setupEngine(m_ui->connectionView->engine()); | ||
78 | kdeclarative.setupContext(); | 78 | kdeclarative.setupContext(); | ||
79 | 79 | | |||
80 | // Check if we can use AP mode to identify security type | ||||
81 | bool useApMode = false; | ||||
82 | bool foundInactive = false; | ||||
83 | | ||||
84 | NetworkManager::WirelessDevice::Ptr wifiDev; | ||||
85 | | ||||
86 | for (const NetworkManager::Device::Ptr &device : NetworkManager::networkInterfaces()) { | ||||
87 | if (device->type() == NetworkManager::Device::Wifi) { | ||||
88 | wifiDev = device.objectCast<NetworkManager::WirelessDevice>(); | ||||
89 | if (wifiDev) { | ||||
90 | if (!wifiDev->isActive()) { | ||||
91 | foundInactive = true; | ||||
92 | } else { | ||||
93 | // Prefer previous device if it was inactive | ||||
94 | if (foundInactive) { | ||||
95 | break; | ||||
96 | } | ||||
97 | } | ||||
98 | | ||||
99 | if (wifiDev->wirelessCapabilities().testFlag(NetworkManager::WirelessDevice::ApCap)) { | ||||
100 | useApMode = true; | ||||
101 | } | ||||
102 | | ||||
103 | // We prefer inactive wireless card with AP capabilities | ||||
104 | if (foundInactive && useApMode) { | ||||
105 | break; | ||||
106 | } | ||||
107 | } | ||||
108 | } | ||||
109 | } | ||||
110 | | ||||
80 | m_ui->connectionView->setMinimumWidth(300); | 111 | m_ui->connectionView->setMinimumWidth(300); | ||
81 | m_ui->connectionView->rootContext()->setContextProperty("alternateBaseColor", mainWidget->palette().color(QPalette::Active, QPalette::AlternateBase)); | 112 | m_ui->connectionView->rootContext()->setContextProperty("alternateBaseColor", mainWidget->palette().color(QPalette::Active, QPalette::AlternateBase)); | ||
82 | m_ui->connectionView->rootContext()->setContextProperty("backgroundColor", mainWidget->palette().color(QPalette::Active, QPalette::Window)); | 113 | m_ui->connectionView->rootContext()->setContextProperty("backgroundColor", mainWidget->palette().color(QPalette::Active, QPalette::Window)); | ||
83 | m_ui->connectionView->rootContext()->setContextProperty("baseColor", mainWidget->palette().color(QPalette::Active, QPalette::Base)); | 114 | m_ui->connectionView->rootContext()->setContextProperty("baseColor", mainWidget->palette().color(QPalette::Active, QPalette::Base)); | ||
84 | m_ui->connectionView->rootContext()->setContextProperty("highlightColor", mainWidget->palette().color(QPalette::Active, QPalette::Highlight)); | 115 | m_ui->connectionView->rootContext()->setContextProperty("highlightColor", mainWidget->palette().color(QPalette::Active, QPalette::Highlight)); | ||
85 | m_ui->connectionView->rootContext()->setContextProperty("textColor", mainWidget->palette().color(QPalette::Active, QPalette::Text)); | 116 | m_ui->connectionView->rootContext()->setContextProperty("textColor", mainWidget->palette().color(QPalette::Active, QPalette::Text)); | ||
86 | m_ui->connectionView->rootContext()->setContextProperty("connectionModified", false); | 117 | m_ui->connectionView->rootContext()->setContextProperty("connectionModified", false); | ||
118 | m_ui->connectionView->rootContext()->setContextProperty("useApMode", useApMode); | ||||
87 | m_ui->connectionView->setClearColor(Qt::transparent); | 119 | m_ui->connectionView->setClearColor(Qt::transparent); | ||
88 | m_ui->connectionView->setResizeMode(QQuickWidget::SizeRootObjectToView); | 120 | m_ui->connectionView->setResizeMode(QQuickWidget::SizeRootObjectToView); | ||
89 | m_ui->connectionView->setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kcm_networkmanagement/qml/main.qml")))); | 121 | m_ui->connectionView->setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kcm_networkmanagement/qml/main.qml")))); | ||
90 | 122 | | |||
91 | QObject *rootItem = m_ui->connectionView->rootObject(); | 123 | QObject *rootItem = m_ui->connectionView->rootObject(); | ||
92 | connect(rootItem, SIGNAL(selectedConnectionChanged(QString)), this, SLOT(onSelectedConnectionChanged(QString))); | 124 | connect(rootItem, SIGNAL(selectedConnectionChanged(QString)), this, SLOT(onSelectedConnectionChanged(QString))); | ||
93 | connect(rootItem, SIGNAL(requestCreateConnection(int,QString,QString,bool)), this, SLOT(onRequestCreateConnection(int,QString,QString,bool))); | 125 | connect(rootItem, SIGNAL(requestCreateConnection(int,QString,QString,bool)), this, SLOT(onRequestCreateConnection(int,QString,QString,bool))); | ||
94 | connect(rootItem, SIGNAL(requestExportConnection(QString)), this, SLOT(onRequestExportConnection(QString))); | 126 | connect(rootItem, SIGNAL(requestExportConnection(QString)), this, SLOT(onRequestExportConnection(QString))); | ||
▲ Show 20 Lines • Show All 477 Lines • Show Last 20 Lines |