summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2012-05-21 08:41:50 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2012-05-21 08:41:50 +0200
commit17a8a827a15df48c7b7ce7958e4408f463e0149f (patch)
tree881d0d791db988005a6be6ed0bee3dad51d25543
parent8d82b27be67953c96e686ed495e0e346efeb60b9 (diff)
qphotorec: signal slot is now handled
-rwxr-xr-xcompile.sh6
-rw-r--r--configure.ac2
-rw-r--r--src/Makefile.am4
-rw-r--r--src/qphotorec.cpp126
-rw-r--r--src/qphotorec.h21
5 files changed, 129 insertions, 30 deletions
diff --git a/compile.sh b/compile.sh
index b2c0401..9cfb834 100755
--- a/compile.sh
+++ b/compile.sh
@@ -18,6 +18,8 @@ else
then
crosscompile_target=$1
TESTDISKCC=$crosscompile_target-gcc
+ PKG_CONFIG_PATH=/usr/$crosscompile_target/lib/pkgconfig
+ export PKG_CONFIG_PATH
fi
fi
case "$crosscompile_target" in
@@ -309,8 +311,8 @@ then
i386-mingw32)
$confdir/configure --host=$crosscompile_target --prefix=$prefix $CONFIGUREOPT --without-iconv --enable-missing-uuid-ok
;;
- i686-pc-mingw32|x86_64-pc-mingw32|x86_64-w64-mingw32)
- $confdir/configure --host=$crosscompile_target --prefix=$prefix $CONFIGUREOPT --enable-missing-uuid-ok
+ i686-pc-mingw32|x86_64-pc-mingw32|i686-w64-mingw32|x86_64-w64-mingw32)
+ $confdir/configure --host=$crosscompile_target --prefix=$prefix $CONFIGUREOPT --enable-missing-uuid-ok --enable-qt
;;
arm-marvell-linux-gnu)
$confdir/configure --host=$crosscompile_target --prefix=$prefix $CONFIGUREOPT --without-ewf --without-ntfs
diff --git a/configure.ac b/configure.ac
index efce417..1a86fb0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -777,6 +777,7 @@ if test "$use_qt" = "true";
then
PKG_CHECK_MODULES(QTCORE, QtCore >= 4.0.1)
PKG_CHECK_MODULES(QTGUI, QtGui >= 4.0.1)
+ MOC=`$PKG_CONFIG QtGui --variable=moc_location`
qphotorec_LDADD="$qphotorec_LDADD $QTGUI_LIBS"
CXXFLAGS="$CXXFLAGS $QTCORE_CFLAGS $QTGUI_CFLAGS"
fi
@@ -794,6 +795,7 @@ AC_SUBST(CFLAGS)
AC_SUBST(CXXFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)
+AC_SUBST(MOC)
AC_SUBST(testdisk_LDADD)
AC_SUBST(photorec_LDADD)
AC_SUBST(photorecf_LDADD)
diff --git a/src/Makefile.am b/src/Makefile.am
index 6ec1fd2..997c6a7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -282,7 +282,7 @@ photorec_SOURCES = phmain.c $(photorec_C) $(photorec_H) $(photorec_ncurses_C) $(
photorecf_SOURCES = phmain.c $(photorec_C) $(photorec_H) $(photorec_ncurses_C) $(photorec_ncurses_H) $(file_C) $(file_H) $(base_C) $(base_H) partgptro.c $(fs_C) $(fs_H) $(ICON_PHOTOREC) suspend.c
-qphotorec_SOURCES = qmainrec.cpp qphotorec.cpp qphotorec.h chgtype.c chgtype.h $(photorec_C) $(photorec_H) $(file_C) $(file_H) $(base_C) $(base_H) partgptro.c $(fs_C) $(fs_H) $(ICON_PHOTOREC) suspend_no.c
+qphotorec_SOURCES = qmainrec.cpp qphotorec.cpp qphotorec.h chgtype.c chgtype.h $(photorec_C) $(photorec_H) $(file_C) $(file_H) $(base_C) $(base_H) partgptro.c $(fs_C) $(fs_H) $(ICON_PHOTOREC) suspend_no.c moc_qphotorec.cpp
fidentify_SOURCES = fidentify.c common.c common.h phcfg.c phcfg.h setdate.c setdate.h $(file_C) $(file_H) log.c log.h crc.c crc.h fat_common.c suspend_no.c
@@ -293,3 +293,5 @@ small: $(sbin_PROGRAMS) $(bin_PROGRAMS)
extras: $(EXTRA_PROGRAMS)
+moc_qphotorec.cpp: qphotorec.h
+ $(MOC) $< -o $@
diff --git a/src/qphotorec.cpp b/src/qphotorec.cpp
index b102e39..0e62cf2 100644
--- a/src/qphotorec.cpp
+++ b/src/qphotorec.cpp
@@ -34,50 +34,132 @@
#ifdef HAVE_TIME_H
#include <time.h>
#endif
+#include <QApplication>
#include <QtGui>
-#include "qphotorec.h"
#include "types.h"
#include "common.h"
#include "hdcache.h"
#include "hdaccess.h"
#include "fnctdsk.h"
+#include "qphotorec.h"
-QPhotorec::QPhotorec(QWidget *parent)
+QPhotorec::QPhotorec(QWidget *parent) : QWidget(parent)
{
- setupUi(this);
+ const int verbose=1;
+ const int testdisk_mode=TESTDISK_O_RDONLY|TESTDISK_O_READAHEAD_32K;
+ list_disk_t *element_disk;
+
+ list_disk=hd_parse(NULL, verbose, testdisk_mode);
+
+ hd_update_all_geometry(list_disk, verbose);
+ /* Activate the cache, even if photorec has its own */
+ for(element_disk=list_disk;element_disk!=NULL;element_disk=element_disk->next)
+ element_disk->disk=new_diskcache(element_disk->disk,testdisk_mode);
+ if(list_disk==NULL)
+ no_disk();
+ else
+ disk_sel();
}
-void QPhotorec::setupUi(QWidget *MainWindow)
+void QPhotorec::partition_selection(disk_t *disk)
{
- MainWindow->setWindowTitle(tr("QPhotorec"));
- HDDlistWidget = new QListWidget();
+ this->setWindowTitle(tr("QPhotoRec: partition selection"));
+ QLabel *t_copy = new QLabel("PhotoRec 6.14-WIP, Data Recovery Utility, May 2012\nChristophe GRENIER <grenier@cgsecurity.org>\nhttp://www.cgsecurity.org");
+ QPushButton *button_quit= new QPushButton("&Quit");
+
QVBoxLayout *mainLayout = new QVBoxLayout();
- mainLayout->addWidget(HDDlistWidget);
- QPushButton *button_next = new QPushButton("&Proceed");
- mainLayout->addWidget(button_next);
+ mainLayout->addWidget(t_copy);
+ mainLayout->addWidget(button_quit);
+// delete this->layout;
+ this->setLayout(mainLayout);
+ connect( button_quit, SIGNAL(clicked()), qApp, SLOT(quit()) );
+}
+
+void QPhotorec::disk_selected()
+{
+ if(HDDlistWidget->selectedItems().count()==1)
+ {
+ list_disk_t *element_disk;
+ const QString& s = HDDlistWidget->selectedItems()[0]->text();
+ for(element_disk=list_disk;element_disk!=NULL;element_disk=element_disk->next)
+ {
+ disk_t *disk=element_disk->disk;
+ if(QString(disk->description_short(disk)).compare(s)==0)
+ {
+ return partition_selection(disk);
+ }
+ }
+ }
+}
+
+void QPhotorec::no_disk()
+{
+ this->setWindowTitle(tr("QPhotoRec"));
+ QLabel *t_copy = new QLabel("PhotoRec 6.14-WIP, Data Recovery Utility, May 2012\nChristophe GRENIER <grenier@cgsecurity.org>\nhttp://www.cgsecurity.org");
+ QLabel *t_free_soft = new QLabel("PhotoRec is free software, and\ncomes with ABSOLUTELY NO WARRANTY.");
+ QLabel *t_no_disk = new QLabel("No harddisk found\n");
+#if defined(__CYGWIN__) || defined(__MINGW32__)
+ t_no_disk->setText("No harddisk found\n"
+ "You need to be administrator to use this program.\n"
+ "Under Win9x, use the DOS version instead.\n"
+ "Under Vista or later, select this program, right-click and choose \"Run as administrator\".\n");
+#elif defined(DJGPP)
+#else
+#ifdef HAVE_GETEUID
+ if(geteuid()!=0)
+ {
+ t_no_disk->setText("No harddisk found\n"
+ "You need to be root to use PhotoRec.");
+ }
+#endif
+#endif
QPushButton *button_quit= new QPushButton("&Quit");
+
+ QVBoxLayout *mainLayout = new QVBoxLayout();
+ mainLayout->addWidget(t_copy);
+ mainLayout->addWidget(t_free_soft);
+ mainLayout->addWidget(t_no_disk);
mainLayout->addWidget(button_quit);
- MainWindow->setLayout(mainLayout);
- ashow();
+ this->setLayout(mainLayout);
+ connect( button_quit, SIGNAL(clicked()), qApp, SLOT(quit()) );
}
-void QPhotorec::ashow()
+
+void QPhotorec::disk_sel()
{
- int verbose=1;
- int testdisk_mode=TESTDISK_O_RDONLY|TESTDISK_O_READAHEAD_32K;
- list_disk_t *list_disk=NULL;
list_disk_t *element_disk;
+ this->setWindowTitle(tr("QPhotoRec"));
+ QLabel *t_copy = new QLabel("PhotoRec 6.14-WIP, Data Recovery Utility, May 2012\nChristophe GRENIER <grenier@cgsecurity.org>\nhttp://www.cgsecurity.org");
+ QLabel *t_free_soft = new QLabel("PhotoRec is free software, and\ncomes with ABSOLUTELY NO WARRANTY.");
+ QLabel *t_select = new QLabel("Please select a media");
- list_disk=hd_parse(list_disk, verbose, testdisk_mode);
-
- hd_update_all_geometry(list_disk, verbose);
- /* Activate the cache, even if photorec has its own */
- for(element_disk=list_disk;element_disk!=NULL;element_disk=element_disk->next)
- element_disk->disk=new_diskcache(element_disk->disk,testdisk_mode);
- /* save disk parameters to rapport */
+ HDDlistWidget = new QListWidget();
for(element_disk=list_disk;element_disk!=NULL;element_disk=element_disk->next)
{
disk_t *disk=element_disk->disk;
HDDlistWidget->addItem(disk->description_short(disk));
}
+ HDDlistWidget->setToolTip("Disk capacity must be correctly detected for a successful recovery.\n"
+ "If a disk listed above has incorrect size, check HD jumper settings, BIOS\n"
+ "detection, and install the latest OS patches and disk drivers."
+ );
+
+ QPushButton *button_proceed = new QPushButton("&Proceed");
+ QPushButton *button_quit= new QPushButton("&Quit");
+
+ QHBoxLayout *B_layout = new QHBoxLayout;
+ B_layout->addWidget(button_proceed);
+ B_layout->addWidget(button_quit);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout();
+ mainLayout->addWidget(t_copy);
+ mainLayout->addWidget(t_free_soft);
+ mainLayout->addWidget(t_select);
+ mainLayout->addWidget(HDDlistWidget);
+ mainLayout->addLayout(B_layout);
+ this->setLayout(mainLayout);
+
+ connect( button_quit, SIGNAL(clicked()), qApp, SLOT(quit()) );
+ connect( button_proceed, SIGNAL(clicked()), this, SLOT(disk_selected()));
+ connect( HDDlistWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(disk_selected()));
}
diff --git a/src/qphotorec.h b/src/qphotorec.h
index 2321a82..872056d 100644
--- a/src/qphotorec.h
+++ b/src/qphotorec.h
@@ -11,18 +11,29 @@
//
#ifndef QPHOTOREC_H
#define QPHOTOREC_H
-#include <QDialog>
-class QListWidget;
-class QPushButton;
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <QWidget>
+#include <QListWidget>
+#include <QPushButton>
+#include "types.h"
+#include "common.h"
class QPhotorec: public QWidget
{
+ Q_OBJECT
+
public:
QPhotorec(QWidget *parent = 0);
- void setupUi(QWidget *MainWindow);
- void ashow();
+ void disk_sel();
+ void no_disk();
+ void partition_selection(disk_t *disk);
+ private slots:
+ void disk_selected();
private:
QListWidget *HDDlistWidget;
QPushButton *btn;
+ list_disk_t *list_disk;
};
#endif