Skip to content

Commit d452327

Browse files
committed
Working on new replace with menu
1 parent 32451d8 commit d452327

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/Interface/Application/ModuleWidget.cc

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ namespace Gui {
7474
<< new QAction("Help", parent)
7575
<< new QAction("Edit Notes...", parent)
7676
<< new QAction("Duplicate", parent)
77-
<< new QAction("Replace With", parent)
77+
<< new QAction("Replace With...", parent)
7878
//<< disabled(new QAction("Ignore*", parent))
7979
<< new QAction("Show Log", parent)
8080
//<< disabled(new QAction("Make Sub-Network", parent)) // Issue #287
@@ -527,22 +527,35 @@ void ModuleWidget::setupModuleActions()
527527
|| theModule_->get_id().name_ == "Subnet")
528528
actionsMenu_->getMenu()->removeAction(actionsMenu_->getAction("Duplicate"));
529529
if (theModule_->get_id().name_ == "Subnet")
530-
actionsMenu_->getMenu()->removeAction(actionsMenu_->getAction("Replace With"));
530+
actionsMenu_->getMenu()->removeAction(actionsMenu_->getAction("Replace With..."));
531531

532532
connectNoteEditorToAction(actionsMenu_->getAction("Notes"));
533533
connectUpdateNote(this);
534534
}
535535

536536
void ModuleWidget::postLoadAction()
537537
{
538-
auto replaceWith = actionsMenu_->getAction("Replace With");
538+
auto replaceWith = actionsMenu_->getAction("Replace With...");
539+
connect(replaceWith, SIGNAL(triggered()), this, SLOT(showReplaceWithWidget()));
540+
replaceWithWidget_ = new QPushButton(this);
539541
auto menu = new QMenu(this);
540-
replaceWith->setMenu(menu);
542+
replaceWithWidget_->setMenu(menu);
541543
fillReplaceWithMenu();
542544
connect(this, SIGNAL(connectionAdded(const SCIRun::Dataflow::Networks::ConnectionDescription&)), this, SLOT(fillReplaceWithMenu()));
543545
connect(this, SIGNAL(connectionDeleted(const SCIRun::Dataflow::Networks::ConnectionId&)), this, SLOT(fillReplaceWithMenu()));
544546
}
545547

548+
void ModuleWidget::showReplaceWithWidget()
549+
{
550+
qDebug() << __FUNCTION__;
551+
QMessageBox msgBox;
552+
QPushButton *connectButton = msgBox.addButton("Replacement", QMessageBox::ActionRole);
553+
connectButton->setMenu(replaceWithWidget_->menu());
554+
QPushButton *abortButton = msgBox.addButton(QMessageBox::Abort);
555+
msgBox.setText("Press button to replace.");
556+
msgBox.exec();
557+
}
558+
546559
bool ModuleWidget::guiVisible() const
547560
{
548561
if (dockable_)
@@ -574,7 +587,7 @@ void ModuleWidget::menuFunction()
574587

575588
QMenu* ModuleWidget::getReplaceWithMenu()
576589
{
577-
return actionsMenu_->getAction("Replace With")->menu();
590+
return replaceWithWidget_->menu();
578591
}
579592

580593
void ModuleWidget::replaceModuleWith()

src/Interface/Application/ModuleWidget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ private Q_SLOTS:
242242
void changeExecuteButtonToStop();
243243
void updateDockWidgetProperties(bool isFloating);
244244
void incomingConnectionStateChanged(bool disabled, int index);
245+
void showReplaceWithWidget();
245246
protected:
246247
virtual void enterEvent(QEvent* event) override;
247248
virtual void leaveEvent(QEvent* event) override;
@@ -253,6 +254,7 @@ private Q_SLOTS:
253254
bool executedOnce_, skipExecuteDueToFatalError_, disabled_;
254255
std::atomic<bool> errored_;
255256
int previousPageIndex_ {0};
257+
QPushButton* replaceWithWidget_{nullptr};
256258

257259
SCIRun::Dataflow::Networks::ModuleHandle theModule_;
258260
std::atomic<int> previousModuleState_;

0 commit comments

Comments
 (0)