mirror of
https://github.com/x64dbg/x64dbg.git
synced 2024-11-27 06:40:24 +00:00
Add app icon to attach dialog
This commit is contained in:
parent
714430c2ac
commit
08eaab1b3e
23
src/gui/Src/BasicView/StdIconSearchListView.cpp
Normal file
23
src/gui/Src/BasicView/StdIconSearchListView.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include "StdIconSearchListView.h"
|
||||
|
||||
StdIconSearchListView::StdIconSearchListView(QWidget* parent, bool enableRegex, bool enableLock)
|
||||
: StdIconSearchListView(parent, enableRegex, enableLock, new StdTableSearchList(new StdIconTable(), new StdIconTable()))
|
||||
{
|
||||
}
|
||||
|
||||
StdIconSearchListView::StdIconSearchListView(QWidget* parent, bool enableRegex, bool enableLock, StdTableSearchList* tableSearchList)
|
||||
: StdSearchListView(parent, enableRegex, enableLock, tableSearchList)
|
||||
{
|
||||
}
|
||||
|
||||
void StdIconSearchListView::setIconColumn(int c)
|
||||
{
|
||||
qobject_cast<StdIconTable*>(stdList())->setIconColumn(c);
|
||||
qobject_cast<StdIconTable*>(stdSearchList())->setIconColumn(c);
|
||||
}
|
||||
|
||||
void StdIconSearchListView::setRowIcon(int r, const QIcon & icon)
|
||||
{
|
||||
clearFilter();
|
||||
qobject_cast<StdIconTable*>(stdList())->setRowIcon(r, icon);
|
||||
}
|
25
src/gui/Src/BasicView/StdIconSearchListView.h
Normal file
25
src/gui/Src/BasicView/StdIconSearchListView.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef STDICONSEARCHLISTVIEW_H
|
||||
#define STDICONSEARCHLISTVIEW_H
|
||||
|
||||
#include "StdSearchListView.h"
|
||||
#include "StdIconTable.h"
|
||||
|
||||
class StdIconSearchListView : public StdSearchListView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
StdIconSearchListView(QWidget* parent, bool enableRegex, bool enableLock);
|
||||
StdIconSearchListView(QWidget* parent, bool enableRegex, bool enableLock, StdTableSearchList* tableSearchList);
|
||||
|
||||
public slots:
|
||||
void setIconColumn(int c);
|
||||
void setRowIcon(int r, const QIcon & icon);
|
||||
|
||||
private:
|
||||
StdTableSearchList* mSearchListData;
|
||||
|
||||
protected:
|
||||
friend class SymbolView;
|
||||
friend class Bridge;
|
||||
};
|
||||
#endif // STDICONSEARCHLISTVIEW_H
|
80
src/gui/Src/BasicView/StdIconTable.cpp
Normal file
80
src/gui/Src/BasicView/StdIconTable.cpp
Normal file
@ -0,0 +1,80 @@
|
||||
#include "StdIconTable.h"
|
||||
|
||||
/************************************************************************************
|
||||
Data Management
|
||||
************************************************************************************/
|
||||
|
||||
void StdIconTable::setRowIcon(int r, const QIcon & icon)
|
||||
{
|
||||
mIcon.at(r) = icon;
|
||||
}
|
||||
|
||||
QIcon StdIconTable::getRowIcon(int r) const
|
||||
{
|
||||
return mIcon.at(r);
|
||||
}
|
||||
|
||||
void StdIconTable::setIconColumn(int c)
|
||||
{
|
||||
mIconColumn = c;
|
||||
}
|
||||
|
||||
int StdIconTable::getIconColumn() const
|
||||
{
|
||||
return mIconColumn;
|
||||
}
|
||||
|
||||
void StdIconTable::setRowCount(dsint count)
|
||||
{
|
||||
int wRowToAddOrRemove = count - int(mIcon.size());
|
||||
for(int i = 0; i < qAbs(wRowToAddOrRemove); i++)
|
||||
{
|
||||
if(wRowToAddOrRemove > 0)
|
||||
mIcon.push_back(QIcon());
|
||||
else
|
||||
mIcon.pop_back();
|
||||
}
|
||||
StdTable::setRowCount(count);
|
||||
}
|
||||
|
||||
void StdIconTable::sortRows(int column, bool ascending)
|
||||
{
|
||||
auto sortFn = mColumnSortFunctions.at(column);
|
||||
std::vector<size_t> index;
|
||||
index.resize(mData.size());
|
||||
size_t i;
|
||||
for(i = 0; i < mData.size(); i++)
|
||||
{
|
||||
index[i] = i;
|
||||
}
|
||||
std::stable_sort(index.begin(), index.end(), [column, ascending, this, &sortFn](const size_t & a, const size_t & b)
|
||||
{
|
||||
auto less = sortFn(mData.at(a).at(column).text, mData.at(b).at(column).text);
|
||||
return ascending ? less : !less;
|
||||
});
|
||||
auto copy1 = mData;
|
||||
auto copy2 = mIcon;
|
||||
for(i = 0; i < mData.size(); i++)
|
||||
{
|
||||
mData[i] = std::move(copy1[index[i]]);
|
||||
mIcon[i] = std::move(copy2[index[i]]);
|
||||
}
|
||||
}
|
||||
|
||||
QString StdIconTable::paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h)
|
||||
{
|
||||
if(col == mIconColumn)
|
||||
{
|
||||
mIcon.at(rowBase + rowOffset).paint(painter, x, y, h, h);
|
||||
QString wStr = StdTable::paintContent(painter, rowBase, rowOffset, col, x + h, y, w, h);
|
||||
|
||||
if(wStr.length())
|
||||
{
|
||||
painter->setPen(getCellColor(rowBase + rowOffset, col));
|
||||
painter->drawText(QRect(x + 4 + h, y, w - 4 - h, h), Qt::AlignVCenter | Qt::AlignLeft, wStr);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
else
|
||||
return StdTable::paintContent(painter, rowBase, rowOffset, col, x, y, w, h);
|
||||
}
|
27
src/gui/Src/BasicView/StdIconTable.h
Normal file
27
src/gui/Src/BasicView/StdIconTable.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef STDICONTABLE_H
|
||||
#define STDICONTABLE_H
|
||||
|
||||
#include "StdTable.h"
|
||||
|
||||
class StdIconTable : public StdTable
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit StdIconTable(QWidget* parent = 0) : StdTable(parent), mIconColumn(0) {};
|
||||
|
||||
// Data Management
|
||||
void setRowIcon(int r, const QIcon & icon);
|
||||
QIcon getRowIcon(int r) const;
|
||||
void setIconColumn(int c);
|
||||
int getIconColumn() const;
|
||||
void setRowCount(dsint count) override;
|
||||
void sortRows(int column, bool ascending) override;
|
||||
|
||||
QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h) override;
|
||||
|
||||
protected:
|
||||
std::vector<QIcon> mIcon; //listof(row) where row = (listof(col) where col = CellData)
|
||||
int mIconColumn;
|
||||
};
|
||||
|
||||
#endif // STDICONTABLE_H
|
@ -1,7 +1,10 @@
|
||||
#include "StdTableSearchList.h"
|
||||
#include "StdIconTable.h"
|
||||
|
||||
void StdTableSearchList::filter(const QString & filter, FilterType type, int startColumn)
|
||||
{
|
||||
StdIconTable* mSearchIconList = qobject_cast<StdIconTable*>(mSearchList);
|
||||
StdIconTable* mIconList = qobject_cast<StdIconTable*>(mList);
|
||||
mSearchList->setRowCount(0);
|
||||
int rows = mList->getRowCount();
|
||||
int columns = mList->getColumnCount();
|
||||
@ -15,6 +18,8 @@ void StdTableSearchList::filter(const QString & filter, FilterType type, int sta
|
||||
mSearchList->setCellContent(j, k, mList->getCellContent(i, k));
|
||||
mSearchList->setCellUserdata(j, k, mList->getCellUserdata(i, k));
|
||||
}
|
||||
if(mSearchIconList && mIconList)
|
||||
mSearchIconList->setRowIcon(j, mIconList->getRowIcon(i));
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "AttachDialog.h"
|
||||
#include "ui_AttachDialog.h"
|
||||
#include "StdSearchListView.h"
|
||||
#include "StdIconSearchListView.h"
|
||||
#include "StdTable.h"
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
@ -27,7 +27,7 @@ AttachDialog::AttachDialog(QWidget* parent) : QDialog(parent), ui(new Ui::Attach
|
||||
connect(ui->btnRefresh, SIGNAL(clicked()), this, SLOT(refresh()));
|
||||
|
||||
// Create search view (regex disabled)
|
||||
mSearchListView = new StdSearchListView(this, false, false);
|
||||
mSearchListView = new StdIconSearchListView(this, false, false);
|
||||
mSearchListView->mSearchStartCol = 0;
|
||||
ui->verticalLayout->insertWidget(0, mSearchListView);
|
||||
|
||||
@ -38,6 +38,7 @@ AttachDialog::AttachDialog(QWidget* parent) : QDialog(parent), ui(new Ui::Attach
|
||||
mSearchListView->addColumnAt(300, tr("Title"), true);
|
||||
mSearchListView->addColumnAt(500, tr("Path"), true);
|
||||
mSearchListView->addColumnAt(800, tr("Command Line Arguments"), true);
|
||||
mSearchListView->setIconColumn(1); // Name
|
||||
mSearchListView->setDrawDebugOnly(false);
|
||||
|
||||
connect(mSearchListView, SIGNAL(enterPressedSignal()), this, SLOT(on_btnAttach_clicked()));
|
||||
@ -74,6 +75,7 @@ void AttachDialog::refresh()
|
||||
mSearchListView->setCellContent(i, ColTitle, QString(entries[i].szExeMainWindowTitle));
|
||||
mSearchListView->setCellContent(i, ColPath, QString(entries[i].szExeFile));
|
||||
mSearchListView->setCellContent(i, ColCommandLine, QString(entries[i].szExeArgs));
|
||||
mSearchListView->setRowIcon(i, getFileIcon(QString(entries[i].szExeFile)));
|
||||
}
|
||||
mSearchListView->reloadData();
|
||||
mSearchListView->refreshSearchList();
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class StdSearchListView;
|
||||
class StdIconSearchListView;
|
||||
class QMenu;
|
||||
class QAction;
|
||||
|
||||
@ -28,7 +28,7 @@ private slots:
|
||||
|
||||
private:
|
||||
Ui::AttachDialog* ui;
|
||||
StdSearchListView* mSearchListView;
|
||||
StdIconSearchListView* mSearchListView;
|
||||
QAction* mAttachAction;
|
||||
QAction* mRefreshAction;
|
||||
|
||||
|
@ -74,6 +74,8 @@ RESOURCES += \
|
||||
resource.qrc
|
||||
|
||||
SOURCES += \
|
||||
Src/BasicView/StdIconSearchListView.cpp \
|
||||
Src/BasicView/StdIconTable.cpp \
|
||||
Src/Gui/CPURegistersView.cpp \
|
||||
Src/Gui/SystemBreakpointScriptDialog.cpp \
|
||||
Src/Imports.cpp \
|
||||
@ -193,6 +195,8 @@ SOURCES += \
|
||||
|
||||
|
||||
HEADERS += \
|
||||
Src/BasicView/StdIconSearchListView.h \
|
||||
Src/BasicView/StdIconTable.h \
|
||||
Src/Gui/CPURegistersView.h \
|
||||
Src/Gui/SystemBreakpointScriptDialog.h \
|
||||
Src/Tracer/TraceRegisters.h \
|
||||
|
Loading…
Reference in New Issue
Block a user