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