[Change] Some slight cleanup.
This commit is contained in:
parent
cc955d6489
commit
60585403ae
@ -7,7 +7,7 @@ LIBS += -L/usr/lib -lpoppler-qt5
|
||||
|
||||
# Input
|
||||
HEADERS += ../src/PDFExportDialog.h \
|
||||
../src/PDFFactory.h \
|
||||
../src/HPDF.h \
|
||||
../src/PDFFileWidget.h \
|
||||
../src/PDFJam.h \
|
||||
../src/PDFPageWidget.h \
|
||||
@ -18,7 +18,7 @@ HEADERS += ../src/PDFExportDialog.h \
|
||||
|
||||
SOURCES += ../src/main.cpp \
|
||||
../src/PDFExportDialog.cpp \
|
||||
../src/PDFFactory.cpp \
|
||||
../src/HPDF.cpp \
|
||||
../src/PDFFileWidget.cpp \
|
||||
../src/PDFJam.cpp \
|
||||
../src/PDFPageWidget.cpp \
|
||||
|
@ -1,13 +1,12 @@
|
||||
#include <QtWidgets>
|
||||
#include <QtGlobal>
|
||||
#include "PDFFactory.h"
|
||||
#include "HPDF.h"
|
||||
#include "PDFExportDialog.h"
|
||||
#include "PDFTableWidget.h"
|
||||
#include "PDFPreviewWidget.h"
|
||||
#include "PDFPageWidget.h"
|
||||
|
||||
PDFFactory::PDFFactory()
|
||||
{
|
||||
HPDF::HPDF(void) {
|
||||
createWidgets();
|
||||
createActions();
|
||||
createToolBars();
|
||||
@ -15,16 +14,15 @@ PDFFactory::PDFFactory()
|
||||
createStatusBar();
|
||||
}
|
||||
|
||||
void PDFFactory::createWidgets()
|
||||
{
|
||||
// Set central widget to be the container root
|
||||
void HPDF::createWidgets(void) {
|
||||
/* Set central widget to be the container root */
|
||||
centralWidget = new QWidget();
|
||||
QVBoxLayout *layout = new QVBoxLayout();
|
||||
layout->setContentsMargins(2,2,2,2);
|
||||
centralWidget->setLayout(layout);
|
||||
setCentralWidget(centralWidget);
|
||||
|
||||
// Create ribbon
|
||||
/*Create ribbon */
|
||||
ribbon = new QTabWidget();
|
||||
ribbon->addTab(new QWidget(), tr("File"));
|
||||
ribbon->addTab(new QWidget(), tr("Edit"));
|
||||
@ -34,7 +32,7 @@ void PDFFactory::createWidgets()
|
||||
ribbon->setFixedHeight(100);
|
||||
layout->addWidget(ribbon);
|
||||
|
||||
// Create main area (table)
|
||||
/* Create main area (table) */
|
||||
|
||||
pdfTableView = new PDFTableWidget();
|
||||
pdfPreview = new PDFPreviewWidget();
|
||||
@ -60,8 +58,7 @@ void PDFFactory::createWidgets()
|
||||
}
|
||||
|
||||
|
||||
void PDFFactory::createActions()
|
||||
{
|
||||
void HPDF::createActions(void) {
|
||||
openAction = new QAction(tr("&Open"), this);
|
||||
openAction->setIcon(QIcon(":/img/open.png"));
|
||||
openAction->setShortcut(tr("Ctrl+O"));
|
||||
@ -116,8 +113,7 @@ void PDFFactory::createActions()
|
||||
connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
|
||||
}
|
||||
|
||||
void PDFFactory::createToolBars()
|
||||
{
|
||||
void HPDF::createToolBars(void) {
|
||||
fileToolBar = new QToolBar(tr("File"));
|
||||
fileToolBar->addAction(openAction);
|
||||
fileToolBar->addAction(exportAction);
|
||||
@ -141,8 +137,7 @@ void PDFFactory::createToolBars()
|
||||
helpToolBar->setIconSize(QSize(48, 48));
|
||||
}
|
||||
|
||||
void PDFFactory::createRibbon()
|
||||
{
|
||||
void HPDF::createRibbon(void) {
|
||||
QWidget *tabFile = ribbon->widget(0);
|
||||
QVBoxLayout *layoutTabFile = new QVBoxLayout();
|
||||
layoutTabFile->setContentsMargins(2,0,2,0);
|
||||
@ -168,12 +163,11 @@ void PDFFactory::createRibbon()
|
||||
tabHelp->setLayout(layoutTabHelp);
|
||||
}
|
||||
|
||||
void PDFFactory::createStatusBar()
|
||||
{
|
||||
void HPDF::createStatusBar(void) {
|
||||
statusBar()->showMessage(tr(""));
|
||||
}
|
||||
|
||||
void PDFFactory::openFile(void) {
|
||||
void HPDF::openFile(void) {
|
||||
QStringList fileNames = QFileDialog::getOpenFileNames(this,
|
||||
tr("Open PDF file"), ".",
|
||||
tr("PDF file (*.pdf)"));
|
||||
@ -186,7 +180,7 @@ void PDFFactory::openFile(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void PDFFactory::exportFile(void) {
|
||||
void HPDF::exportFile(void) {
|
||||
PDFExportDialog *exportDialog = new PDFExportDialog();
|
||||
|
||||
QVector<PDFFileWidget*> selectedFiles = pdfTableView->getSelectedFiles();
|
||||
@ -196,7 +190,7 @@ void PDFFactory::exportFile(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void PDFFactory::exportAllFiles(void) {
|
||||
void HPDF::exportAllFiles(void) {
|
||||
PDFExportDialog *exportDialog = new PDFExportDialog();
|
||||
|
||||
QVector<PDFFileWidget*> visibleFiles = pdfTableView->getVisibleFiles();
|
||||
@ -207,8 +201,8 @@ void PDFFactory::exportAllFiles(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void PDFFactory::about(void) {
|
||||
QMessageBox::information(this, tr("PDFFactory"), tr("HPDF (Harringtons PDF) "
|
||||
void HPDF::about(void) {
|
||||
QMessageBox::information(this, tr("HPDF"), tr("HPDF (Harringtons PDF) "
|
||||
"version 0.1.0\nWritten by: Ritchie Cunningham\n\n"
|
||||
"HPDF is primarily a PDF viewer with the prospect of becoming a full "
|
||||
"featured PDF editor.\n\n"
|
56
src/HPDF.h
Normal file
56
src/HPDF.h
Normal file
@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
#include <QMainWindow>
|
||||
|
||||
class PDFTableWidget;
|
||||
class PDFPreviewWidget;
|
||||
|
||||
class QAction;
|
||||
class QWidget;
|
||||
class QTabWidget;
|
||||
class QScrollArea;
|
||||
class QSplitter;
|
||||
class QToolBar;
|
||||
|
||||
class HPDF: public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HPDF(void);
|
||||
|
||||
private slots:
|
||||
void openFile(void);
|
||||
void exportFile(void);
|
||||
void exportAllFiles(void);
|
||||
void about(void);
|
||||
|
||||
private:
|
||||
void createWidgets(void);
|
||||
void createActions(void);
|
||||
void createToolBars(void);
|
||||
void createRibbon(void);
|
||||
void createStatusBar(void);
|
||||
|
||||
QAction* openAction;
|
||||
QAction* exportAction;
|
||||
QAction* exportAllAction;
|
||||
QAction* cutAction;
|
||||
QAction* copyAction;
|
||||
QAction* pasteAction;
|
||||
QAction* deleteAction;
|
||||
QAction* rotateAction;
|
||||
QAction* aboutAction;
|
||||
QAction* searchAction;
|
||||
|
||||
QWidget* centralWidget;
|
||||
|
||||
QTabWidget* ribbon;
|
||||
QSplitter* splitter;
|
||||
PDFTableWidget* pdfTableView;
|
||||
PDFPreviewWidget* pdfPreview;
|
||||
|
||||
QToolBar* fileToolBar;
|
||||
QToolBar* editToolBar;
|
||||
QToolBar* toolsToolBar;
|
||||
QToolBar* helpToolBar;
|
||||
};
|
@ -7,7 +7,7 @@ PDFExportDialog::PDFExportDialog(QWidget *parent) :
|
||||
mainLayout = new QGridLayout();
|
||||
mainLayout->setSpacing(15);
|
||||
|
||||
// File list
|
||||
/* File list. */
|
||||
fileListBox = new QGroupBox("Selected files");
|
||||
QVBoxLayout *fileListLayout = new QVBoxLayout();
|
||||
fileList = new QListWidget();
|
||||
@ -17,7 +17,7 @@ PDFExportDialog::PDFExportDialog(QWidget *parent) :
|
||||
fileListBox->setLayout(fileListLayout);
|
||||
mainLayout->addWidget(fileListBox, 0, 0, 4, 2);
|
||||
|
||||
// is landscape
|
||||
/* Landscape */
|
||||
landscapeBox = new QGroupBox("Output orientation");
|
||||
QVBoxLayout *landscapeLayout = new QVBoxLayout();
|
||||
chkPortrait = new QRadioButton("Portrait");
|
||||
@ -28,7 +28,7 @@ PDFExportDialog::PDFExportDialog(QWidget *parent) :
|
||||
landscapeLayout->addWidget(chkLandscape);
|
||||
landscapeBox->setLayout(landscapeLayout);
|
||||
|
||||
// n-up
|
||||
/* n-up */
|
||||
nupBox = new QGroupBox("N-up option");
|
||||
nupBox->setCheckable(true);
|
||||
nupBox->setChecked(false);
|
||||
@ -46,7 +46,7 @@ PDFExportDialog::PDFExportDialog(QWidget *parent) :
|
||||
nupLayout->addWidget(txtCol, 1, 1, 1, 2);
|
||||
nupBox->setLayout(nupLayout);
|
||||
|
||||
// offsets
|
||||
/* Offsets */
|
||||
offsetBox = new QGroupBox("Two-sided offset");
|
||||
offsetBox->setCheckable(true);
|
||||
offsetBox->setChecked(false);
|
||||
@ -68,7 +68,7 @@ PDFExportDialog::PDFExportDialog(QWidget *parent) :
|
||||
midFrame->setLayout(midLayout);
|
||||
mainLayout->addWidget(midFrame, 0, 2, 4, 2);
|
||||
|
||||
// buttons
|
||||
/* Buttons */
|
||||
QVBoxLayout *rightLayout = new QVBoxLayout();
|
||||
btnSave = new QPushButton("&Export...");
|
||||
connect(btnSave, SIGNAL(clicked()), this, SLOT(btnSaveClicked()));
|
||||
@ -99,7 +99,7 @@ void PDFExportDialog::setFilesToExport(QVector<PDFFileWidget*> fileWidgets,
|
||||
foreach (const QString str, fileNames) {
|
||||
modelList << str;
|
||||
|
||||
QVector<QVariant> option; // Landscape, row, col, left, right, twosided
|
||||
QVector<QVariant> option; /* Landscape, row, col, left, right, twosided */
|
||||
bool ok;
|
||||
option.append(QVariant(chkLandscape->isChecked()));
|
||||
option.append(QVariant(nupBox->isChecked()));
|
||||
@ -123,15 +123,15 @@ void PDFExportDialog::btnSaveClicked(void) {
|
||||
tr("PDF file (*.pdf)"));
|
||||
if (!fileName.isEmpty()) {
|
||||
QSize nup;
|
||||
//if (option.at(0).toBool())
|
||||
//nup = QSize(option.at(3).toInt(), option.at(2).toInt());
|
||||
//else
|
||||
/*if (option.at(0).toBool())
|
||||
nup = QSize(option.at(3).toInt(), option.at(2).toInt());
|
||||
else*/
|
||||
nup = QSize(option.at(2).toInt(), option.at(3).toInt());
|
||||
|
||||
pdfJam.exportFile(fileIndices.at(selectedIndex), fileWidgets.at(selectedIndex)->getChildCount(), fileName,
|
||||
option.at(1).toBool(), nup, // nup
|
||||
option.at(0).toBool(), // landscape
|
||||
option.at(4).toBool(), option.at(5).toInt()); //offset
|
||||
option.at(1).toBool(), nup, /* nup */
|
||||
option.at(0).toBool(), /* Landscape */
|
||||
option.at(4).toBool(), option.at(5).toInt()); /* Offset. */
|
||||
|
||||
QMessageBox::information(this, tr("PDFFactory"), tr("Exported succesfully to\n%1.").arg(fileName));
|
||||
}
|
||||
@ -145,9 +145,9 @@ void PDFExportDialog::btnSaveAllClicked(void) {
|
||||
tr("PDF file (*.pdf)"));
|
||||
|
||||
QSize nup;
|
||||
//if (chkLandscape->isChecked())
|
||||
//nup = QSize(txtCol->text().toInt(&ok), txtRow->text().toInt(&ok));
|
||||
//else
|
||||
/*if (chkLandscape->isChecked())
|
||||
nup = QSize(txtCol->text().toInt(&ok), txtRow->text().toInt(&ok));
|
||||
else*/
|
||||
nup = QSize(txtRow->text().toInt(&ok), txtCol->text().toInt(&ok));
|
||||
|
||||
if (!fileName.isEmpty()) {
|
||||
|
@ -13,25 +13,25 @@ class PDFExportDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PDFExportDialog(QWidget *parent = 0);
|
||||
explicit PDFExportDialog(QWidget* parent = 0);
|
||||
|
||||
private:
|
||||
QVector<PDFFileWidget*> fileWidgets;
|
||||
QVector<QString> fileNames;
|
||||
QVector<int> fileIndices;
|
||||
QVector<PDFFileWidget*> fileWidgets;
|
||||
QVector<QString> fileNames;
|
||||
QVector<int> fileIndices;
|
||||
QVector<QVector<QVariant> > options;
|
||||
|
||||
private:
|
||||
PDFJam pdfJam;
|
||||
QGroupBox *fileListBox, *landscapeBox, *nupBox, *offsetBox;
|
||||
|
||||
QPushButton *btnSave, *btnSaveAll, *btnCancel;
|
||||
QGridLayout *mainLayout;
|
||||
QPushButton* btnSave, *btnSaveAll, *btnCancel;
|
||||
QGridLayout* mainLayout;
|
||||
|
||||
QListWidget *fileList;
|
||||
QLineEdit *txtRow, *txtCol;
|
||||
QRadioButton *chkPortrait, *chkLandscape;
|
||||
QLineEdit *txtLeftOffset;
|
||||
QListWidget* fileList;
|
||||
QLineEdit* txtRow, *txtCol;
|
||||
QRadioButton* chkPortrait, *chkLandscape;
|
||||
QLineEdit* txtLeftOffset;
|
||||
|
||||
public:
|
||||
void setFilesToExport(QVector<PDFFileWidget*> fileWidgets, QVector<QString> fileNames, QVector<int> fileIndices);
|
||||
@ -41,9 +41,9 @@ private slots:
|
||||
void btnSaveClicked(void);
|
||||
void btnSaveAllClicked(void);
|
||||
void btnCancelClicked(void);
|
||||
void txtRowChanged(const QString &);
|
||||
void txtColChanged(const QString &);
|
||||
void txtLeftChanged(const QString &);
|
||||
void txtRowChanged(const QString&);
|
||||
void txtColChanged(const QString&);
|
||||
void txtLeftChanged(const QString&);
|
||||
void chkLandscapeChanged(bool);
|
||||
void nupBoxToggled(bool);
|
||||
void offsetBoxToggled(bool);
|
||||
|
@ -1,55 +0,0 @@
|
||||
#pragma once
|
||||
#include <QMainWindow>
|
||||
|
||||
class PDFTableWidget;
|
||||
class PDFPreviewWidget;
|
||||
|
||||
class QAction;
|
||||
class QWidget;
|
||||
class QTabWidget;
|
||||
class QScrollArea;
|
||||
class QSplitter;
|
||||
class QToolBar;
|
||||
|
||||
class PDFFactory: public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PDFFactory();
|
||||
|
||||
private slots:
|
||||
void openFile(void);
|
||||
void exportFile(void);
|
||||
void exportAllFiles(void);
|
||||
void about(void);
|
||||
|
||||
private:
|
||||
void createWidgets(void);
|
||||
void createActions(void);
|
||||
void createToolBars(void);
|
||||
void createRibbon(void);
|
||||
void createStatusBar(void);
|
||||
|
||||
QAction *openAction;
|
||||
QAction *exportAction;
|
||||
QAction *exportAllAction;
|
||||
QAction *cutAction;
|
||||
QAction *copyAction;
|
||||
QAction *pasteAction;
|
||||
QAction *deleteAction;
|
||||
QAction *rotateAction;
|
||||
QAction *aboutAction;
|
||||
|
||||
QWidget *centralWidget;
|
||||
|
||||
QTabWidget *ribbon;
|
||||
QSplitter *splitter;
|
||||
PDFTableWidget *pdfTableView;
|
||||
PDFPreviewWidget *pdfPreview;
|
||||
|
||||
QToolBar *fileToolBar;
|
||||
QToolBar *editToolBar;
|
||||
QToolBar *toolsToolBar;
|
||||
QToolBar *helpToolBar;
|
||||
};
|
@ -27,24 +27,26 @@ class PagesContainerWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PagesContainerWidget(QWidget *parent = 0);
|
||||
PagesContainerWidget(QWidget* parent = 0);
|
||||
QSize sizeHint() const;
|
||||
QVector<PDFPageWidget*> pageWidgets;
|
||||
QHBoxLayout *mainLayout;
|
||||
QHBoxLayout* mainLayout;
|
||||
|
||||
void addPageWidget(PDFPageWidget *pageWidget);
|
||||
void setAncestor(QWidget* ancestor){ this-> ancestor = ancestor;}
|
||||
void setFather(QWidget* father){this->father = father;}
|
||||
int getPagesCount() const;
|
||||
QWidget* getFather(){return father;}
|
||||
void addPageWidget(PDFPageWidget* pageWidget);
|
||||
void setAncestor(QWidget* ancestor) { this->ancestor = ancestor; }
|
||||
void setFather(QWidget* father) { this->father = father; }
|
||||
int getPagesCount(void) const;
|
||||
QWidget* getFather(void) { return father; }
|
||||
|
||||
protected:
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void dropEvent(QDropEvent *event);
|
||||
void dragEnterEvent(QDragEnterEvent* event);
|
||||
void dropEvent(QDropEvent* event);
|
||||
|
||||
private:
|
||||
QWidget *ancestor;
|
||||
QWidget *father;
|
||||
|
||||
QWidget* ancestor;
|
||||
QWidget* father;
|
||||
|
||||
private slots:
|
||||
void ShowContextMenu(const QPoint&);
|
||||
};
|
||||
@ -57,7 +59,7 @@ class PDFFileWidget : public QFrame {
|
||||
Q_PROPERTY(bool collapsed READ isCollapsed WRITE setCollapsed)
|
||||
|
||||
public:
|
||||
PDFFileWidget(QWidget *parent = 0);
|
||||
PDFFileWidget(QWidget* parent = 0);
|
||||
|
||||
public:
|
||||
void setAncestor(QWidget* ancestor);
|
||||
@ -68,13 +70,13 @@ public:
|
||||
int getChildCount();
|
||||
|
||||
void setSelected(bool select);
|
||||
bool isSelected() {return selected;}
|
||||
bool isCollapsed(){ return collapsed; }
|
||||
bool isSelected(void) { return selected; }
|
||||
bool isCollapsed(void){ return collapsed; }
|
||||
void setCollapsed(bool collapsed);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void paintEvent(QPaintEvent* event);
|
||||
|
||||
private slots:
|
||||
void removeButtonClicked(void);
|
||||
@ -82,16 +84,17 @@ private slots:
|
||||
void updateThumbnail(QImage,PDFPageWidget*);
|
||||
|
||||
public :
|
||||
PagesContainerWidget *pagesContainerWidget;
|
||||
PagesContainerWidget* pagesContainerWidget;
|
||||
|
||||
private:
|
||||
ThumbGen tgen;
|
||||
QGridLayout *topLayout;
|
||||
QGridLayout* topLayout;
|
||||
|
||||
QLabel *fileNameLabel;
|
||||
QPushButton *collapseButton;
|
||||
QPushButton *removeButton;
|
||||
QScrollArea *scrollArea;
|
||||
QWidget *ancestor;
|
||||
QLabel* fileNameLabel;
|
||||
QPushButton* collapseButton;
|
||||
QPushButton* removeButton;
|
||||
QScrollArea* scrollArea;
|
||||
QWidget* ancestor;
|
||||
|
||||
bool collapsed;
|
||||
bool selected;
|
||||
|
@ -8,7 +8,8 @@ PDFJam::PDFJam()
|
||||
{
|
||||
|
||||
}
|
||||
//to make sure this folder exists and has no file inside
|
||||
|
||||
/* Ensure this folder exists and has no files inside. */
|
||||
void PDFJam::makeCleanFolder(QString path){
|
||||
QString temp = "mkdir -p %1 && rm %2*";
|
||||
int value = system(temp.arg(path).arg(path).toStdString().c_str());
|
||||
@ -21,7 +22,8 @@ void PDFJam::pushCommand(QString cmd){
|
||||
if(!isRunning()) start();
|
||||
|
||||
}
|
||||
//to rotate a page in a pdf file, clockwise direction
|
||||
|
||||
/* Rotate a page in a pdf file, clockwise. */
|
||||
bool PDFJam::rotatePage(int fileIndex,int rotatedPageIndex,int degree){
|
||||
if ((degree!=90) && (degree!=180) && (degree!=270)){
|
||||
return false;
|
||||
@ -33,12 +35,12 @@ bool PDFJam::rotatePage(int fileIndex,int rotatedPageIndex,int degree){
|
||||
|
||||
}
|
||||
|
||||
//to remove a page in a pdf file
|
||||
/*Remove a page in a pdf file. */
|
||||
bool PDFJam::removePage(int fileIndex,int numPages, int deletedPageIndex){
|
||||
if ((deletedPageIndex<0)||(deletedPageIndex>=numPages)) {
|
||||
return false;
|
||||
}
|
||||
//QString temp = "file1.pdf '-' file2.pdf '1,2' file3.pdf '2-' --outfile output.pdf"
|
||||
/*QString temp = "file1.pdf '-' file2.pdf '1,2' file3.pdf '2-' --outfile output.pdf"*/
|
||||
QString rmTemp = "rm /tmp/pdffactory/%1/%2.pdf ";
|
||||
QString cmd = rmTemp.arg(QString::number(fileIndex)).arg(QString::number(deletedPageIndex));
|
||||
QString temp = "mv /tmp/pdffactory/%1/%2.pdf /tmp/pdffactory/%3/%4.pdf ";
|
||||
@ -80,9 +82,9 @@ void PDFJam::pastePage(int fileIndex,int numPages, int pageIndex, int slot=0){
|
||||
|
||||
}
|
||||
void PDFJam::movePage(int fromFileIndex, int fromFileNumPage, int fromPageIndex, int toFileIndex, int toFileNumPage, int toPageIndex ){
|
||||
//TODO:back up clipboard
|
||||
//TODO: back up clipboard
|
||||
|
||||
//if this is page moving within files, update file Index.
|
||||
/* If the page is moving within files, update file index. */
|
||||
if (toFileIndex == fromFileIndex) {
|
||||
toFileNumPage--;
|
||||
if(toPageIndex>fromPageIndex)
|
||||
@ -97,8 +99,8 @@ void PDFJam::savePageAsImage(Poppler::Page pp, QString dest,double dpi = 72){
|
||||
(void)dest;
|
||||
(void)dpi;
|
||||
}
|
||||
//to export file number "fileIndex" to destination
|
||||
//support n-up, orientation, offset options
|
||||
|
||||
/* Export file number "fileIndex" to destination. */
|
||||
void PDFJam::exportFile(int fileIndex,int numPages, QString dest, bool isNup,QSize nup, bool isLandscape , bool hasTwoSidedOffset, int leftOffset){
|
||||
|
||||
QString cmd = "pdfjam ";
|
||||
@ -114,9 +116,9 @@ void PDFJam::exportFile(int fileIndex,int numPages, QString dest, bool isNup,QSi
|
||||
QString nupTemp = " --nup '%1x%2' --frame true ";
|
||||
cmd += nupTemp.arg(QString::number(nup.width())).arg(QString::number(nup.height()));
|
||||
}
|
||||
//offset
|
||||
/* Offset. */
|
||||
if(hasTwoSidedOffset){
|
||||
//pipe to another pdfjam to do offset, after other things are done
|
||||
/* Pipe to another pdfjam to do offset, after other things have been done. */
|
||||
QString outStdout = " --outfile /dev/stdout | pdfjam ";
|
||||
cmd += outStdout.arg(dest);
|
||||
|
||||
@ -124,7 +126,7 @@ void PDFJam::exportFile(int fileIndex,int numPages, QString dest, bool isNup,QSi
|
||||
QString offsetTemp =" --offset \"%1cm 0cm\" ";
|
||||
cmd+=offsetTemp.arg(QString::number(leftOffset));
|
||||
|
||||
//TODO - extension: 2 orientations, this one is after n-up, can extend later
|
||||
/* TODO - extension: 2 orientations, this one is after n-up, can extend later */
|
||||
QString orientation = isLandscape?" --landscape ": " --no-landscape ";
|
||||
cmd += orientation;
|
||||
|
||||
@ -145,6 +147,7 @@ void PDFJam::loadFile(QString fileName, int fileIndex,Poppler::Document* pd){
|
||||
|
||||
QString temp = "pdfjam %1 %2 --outfile %3%4.pdf %5";
|
||||
QString cmd="";
|
||||
|
||||
for (int i = 0; i < numPages; i++) {
|
||||
QString orientation = " --no-landscape ";
|
||||
QSizeF pageSize = pd->page(i)->pageSizeF();
|
||||
@ -155,6 +158,7 @@ void PDFJam::loadFile(QString fileName, int fileIndex,Poppler::Document* pd){
|
||||
}
|
||||
pushCommand(cmd);
|
||||
}
|
||||
|
||||
QString PDFJam::nextCommand(){
|
||||
|
||||
QString cmd;
|
||||
@ -170,7 +174,7 @@ bool PDFJam::isQueueEmpty(){
|
||||
return (cmdQueue.size()==0);
|
||||
}
|
||||
|
||||
void PDFJam::run(){
|
||||
void PDFJam::run(void){
|
||||
while(!isQueueEmpty()){
|
||||
QString cmd = nextCommand();
|
||||
//int value = system(cmd.toStdString().c_str());
|
||||
|
21
src/PDFJam.h
21
src/PDFJam.h
@ -10,23 +10,26 @@ class QImage;
|
||||
class PDFJam: public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PDFJam();
|
||||
void pushCommand(QString);
|
||||
void loadFile(QString fileName,int,Poppler::Document*);
|
||||
void exportFile(int ,int , QString , bool ,QSize , bool , bool , int );
|
||||
void loadFile(QString fileName, int, Poppler::Document*);
|
||||
void exportFile(int, int, QString, bool, QSize, bool, bool, int );
|
||||
|
||||
void savePageAsImage(Poppler::Page pp, QString dest, double);
|
||||
void movePage(int , int , int , int , int , int );
|
||||
void movePage(int, int, int, int, int, int );
|
||||
|
||||
void pastePage(int ,int , int ,int);
|
||||
void copyPage(int , int , int );
|
||||
void cutPage(int ,int , int ,int);
|
||||
void pastePage(int, int, int, int);
|
||||
void copyPage(int, int, int);
|
||||
void cutPage(int, int, int, int);
|
||||
|
||||
bool removePage(int, int, int );
|
||||
bool rotatePage(int, int, int);
|
||||
|
||||
bool removePage(int ,int , int );
|
||||
bool rotatePage(int,int,int);
|
||||
protected:
|
||||
void run();
|
||||
void run(void);
|
||||
|
||||
private:
|
||||
void makeCleanFolder(QString);
|
||||
QVector<QString> cmdQueue;
|
||||
|
@ -86,7 +86,7 @@ void PDFPageWidget::pageRotate(){
|
||||
((PDFTableWidget*)ancestor)->rotatePage(this);
|
||||
}
|
||||
|
||||
void PDFPageWidget::rotate90() {
|
||||
void PDFPageWidget::rotate90(void) {
|
||||
rotation += 90;
|
||||
if (rotation == 360) rotation = 0;
|
||||
|
||||
|
@ -24,48 +24,48 @@ public:
|
||||
QSize sizeHint() const;
|
||||
|
||||
void setThumbnail(QImage pageImage);
|
||||
void setOriginInfo(QString path,int num){pageNo = num;oriFilePath=path;};
|
||||
void setOriginInfo(QString path, int num) { pageNo = num;oriFilePath=path; }
|
||||
void setPopplerPage(Poppler::Page*);
|
||||
void setThumbPopplerPage(Poppler::Page*);
|
||||
void setAncestor(QWidget *ancestor);
|
||||
void setFather(QWidget *father);
|
||||
void rotate90();
|
||||
void setAncestor(QWidget* ancestor);
|
||||
void setFather(QWidget* father);
|
||||
void rotate90(void);
|
||||
Poppler::Page::Rotation getRotation();
|
||||
int getIntRotation(){return rotation;};
|
||||
int setIntRotation(int r){rotation = r;};
|
||||
QWidget* getFather() const { return father;}
|
||||
void registerName(QString name) { path = name;}
|
||||
QString getName() { return path;}
|
||||
int getPageNo() { return pageNo;}
|
||||
QString getOriFilePath() { return oriFilePath;}
|
||||
int getIntRotation(void) { return rotation; }
|
||||
void setIntRotation(int r) { rotation = r; }
|
||||
QWidget* getFather(void) const { return father; }
|
||||
void registerName(QString name) { path = name; }
|
||||
QString getName(void) { return path; }
|
||||
int getPageNo(void) { return pageNo; }
|
||||
QString getOriFilePath() { return oriFilePath; }
|
||||
Poppler::Page* getNewThumbPopplerPage();
|
||||
|
||||
void setSelected(bool select);
|
||||
bool isSelected() {return selected;}
|
||||
bool isSelected(void) { return selected; }
|
||||
|
||||
Poppler::Page* getPage(){return previewPage;}
|
||||
Poppler::Page* getThumbPage(){return thumbPage;}
|
||||
Poppler::Page* getPage(void) { return previewPage; }
|
||||
Poppler::Page* getThumbPage(void) { return thumbPage; }
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void enterEvent(QEvent *event);
|
||||
void leaveEvent(QEvent *event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void dropEvent(QDropEvent *event);
|
||||
void paintEvent(QPaintEvent* event);
|
||||
void enterEvent(QEvent* event);
|
||||
void leaveEvent(QEvent* event);
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void dragEnterEvent(QDragEnterEvent* event);
|
||||
void dropEvent(QDropEvent* event);
|
||||
|
||||
private:
|
||||
//QVector<QPushButton> buttons;
|
||||
QString path;
|
||||
int pageNo;
|
||||
QString oriFilePath;
|
||||
QWidget *ancestor;
|
||||
QWidget *father;
|
||||
QString path;
|
||||
int pageNo;
|
||||
QString oriFilePath;
|
||||
QWidget* ancestor;
|
||||
QWidget* father;
|
||||
|
||||
QImage image;
|
||||
Poppler::Page *previewPage,*thumbPage;
|
||||
QPixmap pixmap;
|
||||
QPushButton *btnRotate, *btnCut, *btnCopy, *btnDelete;
|
||||
QImage image;
|
||||
Poppler::Page* previewPage,*thumbPage;
|
||||
QPixmap pixmap;
|
||||
QPushButton* btnRotate, *btnCut, *btnCopy, *btnDelete;
|
||||
|
||||
int rotation;
|
||||
|
||||
|
@ -22,7 +22,7 @@ void PDFPreviewWidget::updateImage(QImage qimg) {
|
||||
update();
|
||||
}
|
||||
|
||||
void PDFPreviewWidget::regenImage() {
|
||||
void PDFPreviewWidget::regenImage(void) {
|
||||
double dpi;
|
||||
double dpi2;
|
||||
QSize targetSize;
|
||||
@ -38,18 +38,18 @@ void PDFPreviewWidget::regenImage() {
|
||||
dpi2= targetSize.width()/(float)oriSize.width()*oriDpi;
|
||||
dpi = dpi<dpi2?dpi:dpi2;
|
||||
|
||||
//previewImage = pPage->renderToImage(dpi,dpi, -1, -1, -1, -1, rotation);
|
||||
/*previewImage = pPage->renderToImage(dpi,dpi, -1, -1, -1, -1, rotation);*/
|
||||
pgen.render(pPage,dpi,rotation);
|
||||
pgen.start();
|
||||
}
|
||||
|
||||
void PDFPreviewWidget::regenPixmap() {
|
||||
void PDFPreviewWidget::regenPixmap(void) {
|
||||
pixmap = QPixmap::fromImage(previewImage);
|
||||
pixmap = pixmap.scaled(currentPixmapSize, Qt::KeepAspectRatioByExpanding);
|
||||
pixmap = pixmap.scaled(currentPixmapSize, Qt::KeepAspectRatio);
|
||||
currentPixmapSize = pixmap.size();
|
||||
}
|
||||
|
||||
void PDFPreviewWidget::repositionPixmap() {
|
||||
void PDFPreviewWidget::repositionPixmap(void) {
|
||||
currentPixmapPos = QPoint((size().width() - pixmap.width()) / 2, (size().height() - pixmap.height()) / 2);
|
||||
}
|
||||
|
||||
@ -92,17 +92,20 @@ void PDFPreviewWidget::resizeEvent(QResizeEvent *event) {
|
||||
void PDFPreviewWidget::wheelEvent(QWheelEvent *event) {
|
||||
if (pPage!=NULL) {
|
||||
if (event->delta() > 0)
|
||||
currentPixmapSize += QSize(30, 30);
|
||||
currentPixmapSize += QSize(45, 45);
|
||||
else if (event->delta() < 0)
|
||||
currentPixmapSize -= QSize(30, 30);
|
||||
currentPixmapSize -= QSize(45, 45);
|
||||
|
||||
if (currentPixmapSize.width() < 150 || currentPixmapSize.height() < 150) {
|
||||
currentPixmapSize = QSize(150, 150);
|
||||
}
|
||||
|
||||
regenImage();
|
||||
//regenImage();
|
||||
|
||||
regenPixmap();
|
||||
repositionPixmap();
|
||||
/* TODO: This could be buggy. -- Monitor this. */
|
||||
regenImage(); /* This appears to stop aspect ratio from being a douche. */
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
@ -18,24 +18,25 @@ class PreviewGen;
|
||||
class PDFPreviewWidget : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PDFPreviewWidget(QWidget *parent = 0);
|
||||
explicit PDFPreviewWidget(QWidget* parent = 0);
|
||||
|
||||
public slots:
|
||||
void regenImage();
|
||||
void regenPixmap();
|
||||
void repositionPixmap();
|
||||
void regenImage(void);
|
||||
void regenPixmap(void);
|
||||
void repositionPixmap(void);
|
||||
void previewUpdate(Poppler::Page*, Poppler::Page::Rotation);
|
||||
void checkPreviewUpdate(Poppler::Page*, Poppler::Page::Rotation);
|
||||
void checkPagePreviewExisted(Poppler::Page*);
|
||||
|
||||
protected:
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
void wheelEvent(QWheelEvent* event);
|
||||
void paintEvent(QPaintEvent* event);
|
||||
void resizeEvent(QResizeEvent* event);
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void mouseMoveEvent(QMouseEvent* event);
|
||||
void mouseReleaseEvent(QMouseEvent* event);
|
||||
|
||||
public:
|
||||
Poppler::Page* pPage;
|
||||
@ -45,10 +46,10 @@ private:
|
||||
QPixmap pixmap;
|
||||
Poppler::Page::Rotation rotation;
|
||||
|
||||
QSize currentPixmapSize;
|
||||
QPoint currentPixmapPos;
|
||||
QPoint lastPixmapPos;
|
||||
QPoint dragStartPos;
|
||||
QSize currentPixmapSize;
|
||||
QPoint currentPixmapPos;
|
||||
QPoint lastPixmapPos;
|
||||
QPoint dragStartPos;
|
||||
|
||||
private slots:
|
||||
void updateImage(QImage);
|
||||
|
@ -6,10 +6,9 @@
|
||||
#include <QtAlgorithms>
|
||||
#include "PDFJam.h"
|
||||
|
||||
// Constructor
|
||||
PDFTableWidget::PDFTableWidget(QWidget* parent) : QFrame(parent)
|
||||
{
|
||||
// Frame (Expanding with VBox) - Scroll Area (Expanding) - Container (Expanding with VBox) - Children
|
||||
/* Frame (Expanding with VBox) - Scroll Area (Expanding) - Container (Expanding with VBox) - Children */
|
||||
|
||||
setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
@ -103,7 +102,7 @@ QVector<QString> PDFTableWidget::getVisibleFileNames() {
|
||||
}
|
||||
|
||||
void PDFTableWidget::registerPage(PDFPageWidget* child){
|
||||
//come up with a new name here
|
||||
/* come up with a new name here. */
|
||||
QString name = QString("/home/pdfpage").append(QString::number(pageChilds.size()));
|
||||
pageChilds[name] = child;
|
||||
child->registerName(name);
|
||||
@ -164,13 +163,13 @@ void PDFTableWidget::fileRemoveButtonClicked(PDFFileWidget* sender) {
|
||||
selectedPages.remove(selectedPages.indexOf(pageWidget));
|
||||
}
|
||||
|
||||
// Handle remove file
|
||||
/* Handle remove file. */
|
||||
sender->hide();
|
||||
}
|
||||
|
||||
void PDFTableWidget::pageClicked(PDFPageWidget *sender, QMouseEvent* event, QString path){
|
||||
if (event->button() == Qt::LeftButton){
|
||||
// Handle selection
|
||||
/* Handle selection */
|
||||
if (selectedPages.size() > 0 && event->modifiers() != Qt::ControlModifier) {
|
||||
|
||||
if (sender->isSelected() ){
|
||||
@ -260,8 +259,7 @@ void PDFTableWidget::deletePageSkipSelection(PDFPageWidget* pageWidget){
|
||||
pageChilds.remove(pageWidget->getName());
|
||||
|
||||
|
||||
// PLS ACTIVATE THIS LINE ONCE EVERYTHING HAS BEEN FIXED
|
||||
// :D :D :D :D :D :D
|
||||
/* Uncomment once everything is fixed. */
|
||||
//delete page;
|
||||
|
||||
}
|
||||
@ -288,8 +286,7 @@ void PDFTableWidget::deletePage(PDFPageWidget* pageWidget){
|
||||
pageChilds.remove(pageWidget->getName());
|
||||
|
||||
|
||||
// PLS ACTIVATE THIS LINE ONCE EVERYTHING HAS BEEN FIXED
|
||||
// :D :D :D :D :D :D
|
||||
/* Uncomment once everything is fixed. */
|
||||
//delete page;
|
||||
|
||||
}
|
||||
@ -306,7 +303,7 @@ void PDFTableWidget::cutPage(PDFPageWidget* pageWidget){
|
||||
pdfJam.cutPage(daddyID, daddy->pagesContainerWidget->pageWidgets.size(),pageID, id);
|
||||
}
|
||||
|
||||
void PDFTableWidget::clearClipboard(){
|
||||
void PDFTableWidget::clearClipboard(void){
|
||||
copiedPages.clear();
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ class PDFTableWidget: public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PDFTableWidget(QWidget *parent = 0);
|
||||
PDFTableWidget(QWidget* parent = 0);
|
||||
void loadFile (QString fileName);
|
||||
void registerPage(PDFPageWidget *child);
|
||||
|
||||
@ -30,10 +30,10 @@ public:
|
||||
ThumbGen mainTgen;
|
||||
|
||||
private:
|
||||
QVBoxLayout *outerLayout;
|
||||
QScrollArea *scrollArea;
|
||||
QWidget *containerWidget;
|
||||
QVBoxLayout *containerLayout;
|
||||
QVBoxLayout* outerLayout;
|
||||
QScrollArea* scrollArea;
|
||||
QWidget* containerWidget;
|
||||
QVBoxLayout* containerLayout;
|
||||
|
||||
QVector<Poppler::Document*> files;
|
||||
QVector<QString> fileNames;
|
||||
@ -58,6 +58,7 @@ private:
|
||||
QVector<PDFFileWidget*> selectedFiles;
|
||||
|
||||
QVector<PDFPageWidget*> copiedPages;
|
||||
|
||||
public:
|
||||
QVector<PDFFileWidget*> getSelectedFiles();
|
||||
QVector<int> getSelectedIndices();
|
||||
@ -76,8 +77,8 @@ public:
|
||||
void pastePage(PDFFileWidget* fileWidget, int pageID);
|
||||
void rotatePage(PDFPageWidget* pageWidget);
|
||||
void cutPage(PDFPageWidget* pageWidget);
|
||||
void clearClipboard();
|
||||
bool hasClipboard(){ return copiedPages.size() > 0; }
|
||||
void clearClipboard(void);
|
||||
bool hasClipboard(void) { return copiedPages.size() > 0; }
|
||||
|
||||
public slots:
|
||||
void rotateSelected();
|
||||
|
@ -23,7 +23,7 @@ protected:
|
||||
QMutex mutex;
|
||||
|
||||
public:
|
||||
double calcDpi(Poppler::Page *pdfPage, double dpi);
|
||||
double calcDpi(Poppler::Page* pdfPage, double dpi);
|
||||
|
||||
signals:
|
||||
void updatePreview(QImage);
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
|
||||
#include "PDFPageWidget.h"
|
||||
ThumbGen::ThumbGen()
|
||||
ThumbGen::ThumbGen(void)
|
||||
{
|
||||
|
||||
}
|
||||
@ -41,6 +41,5 @@ void ThumbGen::render(PDFPageWidget* pw,Poppler::Page* pp){
|
||||
pWidgets.append(pw);
|
||||
pPages.append(pp);
|
||||
mutex.unlock();
|
||||
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ class ThumbGen: public QThread
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ThumbGen();
|
||||
ThumbGen(void);
|
||||
void render(PDFPageWidget*,Poppler::Page*);
|
||||
|
||||
protected:
|
||||
@ -23,7 +23,7 @@ protected:
|
||||
QMutex mutex;
|
||||
|
||||
public:
|
||||
double calcDpi(Poppler::Page *pdfPage, QSize targetSize);
|
||||
double calcDpi(Poppler::Page* pdfPage, QSize targetSize);
|
||||
|
||||
signals:
|
||||
void updateThumbnail(QImage, PDFPageWidget*);
|
||||
|
@ -1,13 +1,13 @@
|
||||
// main.cpp
|
||||
|
||||
#include <QApplication>
|
||||
#include "PDFFactory.h"
|
||||
#include "HPDF.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
PDFFactory pdffactory;
|
||||
pdffactory.show();
|
||||
HPDF hpdf;
|
||||
hpdf.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user