From a8e8a77bc51fc87a5f3c4fec71070b5534659ad8 Mon Sep 17 00:00:00 2001 From: Rym Bouabid Date: Tue, 19 Sep 2023 12:49:14 +0200 Subject: [PATCH] Revamp Local Fortune Server Example: Allow specifying the server name The server used to hardcode the name while the client allows the user to specify it. The server's UI is adjusted to let the user first specify the server name he wants to listen to and second stop listening to the current server. Task-number: QTBUG-117064 Pick-to: 6.6 6.5 Change-Id: I80fc976151ead7a181fbc32080597277bc515313 Reviewed-by: Ivan Solovev --- .../doc/images/localfortuneserver-example.png | Bin 5715 -> 14948 bytes .../corelib/ipc/localfortuneserver/server.cpp | 86 +++++++++++++----- .../corelib/ipc/localfortuneserver/server.h | 12 +++ 3 files changed, 77 insertions(+), 21 deletions(-) diff --git a/examples/corelib/ipc/doc/images/localfortuneserver-example.png b/examples/corelib/ipc/doc/images/localfortuneserver-example.png index 2f04c7528eb617dbed28744de783b30dff13572d..778c7c85b042ef3bbc4913ba4092896675465b43 100644 GIT binary patch literal 14948 zcmeI2WpEr%vfw3IjFtr!Gcz+-vc+IASH)SP&2p1ToPcav&g}%)s+#Xh`6Vt+)QDj{(|$GbNW8haZwz8jVzr?eKA+ zreI<7(;A`uw}XSuLso4J)v)uU$le*b4N@*L*lKT)DlS!xmiTy$OohVBQ_vUMRGqvM zr>*$#o*c0d)7@1h|5?!=)5fPZ^^AahuN-;=Te>X5T z5p}gSkav|<&~r7@O<^npfFtFDlaJDeFwBvH-CHl)R7x4VgWqKllzfA1S zc!^Y`WC*@n*%}bA(6P`l&Kk&&{Sf}U3!ubHWNdG5%|%b| z#7t*pYedh;$;nC2z(mi)L<_W_wR5qw*Kww`v?KoG;%`2F7})9AnpoSLSXmPM@u{P0 zC)rbPV+WY;JF2_>payf6_9tu>7U{H4=a@NXIa z=jr-Sy8f*U{9DHVdAk1pN*C-u;LgAjNOVp>blb1ACIez0xSgPw0yOY&ht>}U0U-bp z`yrsj9Wxt4m3HaWm*Fi};IyvrVq)fJ7jBnt=TtX@|;h^~l zG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c&p9grpst@#~3Y!D^ zX19!@!*KyT??mJwlbBeQkSw99RE0md^b74Z?(aHsi00p0TQbP$89UtEdo!lee(m7hxQW-#DE@U^rtI2|8Uw4nYuQ&nF)EDQLhF){j z!G{d}B-o)lfCR9{Hg38z94us49fs$Qw5>`x1V$nu zlQAWMS|2bWLl9Q+d*f#>05DGaSLjMU=?&V|#4Hkfhoc;9n6VcloeX1AfWzK}el@haj>+26=>VAm>#EbqR zIN$wIf0VdgOQ%Rc7@V>{#VZhL$2!##@jN{JUd_D#Yf{!!+VkhnUs90*I|Id@ARKKY z?>$2p$^?Bk%QVovlyAJ@1E*tVS0Q(5QHiDA8R+Y-zmjPbMhn6ZJme!1@L$NvF-^>r2i diff --git a/examples/corelib/ipc/localfortuneserver/server.cpp b/examples/corelib/ipc/localfortuneserver/server.cpp index dcf13b0f37..77322e03bd 100644 --- a/examples/corelib/ipc/localfortuneserver/server.cpp +++ b/examples/corelib/ipc/localfortuneserver/server.cpp @@ -3,32 +3,33 @@ #include "server.h" +#include #include #include #include +#include #include #include #include #include +using namespace Qt::StringLiterals; + +static const QString idleStateText = QObject::tr("Press \"Listen\" to start the server"); + Server::Server(QWidget *parent) - : QDialog(parent) + : QDialog(parent), + server(new QLocalServer(this)), + hostLineEdit(new QLineEdit(u"fortune"_s)), + statusLabel(new QLabel(idleStateText)), + listenButton(new QPushButton(tr("Listen"))), + stopListeningButton(new QPushButton(tr("Stop Listening"))) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - server = new QLocalServer(this); - if (!server->listen("fortune")) { - QMessageBox::critical(this, tr("Local Fortune Server"), - tr("Unable to start the server: %1.") - .arg(server->errorString())); - close(); - return; - } - - QLabel *statusLabel = new QLabel; statusLabel->setWordWrap(true); - statusLabel->setText(tr("The server is running.\n" - "Run the Local Fortune Client example now.")); + + stopListeningButton->setDisabled(true); fortunes << tr("You've been leading a dog's life. Stay off the furniture.") << tr("You've got to think about tomorrow.") @@ -38,21 +39,64 @@ Server::Server(QWidget *parent) << tr("You cannot kill time without injuring eternity.") << tr("Computers are not intelligent. They only think they are."); + QLabel *hostLabel = new QLabel(tr("Server name:")); + + connect(server, &QLocalServer::newConnection, this, &Server::sendFortune); + connect(hostLineEdit, &QLineEdit::textChanged, this, &Server::toggleListenButton); + connect(listenButton, &QPushButton::clicked, this, &Server::listenToServer); + connect(stopListeningButton, &QPushButton::clicked,this, &Server::stopListening); + QPushButton *quitButton = new QPushButton(tr("Quit")); quitButton->setAutoDefault(false); connect(quitButton, &QPushButton::clicked, this, &Server::close); - connect(server, &QLocalServer::newConnection, this, &Server::sendFortune); - QHBoxLayout *buttonLayout = new QHBoxLayout; - buttonLayout->addStretch(1); - buttonLayout->addWidget(quitButton); - buttonLayout->addStretch(1); + QDialogButtonBox *buttonBox = new QDialogButtonBox; + buttonBox->addButton(listenButton, QDialogButtonBox::ActionRole); + buttonBox->addButton(stopListeningButton, QDialogButtonBox::ActionRole); + buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole); - QVBoxLayout *mainLayout = new QVBoxLayout(this); - mainLayout->addWidget(statusLabel); - mainLayout->addLayout(buttonLayout); + QGridLayout *mainLayout = new QGridLayout(this); + mainLayout->addWidget(hostLabel, 0, 0); + mainLayout->addWidget(hostLineEdit, 0, 1); + mainLayout->addWidget(statusLabel, 2, 0, 3, 2); + mainLayout->addWidget(buttonBox, 10, 0, 2, 2); setWindowTitle(QGuiApplication::applicationDisplayName()); + hostLineEdit->setFocus(); +} + +void Server::listenToServer() +{ + name = hostLineEdit->text(); + if (!server->listen(name)) { + QMessageBox::critical(this, tr("Local Fortune Server"), + tr("Unable to start the server: %1.") + .arg(server->errorString())); + name.clear(); + return; + } + statusLabel->setText(tr("The server is running.\n" + "Run the Local Fortune Client example now.")); + toggleListenButton(); +} + +void Server::stopListening() +{ + server->close(); + name.clear(); + statusLabel->setText(idleStateText); + toggleListenButton(); +} + +void Server::toggleListenButton() +{ + if (server->isListening()) { + listenButton->setDisabled(true); + stopListeningButton->setEnabled(true); + } else { + listenButton->setEnabled(!hostLineEdit->text().isEmpty()); + stopListeningButton->setDisabled(true); + } } void Server::sendFortune() diff --git a/examples/corelib/ipc/localfortuneserver/server.h b/examples/corelib/ipc/localfortuneserver/server.h index 1aa63c8d22..1efba8fca9 100644 --- a/examples/corelib/ipc/localfortuneserver/server.h +++ b/examples/corelib/ipc/localfortuneserver/server.h @@ -6,7 +6,10 @@ #include #include +#include +#include #include +#include class Server : public QDialog { @@ -17,8 +20,17 @@ public: private: void sendFortune(); + void toggleListenButton(); + void listenToServer(); + void stopListening(); + QLocalServer *server; + QLineEdit *hostLineEdit; + QLabel *statusLabel; + QPushButton *listenButton; + QPushButton *stopListeningButton; QStringList fortunes; + QString name; }; #endif