feat: more useful information from property dialog

This commit is contained in:
Gary Wang 2020-11-04 00:16:37 +08:00
parent 71c38c8e96
commit 1066fa45ea
4 changed files with 264 additions and 62 deletions

View File

@ -170,7 +170,7 @@
<context>
<name>GraphicsView</name>
<message>
<location filename="../graphicsview.cpp" line="254"/>
<location filename="../graphicsview.cpp" line="261"/>
<source>File url list is empty</source>
<translation type="unfinished"></translation>
</message>
@ -180,12 +180,18 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../graphicsview.cpp" line="262"/>
<source>Image data is invalid</source>
<location filename="../graphicsview.cpp" line="55"/>
<location filename="../graphicsview.cpp" line="59"/>
<source>Image data is invalid or currently unsupported</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../graphicsview.cpp" line="269"/>
<source>Image data is invalid</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../graphicsview.cpp" line="276"/>
<source>Not supported mimedata: %1</source>
<translation type="unfinished"></translation>
</message>
@ -253,44 +259,120 @@
<context>
<name>MetadataDialog</name>
<message>
<location filename="../metadatadialog.cpp" line="16"/>
<location filename="../metadatadialog.cpp" line="75"/>
<source>Image Metadata</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MetadataModel</name>
<message>
<location filename="../metadatamodel.cpp" line="29"/>
<source>General</source>
<comment>General info about the image, section name.</comment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="32"/>
<source>File Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="34"/>
<source>File Size</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="36"/>
<source>Last Modified</source>
<source>Origin</source>
<comment>Section name.</comment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="38"/>
<source>Image Size</source>
<source>Image</source>
<comment>Section name.</comment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="46"/>
<location filename="../metadatamodel.cpp" line="44"/>
<source>File</source>
<comment>Section name.</comment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="40"/>
<source>Camera</source>
<comment>Section name.</comment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="27"/>
<source>%1 File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="35"/>
<source>Description</source>
<comment>Section name.</comment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="41"/>
<source>Advanced photo</source>
<comment>Section name.</comment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="42"/>
<source>GPS</source>
<comment>Section name.</comment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="47"/>
<source>Dimensions</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="49"/>
<source>Aspect Ratio</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="52"/>
<source>Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="54"/>
<source>Item type</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="56"/>
<source>Folder path</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="58"/>
<source>Size</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="60"/>
<source>Date Created</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="62"/>
<source>Date Modified</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="70"/>
<source>%1 x %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="88"/>
<source>%1 : %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="204"/>
<source>Property</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="204"/>
<source>Value</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsDialog</name>

View File

@ -170,7 +170,7 @@
<context>
<name>GraphicsView</name>
<message>
<location filename="../graphicsview.cpp" line="254"/>
<location filename="../graphicsview.cpp" line="261"/>
<source>File url list is empty</source>
<translation> URL </translation>
</message>
@ -180,12 +180,18 @@
<translation></translation>
</message>
<message>
<location filename="../graphicsview.cpp" line="262"/>
<location filename="../graphicsview.cpp" line="55"/>
<location filename="../graphicsview.cpp" line="59"/>
<source>Image data is invalid or currently unsupported</source>
<translation></translation>
</message>
<message>
<location filename="../graphicsview.cpp" line="269"/>
<source>Image data is invalid</source>
<translation></translation>
</message>
<message>
<location filename="../graphicsview.cpp" line="269"/>
<location filename="../graphicsview.cpp" line="276"/>
<source>Not supported mimedata: %1</source>
<translation> MimeData %1</translation>
</message>
@ -225,7 +231,7 @@
<message>
<location filename="../mainwindow.cpp" line="492"/>
<source>Properties</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="30"/>
@ -253,43 +259,119 @@
<context>
<name>MetadataDialog</name>
<message>
<location filename="../metadatadialog.cpp" line="16"/>
<location filename="../metadatadialog.cpp" line="75"/>
<source>Image Metadata</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
</context>
<context>
<name>MetadataModel</name>
<message>
<location filename="../metadatamodel.cpp" line="29"/>
<source>General</source>
<comment>General info about the image, section name.</comment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="32"/>
<source>File Name</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="34"/>
<source>File Size</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="36"/>
<source>Last Modified</source>
<translation type="unfinished"></translation>
<source>Origin</source>
<comment>Section name.</comment>
<translation></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="38"/>
<source>Image Size</source>
<translation type="unfinished"></translation>
<source>Image</source>
<comment>Section name.</comment>
<translation></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="46"/>
<location filename="../metadatamodel.cpp" line="44"/>
<source>File</source>
<comment>Section name.</comment>
<translation></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="40"/>
<source>Camera</source>
<comment>Section name.</comment>
<translation></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="27"/>
<source>%1 File</source>
<translation>%1 </translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="35"/>
<source>Description</source>
<comment>Section name.</comment>
<translation></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="41"/>
<source>Advanced photo</source>
<comment>Section name.</comment>
<translation></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="42"/>
<source>GPS</source>
<comment>Section name.</comment>
<translation>GPS</translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="47"/>
<source>Dimensions</source>
<translation></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="49"/>
<source>Aspect Ratio</source>
<translation></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="52"/>
<source>Name</source>
<translation></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="54"/>
<source>Item type</source>
<translation></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="56"/>
<source>Folder path</source>
<translation></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="58"/>
<source>Size</source>
<translation></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="60"/>
<source>Date Created</source>
<translation></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="62"/>
<source>Date Modified</source>
<translation></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="70"/>
<source>%1 x %2</source>
<translation type="unfinished"></translation>
<translation>%1 x %2</translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="88"/>
<source>%1 : %2</source>
<translation>%1 : %2</translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="204"/>
<source>Property</source>
<translation></translation>
</message>
<message>
<location filename="../metadatamodel.cpp" line="204"/>
<source>Value</source>
<translation></translation>
</message>
</context>
<context>

View File

@ -21,21 +21,45 @@ void MetadataModel::setFile(const QString &imageFilePath)
QFileInfo fileInfo(imageFilePath);
// It'll be fine if we don't re-use the image reader we pass to the graphics scene for now.
QImageReader imgReader(imageFilePath);
imgReader.setAutoTransform(true);
imgReader.setDecideFormatFromContent(true);
const QString & itemTypeString = tr("%1 File").arg(QString(imgReader.format().toUpper()));
const QString & sizeString = QLocale().formattedDataSize(fileInfo.size());
const QString & timeString = QLocale().toString(fileInfo.lastModified(), QLocale::LongFormat);
const QString & imageSizeString = imageSize(imgReader.size());
const QString & birthTimeString = QLocale().toString(fileInfo.birthTime(), QLocale::LongFormat);
const QString & lastModifiedTimeString = QLocale().toString(fileInfo.lastModified(), QLocale::LongFormat);
const QString & imageDimensionsString = imageSize(imgReader.size());
const QString & imageRatioString = imageSizeRatio(imgReader.size());
appendSection(QStringLiteral("General"), tr("General", "General info about the image, section name."));
#if 0
appendSection(QStringLiteral("Description"), tr("Description", "Section name."));
appendSection(QStringLiteral("Origin"), tr("Origin", "Section name."));
#endif // 0
appendSection(QStringLiteral("Image"), tr("Image", "Section name."));
#if 0
appendSection(QStringLiteral("Camera"), tr("Camera", "Section name."));
appendSection(QStringLiteral("AdvancedPhoto"), tr("Advanced photo", "Section name."));
appendSection(QStringLiteral("GPS"), tr("GPS", "Section name."));
#endif // 0
appendSection(QStringLiteral("File"), tr("File", "Section name."));
appendProperty(QStringLiteral("General"), QStringLiteral("General.Name"),
tr("File Name"), fileInfo.fileName());
appendProperty(QStringLiteral("General"), QStringLiteral("General.Size"),
tr("File Size"), sizeString);
appendProperty(QStringLiteral("General"), QStringLiteral("General.Time"),
tr("Last Modified"), timeString);
appendProperty(QStringLiteral("General"), QStringLiteral("General.ImageSize"),
tr("Image Size"), imageSizeString);
appendProperty(QStringLiteral("Image"), QStringLiteral("Image.Dimensions"),
tr("Dimensions"), imageDimensionsString);
appendProperty(QStringLiteral("Image"), QStringLiteral("Image.SizeRatio"),
tr("Aspect Ratio"), imageRatioString);
appendProperty(QStringLiteral("File"), QStringLiteral("File.Name"),
tr("Name"), fileInfo.fileName());
appendProperty(QStringLiteral("File"), QStringLiteral("File.ItemType"),
tr("Item type"), itemTypeString);
appendProperty(QStringLiteral("File"), QStringLiteral("File.Path"),
tr("Folder path"), fileInfo.path());
appendProperty(QStringLiteral("File"), QStringLiteral("File.Size"),
tr("Size"), sizeString);
appendProperty(QStringLiteral("File"), QStringLiteral("File.CreatedTime"),
tr("Date Created"), birthTimeString);
appendProperty(QStringLiteral("File"), QStringLiteral("File.LastModified"),
tr("Date Modified"), lastModifiedTimeString);
}
QString MetadataModel::imageSize(const QSize &size)
@ -51,6 +75,19 @@ QString MetadataModel::imageSize(const QSize &size)
return imageSize;
}
int simplegcd(int a, int b) {
return b == 0 ? a : simplegcd(b, a % b);
}
QString MetadataModel::imageSizeRatio(const QSize &size)
{
if (!size.isValid()) {
return QStringLiteral("-");
}
int gcd = simplegcd(size.width(), size.height());
return tr("%1 : %2").arg(QString::number(size.width() / gcd), QString::number(size.height() / gcd));
}
bool MetadataModel::appendSection(const QString &sectionKey, const QString &sectionDisplayName)
{
if (m_sections.contains(sectionKey)) {

View File

@ -13,6 +13,7 @@ public:
void setFile(const QString & imageFilePath);
static QString imageSize(const QSize &size);
static QString imageSizeRatio(const QSize &size);
bool appendSection(const QString & sectionKey, const QString & sectionDisplayName);
bool appendProperty(const QString & sectionKey, const QString & propertyKey,
const QString & propertyDisplayName, const QString & propertyValue = QString());