Skip to content

Commit 2c3ec58

Browse files
author
Alexander Bychuk
committed
new : add find-window for export table
1 parent 065b10e commit 2c3ec58

File tree

6 files changed

+115
-2
lines changed

6 files changed

+115
-2
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ set(SOURCES
2828
mainwindow.ui
2929
qldd.cpp
3030
qldd.h
31+
finfdialog.cpp
32+
finfdialog.h
33+
finfdialog.ui
3134
)
3235
target_sources(Qldd PRIVATE ${SOURCES})
3336
target_link_libraries(Qldd PRIVATE Qt5::Widgets)

finfdialog.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "finfdialog.h"
2+
#include "ui_finfdialog.h"
3+
#include "mainwindow.h"
4+
5+
FinfDialog::FinfDialog(QWidget *parent) : QDialog(parent), ui(new Ui::FinfDialog) {
6+
ui->setupUi(this);
7+
shortcutClose = new QShortcut(QKeySequence(Qt::Key_Escape), this);
8+
connect(shortcutClose, SIGNAL(activated()), this, SLOT(close()));
9+
10+
shortcutFind = new QShortcut(QKeySequence(Qt::Key_Enter), this);
11+
connect(shortcutFind, SIGNAL(activated()), this, SLOT(find()));
12+
}
13+
14+
FinfDialog::~FinfDialog() { delete ui; }
15+
16+
void FinfDialog::on_findButton_clicked() {
17+
if (!ui->findLineEdit->text().isEmpty()) {
18+
MainWindow *mw = dynamic_cast<MainWindow *>(parentWidget());
19+
mw->fillExportTable(ui->findLineEdit->text());
20+
close();
21+
}
22+
}

finfdialog.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#ifndef FINFDIALOG_H
2+
#define FINFDIALOG_H
3+
4+
#include <QDialog>
5+
#include <QShortcut>
6+
7+
namespace Ui {
8+
class FinfDialog;
9+
}
10+
11+
class FinfDialog : public QDialog {
12+
Q_OBJECT
13+
14+
public:
15+
explicit FinfDialog(QWidget *parent = nullptr);
16+
~FinfDialog();
17+
18+
private slots:
19+
void on_findButton_clicked();
20+
21+
private:
22+
Ui::FinfDialog *ui;
23+
QShortcut *shortcutClose;
24+
QShortcut *shortcutFind;
25+
};
26+
27+
#endif // FINFDIALOG_H

finfdialog.ui

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>FinfDialog</class>
4+
<widget class="QDialog" name="FinfDialog">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>400</width>
10+
<height>93</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Dialog</string>
15+
</property>
16+
<property name="autoFillBackground">
17+
<bool>true</bool>
18+
</property>
19+
<property name="modal">
20+
<bool>true</bool>
21+
</property>
22+
<layout class="QHBoxLayout" name="horizontalLayout">
23+
<item>
24+
<widget class="QLineEdit" name="findLineEdit"/>
25+
</item>
26+
<item>
27+
<widget class="QPushButton" name="findButton">
28+
<property name="text">
29+
<string>Find</string>
30+
</property>
31+
</widget>
32+
</item>
33+
</layout>
34+
</widget>
35+
<resources/>
36+
<connections/>
37+
</ui>

mainwindow.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <QFileDialog>
55
#include <QShortcut>
66
#include <QMessageBox>
7+
#include "finfdialog.h"
78

89
#ifdef __APPLE__
910
#define FIXED_FONT "Menlo"
@@ -31,14 +32,18 @@ MainWindow::MainWindow(const QString &fileName, QWidget *parent)
3132
ui->treeWidget->setFont(fixedFont);
3233

3334
shortcutClose = new QShortcut(QKeySequence(Qt::Key_Escape), this);
34-
connect(shortcutClose, SIGNAL(activated()), this, SLOT(close()));
35+
connect(shortcutClose, SIGNAL(activated()), this, SLOT(myClose()));
36+
37+
shortcutFind = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_F), this);
38+
connect(shortcutFind, SIGNAL(activated()), this, SLOT(find()));
3539

3640
createActions();
3741
createMenus();
3842

3943
if (!fileName.isEmpty()) {
4044
reset(fileName);
4145
}
46+
ui->tabWidget->setCurrentIndex(0);
4247
}
4348

4449
MainWindow::~MainWindow() {
@@ -47,12 +52,14 @@ MainWindow::~MainWindow() {
4752
delete helpMenu;
4853
}
4954

55+
void MainWindow::fillExportTable(const QString &filter) { qldd->fillExportTable(*ui->listWidgetExportTable, filter); }
56+
5057
void MainWindow::reset(const QString &fileName) {
5158
qldd.reset(new QLdd(fileName, qApp->applicationDirPath()));
5259
QTreeWidgetItem *header = ui->treeWidget->headerItem();
5360
header->setText(0, "Dependency");
5461
qldd->fillDependency(*ui->treeWidget);
55-
qldd->fillExportTable(*ui->listWidgetExportTable, "");
62+
fillExportTable("");
5663

5764
ui->lineEditFileName->setText(qldd->getBinaryName());
5865
ui->lineEditFileSize->setText(qldd->getStringFileSize() + "( " + QString::number(qldd->getFileSize()) + " bytes )");
@@ -96,6 +103,19 @@ void MainWindow::about() {
96103
"given executable or dynamic library on Linux. It is a GUI replacement for the ldd, file and nm command."));
97104
}
98105

106+
void MainWindow::find() {
107+
auto fd = new FinfDialog(this);
108+
fd->show();
109+
}
110+
111+
void MainWindow::myClose() {
112+
if (ui->tabWidget->currentIndex() == 1) {
113+
fillExportTable("");
114+
} else {
115+
close();
116+
}
117+
}
118+
99119
void MainWindow::createActions() {
100120
openAct = new QAction(QIcon("gtk-open"), tr("&Open..."), this);
101121
openAct->setShortcuts(QKeySequence::Open);

mainwindow.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ class MainWindow : public QMainWindow {
1616
public:
1717
explicit MainWindow(const QString &fileName, QWidget *parent = nullptr);
1818
~MainWindow() override;
19+
void fillExportTable(const QString &filter);
1920
private slots:
2021
void open();
2122
void about();
23+
void find();
24+
void myClose();
2225

2326
void on_checkBoxOwnerRead_clicked(bool checked);
2427

@@ -45,6 +48,7 @@ class MainWindow : public QMainWindow {
4548
Ui::MainWindow *ui;
4649
QScopedPointer<QLdd> qldd;
4750
QShortcut *shortcutClose;
51+
QShortcut *shortcutFind;
4852
QMenu *fileMenu;
4953
QMenu *helpMenu;
5054
QAction *openAct;

0 commit comments

Comments
 (0)