diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d19312..7986dee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,9 @@ set(SOURCES mainwindow.ui qldd.cpp qldd.h + finfdialog.cpp + finfdialog.h + finfdialog.ui ) target_sources(Qldd PRIVATE ${SOURCES}) target_link_libraries(Qldd PRIVATE Qt5::Widgets) diff --git a/finfdialog.cpp b/finfdialog.cpp new file mode 100644 index 0000000..5abfe97 --- /dev/null +++ b/finfdialog.cpp @@ -0,0 +1,22 @@ +#include "finfdialog.h" +#include "ui_finfdialog.h" +#include "mainwindow.h" + +FinfDialog::FinfDialog(QWidget *parent) : QDialog(parent), ui(new Ui::FinfDialog) { + ui->setupUi(this); + shortcutClose = new QShortcut(QKeySequence(Qt::Key_Escape), this); + connect(shortcutClose, SIGNAL(activated()), this, SLOT(close())); + + shortcutFind = new QShortcut(QKeySequence(Qt::Key_Enter), this); + connect(shortcutFind, SIGNAL(activated()), this, SLOT(find())); +} + +FinfDialog::~FinfDialog() { delete ui; } + +void FinfDialog::on_findButton_clicked() { + if (!ui->findLineEdit->text().isEmpty()) { + MainWindow *mw = dynamic_cast(parentWidget()); + mw->fillExportTable(ui->findLineEdit->text()); + close(); + } +} diff --git a/finfdialog.h b/finfdialog.h new file mode 100644 index 0000000..8e224f9 --- /dev/null +++ b/finfdialog.h @@ -0,0 +1,27 @@ +#ifndef FINFDIALOG_H +#define FINFDIALOG_H + +#include +#include + +namespace Ui { +class FinfDialog; +} + +class FinfDialog : public QDialog { + Q_OBJECT + + public: + explicit FinfDialog(QWidget *parent = nullptr); + ~FinfDialog(); + + private slots: + void on_findButton_clicked(); + + private: + Ui::FinfDialog *ui; + QShortcut *shortcutClose; + QShortcut *shortcutFind; +}; + +#endif // FINFDIALOG_H diff --git a/finfdialog.ui b/finfdialog.ui new file mode 100644 index 0000000..c250048 --- /dev/null +++ b/finfdialog.ui @@ -0,0 +1,37 @@ + + + FinfDialog + + + + 0 + 0 + 400 + 93 + + + + Dialog + + + true + + + true + + + + + + + + + Find + + + + + + + + diff --git a/mainwindow.cpp b/mainwindow.cpp index 544dcf3..6e7d16f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -4,6 +4,7 @@ #include #include #include +#include "finfdialog.h" #ifdef __APPLE__ #define FIXED_FONT "Menlo" @@ -31,7 +32,10 @@ MainWindow::MainWindow(const QString &fileName, QWidget *parent) ui->treeWidget->setFont(fixedFont); shortcutClose = new QShortcut(QKeySequence(Qt::Key_Escape), this); - connect(shortcutClose, SIGNAL(activated()), this, SLOT(close())); + connect(shortcutClose, SIGNAL(activated()), this, SLOT(myClose())); + + shortcutFind = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_F), this); + connect(shortcutFind, SIGNAL(activated()), this, SLOT(find())); createActions(); createMenus(); @@ -39,6 +43,7 @@ MainWindow::MainWindow(const QString &fileName, QWidget *parent) if (!fileName.isEmpty()) { reset(fileName); } + ui->tabWidget->setCurrentIndex(0); } MainWindow::~MainWindow() { @@ -47,12 +52,14 @@ MainWindow::~MainWindow() { delete helpMenu; } +void MainWindow::fillExportTable(const QString &filter) { qldd->fillExportTable(*ui->listWidgetExportTable, filter); } + void MainWindow::reset(const QString &fileName) { qldd.reset(new QLdd(fileName, qApp->applicationDirPath())); QTreeWidgetItem *header = ui->treeWidget->headerItem(); header->setText(0, "Dependency"); qldd->fillDependency(*ui->treeWidget); - qldd->fillExportTable(*ui->listWidgetExportTable, ""); + fillExportTable(""); ui->lineEditFileName->setText(qldd->getBinaryName()); ui->lineEditFileSize->setText(qldd->getStringFileSize() + "( " + QString::number(qldd->getFileSize()) + " bytes )"); @@ -96,6 +103,19 @@ void MainWindow::about() { "given executable or dynamic library on Linux. It is a GUI replacement for the ldd, file and nm command.")); } +void MainWindow::find() { + auto fd = new FinfDialog(this); + fd->show(); +} + +void MainWindow::myClose() { + if (ui->tabWidget->currentIndex() == 1) { + fillExportTable(""); + } else { + close(); + } +} + void MainWindow::createActions() { openAct = new QAction(QIcon("gtk-open"), tr("&Open..."), this); openAct->setShortcuts(QKeySequence::Open); diff --git a/mainwindow.h b/mainwindow.h index 21fd5c1..d3b11f7 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -16,9 +16,12 @@ class MainWindow : public QMainWindow { public: explicit MainWindow(const QString &fileName, QWidget *parent = nullptr); ~MainWindow() override; + void fillExportTable(const QString &filter); private slots: void open(); void about(); + void find(); + void myClose(); void on_checkBoxOwnerRead_clicked(bool checked); @@ -45,6 +48,7 @@ class MainWindow : public QMainWindow { Ui::MainWindow *ui; QScopedPointer qldd; QShortcut *shortcutClose; + QShortcut *shortcutFind; QMenu *fileMenu; QMenu *helpMenu; QAction *openAct;