image viewer
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
#include "cimageviewer.h"
|
||||
#include "ui_cimageviewer.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
cImageViewer::cImageViewer(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
@@ -8,6 +12,11 @@ cImageViewer::cImageViewer(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->m_lpImage->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
||||
|
||||
// connect(ui->m_lpImage, &cLabel::imageNext, this, &cImageViewer::onImageNext);
|
||||
// connect(ui->m_lpImage, &cLabel::imagePrev, this, &cImageViewer::onImagePrev);
|
||||
// connect(ui->m_lpImage, &cLabel::imageFirst, this, &cImageViewer::onImageFirst);
|
||||
// connect(ui->m_lpImage, &cLabel::imageLast, this, &cImageViewer::onImageLast);
|
||||
}
|
||||
|
||||
cImageViewer::~cImageViewer()
|
||||
@@ -18,4 +27,52 @@ cImageViewer::~cImageViewer()
|
||||
void cImageViewer::setImage(cImage* lpImage)
|
||||
{
|
||||
ui->m_lpImage->setImage(lpImage);
|
||||
|
||||
setWindowFlag(Qt::Window);
|
||||
showFullScreen();
|
||||
|
||||
ui->m_lpImage->setFocus();
|
||||
}
|
||||
|
||||
void cImageViewer::keyPressEvent(QKeyEvent* e)
|
||||
{
|
||||
switch(e->key())
|
||||
{
|
||||
case Qt::Key_Left:
|
||||
emit imagePrev();
|
||||
break;
|
||||
case Qt::Key_Right:
|
||||
emit imageNext();
|
||||
break;
|
||||
case Qt::Key_Home:
|
||||
emit imageFirst();
|
||||
break;
|
||||
case Qt::Key_End:
|
||||
emit imageLast();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
QDialog::keyPressEvent(e);
|
||||
}
|
||||
|
||||
void cImageViewer::onImageNext()
|
||||
{
|
||||
emit imageNext();
|
||||
}
|
||||
|
||||
void cImageViewer::onImagePrev()
|
||||
{
|
||||
emit imagePrev();
|
||||
}
|
||||
|
||||
void cImageViewer::onImageLast()
|
||||
{
|
||||
emit imageLast();
|
||||
}
|
||||
|
||||
void cImageViewer::onImageFirst()
|
||||
{
|
||||
emit imageFirst();
|
||||
}
|
||||
|
||||
@@ -22,6 +22,61 @@ public:
|
||||
void setImage(cImage* lpImage);
|
||||
private:
|
||||
Ui::cImageViewer* ui;
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* e);
|
||||
|
||||
private slots:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onImageNext
|
||||
*/
|
||||
void onImageNext();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onImagePrev
|
||||
*/
|
||||
void onImagePrev();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onImageLast
|
||||
*/
|
||||
void onImageLast();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onImageFirst
|
||||
*/
|
||||
void onImageFirst();
|
||||
|
||||
signals:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn imageNext
|
||||
*/
|
||||
void imageNext();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn imagePrev
|
||||
*/
|
||||
void imagePrev();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn imageLast
|
||||
*/
|
||||
void imageLast();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn imageFirst
|
||||
*/
|
||||
void imageFirst();
|
||||
};
|
||||
|
||||
#endif // CIMAGEVIEWER_H
|
||||
|
||||
+25
@@ -1,11 +1,13 @@
|
||||
#include "clabel.h"
|
||||
|
||||
#include <QResizeEvent>
|
||||
#include <QKeyEvent>
|
||||
|
||||
|
||||
cLabel::cLabel(QWidget *parent, Qt::WindowFlags f) :
|
||||
QLabel(parent, f)
|
||||
{
|
||||
installEventFilter(this);
|
||||
}
|
||||
|
||||
cLabel::cLabel(const QString &text, QWidget *parent, Qt::WindowFlags f) :
|
||||
@@ -23,3 +25,26 @@ void cLabel::resizeEvent(QResizeEvent* e)
|
||||
QLabel::resizeEvent(e);
|
||||
setPixmap(QPixmap::fromImage(m_lpImage->scaled(width(), height(), Qt::AspectRatioMode::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation)));
|
||||
}
|
||||
|
||||
void cLabel::keyPressEvent(QKeyEvent* e)
|
||||
{
|
||||
switch(e->key())
|
||||
{
|
||||
case Qt::Key_Left:
|
||||
emit imagePrev();
|
||||
break;
|
||||
case Qt::Key_Right:
|
||||
emit imageNext();
|
||||
break;
|
||||
case Qt::Key_Home:
|
||||
emit imageFirst();
|
||||
break;
|
||||
case Qt::Key_End:
|
||||
emit imageLast();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
QLabel::keyPressEvent(e);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
class cLabel : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
cLabel(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
||||
cLabel(const QString &text, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
||||
@@ -19,6 +21,33 @@ private:
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent* e);
|
||||
void keyPressEvent(QKeyEvent* e);
|
||||
|
||||
signals:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn imageNext
|
||||
*/
|
||||
void imageNext();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn imagePrev
|
||||
*/
|
||||
void imagePrev();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn imageLast
|
||||
*/
|
||||
void imageLast();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn imageFirst
|
||||
*/
|
||||
void imageFirst();
|
||||
};
|
||||
|
||||
#endif // CLABEL_H
|
||||
|
||||
@@ -476,8 +476,18 @@ void cMainWindow::onThumbnailDoubleClicked(const QModelIndex& index)
|
||||
if(image.isNull())
|
||||
return;
|
||||
|
||||
connect(&imageViewer, &cImageViewer::imageNext, this, &cMainWindow::onImageNext);
|
||||
connect(&imageViewer, &cImageViewer::imagePrev, this, &cMainWindow::onImagePrev);
|
||||
connect(&imageViewer, &cImageViewer::imageFirst, this, &cMainWindow::onImageFirst);
|
||||
connect(&imageViewer, &cImageViewer::imageLast, this, &cMainWindow::onImageLast);
|
||||
|
||||
imageViewer.setImage(&image);
|
||||
imageViewer.exec();
|
||||
|
||||
disconnect(&imageViewer, &cImageViewer::imageNext, this, &cMainWindow::onImageNext);
|
||||
disconnect(&imageViewer, &cImageViewer::imagePrev, this, &cMainWindow::onImagePrev);
|
||||
disconnect(&imageViewer, &cImageViewer::imageFirst, this, &cMainWindow::onImageFirst);
|
||||
disconnect(&imageViewer, &cImageViewer::imageLast, this, &cMainWindow::onImageLast);
|
||||
}
|
||||
|
||||
void cMainWindow::onFolderSelected(const QItemSelection& /*selection*/, const QItemSelection& /*previous*/)
|
||||
@@ -982,3 +992,23 @@ void cMainWindow::onFilterTagChanged(QList<qint32> idList, bool bAnd)
|
||||
m_lpThumbnailSortFilterProxyModel->setTagList(idList, bAnd);
|
||||
showCount();
|
||||
}
|
||||
|
||||
void cMainWindow::onImageNext()
|
||||
{
|
||||
qDebug() << "next image";
|
||||
}
|
||||
|
||||
void cMainWindow::onImagePrev()
|
||||
{
|
||||
qDebug() << "prev image";
|
||||
}
|
||||
|
||||
void cMainWindow::onImageLast()
|
||||
{
|
||||
qDebug() << "last image";
|
||||
}
|
||||
|
||||
void cMainWindow::onImageFirst()
|
||||
{
|
||||
qDebug() << "first image";
|
||||
}
|
||||
|
||||
@@ -393,6 +393,31 @@ private slots:
|
||||
\param idList
|
||||
*/
|
||||
void onFilterTagChanged(QList<qint32> idList, bool bAnd);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onImageNext
|
||||
*/
|
||||
void onImageNext();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onImagePrev
|
||||
*/
|
||||
void onImagePrev();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onImageLast
|
||||
*/
|
||||
void onImageLast();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onImageFirst
|
||||
*/
|
||||
void onImageFirst();
|
||||
};
|
||||
|
||||
#endif // CMAINWINDOW_H
|
||||
|
||||
+2
-2
@@ -127,11 +127,11 @@ QStandardItem* insertPath(QString szPath, QStandardItem* lpRootItem)
|
||||
switch(path)
|
||||
{
|
||||
case 0:
|
||||
lpNewItem->setData(QVariant::fromValue(true), STYLEDDELEGATE_BOLD);
|
||||
lpNewItem->setData(QVariant::fromValue(false), STYLEDDELEGATE_BOLD);
|
||||
lpNewItem->setData(QVariant::fromValue(false), STYLEDDELEGATE_ITALIC);
|
||||
break;
|
||||
case 1:
|
||||
lpNewItem->setData(QVariant::fromValue(false), STYLEDDELEGATE_BOLD);
|
||||
lpNewItem->setData(QVariant::fromValue(true), STYLEDDELEGATE_BOLD);
|
||||
lpNewItem->setData(QVariant::fromValue(false), STYLEDDELEGATE_ITALIC);
|
||||
break;
|
||||
case 2:
|
||||
|
||||
Reference in New Issue
Block a user