Skip to content

Commit ac6dfda

Browse files
author
bas524
committed
update : add menu, add action for filemanager nemo (cinnamon)
add owner name and group name
1 parent 3afbcfb commit ac6dfda

File tree

10 files changed

+245
-12
lines changed

10 files changed

+245
-12
lines changed

Qldd.desktop

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[Desktop Entry]
2+
Encoding=UTF-8
3+
Name=LinuxDependency
4+
Comment=View exeutable dependency
5+
Exec=Qldd
6+
Icon=/home/`whoami`/.local/share/icons/Qldd.ico
7+
Categories=Application;Development
8+
Version=1.0
9+
Type=Application
10+
Terminal=0
11+

Qldd.ico

9.44 KB
Binary file not shown.

Qldd.png

2.15 KB
Loading

main.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ int main(int argc, char *argv[]) {
2525

2626
const QStringList args = parser.positionalArguments();
2727
// source is args.at(0), destination is args.at(1)
28-
QString fName = args.at(0);
28+
QString fName;
29+
if (args.size() > 0) {
30+
fName = args.at(0);
31+
}
32+
2933

3034
MainWindow w(fName);
3135

mainwindow.cpp

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,52 @@
33
#include <QFile>
44
#include <QTextStream>
55
#include <iostream>
6+
#include <QFileDialog>
7+
#include <QShortcut>
8+
#include <QMessageBox>
69

710
MainWindow::MainWindow(const QString &fileName, QWidget *parent) :
811
QMainWindow(parent),
912
ui(new Ui::MainWindow),
10-
qldd(NULL) {
13+
qldd(NULL),
14+
shortcutClose(NULL),
15+
fileMenu(NULL),
16+
helpMenu(NULL),
17+
openAct(NULL),
18+
aboutAct(NULL),
19+
aboutQtAct(NULL),
20+
exitAct(NULL) {
1121
ui->setupUi(this);
1222

23+
shortcutClose = new QShortcut(QKeySequence(Qt::Key_Escape), this);
24+
connect(shortcutClose, SIGNAL(activated()), this, SLOT(close()));
25+
26+
createActions();
27+
createMenus();
28+
29+
if (!fileName.isEmpty()) {
30+
reset(fileName);
31+
}
32+
}
33+
34+
MainWindow::~MainWindow() {
35+
delete ui;
36+
if (qldd) {
37+
delete qldd;
38+
}
39+
delete fileMenu;
40+
delete helpMenu;
41+
delete openAct;
42+
delete aboutAct;
43+
delete aboutQtAct;
44+
delete exitAct;
45+
}
46+
47+
void MainWindow::reset(const QString &fileName) {
48+
if (qldd) {
49+
delete qldd;
50+
qldd = NULL;
51+
}
1352
qldd = new QLdd(fileName, qApp->applicationDirPath());
1453
QTreeWidgetItem *header = ui->treeWidget->headerItem();
1554
header->setText(0, "Dependency");
@@ -26,6 +65,10 @@ MainWindow::MainWindow(const QString &fileName, QWidget *parent) :
2665
ui->labelTimeModify->setText("Modify Time ");
2766
ui->lineEditTimeModify->setText(qldd->getModifyTime());
2867

68+
69+
ui->lineEditOwner->setText(qldd->getOwnerName());
70+
ui->lineEditGroup->setText(qldd->getGroupName());
71+
2972
ui->textEditInformation->setText(qldd->getInfo());
3073
QMOD owner = qldd->getOwnerMod();
3174
QMOD group = qldd->getGroupMod();
@@ -44,7 +87,47 @@ MainWindow::MainWindow(const QString &fileName, QWidget *parent) :
4487
ui->checkBoxOtherExec->setChecked(other.execute);
4588
}
4689

47-
MainWindow::~MainWindow() {
48-
delete ui;
49-
delete qldd;
90+
void MainWindow::open() {
91+
92+
QString fileName = QFileDialog::getOpenFileName(this);
93+
if (!fileName.isEmpty()) {
94+
reset(fileName);
95+
}
96+
97+
}
98+
99+
void MainWindow::about() {
100+
QMessageBox::about(this, tr("About Application"),
101+
tr("Linuxdependency shows all dependent libraries of a given executable or dynamic library on Linux. It is a GUI replacement for the ldd command."));
102+
}
103+
104+
void MainWindow::createActions() {
105+
openAct = new QAction(QIcon("gtk-open"), tr("&Open..."), this);
106+
openAct->setShortcuts(QKeySequence::Open);
107+
openAct->setStatusTip(tr("Open an existing file"));
108+
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
109+
110+
aboutAct = new QAction(tr("&About"), this);
111+
aboutAct->setStatusTip(tr("Show the application's About box"));
112+
connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
113+
114+
exitAct = new QAction(tr("E&xit"), this);
115+
exitAct->setShortcuts(QKeySequence::Quit);
116+
exitAct->setStatusTip(tr("Exit the application"));
117+
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
118+
119+
aboutQtAct = new QAction(tr("About &Qt"), this);
120+
aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
121+
connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
122+
}
123+
124+
void MainWindow::createMenus() {
125+
fileMenu = menuBar()->addMenu(tr("&File"));
126+
fileMenu->addAction(openAct);
127+
fileMenu->addSeparator();
128+
fileMenu->addAction(exitAct);
129+
130+
helpMenu = menuBar()->addMenu(tr("&Help"));
131+
helpMenu->addAction(aboutAct);
132+
helpMenu->addAction(aboutQtAct);
50133
}

mainwindow.h

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,35 @@
33

44
#include <QMainWindow>
55
#include <qldd.h>
6+
#include <QShortcut>
67

78
namespace Ui {
8-
class MainWindow;
9+
class MainWindow;
910
}
1011

11-
class MainWindow : public QMainWindow
12-
{
12+
class MainWindow : public QMainWindow {
1313
Q_OBJECT
1414

1515
public:
1616
explicit MainWindow(const QString &fileName, QWidget *parent = 0);
1717
~MainWindow();
18+
private slots:
19+
void open();
20+
void about();
1821

1922
private:
23+
void createActions();
24+
void createMenus();
25+
void reset(const QString &fileName);
2026
Ui::MainWindow *ui;
2127
QLdd *qldd;
28+
QShortcut *shortcutClose;
29+
QMenu *fileMenu;
30+
QMenu *helpMenu;
31+
QAction *openAct;
32+
QAction *aboutAct;
33+
QAction *aboutQtAct;
34+
QAction *exitAct;
2235
};
2336

2437
#endif // MAINWINDOW_H

mainwindow.ui

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>1300</width>
10-
<height>1294</height>
9+
<width>1084</width>
10+
<height>760</height>
1111
</rect>
1212
</property>
1313
<property name="font">
@@ -18,6 +18,10 @@
1818
<property name="windowTitle">
1919
<string>MainWindow</string>
2020
</property>
21+
<property name="windowIcon">
22+
<iconset>
23+
<normaloff>Qldd.ico</normaloff>Qldd.ico</iconset>
24+
</property>
2125
<widget class="QWidget" name="centralWidget">
2226
<layout class="QGridLayout" name="gridLayout_6">
2327
<item row="0" column="0">
@@ -223,6 +227,77 @@
223227
</item>
224228
</layout>
225229
</item>
230+
<item>
231+
<widget class="QGroupBox" name="groupUserGroup">
232+
<property name="font">
233+
<font>
234+
<family>Ubuntu Mono</family>
235+
</font>
236+
</property>
237+
<property name="title">
238+
<string>Holder</string>
239+
</property>
240+
<property name="alignment">
241+
<set>Qt::AlignBottom|Qt::AlignRight|Qt::AlignTrailing</set>
242+
</property>
243+
<layout class="QGridLayout" name="gridLayout_7">
244+
<item row="0" column="0">
245+
<widget class="QLabel" name="labelOwner">
246+
<property name="text">
247+
<string>Owner</string>
248+
</property>
249+
</widget>
250+
</item>
251+
<item row="0" column="2">
252+
<spacer name="horizontalSpacer_4">
253+
<property name="orientation">
254+
<enum>Qt::Horizontal</enum>
255+
</property>
256+
<property name="sizeHint" stdset="0">
257+
<size>
258+
<width>40</width>
259+
<height>20</height>
260+
</size>
261+
</property>
262+
</spacer>
263+
</item>
264+
<item row="2" column="0">
265+
<widget class="QLabel" name="labelGroup">
266+
<property name="text">
267+
<string>Group</string>
268+
</property>
269+
</widget>
270+
</item>
271+
<item row="0" column="1">
272+
<widget class="QLineEdit" name="lineEditOwner">
273+
<property name="readOnly">
274+
<bool>true</bool>
275+
</property>
276+
</widget>
277+
</item>
278+
<item row="2" column="1">
279+
<widget class="QLineEdit" name="lineEditGroup">
280+
<property name="readOnly">
281+
<bool>true</bool>
282+
</property>
283+
</widget>
284+
</item>
285+
<item row="2" column="2">
286+
<spacer name="horizontalSpacer_5">
287+
<property name="orientation">
288+
<enum>Qt::Horizontal</enum>
289+
</property>
290+
<property name="sizeHint" stdset="0">
291+
<size>
292+
<width>40</width>
293+
<height>20</height>
294+
</size>
295+
</property>
296+
</spacer>
297+
</item>
298+
</layout>
299+
</widget>
300+
</item>
226301
<item>
227302
<widget class="QGroupBox" name="groupBoxOwner">
228303
<property name="font">
@@ -466,8 +541,8 @@
466541
<rect>
467542
<x>0</x>
468543
<y>0</y>
469-
<width>1300</width>
470-
<height>40</height>
544+
<width>1084</width>
545+
<height>24</height>
471546
</rect>
472547
</property>
473548
</widget>

qldd.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#include <ctime>
55
#include <iomanip>
66
#include <sstream>
7+
#include <sys/types.h>
8+
#include <pwd.h>
9+
#include <grp.h>
710
#include <QTreeWidgetItem>
811

912
#define MAXBUFFER 512
@@ -36,6 +39,10 @@ QLdd::QLdd(const QString &fileName, const QString &lddDirPath) :
3639
_otherMod.write = S_IWOTH & _fstat.st_mode;
3740
_otherMod.execute = S_IXOTH & _fstat.st_mode;
3841

42+
struct passwd *pw = getpwuid(_fstat.st_uid);
43+
_ownerName.append(pw->pw_name);
44+
struct group *gr = getgrgid(_fstat.st_gid);
45+
_groupName.append(gr->gr_name);
3946
}
4047

4148
QLdd::~QLdd() {
@@ -202,6 +209,21 @@ const QMOD &QLdd::getOtherMod() const {
202209
void QLdd::setOtherMod(const QMOD &otherMod) {
203210
_otherMod = otherMod;
204211
}
212+
const QString &QLdd::getOwnerName() const {
213+
return _ownerName;
214+
}
215+
216+
void QLdd::setOwnerName(const QString &ownerName) {
217+
_ownerName = ownerName;
218+
}
219+
220+
const QString &QLdd::getGroupName() const {
221+
return _groupName;
222+
}
223+
224+
void QLdd::setGroupName(const QString &groupName) {
225+
_groupName = groupName;
226+
}
205227

206228
const QString &QLdd::getAccessTime() {
207229
return _tmAccess;

qldd.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ class QLdd {
3434
const QMOD &getOtherMod() const;
3535
void setOtherMod(const QMOD &otherMod);
3636

37+
const QString &getOwnerName() const;
38+
void setOwnerName(const QString &ownerName);
39+
40+
const QString &getGroupName() const;
41+
void setGroupName(const QString &groupName);
42+
3743
private:
3844
QString _fileName;
3945
struct stat64 _fstat;
@@ -46,6 +52,8 @@ class QLdd {
4652
QMOD _ownerMod;
4753
QMOD _groupMod;
4854
QMOD _otherMod;
55+
QString _ownerName;
56+
QString _groupName;
4957
};
5058

5159
#endif // QLDD_H

qldd.nemo_action

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[Nemo Action]
2+
3+
Name=View dependecy
4+
5+
Comment=View library dependency of %f
6+
7+
Exec=/usr/bin/Qldd %F
8+
9+
Selection=s
10+
11+
Mimetypes=application/*;
12+
13+
Dependencies=ldd;
14+
15+
Selection=s
16+
17+
Icon-Name=gtk-execute

0 commit comments

Comments
 (0)