6 #include <QIntValidator>
8 #include "ui_dbusserveraddressselector.h"
15 using namespace swift::config;
17 using namespace swift::misc::network;
21 CDBusServerAddressSelector::CDBusServerAddressSelector(QWidget *parent)
29 ui->cb_DBusServerAddress->addItems(CNetworkUtils::getKnownLocalIpV4Addresses());
30 ui->cb_DBusServerAddress->setCurrentIndex(0);
33 ui->le_DBusServerPort->setValidator(
new QIntValidator(0, 65535,
this));
34 connect(ui->rb_DBusP2P, &QRadioButton::released,
this, &CDBusServerAddressSelector::onRadioButtonReleased);
35 connect(ui->rb_DBusSession, &QRadioButton::released,
this, &CDBusServerAddressSelector::onRadioButtonReleased);
36 connect(ui->rb_DBusSystem, &QRadioButton::released,
this, &CDBusServerAddressSelector::onRadioButtonReleased);
38 connect(ui->cb_DBusServerAddress, &QComboBox::currentTextChanged,
this,
46 if (!this->
isP2P()) {
return {}; }
47 return CDBusServer::p2pAddress(ui->cb_DBusServerAddress->currentText() +
":" + ui->le_DBusServerPort->text());
52 if (ui->rb_DBusSession->isChecked()) {
return CDBusServer::sessionBusAddress(); }
53 if (ui->rb_DBusSystem->isChecked()) {
return CDBusServer::systemBusAddress(); }
66 const QString dBusLc = dBus.toLower().trimmed();
68 CDBusServer::dBusAddressToHostAndPort(dBusLc, host, port);
71 if (ui->cb_DBusServerAddress->findText(host) < 0) { ui->cb_DBusServerAddress->addItem(host); }
72 ui->cb_DBusServerAddress->setCurrentText(host);
73 ui->le_DBusServerPort->setText(port);
79 const QString dBusLc = dBus.toLower().trimmed();
80 if (dBusLc.isEmpty() || dBusLc.startsWith(
"session")) { ui->rb_DBusSession->setChecked(
true); }
81 else if (dBusLc.startsWith(
"sys")) { ui->rb_DBusSystem->setChecked(
true); }
84 ui->rb_DBusP2P->setChecked(
true);
86 CDBusServer::dBusAddressToHostAndPort(dBusLc, host, port);
89 if (ui->cb_DBusServerAddress->findText(host) < 0) { ui->cb_DBusServerAddress->addItem(host); }
90 ui->cb_DBusServerAddress->setCurrentText(host);
91 ui->le_DBusServerPort->setText(port);
94 this->onRadioButtonReleased();
99 const bool wasChecked = ui->rb_DBusSystem->isChecked();
100 ui->rb_DBusSystem->setVisible(visible);
101 if (!visible && wasChecked) { ui->rb_DBusSession->setChecked(
true); }
106 ui->rb_DBusP2P->setVisible(visible);
107 ui->fr_DBusServerAddress->setVisible(visible);
116 void CDBusServerAddressSelector::onRadioButtonReleased()
118 const bool p2p = this->
isP2P();
119 ui->le_DBusServerPort->setEnabled(p2p);
120 ui->cb_DBusServerAddress->setEnabled(p2p);
QString getCmdDBusAddressValue() const
DBus address from CMD line, otherwise "".
Select DBus address such as session P2P, ...
QStringList getDBusCmdLineArgs() const
Get DBus cmd.line arguments.
QString getDBusAddress() const
DBus address for all 3 options.
QString getP2PAddress() const
DBus address for P2P or empty.
void editingFinished()
Is being edited.
void setSystemDBusVisible(bool visible)
Set system DBus radio button visible/invisible.
void setP2PDBusVisible(bool visible)
P2P visible.
virtual ~CDBusServerAddressSelector()
Dtor.
void setDefaultP2PAddress(const QString &address)
Set default P2P address.
bool isP2P() const
P2P DBus address.
void set(const QString &dBus)
Set values.
void setForXSwiftBus()
Set to be used for xswiftbus.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
High level reusable GUI components.
Free functions in swift::misc.