mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Descubrimiento autom?tico de la direcci?n ip local (BETA)
This commit is contained in:
parent
51b62edc71
commit
b0cfaaf13c
@ -6,6 +6,7 @@
|
||||
|
||||
//interfaz al servidor
|
||||
LibraryWindow * mw;
|
||||
Startup * s;
|
||||
|
||||
int main( int argc, char ** argv )
|
||||
{
|
||||
@ -21,7 +22,7 @@ int main( int argc, char ** argv )
|
||||
mw->resize(800,480);
|
||||
mw->showMaximized();
|
||||
|
||||
Startup * s = new Startup();
|
||||
s = new Startup();
|
||||
s->start();
|
||||
|
||||
return app.exec();
|
||||
|
@ -73,5 +73,9 @@ Startup::Startup()
|
||||
|
||||
}
|
||||
|
||||
QString Startup::getPort()
|
||||
{
|
||||
return QString("%1").arg(listener->serverPort());
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,6 +24,8 @@ public:
|
||||
void start();
|
||||
/** Stop the server */
|
||||
void stop();
|
||||
|
||||
QString getPort();
|
||||
protected:
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,13 @@
|
||||
#include "server_config_dialog.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QGridLayout>
|
||||
#include <QNetworkInterface>
|
||||
#include <QHostInfo>
|
||||
#include <QHostAddress>
|
||||
|
||||
#include "startup.h"
|
||||
|
||||
extern Startup * s;
|
||||
|
||||
ServerConfigDialog::ServerConfigDialog(QWidget * parent)
|
||||
:QDialog(parent)
|
||||
@ -21,7 +27,28 @@ ServerConfigDialog::ServerConfigDialog(QWidget * parent)
|
||||
|
||||
void ServerConfigDialog::generateQR()
|
||||
{
|
||||
generateQR("192.168.2.110:8080");
|
||||
//QString items;
|
||||
//foreach(QNetworkInterface interface, QNetworkInterface::allInterfaces())
|
||||
//{
|
||||
// if (~interface.flags() & QNetworkInterface::IsLoopBack)//interface.flags().testFlag(QNetworkInterface::IsRunning))
|
||||
// foreach (QNetworkAddressEntry entry, interface.addressEntries())
|
||||
// {
|
||||
// if ( interface.hardwareAddress() != "00:00:00:00:00:00" && entry.ip().toString().contains("."))
|
||||
// items.append(interface.name() + entry.ip().toString());
|
||||
// }
|
||||
//}
|
||||
|
||||
QString dir;
|
||||
QList<QHostAddress> list = QHostInfo::fromName( QHostInfo::localHostName() ).addresses();
|
||||
foreach(QHostAddress add, list)
|
||||
{
|
||||
dir = add.toString();
|
||||
if(dir.contains("."))
|
||||
break;
|
||||
}
|
||||
generateQR(dir+":"+s->getPort());
|
||||
//qrCode->setText(dir+":8080");
|
||||
|
||||
}
|
||||
|
||||
void ServerConfigDialog::generateQR(const QString & serverAddress)
|
||||
|
Loading…
Reference in New Issue
Block a user