@@ -68,18 +68,23 @@ MonaiLabelTool::~MonaiLabelTool() {}
6868// ---------------------------------------------------------------------------
6969void MonaiLabelTool::triggerUpdateView () { Q_EMIT update_view (); }
7070
71+ // ---------------------------------------------------------------------------
72+ void MonaiLabelTool::set_connect_button () {
73+ Style::apply_normal_button_style (ui_->connectServerButton );
74+ ui_->connectServerButton ->setText (" Connect Server" );
75+ ui_->connectServerButton ->setIcon (QIcon (" :/Studio/Images/connect.png" ));
76+ ui_->connectServerButton ->setEnabled (true );
77+ ui_->serverAddressField ->setEnabled (true );
78+ }
79+
7180// ---------------------------------------------------------------------------
7281void MonaiLabelTool::onConnectServer () {
7382 if (tool_is_running_ && monai_label_job_) {
7483 ui_->connectServerButton ->setText (" Disconnecting..." );
7584 monai_label_job_->abort ();
7685 shutdown ();
7786 SW_STATUS (" Server disconnected successfully." );
78- Style::apply_normal_button_style (ui_->connectServerButton );
79- ui_->connectServerButton ->setText (" Connect Server" );
80- ui_->connectServerButton ->setIcon (QIcon (" :/Studio/Images/connect.png" ));
81- ui_->connectServerButton ->setEnabled (true );
82- ui_->serverAddressField ->setEnabled (true );
87+ set_connect_button ();
8388 enable_actions ();
8489 session_->get_project ()->save ();
8590 monai_label_job_ = nullptr ;
@@ -118,7 +123,9 @@ void MonaiLabelTool::enable_actions() {
118123 ui_->runSegmentationButton ->setEnabled (false );
119124 ui_->submitLabelButton ->setEnabled (false );
120125 std::string feature_name = MonaiLabelUtils::getFeatureName (session_);
121- if (!feature_name.empty ()) session_->set_image_name (feature_name);
126+ if (!feature_name.empty ()) {
127+ session_->set_image_name (feature_name);
128+ }
122129}
123130
124131// ---------------------------------------------------------------------------
@@ -174,7 +181,12 @@ void MonaiLabelTool::runSegmentationTool() {
174181}
175182
176183// ---------------------------------------------------------------------------
177- void MonaiLabelTool::handleClientInitialized () {
184+ void MonaiLabelTool::handleClientInitialized (bool success) {
185+ if (!success) {
186+ SW_LOG (" Connection failed" );
187+ set_connect_button ();
188+ return ;
189+ }
178190 SW_LOG (" ✅ Connection successfully established to the server, continue with segmentation!" );
179191 tool_is_running_ = true ;
180192 if (session_->get_shapes ().size () > 1 ) {
0 commit comments