Better image file handling in EditDialog

Put the image editor into a scrollarea so the dialog doesn't screw up
when importing a large image file.

When importing a file add a filter to the file dialog to only show image
files.
This commit is contained in:
Martin Kleusberg
2013-03-17 13:02:49 +01:00
parent 67c141c192
commit 66b1a62fa4
2 changed files with 31 additions and 2 deletions

View File

@@ -59,11 +59,17 @@ void EditDialog::loadText(const QByteArray& data, int row, int col)
void EditDialog::importData()
{
// Get list of supported image file formats to include them in the file dialog filter
QString image_formats;
QList<QByteArray> image_formats_list = QImageReader::supportedImageFormats();
for(int i=0;i<image_formats_list.size();++i)
image_formats.append(QString("*.%1 ").arg(QString::fromUtf8(image_formats_list.at(i))));
QString fileName = QFileDialog::getOpenFileName(
this,
tr("Choose a file"),
defaultlocation,
tr("Text files(*.txt);;All files(*)"));
tr("Text files(*.txt);;Image files(%1);;All files(*)").arg(image_formats));
if(QFile::exists(fileName))
{
QFile file(fileName);

View File

@@ -95,7 +95,30 @@
</property>
</widget>
<widget class="QWidget" name="editorBinary"/>
<widget class="QLabel" name="editorImage"/>
<widget class="QScrollArea" name="editorImageScrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>358</width>
<height>267</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="editorImage">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
</item>
<item>