stop button, RAW image rotation

This commit is contained in:
2019-11-14 10:43:23 +01:00
parent da4ca4cad6
commit fc6e9d0451
5 changed files with 176 additions and 94 deletions
+27 -10
View File
@@ -18,56 +18,64 @@
cImage::cImage() :
QImage(),
m_isChromatic(true),
m_camType(camera_unknown)
m_camType(camera_unknown),
m_raw(false)
{
}
cImage::cImage(const QSize &size, QImage::Format format) :
QImage(size, format),
m_isChromatic(true),
m_camType(camera_unknown)
m_camType(camera_unknown),
m_raw(false)
{
}
cImage::cImage(int width, int height, QImage::Format format) :
QImage(width, height, format),
m_isChromatic(true),
m_camType(camera_unknown)
m_camType(camera_unknown),
m_raw(false)
{
}
cImage::cImage(uchar *data, int width, int height, QImage::Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo) :
QImage(data, width, height, format, cleanupFunction, cleanupInfo),
m_isChromatic(true),
m_camType(camera_unknown)
m_camType(camera_unknown),
m_raw(false)
{
}
cImage::cImage(const uchar *data, int width, int height, QImage::Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo) :
QImage(data, width, height, format, cleanupFunction, cleanupInfo),
m_isChromatic(true),
m_camType(camera_unknown)
m_camType(camera_unknown),
m_raw(false)
{
}
cImage::cImage(uchar *data, int width, int height, int bytesPerLine, QImage::Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo) :
QImage(data, width, height, bytesPerLine, format, cleanupFunction, cleanupInfo),
m_isChromatic(true),
m_camType(camera_unknown)
m_camType(camera_unknown),
m_raw(false)
{
}
cImage::cImage(const uchar *data, int width, int height, int bytesPerLine, QImage::Format format, QImageCleanupFunction cleanupFunction, void *cleanupInfo) :
QImage(data, width, height, bytesPerLine, format, cleanupFunction, cleanupInfo),
m_isChromatic(true),
m_camType(camera_unknown)
m_camType(camera_unknown),
m_raw(false)
{
}
cImage::cImage(const QString &fileName, const char *format) :
QImage(),
m_isChromatic(true),
m_camType(camera_unknown)
m_camType(camera_unknown),
m_raw(false)
{
load(fileName, format);
}
@@ -75,14 +83,16 @@ cImage::cImage(const QString &fileName, const char *format) :
cImage::cImage(const QImage &image) :
QImage(image),
m_isChromatic(true),
m_camType(camera_unknown)
m_camType(camera_unknown),
m_raw(false)
{
}
cImage::cImage(QImage &&other) :
QImage(other),
m_isChromatic(true),
m_camType(camera_unknown)
m_camType(camera_unknown),
m_raw(false)
{
}
@@ -407,5 +417,12 @@ bool cImage::loadRAW(const QString &fileName)
iProcessor.recycle();
rawMat.release();
m_raw = true;
return(true);
}
bool cImage::isRaw()
{
return(m_raw);
}
+9
View File
@@ -122,6 +122,14 @@ public:
*/
bool load(const QString &fileName, const char *format = nullptr);
/*!
\brief
\fn isRaw
\return bool
*/
bool isRaw();
protected:
/*!
\brief
@@ -205,6 +213,7 @@ protected:
private:
bool m_isChromatic; /*!< TODO: describe */
Cam m_camType; /*!< TODO: describe */
bool m_raw; /*!< TODO: describe */
/*!
\brief
+106 -32
View File
@@ -36,7 +36,17 @@ cMainWindow::cMainWindow(cSplashScreen* lpSplashScreen, QWidget *parent) :
ui(new Ui::cMainWindow),
m_lpSplashScreen(lpSplashScreen),
m_lpProgressBar(nullptr),
m_working(false)
m_lpFileToolBar(nullptr),
m_lpOpenFileAction(nullptr),
m_lpOpenDirectoryAction(nullptr),
m_lpListToolBar(nullptr),
m_lpDeleteAction(nullptr),
m_lpClearAction(nullptr),
m_lpActionToolBar(nullptr),
m_lpConvertAction(nullptr),
m_lpStopAction(nullptr),
m_working(false),
m_stopIt(false)
{
initUI();
createActions();
@@ -44,6 +54,7 @@ cMainWindow::cMainWindow(cSplashScreen* lpSplashScreen, QWidget *parent) :
setImageFormats();
countImages();
m_lpStopAction->setEnabled(false);
}
cMainWindow::~cMainWindow()
@@ -117,16 +128,7 @@ void cMainWindow::createActions()
createFileActions();
createContextActions();
connect(ui->m_lpAddFile, &QPushButton::clicked, this, &cMainWindow::onAddFile);
connect(ui->m_lpAddFolder, &QPushButton::clicked, this, &cMainWindow::onAddFolder);
connect(ui->m_lpRemoveSelected, &QPushButton::clicked, this, &cMainWindow::onRemoveSelected);
connect(ui->m_lpClearList, &QPushButton::clicked, this, &cMainWindow::onClearList);
connect(ui->m_lpFileList, &cTreeView::deleteEntrys, this, &cMainWindow::onDeleteEntrys);
connect(ui->m_lpConvert, &QPushButton::clicked, this, &cMainWindow::onConvert);
connect(ui->m_lpFileList, &cTreeView::addEntrys, this, &cMainWindow::onAddEntrys);
connect(ui->m_lpThumbnailSize, &QSlider::valueChanged, this, &cMainWindow::onThumbnailSize);
}
@@ -136,6 +138,34 @@ void cMainWindow::createContextActions()
void cMainWindow::createFileActions()
{
m_lpFileToolBar = addToolBar("file");
const QIcon openIcon = QIcon::fromTheme("document-open");
m_lpOpenFileAction = m_lpFileToolBar->addAction(openIcon, tr("&Open..."), this, &cMainWindow::onAddFile);
m_lpOpenFileAction->setShortcut(QKeySequence::Open);
const QIcon openDirectoryIcon = QIcon::fromTheme("folder");
m_lpOpenDirectoryAction = m_lpFileToolBar->addAction(openIcon, tr("&Open Folder..."), this, &cMainWindow::onAddFolder);
m_lpListToolBar = addToolBar("list");
const QIcon deleteIcon = QIcon::fromTheme("edit-delete");
m_lpDeleteAction = m_lpListToolBar->addAction(deleteIcon, tr("&Delete"), this, &cMainWindow::onDeleteEntrys);
m_lpDeleteAction->setShortcut(QKeySequence::Delete);
const QIcon clearIcon = QIcon::fromTheme("edit-clear");
m_lpClearAction = m_lpListToolBar->addAction(clearIcon, tr("&Clear"), this, &cMainWindow::onClearList);
m_lpActionToolBar = addToolBar("action");
const QIcon convertIcon = QIcon::fromTheme("system-run");
m_lpConvertAction = m_lpActionToolBar->addAction(convertIcon, tr("&Convert"), this, &cMainWindow::onConvert);
m_lpConvertAction->setShortcut(QKeySequence::Delete);
const QIcon stopIcon = QIcon::fromTheme("process-stop");
m_lpStopAction = m_lpActionToolBar->addAction(stopIcon, tr("&Stop"), this, &cMainWindow::onStop);
}
void cMainWindow::setImageFormats()
@@ -266,6 +296,8 @@ void cMainWindow::onAddFolder()
settings.setValue("import/recursive", QVariant::fromValue(checked));
m_working = true;
m_stopIt = false;
setActionEnabled(false, false, false, false, false, true);
ui->m_lpStatusBar->showMessage(tr("importing..."));
qApp->processEvents();
@@ -275,6 +307,7 @@ void cMainWindow::onAddFolder()
ui->m_lpFileList->resizeColumnToContents(i);
ui->m_lpStatusBar->showMessage(tr("done."), 3000);
setActionEnabled(true, true, true, true, true, false);
m_working = false;
countImages();
@@ -304,6 +337,9 @@ void cMainWindow::onClearList()
void cMainWindow::onAddEntrys(const QStringList& fileList)
{
m_working = true;
m_stopIt = false;
setActionEnabled(false, false, false, false, false, true);
ui->m_lpStatusBar->showMessage(tr("importing..."));
qApp->processEvents();
@@ -322,12 +358,15 @@ void cMainWindow::onAddEntrys(const QStringList& fileList)
if(mimeType.name().startsWith("image"))
addFile(file);
}
if(m_stopIt)
break;
}
for(int i = 0;i < m_lpFileListModel->columnCount();i++)
ui->m_lpFileList->resizeColumnToContents(i);
ui->m_lpStatusBar->showMessage(tr("done."), 3000);
setActionEnabled(true, true, true, true, true, false);
m_working = false;
countImages();
@@ -345,11 +384,19 @@ void cMainWindow::addPath(const QString& path, bool recursive)
if(recursive)
{
for(int i = 0;i < dirList.count();i++)
{
addPath(path + "/" + dirList[i], recursive);
if(m_stopIt)
break;
}
}
for(int i = 0;i < fileList.count();i++)
{
addFile(path + "/" + fileList[i]);
if(m_stopIt)
break;
}
}
void cMainWindow::addFile(const QString& file)
@@ -398,7 +445,6 @@ void cMainWindow::addFile(const QString& file)
m_lpFileListModel->appendRow(items);
countImages();
qApp->processEvents();
}
@@ -421,10 +467,18 @@ void cMainWindow::onConvert()
return;
m_working = true;
m_stopIt = false;
setActionEnabled(false, false, false, false, false, true);
doExport();
setActionEnabled(true, true, true, true, true, false);
m_working = false;
}
void cMainWindow::onStop()
{
m_stopIt = true;
}
void cMainWindow::onThumbnailSize(int size)
{
ui->m_lpThumbnailSizeValue->setText(QString::number(size));
@@ -481,7 +535,14 @@ void cMainWindow::doExport()
overwrite = exportFile(exportSettings, lpExif, overwrite);
m_lpProgressBar->setValue(i+1);
qApp->processEvents();
if(m_stopIt)
{
addToExportLog(m_exportLog, "<b>aborted.</b>");
break;
}
}
m_lpProgressBar->setVisible(false);
@@ -689,27 +750,30 @@ OVERWRITE cMainWindow::exportFile(const EXPORTSETTINGS& exportSettings, cEXIF* l
cImage image(lpExif->fileName());
if(!image.isNull())
{
// QTransform rotation;
// int angle = 0;
if(!image.isRaw())
{
QTransform rotation;
int angle = 0;
// switch(lpExif->imageOrientation())
// {
// case 8:
// angle = 270;
// break;
// case 3:
// angle = 180;
// break;
// case 6:
// angle = 90;
// break;
// }
switch(lpExif->imageOrientation())
{
case 8:
angle = 270;
break;
case 3:
angle = 180;
break;
case 6:
angle = 90;
break;
}
// if(angle != 0)
// {
// rotation.rotate(angle);
// image = image.transformed(rotation);
// }
if(angle != 0)
{
rotation.rotate(angle);
image = image.transformed(rotation);
}
}
addToExportLog(m_exportLog, "Loading file: <span class='optionok'>successful</span>");
@@ -823,7 +887,17 @@ void cMainWindow::countImages()
ui->m_lpStatusBar->showMessage(QString("%1 image(s)").arg(count));
if(count)
ui->m_lpConvert->setEnabled(true);
m_lpConvertAction->setEnabled(true);
else
ui->m_lpConvert->setEnabled(false);
m_lpConvertAction->setEnabled(false);
}
void cMainWindow::setActionEnabled(bool openFileAction, bool openDirectoryAction, bool deleteAction, bool clearAction, bool convertAction, bool stopAction)
{
m_lpOpenFileAction->setEnabled(openFileAction);
m_lpOpenDirectoryAction->setEnabled(openDirectoryAction);
m_lpDeleteAction->setEnabled(deleteAction);
m_lpClearAction->setEnabled(clearAction);
m_lpConvertAction->setEnabled(convertAction);
m_lpStopAction->setEnabled(stopAction);
}
+34
View File
@@ -18,6 +18,8 @@
#include <QMimeDatabase>
#include <QProgressBar>
#include <QToolBar>
#include <QAction>
QT_BEGIN_NAMESPACE
@@ -131,10 +133,23 @@ private:
QStandardItemModel* m_lpFileListModel; /*!< TODO: describe */
QProgressBar* m_lpProgressBar; /*!< TODO: describe */
QToolBar* m_lpFileToolBar; /*!< TODO: describe */
QAction* m_lpOpenFileAction; /*!< TODO: describe */
QAction* m_lpOpenDirectoryAction; /*!< TODO: describe */
QToolBar* m_lpListToolBar; /*!< TODO: describe */
QAction* m_lpDeleteAction; /*!< TODO: describe */
QAction* m_lpClearAction; /*!< TODO: describe */
QToolBar* m_lpActionToolBar; /*!< TODO: describe */
QAction* m_lpConvertAction; /*!< TODO: describe */
QAction* m_lpStopAction; /*!< TODO: describe */
QMimeDatabase m_mimeDB; /*!< TODO: describe */
QList<IMAGEFORMAT> m_imageFormats; /*!< TODO: describe */
bool m_working; /*!< TODO: describe */
bool m_stopIt; /*!< TODO: describe */
QString m_exportLog; /*!< TODO: describe */
@@ -265,6 +280,19 @@ private:
*/
void countImages();
/*!
\brief
\fn setActionEnabled
\param openFileAction
\param openDirectoryAction
\param deleteAction
\param clearAction
\param convertAction
\param stopAction
*/
void setActionEnabled(bool openFileAction, bool openDirectoryAction, bool deleteAction, bool clearAction, bool convertAction, bool stopAction);
private slots:
/*!
\brief
@@ -296,6 +324,12 @@ private slots:
\fn onConvert
*/
void onConvert();
/*!
\brief
\fn onStop
*/
void onStop();
/*!
\brief
-52
View File
@@ -17,58 +17,6 @@
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="m_lpAddFile">
<property name="text">
<string>add file...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_lpAddFolder">
<property name="text">
<string>add folder...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_lpRemoveSelected">
<property name="text">
<string>remove selected</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_lpClearList">
<property name="text">
<string>clear list</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_lpConvert">
<property name="text">
<string>convert...</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>