From 15f55e317d6ca487560e41b57b955d517b5f7954 Mon Sep 17 00:00:00 2001 From: birkeh Date: Tue, 21 Jan 2020 23:36:30 +0100 Subject: [PATCH] initial commit --- cexif.cpp | 10 ++--- cfilebrowser.cpp | 84 ++++++++++++++++++++++++++++++++++++- cfilebrowser.h | 33 ++++++++++++++- cfilebrowser.ui | 42 +++++++++++++++---- cfileviewer.cpp | 22 ++++++++++ cfileviewer.h | 7 +++- cfileviewer.ui | 89 ++++++++++++++++++++++++++++++++++++---- cmainwindow.cpp | 20 +++++---- cmainwindow.h | 6 +++ cmainwindow.ui | 12 ++++-- common.cpp | 31 ++++++++++++++ common.h | 8 ++++ images/tango/index.theme | 14 +++++++ main.cpp | 4 +- picturePrint.pro | 10 +++++ 15 files changed, 355 insertions(+), 37 deletions(-) create mode 100644 images/tango/index.theme diff --git a/cexif.cpp b/cexif.cpp index c11a812..71301af 100644 --- a/cexif.cpp +++ b/cexif.cpp @@ -539,7 +539,7 @@ cEXIFCompressionList::cEXIFCompressionList() { QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setHostName("localhost"); - db.setDatabaseName("pictureConvert.db"); + db.setDatabaseName("picturePrint.db"); if(!db.open()) return; @@ -601,7 +601,7 @@ cEXIFLightSourceList::cEXIFLightSourceList() { QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setHostName("localhost"); - db.setDatabaseName("pictureConvert.db"); + db.setDatabaseName("picturePrint.db"); if(!db.open()) return; @@ -663,7 +663,7 @@ cEXIFFlashList::cEXIFFlashList() { QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setHostName("localhost"); - db.setDatabaseName("pictureConvert.db"); + db.setDatabaseName("picturePrint.db"); if(!db.open()) return; @@ -729,7 +729,7 @@ cEXIFTagList::cEXIFTagList() { QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setHostName("localhost"); - db.setDatabaseName("pictureConvert.db"); + db.setDatabaseName("picturePrint.db"); if(!db.open()) return; @@ -1039,7 +1039,7 @@ cXMPTagList::cXMPTagList() { QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setHostName("localhost"); - db.setDatabaseName("pictureConvert.db"); + db.setDatabaseName("picturePrint.db"); if(!db.open()) return; diff --git a/cfilebrowser.cpp b/cfilebrowser.cpp index 9b0d156..cae6f9e 100644 --- a/cfilebrowser.cpp +++ b/cfilebrowser.cpp @@ -1,14 +1,94 @@ #include "cfilebrowser.h" +#include "cfileviewer.h" + #include "ui_cfilebrowser.h" -cFileBrowser::cFileBrowser(QWidget *parent) : +#include +#include + +#include +#include + +#include + +#include + + +cFileBrowser::cFileBrowser(QProgressBar* lpProgressBar, QList* lpImageFormats, QWidget *parent) : QWidget(parent), - ui(new Ui::cFileBrowser) + ui(new Ui::cFileBrowser), + m_lpFileListModel(nullptr), + m_lpProgressBar(lpProgressBar), + m_lpImageFormats(lpImageFormats) { ui->setupUi(this); + + ui->m_lpFileList->setGridSize(QSize(THUMBNAIL_WIDTH+2+4, THUMBNAIL_WIDTH+34+4)); + +// m_directoryListModel.setRootPath(""); + m_directoryListModel.setRootPath("C:/Users/birkeh/Pictures"); + m_directoryListModel.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot); + ui->m_lpDirectoryList->setModel(&m_directoryListModel); + ui->m_lpDirectoryList->setAnimated(false); + ui->m_lpDirectoryList->setIndentation(20); + ui->m_lpDirectoryList->setColumnWidth(0, 250); + + m_lpFileListModel = new QStandardItemModel(0, 0); + ui->m_lpFileList->setModel(m_lpFileListModel); + + connect(ui->m_lpDirectoryList->selectionModel(), &QItemSelectionModel::selectionChanged, this, &cFileBrowser::onDirectoryChanged); } cFileBrowser::~cFileBrowser() { delete ui; } + +void cFileBrowser::onDirectoryChanged(const QItemSelection& selected, const QItemSelection& /*deselected*/) +{ + m_lpProgressBar->setVisible(true); + + m_lpFileListModel->clear(); + + QFileInfo info = m_directoryListModel.fileInfo(selected.indexes()[0]); + QDir dir(info.filePath()); + + QFileInfoList list = dir.entryInfoList(generateReadList(*m_lpImageFormats), QDir::Files, QDir::Name); + + m_lpProgressBar->setRange(0, list.count()); + + for(int x = 0;x < list.count();x++) + { + addFile(list[x]); + m_lpProgressBar->setValue(x); +// qApp->sendPostedEvents(); + qApp->processEvents(); + } + + m_lpProgressBar->setVisible(false); +} + +void cFileBrowser::addFile(const QFileInfo& fileInfo) +{ + cEXIF* lpExif = new cEXIF(&m_exifTAGList, &m_exifCompressionList, &m_exifLightSourceList, &m_exifFlashList, &m_iptcTagList, &m_xmpTagList); + + if(!lpExif->fromFile(fileInfo.filePath())) + { + delete lpExif; + return; + } + + QImage thumbnail = lpExif->thumbnail(); + + QImage thumb(THUMBNAIL_WIDTH, thumbnail.height(), QImage::Format_ARGB32); + thumb.fill(qRgba(0, 0, 0, 0)); + QPainter painter(&thumb); + painter.drawImage((THUMBNAIL_WIDTH-thumbnail.width())/2, 0, thumbnail); + + QStandardItem* lpItem = new QStandardItem(""); + cFileViewer* lpFileViewer = new cFileViewer; + lpFileViewer->setImage(fileInfo.filePath(), QPixmap::fromImage(thumb)); + + m_lpFileListModel->appendRow(lpItem); + ui->m_lpFileList->setIndexWidget(m_lpFileListModel->index(m_lpFileListModel->rowCount()-1, 0), lpFileViewer); +} diff --git a/cfilebrowser.h b/cfilebrowser.h index 0d70e42..4292993 100644 --- a/cfilebrowser.h +++ b/cfilebrowser.h @@ -1,8 +1,19 @@ #ifndef CFILEBROWSER_H #define CFILEBROWSER_H + +#include "common.h" +#include "cexif.h" #include +#include +#include +#include +#include + +#include + + namespace Ui { class cFileBrowser; } @@ -12,11 +23,29 @@ class cFileBrowser : public QWidget Q_OBJECT public: - explicit cFileBrowser(QWidget *parent = nullptr); + explicit cFileBrowser(QProgressBar* lpProgressBar, QList* lpImageFormats, QWidget *parent = nullptr); ~cFileBrowser(); private: - Ui::cFileBrowser *ui; + Ui::cFileBrowser* ui; + QFileSystemModel m_directoryListModel; + QStandardItemModel* m_lpFileListModel; + QProgressBar* m_lpProgressBar; + QList* m_lpImageFormats; + + cEXIFTagList m_exifTAGList; + cEXIFCompressionList m_exifCompressionList; + cEXIFLightSourceList m_exifLightSourceList; + cEXIFFlashList m_exifFlashList; + + cIPTCTagList m_iptcTagList; + + cXMPTagList m_xmpTagList; + + void addFile(const QFileInfo& fileInfo); + +private slots: + void onDirectoryChanged(const QItemSelection& selected, const QItemSelection& deselected); }; #endif // CFILEBROWSER_H diff --git a/cfilebrowser.ui b/cfilebrowser.ui index c52210f..bb54346 100644 --- a/cfilebrowser.ui +++ b/cfilebrowser.ui @@ -1,21 +1,49 @@ + - - - cFileBrowser - + 0 0 - 400 - 300 + 779 + 602 Form + + + + + Qt::Horizontal + + + + + QAbstractItemView::NoEditTriggers + + + QListView::LeftToRight + + + QListView::Adjust + + + + 202 + 236 + + + + QListView::IconMode + + + + + - + diff --git a/cfileviewer.cpp b/cfileviewer.cpp index 40f4614..a6dce44 100644 --- a/cfileviewer.cpp +++ b/cfileviewer.cpp @@ -1,14 +1,36 @@ +#include "common.h" + #include "cfileviewer.h" #include "ui_cfileviewer.h" +#include + + cFileViewer::cFileViewer(QWidget *parent) : QWidget(parent), ui(new Ui::cFileViewer) { ui->setupUi(this); + + ui->m_lpImage->setMinimumSize(THUMBNAIL_WIDTH, THUMBNAIL_WIDTH); + ui->m_lpImage->setMaximumSize(THUMBNAIL_WIDTH, THUMBNAIL_WIDTH); + ui->m_lpImage->resize(THUMBNAIL_WIDTH, THUMBNAIL_WIDTH); + + setMinimumSize(THUMBNAIL_WIDTH+2, THUMBNAIL_WIDTH+34); + setMaximumSize(THUMBNAIL_WIDTH+2, THUMBNAIL_WIDTH+34); + resize(THUMBNAIL_WIDTH+2, THUMBNAIL_WIDTH+34); } cFileViewer::~cFileViewer() { delete ui; } + +void cFileViewer::setImage(const QString& fileName, const QPixmap& image) +{ + QFileInfo fileInfo(fileName); + + m_fileName = fileName; + ui->m_lpImage->setPixmap(image); + ui->m_lpFileName->setText(fileInfo.fileName()); +} diff --git a/cfileviewer.h b/cfileviewer.h index 6b20d77..7c0d258 100644 --- a/cfileviewer.h +++ b/cfileviewer.h @@ -1,8 +1,10 @@ #ifndef CFILEVIEWER_H #define CFILEVIEWER_H + #include + namespace Ui { class cFileViewer; } @@ -15,8 +17,11 @@ public: explicit cFileViewer(QWidget *parent = nullptr); ~cFileViewer(); + void setImage(const QString& fileName, const QPixmap& image); + private: - Ui::cFileViewer *ui; + Ui::cFileViewer* ui; + QString m_fileName; }; #endif // CFILEVIEWER_H diff --git a/cfileviewer.ui b/cfileviewer.ui index 7322fc3..8771a0e 100644 --- a/cfileviewer.ui +++ b/cfileviewer.ui @@ -1,21 +1,96 @@ + - - - cFileViewer - + 0 0 - 400 - 300 + 100 + 100 + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + Form + + true + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 0 + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + IMAGE + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + + - + diff --git a/cmainwindow.cpp b/cmainwindow.cpp index df04428..4c6e17e 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -15,12 +15,13 @@ cMainWindow::cMainWindow(cSplashScreen* lpSplashScreen, QWidget *parent) : QMainWindow(parent), ui(new Ui::cMainWindow), - m_lpSplashScreen(lpSplashScreen) + m_lpSplashScreen(lpSplashScreen), + m_lpFileBrowser(0) { + setImageFormats(); + initUI(); createActions(); - - setImageFormats(); } cMainWindow::~cMainWindow() @@ -58,7 +59,14 @@ void cMainWindow::initUI() ui->setupUi(this); -// QIcon::setThemeName("TangoMFK"); + QIcon::setThemeName("TangoMFK"); + + m_lpProgressBar = new QProgressBar(this); + m_lpProgressBar->setVisible(false); + ui->m_lpStatusBar->addPermanentWidget(m_lpProgressBar); + + m_lpFileBrowser = new cFileBrowser(m_lpProgressBar, &m_imageFormats, this); + ui->m_lpMainTab->addTab(m_lpFileBrowser, "Files"); // m_lpFileListModel = new QStandardItemModel; // ui->m_lpFileList->setModel(m_lpFileListModel); @@ -76,10 +84,6 @@ void cMainWindow::initUI() move(iX, iY); } -// m_lpProgressBar = new QProgressBar(this); -// m_lpProgressBar->setVisible(false); -// ui->m_lpStatusBar->addPermanentWidget(m_lpProgressBar); - // QStringList headerLabels = QStringList() << tr("icon") << tr("path") << tr("file") << tr("size") << tr("date") << tr("width") << tr("height") << (""); // m_lpFileListModel->setHorizontalHeaderLabels(headerLabels); } diff --git a/cmainwindow.h b/cmainwindow.h index 7497cb4..bead136 100644 --- a/cmainwindow.h +++ b/cmainwindow.h @@ -5,8 +5,11 @@ #include "csplashscreen.h" #include "common.h" +#include "cfilebrowser.h" + #include #include +#include QT_BEGIN_NAMESPACE @@ -25,6 +28,9 @@ public: private: Ui::cMainWindow* ui; cSplashScreen* m_lpSplashScreen; + QProgressBar* m_lpProgressBar; + + cFileBrowser* m_lpFileBrowser; QList m_imageFormats; diff --git a/cmainwindow.ui b/cmainwindow.ui index 3f6225c..b20ef47 100644 --- a/cmainwindow.ui +++ b/cmainwindow.ui @@ -13,8 +13,14 @@ - - + + + + + + + + 0 @@ -24,7 +30,7 @@ - + diff --git a/common.cpp b/common.cpp index 67c02a2..2dd685f 100644 --- a/common.cpp +++ b/common.cpp @@ -1 +1,32 @@ #include "common.h" + + +QStringList generateReadList(const QList& imageFormats) +{ + QStringList readList; + + for(int z = 0;z < imageFormats.count();z++) + { + IMAGEFORMAT i = imageFormats[z]; + + if(i.read) + readList.append(i.extension.split(" ")); + } + + return(readList); +} + +QStringList generateWriteList(const QList& imageFormats) +{ + QStringList writeList; + + for(int z = 0;z < imageFormats.count();z++) + { + IMAGEFORMAT i = imageFormats[z]; + + if(i.write) + writeList.append(i.extension.split("")); + } + + return(writeList); +} diff --git a/common.h b/common.h index a5acfbe..570be92 100644 --- a/common.h +++ b/common.h @@ -5,6 +5,10 @@ #include +#define THUMBNAIL_WIDTH 160 +#define THUMBNAIL_HEIGHT 120 + + #ifdef __GNUC__ #define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __PRETTY_FUNCTION__ << ":" #elif __MINGW32__ @@ -28,4 +32,8 @@ typedef struct tagIMAGEFORMAT } IMAGEFORMAT; +QStringList generateReadList(const QList& imageFormats); +QStringList generateWriteList(const QList& imageFormats); + + #endif // COMMON_H diff --git a/images/tango/index.theme b/images/tango/index.theme new file mode 100644 index 0000000..45b1be8 --- /dev/null +++ b/images/tango/index.theme @@ -0,0 +1,14 @@ +[Icon Theme] +Name=tango +Comment=Original tango icons +Inherits=default +Directories=16x16,22x22,32x32 + +[16x16] +Size=16 + +[22x22] +Size=22 + +[32x32] +Size=32 diff --git a/main.cpp b/main.cpp index 5d2dd15..c9a8b6c 100644 --- a/main.cpp +++ b/main.cpp @@ -14,10 +14,10 @@ int main(int argc, char *argv[]) QApplication a(argc, argv); a.setApplicationVersion(APP_VERSION); - a.setApplicationDisplayName("pictureConvert"); + a.setApplicationDisplayName("picturePrint"); a.setOrganizationName("WIN-DESIGN"); a.setOrganizationDomain("windesign.at"); - a.setApplicationName("pictureConvert"); + a.setApplicationName("picturePrint"); QSettings settings; diff --git a/picturePrint.pro b/picturePrint.pro index 3732027..9758335 100644 --- a/picturePrint.pro +++ b/picturePrint.pro @@ -44,17 +44,27 @@ DEFINES += APP_VERSION=\\\"$$VERSION\\\" #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ + cexif.cpp \ + cfilebrowser.cpp \ + cfileviewer.cpp \ + cimage.cpp \ common.cpp \ csplashscreen.cpp \ main.cpp \ cmainwindow.cpp HEADERS += \ + cexif.h \ + cfilebrowser.h \ + cfileviewer.h \ + cimage.h \ cmainwindow.h \ common.h \ csplashscreen.h FORMS += \ + cfilebrowser.ui \ + cfileviewer.ui \ cmainwindow.ui TRANSLATIONS += \