diff --git a/src/gui/Src/Gui/AttachDialog.cpp b/src/gui/Src/Gui/AttachDialog.cpp index 5c26533b..cb862189 100644 --- a/src/gui/Src/Gui/AttachDialog.cpp +++ b/src/gui/Src/Gui/AttachDialog.cpp @@ -1,5 +1,6 @@ #include "AttachDialog.h" #include "ui_AttachDialog.h" +#include "SearchListView.h" #include AttachDialog::AttachDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AttachDialog) @@ -9,26 +10,43 @@ AttachDialog::AttachDialog(QWidget* parent) : QDialog(parent), ui(new Ui::Attach setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint); #endif - //setup actions + // Setup actions/shortcuts + // + // Enter key as shortcut for "Attach" mAttachAction = new QAction("Attach", this); mAttachAction->setShortcut(QKeySequence("enter")); connect(mAttachAction, SIGNAL(triggered()), this, SLOT(on_btnAttach_clicked())); + // F5 as shortcut to refresh view mRefreshAction = new QAction("Refresh", this); mRefreshAction->setShortcut(QKeySequence("F5")); connect(mRefreshAction, SIGNAL(triggered()), this, SLOT(refresh())); this->addAction(mRefreshAction); + // Create search view (regex disabled) + mSearchListView = new SearchListView(false); + mSearchListView->mSearchStartCol = 1; + ui->verticalLayout->insertWidget(0, mSearchListView); //setup process list - int charwidth = ui->listProcesses->getCharWidth(); - ui->listProcesses->addColumnAt(charwidth * sizeof(int) * 2 + 8, "PID", true); - ui->listProcesses->addColumnAt(800, "Path", true); - ui->listProcesses->setDrawDebugOnly(false); - connect(ui->listProcesses, SIGNAL(enterPressedSignal()), this, SLOT(on_btnAttach_clicked())); - connect(ui->listProcesses, SIGNAL(doubleClickedSignal()), this, SLOT(on_btnAttach_clicked())); - connect(ui->listProcesses, SIGNAL(contextMenuSignal(QPoint)), this, SLOT(processListContextMenu(QPoint))); + int charwidth = mSearchListView->mList->getCharWidth(); + mSearchListView->mList->addColumnAt(charwidth * sizeof(int) * 2 + 8, "PID", true); + mSearchListView->mList->addColumnAt(800, "Path", true); + mSearchListView->mList->setDrawDebugOnly(false); + charwidth = mSearchListView->mSearchList->getCharWidth(); + mSearchListView->mSearchList->addColumnAt(charwidth * sizeof(int) * 2 + 8, "PID", true); + mSearchListView->mSearchList->addColumnAt(800, "Path", true); + mSearchListView->mSearchList->setDrawDebugOnly(false); + + connect(mSearchListView, SIGNAL(enterPressedSignal()), this, SLOT(on_btnAttach_clicked())); + connect(mSearchListView, SIGNAL(doubleClickedSignal()), this, SLOT(on_btnAttach_clicked())); + connect(mSearchListView, SIGNAL(listContextMenuSignal(QMenu*)), this, SLOT(processListContextMenu(QMenu*))); + + // Highlight the search box + mSearchListView->mCurList->setFocus(); + + // Populate the process list atleast once refresh(); } @@ -39,40 +57,35 @@ AttachDialog::~AttachDialog() void AttachDialog::refresh() { - ui->listProcesses->setRowCount(0); - ui->listProcesses->setTableOffset(0); + mSearchListView->mCurList->setRowCount(0); + mSearchListView->mCurList->setTableOffset(0); DBGPROCESSINFO* entries; int count; if(!DbgFunctions()->GetProcessList(&entries, &count)) return; - ui->listProcesses->setRowCount(count); + mSearchListView->mCurList->setRowCount(count); for(int i = 0; i < count; i++) { - ui->listProcesses->setCellContent(i, 0, QString().sprintf("%.8X", entries[i].dwProcessId)); - ui->listProcesses->setCellContent(i, 1, QString(entries[i].szExeFile)); + mSearchListView->mCurList->setCellContent(i, 0, QString().sprintf("%.8X", entries[i].dwProcessId)); + mSearchListView->mCurList->setCellContent(i, 1, QString(entries[i].szExeFile)); } - ui->listProcesses->setSingleSelection(0); - ui->listProcesses->reloadData(); + mSearchListView->mCurList->setSingleSelection(0); + mSearchListView->mCurList->reloadData(); } void AttachDialog::on_btnAttach_clicked() { - QString pid = ui->listProcesses->getCellContent(ui->listProcesses->getInitialSelection(), 0); + QString pid = mSearchListView->mCurList->getCellContent(mSearchListView->mList->getInitialSelection(), 0); DbgCmdExec(QString("attach " + pid).toUtf8().constData()); accept(); } -void AttachDialog::processListContextMenu(const QPoint & pos) +void AttachDialog::processListContextMenu(QMenu* wMenu) { - QMenu* wMenu = new QMenu(this); //create context menu + // Don't show menu options if nothing is listed + if(!mSearchListView->mCurList->getRowCount()) + return; + wMenu->addAction(mAttachAction); wMenu->addAction(mRefreshAction); - QMenu wCopyMenu("&Copy", this); - ui->listProcesses->setupCopyMenu(&wCopyMenu); - if(wCopyMenu.actions().length()) - { - wMenu->addSeparator(); - wMenu->addMenu(&wCopyMenu); - } - wMenu->exec(mapToGlobal(pos)); //execute context menu } diff --git a/src/gui/Src/Gui/AttachDialog.h b/src/gui/Src/Gui/AttachDialog.h index 55c49ca4..11086d70 100644 --- a/src/gui/Src/Gui/AttachDialog.h +++ b/src/gui/Src/Gui/AttachDialog.h @@ -2,6 +2,7 @@ #define ATTACHDIALOG_H #include +#include "SearchListView.h" namespace Ui { @@ -19,10 +20,13 @@ public: private slots: void on_btnAttach_clicked(); void refresh(); - void processListContextMenu(const QPoint & pos); + void processListContextMenu(QMenu* wMenu); private: Ui::AttachDialog* ui; + + SearchListView* mSearchListView; + QAction* mAttachAction; QAction* mRefreshAction; }; diff --git a/src/gui/Src/Gui/AttachDialog.ui b/src/gui/Src/Gui/AttachDialog.ui index e736d5db..c481937e 100644 --- a/src/gui/Src/Gui/AttachDialog.ui +++ b/src/gui/Src/Gui/AttachDialog.ui @@ -6,8 +6,8 @@ 0 0 - 611 - 293 + 800 + 400 @@ -38,22 +38,6 @@ QLayout::SetDefaultConstraint - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - @@ -119,14 +103,6 @@ - - - StdTable - QFrame -
StdTable.h
- 1 -
-