From 4ce65e82f5865469f392b0d021da588366bc14c3 Mon Sep 17 00:00:00 2001 From: Marc Bartholomaeus Date: Thu, 18 Apr 2013 00:53:12 +0200 Subject: [PATCH] cmake-gui: Add search functions to the context menu of the Output widget Signed-off-by: Alex Neundorf --- Source/QtDialog/CMakeSetupDialog.cxx | 20 ++++++++++++++++++++ Source/QtDialog/CMakeSetupDialog.h | 1 + 2 files changed, 21 insertions(+) diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 3cf799f79..0be45c6c7 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -183,6 +183,10 @@ CMakeSetupDialog::CMakeSetupDialog() this->Output->setFont(outputFont); this->ErrorFormat.setForeground(QBrush(Qt::red)); + this->Output->setContextMenuPolicy(Qt::CustomContextMenu); + connect(this->Output, SIGNAL(customContextMenuRequested(const QPoint&)), + this, SLOT(doOutputContextMenu(const QPoint &))); + // start the cmake worker thread this->CMakeThread = new QCMakeThread(this); QObject::connect(this->CMakeThread, SIGNAL(cmakeInitialized()), @@ -1160,6 +1164,22 @@ void CMakeSetupDialog::setSearchFilter(const QString& str) this->CacheValues->setSearchFilter(str); } +void CMakeSetupDialog::doOutputContextMenu(const QPoint &pt) +{ + QMenu *menu = this->Output->createStandardContextMenu(); + + menu->addSeparator(); + menu->addAction(tr("Find..."), + this, SLOT(doOutputFindDialog())); + menu->addAction(tr("Find Next"), + this, SLOT(doOutputFindNext()), QKeySequence::FindNext); + menu->addAction(tr("Find Previous"), + this, SLOT(doOutputFindPrev()), QKeySequence::FindPrevious); + + menu->exec(this->Output->mapToGlobal(pt)); + delete menu; +} + void CMakeSetupDialog::doOutputFindDialog() { QStringList strings(this->FindHistory); diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h index 88fefccf3..100834d32 100644 --- a/Source/QtDialog/CMakeSetupDialog.h +++ b/Source/QtDialog/CMakeSetupDialog.h @@ -77,6 +77,7 @@ protected slots: bool doConfigureInternal(); bool doGenerateInternal(); void exitLoop(int); + void doOutputContextMenu(const QPoint &); void doOutputFindDialog(); void doOutputFindNext(bool directionForward = true); void doOutputFindPrev();