initial commit
This commit is contained in:
+34
-12
@@ -20,11 +20,14 @@
|
||||
#include <QImageReader>
|
||||
#include <QImageWriter>
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
|
||||
cMainWindow::cMainWindow(cSplashScreen* lpSplashScreen, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::cMainWindow),
|
||||
m_lpSplashScreen(lpSplashScreen)
|
||||
m_lpSplashScreen(lpSplashScreen),
|
||||
m_working(false)
|
||||
{
|
||||
initUI();
|
||||
createActions();
|
||||
@@ -40,6 +43,13 @@ cMainWindow::~cMainWindow()
|
||||
|
||||
void cMainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if(m_working)
|
||||
{
|
||||
QMessageBox::information(this, tr("Close"), tr("Can't close, pictureConvert is working."));
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
QSettings settings;
|
||||
settings.setValue("main/width", QVariant::fromValue(size().width()));
|
||||
settings.setValue("main/height", QVariant::fromValue(size().height()));
|
||||
@@ -97,7 +107,7 @@ void cMainWindow::createActions()
|
||||
|
||||
connect(ui->m_lpConvert, &QPushButton::clicked, this, &cMainWindow::onConvert);
|
||||
|
||||
connect(ui->m_lpFileList, &cTreeView::addEntry, this, &cMainWindow::onAddEntry);
|
||||
connect(ui->m_lpFileList, &cTreeView::addEntrys, this, &cMainWindow::onAddEntrys);
|
||||
|
||||
connect(ui->m_lpThumbnailSize, &QSlider::valueChanged, this, &cMainWindow::onThumbnailSize);
|
||||
}
|
||||
@@ -257,8 +267,7 @@ void cMainWindow::onAddFile()
|
||||
path = info.path();
|
||||
settings.setValue("import/oldPath", QVariant::fromValue(path));
|
||||
|
||||
for(int i = 0;i < fileList.count();i++)
|
||||
onAddEntry(fileList[i]);
|
||||
onAddEntrys(fileList);
|
||||
}
|
||||
|
||||
void cMainWindow::onAddFolder()
|
||||
@@ -290,10 +299,14 @@ void cMainWindow::onAddFolder()
|
||||
settings.setValue("import/oldPath", QVariant::fromValue(path));
|
||||
settings.setValue("import/recursive", QVariant::fromValue(checked));
|
||||
|
||||
m_working = true;
|
||||
|
||||
addPath(path, checked);
|
||||
|
||||
for(int i = 0;i < m_lpFileListModel->columnCount();i++)
|
||||
ui->m_lpFileList->resizeColumnToContents(i);
|
||||
|
||||
m_working = false;
|
||||
}
|
||||
|
||||
void cMainWindow::onRemoveSelected()
|
||||
@@ -308,22 +321,31 @@ void cMainWindow::onClearList()
|
||||
m_lpFileListModel->setHorizontalHeaderLabels(headerLabels);
|
||||
}
|
||||
|
||||
void cMainWindow::onAddEntry(const QString& file)
|
||||
void cMainWindow::onAddEntrys(const QStringList& fileList)
|
||||
{
|
||||
QFileInfo fileInfo(file);
|
||||
m_working = true;
|
||||
|
||||
if(fileInfo.isDir())
|
||||
addPath(file);
|
||||
else
|
||||
for(int i = 0;i < fileList.count();i++)
|
||||
{
|
||||
QMimeType mimeType = m_mimeDB.mimeTypeForFile(file);
|
||||
QString file = fileList[i];
|
||||
|
||||
if(mimeType.name().startsWith("image"))
|
||||
addFile(file);
|
||||
QFileInfo fileInfo(file);
|
||||
|
||||
if(fileInfo.isDir())
|
||||
addPath(file);
|
||||
else
|
||||
{
|
||||
QMimeType mimeType = m_mimeDB.mimeTypeForFile(file);
|
||||
|
||||
if(mimeType.name().startsWith("image"))
|
||||
addFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0;i < m_lpFileListModel->columnCount();i++)
|
||||
ui->m_lpFileList->resizeColumnToContents(i);
|
||||
|
||||
m_working = false;
|
||||
}
|
||||
|
||||
void cMainWindow::addPath(const QString& path, bool recursive)
|
||||
|
||||
+2
-1
@@ -42,6 +42,7 @@ private:
|
||||
QMimeDatabase m_mimeDB;
|
||||
QList<IMAGEFORMAT> m_imageFormats;
|
||||
|
||||
bool m_working;
|
||||
|
||||
void initUI();
|
||||
void createActions();
|
||||
@@ -61,7 +62,7 @@ private slots:
|
||||
void onConvert();
|
||||
|
||||
void onThumbnailSize(int size);
|
||||
void onAddEntry(const QString& file);
|
||||
void onAddEntrys(const QStringList& fileList);
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event);
|
||||
|
||||
+2
-2
@@ -157,7 +157,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<widget class="QMenuBar" name="m_lpMenuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@@ -167,7 +167,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QStatusBar" name="m_lpStatusBar"/>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
||||
+3
-1
@@ -31,7 +31,9 @@ void cTreeView::dropEvent(QDropEvent* event)
|
||||
QList<QUrl> urlList = mimeData->urls();
|
||||
|
||||
for(int i = 0; i < urlList.size(); i++)
|
||||
emit addEntry(urlList[i].toLocalFile());
|
||||
pathList.append(urlList[i].toLocalFile());
|
||||
|
||||
emit addEntrys(pathList);
|
||||
}
|
||||
|
||||
event->acceptProposedAction();
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ protected:
|
||||
private:
|
||||
|
||||
signals:
|
||||
void addEntry(const QString& path);
|
||||
void addEntrys(const QStringList& fileList);
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cTreeView*)
|
||||
|
||||
Reference in New Issue
Block a user