Skip to content

Commit

Permalink
new : add find-window for export table
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Bychuk committed Sep 21, 2020
1 parent 065b10e commit 2c3ec58
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 22 additions & 0 deletions finfdialog.cpp
Original file line number Diff line number Diff line change
@@ -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<MainWindow *>(parentWidget());
mw->fillExportTable(ui->findLineEdit->text());
close();
}
}
27 changes: 27 additions & 0 deletions finfdialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef FINFDIALOG_H
#define FINFDIALOG_H

#include <QDialog>
#include <QShortcut>

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
37 changes: 37 additions & 0 deletions finfdialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FinfDialog</class>
<widget class="QDialog" name="FinfDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>93</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="findLineEdit"/>
</item>
<item>
<widget class="QPushButton" name="findButton">
<property name="text">
<string>Find</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
24 changes: 22 additions & 2 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QFileDialog>
#include <QShortcut>
#include <QMessageBox>
#include "finfdialog.h"

#ifdef __APPLE__
#define FIXED_FONT "Menlo"
Expand Down Expand Up @@ -31,14 +32,18 @@ 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();

if (!fileName.isEmpty()) {
reset(fileName);
}
ui->tabWidget->setCurrentIndex(0);
}

MainWindow::~MainWindow() {
Expand All @@ -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 )");
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -45,6 +48,7 @@ class MainWindow : public QMainWindow {
Ui::MainWindow *ui;
QScopedPointer<QLdd> qldd;
QShortcut *shortcutClose;
QShortcut *shortcutFind;
QMenu *fileMenu;
QMenu *helpMenu;
QAction *openAct;
Expand Down

0 comments on commit 2c3ec58

Please sign in to comment.