From feda8a7db8d1d7c5439aa8f8feef7cc0dd2b59a0 Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Fri, 27 Jul 2018 23:51:12 -0400 Subject: New upstream version 3.2.1+dfsg1 --- Plugins/MultiEditorImage/MultiEditorImage.pro | 32 +++ Plugins/MultiEditorImage/MultiEditorImage_de.qm | Bin 0 -> 23 bytes Plugins/MultiEditorImage/MultiEditorImage_de.ts | 81 +++++++ Plugins/MultiEditorImage/MultiEditorImage_es.qm | Bin 0 -> 23 bytes Plugins/MultiEditorImage/MultiEditorImage_es.ts | 81 +++++++ Plugins/MultiEditorImage/MultiEditorImage_fr.qm | Bin 0 -> 23 bytes Plugins/MultiEditorImage/MultiEditorImage_fr.ts | 81 +++++++ Plugins/MultiEditorImage/MultiEditorImage_it.qm | Bin 0 -> 23 bytes Plugins/MultiEditorImage/MultiEditorImage_it.ts | 81 +++++++ Plugins/MultiEditorImage/MultiEditorImage_pl.qm | Bin 0 -> 2277 bytes Plugins/MultiEditorImage/MultiEditorImage_pl.ts | 81 +++++++ Plugins/MultiEditorImage/MultiEditorImage_pt_BR.qm | Bin 0 -> 23 bytes Plugins/MultiEditorImage/MultiEditorImage_pt_BR.ts | 81 +++++++ Plugins/MultiEditorImage/MultiEditorImage_ro_RO.qm | Bin 0 -> 30 bytes Plugins/MultiEditorImage/MultiEditorImage_ro_RO.ts | 81 +++++++ Plugins/MultiEditorImage/MultiEditorImage_ru.qm | Bin 0 -> 34 bytes Plugins/MultiEditorImage/MultiEditorImage_ru.ts | 81 +++++++ Plugins/MultiEditorImage/MultiEditorImage_sk.qm | Bin 0 -> 27 bytes Plugins/MultiEditorImage/MultiEditorImage_sk.ts | 81 +++++++ Plugins/MultiEditorImage/MultiEditorImage_zh_CN.qm | 1 + Plugins/MultiEditorImage/MultiEditorImage_zh_CN.ts | 81 +++++++ Plugins/MultiEditorImage/multieditorimage.cpp | 268 +++++++++++++++++++++ Plugins/MultiEditorImage/multieditorimage.h | 67 ++++++ Plugins/MultiEditorImage/multieditorimage.json | 7 + Plugins/MultiEditorImage/multieditorimage.qrc | 15 ++ Plugins/MultiEditorImage/multieditorimage_global.h | 12 + Plugins/MultiEditorImage/package.xml | 10 + 27 files changed, 1222 insertions(+) create mode 100644 Plugins/MultiEditorImage/MultiEditorImage.pro create mode 100644 Plugins/MultiEditorImage/MultiEditorImage_de.qm create mode 100644 Plugins/MultiEditorImage/MultiEditorImage_de.ts create mode 100644 Plugins/MultiEditorImage/MultiEditorImage_es.qm create mode 100644 Plugins/MultiEditorImage/MultiEditorImage_es.ts create mode 100644 Plugins/MultiEditorImage/MultiEditorImage_fr.qm create mode 100644 Plugins/MultiEditorImage/MultiEditorImage_fr.ts create mode 100644 Plugins/MultiEditorImage/MultiEditorImage_it.qm create mode 100644 Plugins/MultiEditorImage/MultiEditorImage_it.ts create mode 100644 Plugins/MultiEditorImage/MultiEditorImage_pl.qm create mode 100644 Plugins/MultiEditorImage/MultiEditorImage_pl.ts create mode 100644 Plugins/MultiEditorImage/MultiEditorImage_pt_BR.qm create mode 100644 Plugins/MultiEditorImage/MultiEditorImage_pt_BR.ts create mode 100644 Plugins/MultiEditorImage/MultiEditorImage_ro_RO.qm create mode 100644 Plugins/MultiEditorImage/MultiEditorImage_ro_RO.ts create mode 100644 Plugins/MultiEditorImage/MultiEditorImage_ru.qm create mode 100644 Plugins/MultiEditorImage/MultiEditorImage_ru.ts create mode 100644 Plugins/MultiEditorImage/MultiEditorImage_sk.qm create mode 100644 Plugins/MultiEditorImage/MultiEditorImage_sk.ts create mode 100644 Plugins/MultiEditorImage/MultiEditorImage_zh_CN.qm create mode 100644 Plugins/MultiEditorImage/MultiEditorImage_zh_CN.ts create mode 100644 Plugins/MultiEditorImage/multieditorimage.cpp create mode 100644 Plugins/MultiEditorImage/multieditorimage.h create mode 100644 Plugins/MultiEditorImage/multieditorimage.json create mode 100644 Plugins/MultiEditorImage/multieditorimage.qrc create mode 100644 Plugins/MultiEditorImage/multieditorimage_global.h create mode 100644 Plugins/MultiEditorImage/package.xml (limited to 'Plugins/MultiEditorImage') diff --git a/Plugins/MultiEditorImage/MultiEditorImage.pro b/Plugins/MultiEditorImage/MultiEditorImage.pro new file mode 100644 index 0000000..09b15f3 --- /dev/null +++ b/Plugins/MultiEditorImage/MultiEditorImage.pro @@ -0,0 +1,32 @@ +include($$PWD/../../SQLiteStudio3/plugins.pri) + +QT += widgets + +TARGET = MultiEditorImage +TEMPLATE = lib + +DEFINES += MULTIEDITORIMAGE_LIBRARY + +SOURCES += multieditorimage.cpp + +HEADERS += multieditorimage.h\ + multieditorimage_global.h + +OTHER_FILES += \ + multieditorimage.json + +RESOURCES += \ + multieditorimage.qrc + +TRANSLATIONS += \ + MultiEditorImage_ro_RO.ts\ + MultiEditorImage_de.ts\ + MultiEditorImage_it.ts\ + MultiEditorImage_zh_CN.ts\ + MultiEditorImage_sk.ts\ + MultiEditorImage_ru.ts\ + MultiEditorImage_pt_BR.ts\ + MultiEditorImage_fr.ts\ + MultiEditorImage_es.ts\ + MultiEditorImage_pl.ts + diff --git a/Plugins/MultiEditorImage/MultiEditorImage_de.qm b/Plugins/MultiEditorImage/MultiEditorImage_de.qm new file mode 100644 index 0000000..9dad8df Binary files /dev/null and b/Plugins/MultiEditorImage/MultiEditorImage_de.qm differ diff --git a/Plugins/MultiEditorImage/MultiEditorImage_de.ts b/Plugins/MultiEditorImage/MultiEditorImage_de.ts new file mode 100644 index 0000000..dd7fa7e --- /dev/null +++ b/Plugins/MultiEditorImage/MultiEditorImage_de.ts @@ -0,0 +1,81 @@ + + + + + MultiEditorImage + + + Load from file + + + + + Store in a file + + + + + Zoom in by 25% + + + + + Zoom out by 25% + + + + + Reset zoom + + + + + Images (*.jpeg *.jpg *.png *.bmp *.gif *.tiff *.jp2 *.svg *.tga *.icns *.webp *.wbmp *.mng);;All files (*) + + + + + Open image + + + + + Could not open file %1 for reading. + Could not nopen file %1 for reading. + + + + + All files (*) + + + + + Save image + + + + + Tried to save image under different format (%1) than original (%2), but application failed to convert it. The image with unchanged format (%3) will be saved under the given name (%4) + + + + + Could not nopen file %1 for writting. + + + + + Could not write image into the file %1 + + + + + MultiEditorImagePlugin + + + Image + + + + diff --git a/Plugins/MultiEditorImage/MultiEditorImage_es.qm b/Plugins/MultiEditorImage/MultiEditorImage_es.qm new file mode 100644 index 0000000..9dad8df Binary files /dev/null and b/Plugins/MultiEditorImage/MultiEditorImage_es.qm differ diff --git a/Plugins/MultiEditorImage/MultiEditorImage_es.ts b/Plugins/MultiEditorImage/MultiEditorImage_es.ts new file mode 100644 index 0000000..6656179 --- /dev/null +++ b/Plugins/MultiEditorImage/MultiEditorImage_es.ts @@ -0,0 +1,81 @@ + + + + + MultiEditorImage + + + Load from file + + + + + Store in a file + + + + + Zoom in by 25% + + + + + Zoom out by 25% + + + + + Reset zoom + + + + + Images (*.jpeg *.jpg *.png *.bmp *.gif *.tiff *.jp2 *.svg *.tga *.icns *.webp *.wbmp *.mng);;All files (*) + + + + + Open image + + + + + Could not open file %1 for reading. + Could not nopen file %1 for reading. + + + + + All files (*) + + + + + Save image + + + + + Tried to save image under different format (%1) than original (%2), but application failed to convert it. The image with unchanged format (%3) will be saved under the given name (%4) + + + + + Could not nopen file %1 for writting. + + + + + Could not write image into the file %1 + + + + + MultiEditorImagePlugin + + + Image + + + + diff --git a/Plugins/MultiEditorImage/MultiEditorImage_fr.qm b/Plugins/MultiEditorImage/MultiEditorImage_fr.qm new file mode 100644 index 0000000..c02994c Binary files /dev/null and b/Plugins/MultiEditorImage/MultiEditorImage_fr.qm differ diff --git a/Plugins/MultiEditorImage/MultiEditorImage_fr.ts b/Plugins/MultiEditorImage/MultiEditorImage_fr.ts new file mode 100644 index 0000000..4eec2b0 --- /dev/null +++ b/Plugins/MultiEditorImage/MultiEditorImage_fr.ts @@ -0,0 +1,81 @@ + + + + + MultiEditorImage + + + Load from file + + + + + Store in a file + + + + + Zoom in by 25% + + + + + Zoom out by 25% + + + + + Reset zoom + + + + + Images (*.jpeg *.jpg *.png *.bmp *.gif *.tiff *.jp2 *.svg *.tga *.icns *.webp *.wbmp *.mng);;All files (*) + + + + + Open image + + + + + Could not open file %1 for reading. + Could not nopen file %1 for reading. + + + + + All files (*) + + + + + Save image + + + + + Tried to save image under different format (%1) than original (%2), but application failed to convert it. The image with unchanged format (%3) will be saved under the given name (%4) + + + + + Could not nopen file %1 for writting. + + + + + Could not write image into the file %1 + + + + + MultiEditorImagePlugin + + + Image + + + + diff --git a/Plugins/MultiEditorImage/MultiEditorImage_it.qm b/Plugins/MultiEditorImage/MultiEditorImage_it.qm new file mode 100644 index 0000000..9dad8df Binary files /dev/null and b/Plugins/MultiEditorImage/MultiEditorImage_it.qm differ diff --git a/Plugins/MultiEditorImage/MultiEditorImage_it.ts b/Plugins/MultiEditorImage/MultiEditorImage_it.ts new file mode 100644 index 0000000..168db58 --- /dev/null +++ b/Plugins/MultiEditorImage/MultiEditorImage_it.ts @@ -0,0 +1,81 @@ + + + + + MultiEditorImage + + + Load from file + + + + + Store in a file + + + + + Zoom in by 25% + + + + + Zoom out by 25% + + + + + Reset zoom + + + + + Images (*.jpeg *.jpg *.png *.bmp *.gif *.tiff *.jp2 *.svg *.tga *.icns *.webp *.wbmp *.mng);;All files (*) + + + + + Open image + + + + + Could not open file %1 for reading. + Could not nopen file %1 for reading. + + + + + All files (*) + + + + + Save image + + + + + Tried to save image under different format (%1) than original (%2), but application failed to convert it. The image with unchanged format (%3) will be saved under the given name (%4) + + + + + Could not nopen file %1 for writting. + + + + + Could not write image into the file %1 + + + + + MultiEditorImagePlugin + + + Image + + + + diff --git a/Plugins/MultiEditorImage/MultiEditorImage_pl.qm b/Plugins/MultiEditorImage/MultiEditorImage_pl.qm new file mode 100644 index 0000000..5f02c32 Binary files /dev/null and b/Plugins/MultiEditorImage/MultiEditorImage_pl.qm differ diff --git a/Plugins/MultiEditorImage/MultiEditorImage_pl.ts b/Plugins/MultiEditorImage/MultiEditorImage_pl.ts new file mode 100644 index 0000000..2d70c19 --- /dev/null +++ b/Plugins/MultiEditorImage/MultiEditorImage_pl.ts @@ -0,0 +1,81 @@ + + + + + MultiEditorImage + + + Load from file + Wczytaj z pliku + + + + Store in a file + Zapisz do pliku + + + + Zoom in by 25% + PowiÄ™ksz o 25% + + + + Zoom out by 25% + Pomniejsz o 25% + + + + Reset zoom + Zresetuj powiÄ™kszenie + + + + Images (*.jpeg *.jpg *.png *.bmp *.gif *.tiff *.jp2 *.svg *.tga *.icns *.webp *.wbmp *.mng);;All files (*) + Obrazy (*.jpeg *.jpg *.png *.bmp *.gif *.tiff *.jp2 *.svg *.tga *.icns *.webp *.wbmp *.mng);;Wszystkie pliki (*) + + + + Open image + Otwórz obraz + + + + Could not open file %1 for reading. + Could not nopen file %1 for reading. + Nie można otworzyć pliku %1 do odczytu. + + + + All files (*) + Wszystkie pliki (*) + + + + Save image + Zapisz obraz + + + + Tried to save image under different format (%1) than original (%2), but application failed to convert it. The image with unchanged format (%3) will be saved under the given name (%4) + Próbowano zapisać obraz używajÄ…c innego formatu (%1) niż oryginaÅ‚ (%2), lecz aplikacji nie udaÅ‚o siÄ™ dokonać konwersji. Obraz z niezmienionym formacie (%3) zostanie zapisany pod podanÄ… nazwÄ… (%4) + + + + Could not nopen file %1 for writting. + Nie można otworzyć pliku %1 do zapisu. + + + + Could not write image into the file %1 + Nie można zapisać obrazu do pliku %1 + + + + MultiEditorImagePlugin + + + Image + Obraz + + + diff --git a/Plugins/MultiEditorImage/MultiEditorImage_pt_BR.qm b/Plugins/MultiEditorImage/MultiEditorImage_pt_BR.qm new file mode 100644 index 0000000..c02994c Binary files /dev/null and b/Plugins/MultiEditorImage/MultiEditorImage_pt_BR.qm differ diff --git a/Plugins/MultiEditorImage/MultiEditorImage_pt_BR.ts b/Plugins/MultiEditorImage/MultiEditorImage_pt_BR.ts new file mode 100644 index 0000000..ca226bd --- /dev/null +++ b/Plugins/MultiEditorImage/MultiEditorImage_pt_BR.ts @@ -0,0 +1,81 @@ + + + + + MultiEditorImage + + + Load from file + + + + + Store in a file + + + + + Zoom in by 25% + + + + + Zoom out by 25% + + + + + Reset zoom + + + + + Images (*.jpeg *.jpg *.png *.bmp *.gif *.tiff *.jp2 *.svg *.tga *.icns *.webp *.wbmp *.mng);;All files (*) + + + + + Open image + + + + + Could not open file %1 for reading. + Could not nopen file %1 for reading. + + + + + All files (*) + + + + + Save image + + + + + Tried to save image under different format (%1) than original (%2), but application failed to convert it. The image with unchanged format (%3) will be saved under the given name (%4) + + + + + Could not nopen file %1 for writting. + + + + + Could not write image into the file %1 + + + + + MultiEditorImagePlugin + + + Image + + + + diff --git a/Plugins/MultiEditorImage/MultiEditorImage_ro_RO.qm b/Plugins/MultiEditorImage/MultiEditorImage_ro_RO.qm new file mode 100644 index 0000000..2856eb9 Binary files /dev/null and b/Plugins/MultiEditorImage/MultiEditorImage_ro_RO.qm differ diff --git a/Plugins/MultiEditorImage/MultiEditorImage_ro_RO.ts b/Plugins/MultiEditorImage/MultiEditorImage_ro_RO.ts new file mode 100644 index 0000000..7b672e5 --- /dev/null +++ b/Plugins/MultiEditorImage/MultiEditorImage_ro_RO.ts @@ -0,0 +1,81 @@ + + + + + MultiEditorImage + + + Load from file + + + + + Store in a file + + + + + Zoom in by 25% + + + + + Zoom out by 25% + + + + + Reset zoom + + + + + Images (*.jpeg *.jpg *.png *.bmp *.gif *.tiff *.jp2 *.svg *.tga *.icns *.webp *.wbmp *.mng);;All files (*) + + + + + Open image + + + + + Could not open file %1 for reading. + Could not nopen file %1 for reading. + + + + + All files (*) + + + + + Save image + + + + + Tried to save image under different format (%1) than original (%2), but application failed to convert it. The image with unchanged format (%3) will be saved under the given name (%4) + + + + + Could not nopen file %1 for writting. + + + + + Could not write image into the file %1 + + + + + MultiEditorImagePlugin + + + Image + + + + diff --git a/Plugins/MultiEditorImage/MultiEditorImage_ru.qm b/Plugins/MultiEditorImage/MultiEditorImage_ru.qm new file mode 100644 index 0000000..7431612 Binary files /dev/null and b/Plugins/MultiEditorImage/MultiEditorImage_ru.qm differ diff --git a/Plugins/MultiEditorImage/MultiEditorImage_ru.ts b/Plugins/MultiEditorImage/MultiEditorImage_ru.ts new file mode 100644 index 0000000..f383c0f --- /dev/null +++ b/Plugins/MultiEditorImage/MultiEditorImage_ru.ts @@ -0,0 +1,81 @@ + + + + + MultiEditorImage + + + Load from file + + + + + Store in a file + + + + + Zoom in by 25% + + + + + Zoom out by 25% + + + + + Reset zoom + + + + + Images (*.jpeg *.jpg *.png *.bmp *.gif *.tiff *.jp2 *.svg *.tga *.icns *.webp *.wbmp *.mng);;All files (*) + + + + + Open image + + + + + Could not open file %1 for reading. + Could not nopen file %1 for reading. + + + + + All files (*) + + + + + Save image + + + + + Tried to save image under different format (%1) than original (%2), but application failed to convert it. The image with unchanged format (%3) will be saved under the given name (%4) + + + + + Could not nopen file %1 for writting. + + + + + Could not write image into the file %1 + + + + + MultiEditorImagePlugin + + + Image + + + + diff --git a/Plugins/MultiEditorImage/MultiEditorImage_sk.qm b/Plugins/MultiEditorImage/MultiEditorImage_sk.qm new file mode 100644 index 0000000..1776294 Binary files /dev/null and b/Plugins/MultiEditorImage/MultiEditorImage_sk.qm differ diff --git a/Plugins/MultiEditorImage/MultiEditorImage_sk.ts b/Plugins/MultiEditorImage/MultiEditorImage_sk.ts new file mode 100644 index 0000000..3a0b3af --- /dev/null +++ b/Plugins/MultiEditorImage/MultiEditorImage_sk.ts @@ -0,0 +1,81 @@ + + + + + MultiEditorImage + + + Load from file + + + + + Store in a file + + + + + Zoom in by 25% + + + + + Zoom out by 25% + + + + + Reset zoom + + + + + Images (*.jpeg *.jpg *.png *.bmp *.gif *.tiff *.jp2 *.svg *.tga *.icns *.webp *.wbmp *.mng);;All files (*) + + + + + Open image + + + + + Could not open file %1 for reading. + Could not nopen file %1 for reading. + + + + + All files (*) + + + + + Save image + + + + + Tried to save image under different format (%1) than original (%2), but application failed to convert it. The image with unchanged format (%3) will be saved under the given name (%4) + + + + + Could not nopen file %1 for writting. + + + + + Could not write image into the file %1 + + + + + MultiEditorImagePlugin + + + Image + + + + diff --git a/Plugins/MultiEditorImage/MultiEditorImage_zh_CN.qm b/Plugins/MultiEditorImage/MultiEditorImage_zh_CN.qm new file mode 100644 index 0000000..be651ee --- /dev/null +++ b/Plugins/MultiEditorImage/MultiEditorImage_zh_CN.qm @@ -0,0 +1 @@ +<¸dÊÍ!¿`¡½Ý \ No newline at end of file diff --git a/Plugins/MultiEditorImage/MultiEditorImage_zh_CN.ts b/Plugins/MultiEditorImage/MultiEditorImage_zh_CN.ts new file mode 100644 index 0000000..be7365d --- /dev/null +++ b/Plugins/MultiEditorImage/MultiEditorImage_zh_CN.ts @@ -0,0 +1,81 @@ + + + + + MultiEditorImage + + + Load from file + + + + + Store in a file + + + + + Zoom in by 25% + + + + + Zoom out by 25% + + + + + Reset zoom + + + + + Images (*.jpeg *.jpg *.png *.bmp *.gif *.tiff *.jp2 *.svg *.tga *.icns *.webp *.wbmp *.mng);;All files (*) + + + + + Open image + + + + + Could not open file %1 for reading. + Could not nopen file %1 for reading. + + + + + All files (*) + + + + + Save image + + + + + Tried to save image under different format (%1) than original (%2), but application failed to convert it. The image with unchanged format (%3) will be saved under the given name (%4) + + + + + Could not nopen file %1 for writting. + + + + + Could not write image into the file %1 + + + + + MultiEditorImagePlugin + + + Image + + + + diff --git a/Plugins/MultiEditorImage/multieditorimage.cpp b/Plugins/MultiEditorImage/multieditorimage.cpp new file mode 100644 index 0000000..59b5a49 --- /dev/null +++ b/Plugins/MultiEditorImage/multieditorimage.cpp @@ -0,0 +1,268 @@ +#include "multieditorimage.h" +#include "common/unused.h" +#include "iconmanager.h" +#include "uiconfig.h" +#include "services/notifymanager.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +MultiEditorImage::MultiEditorImage() +{ + setLayout(new QHBoxLayout()); + scrollArea = new QScrollArea(); + scrollArea->setBackgroundRole(QPalette::Dark); + layout()->addWidget(scrollArea); + + QToolBar* tb = new QToolBar(); + tb->setOrientation(Qt::Vertical); + loadAction = tb->addAction(ICONS.OPEN_FILE, tr("Load from file"), this, SLOT(openFile())); + tb->addAction(ICONS.SAVE_FILE, tr("Store in a file"), this, SLOT(saveFile())); + zoomInAct = tb->addAction(ICONS.ZOOM_IN, tr("Zoom in by 25%"), this, SLOT(zoomIn())); + zoomOutAct = tb->addAction(ICONS.ZOOM_OUT, tr("Zoom out by 25%"), this, SLOT(zoomOut())); + tb->addAction(ICONS.ZOOM_RESET, tr("Reset zoom"), this, SLOT(resetZoom())); + layout()->addWidget(tb); + + imgLabel = new QLabel(); + imgLabel->setBackgroundRole(QPalette::Base); + imgLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); + imgLabel->setScaledContents(true); + scrollArea->setWidget(imgLabel); + imgLabel->show(); +} + +void MultiEditorImage::setValue(const QVariant &value) +{ + this->imgData = value.toByteArray(); + + QPixmap imgPixmap; + if (imgPixmap.loadFromData(this->imgData)) + { + imgLabel->setPixmap(imgPixmap); + + QBuffer buf(&(this->imgData)); + QImageReader ir(&buf); + imgFormat = ir.format(); + } + else + { + imgLabel->clear(); + imgFormat.clear(); + } + + imgLabel->adjustSize(); +} + +QVariant MultiEditorImage::getValue() +{ + return imgData; +} + +void MultiEditorImage::setReadOnly(bool boolValue) +{ + loadAction->setEnabled(!boolValue); +} + +QList MultiEditorImage::getNoScrollWidgets() +{ + QList list; + list << scrollArea << imgLabel; + return list; +} + +void MultiEditorImage::focusThisWidget() +{ +} + +void MultiEditorImage::notifyAboutUnload() +{ + emit aboutToBeDeleted(); +} + +void MultiEditorImage::scale(double factor) +{ + currentZoom *= factor; + imgLabel->resize(currentZoom * imgLabel->pixmap()->size()); + zoomInAct->setEnabled(currentZoom < 10.0); + zoomOutAct->setEnabled(currentZoom > 0.1); +} + +void MultiEditorImage::openFile() +{ + QString dir = getFileDialogInitPath(); + QString filter = tr("Images (*.jpeg *.jpg *.png *.bmp *.gif *.tiff *.jp2 *.svg *.tga *.icns *.webp *.wbmp *.mng);;All files (*)"); + QString fileName = QFileDialog::getOpenFileName(this, tr("Open image"), dir, filter); + if (fileName.isNull()) + return; + + setFileDialogInitPathByFile(fileName); + + QFile file(fileName); + if (!file.open(QIODevice::ReadOnly)) + { + notifyError(tr("Could not open file %1 for reading.").arg(fileName)); + return; + } + + QByteArray newData = file.readAll(); + file.close(); + + setValue(newData); + emit valueModified(); +} + +void MultiEditorImage::saveFile() +{ + QString dir = getFileDialogInitPath(); + QString filter; + QString selectedFilter; + QString format = QString::fromLatin1(imgFormat); + if (!format.isEmpty()) + { + selectedFilter = QString("%1 (*.%2)").arg(format, format.toLower()); + filter = QString("%1;;%3").arg(selectedFilter, tr("All files (*)")); + } + QString fileName = QFileDialog::getSaveFileName(this, tr("Save image"), dir, filter, selectedFilter.isEmpty() ? nullptr : &selectedFilter); + if (fileName.isNull()) + return; + + setFileDialogInitPathByFile(fileName); + + if (!format.isEmpty() && !fileName.endsWith(format, Qt::CaseInsensitive) && imgLabel->pixmap()) + { + if (!imgLabel->pixmap()->save(fileName)) + { + QString requestedFormat = QFileInfo(fileName).completeSuffix(); + notifyWarn(tr("Tried to save image under different format (%1) than original (%2), " + "but application failed to convert it. The image with unchanged format (%3) " + "will be saved under the given name (%4)").arg(requestedFormat, format, format, fileName)); + } + else + return; + } + + QFile file(fileName); + if (!file.open(QIODevice::WriteOnly)) + { + notifyError(tr("Could not nopen file %1 for writting.").arg(fileName)); + return; + } + + if (file.write(imgData) < imgData.size()) + notifyError(tr("Could not write image into the file %1").arg(fileName)); + + file.close(); +} + +void MultiEditorImage::zoomIn() +{ + scale(1.25); +} + +void MultiEditorImage::zoomOut() +{ + scale(0.8); +} + +void MultiEditorImage::resetZoom() +{ + imgLabel->adjustSize(); + currentZoom = 1.0; +} + +MultiEditorWidget* MultiEditorImagePlugin::getInstance() +{ + MultiEditorImage* instance = new MultiEditorImage(); + instances << instance; + connect(instance, &QObject::destroyed, [this, instance]() + { + instances.removeOne(instance); + }); + return instance; +} + +bool MultiEditorImagePlugin::validFor(const DataType& dataType) +{ + switch (dataType.getType()) + { + case DataType::BLOB: + case DataType::NONE: + case DataType::unknown: + return true; + case DataType::BOOLEAN: + case DataType::BIGINT: + case DataType::DECIMAL: + case DataType::DOUBLE: + case DataType::INTEGER: + case DataType::INT: + case DataType::NUMERIC: + case DataType::REAL: + case DataType::STRING: + case DataType::TEXT: + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::DATE: + case DataType::DATETIME: + case DataType::TIME: + break; + } + return false; +} + +int MultiEditorImagePlugin::getPriority(const DataType& dataType) +{ + switch (dataType.getType()) + { + case DataType::BLOB: + return 10; + case DataType::NONE: + case DataType::unknown: + return 50; + case DataType::BOOLEAN: + case DataType::BIGINT: + case DataType::DECIMAL: + case DataType::DOUBLE: + case DataType::INTEGER: + case DataType::INT: + case DataType::NUMERIC: + case DataType::REAL: + case DataType::STRING: + case DataType::TEXT: + case DataType::CHAR: + case DataType::VARCHAR: + case DataType::DATE: + case DataType::DATETIME: + case DataType::TIME: + break; + } + return 100; +} + +QString MultiEditorImagePlugin::getTabLabel() +{ + return tr("Image"); +} + +bool MultiEditorImagePlugin::init() +{ + Q_INIT_RESOURCE(multieditorimage); + return GenericPlugin::init(); +} + +void MultiEditorImagePlugin::deinit() +{ + for (MultiEditorImage* editor : instances) + { + editor->notifyAboutUnload(); + delete editor; + } + + Q_CLEANUP_RESOURCE(multieditorimage); +} diff --git a/Plugins/MultiEditorImage/multieditorimage.h b/Plugins/MultiEditorImage/multieditorimage.h new file mode 100644 index 0000000..7a305cf --- /dev/null +++ b/Plugins/MultiEditorImage/multieditorimage.h @@ -0,0 +1,67 @@ +#ifndef MULTIEDITORIMAGE_H +#define MULTIEDITORIMAGE_H + +#include "multieditor/multieditorwidget.h" +#include "multieditor/multieditorwidgetplugin.h" +#include "multieditorimage_global.h" +#include "datatype.h" +#include "plugins/genericplugin.h" +#include + +class QLabel; +class QScrollArea; +class QScrollBar; + +class MultiEditorImage : public MultiEditorWidget +{ + Q_OBJECT + + public: + MultiEditorImage(); + + void setValue(const QVariant& value); + QVariant getValue(); + void setReadOnly(bool boolValue); + QList getNoScrollWidgets(); + void focusThisWidget(); + void notifyAboutUnload(); + + private: + void scale(double factor); + + QByteArray imgData; + QByteArray imgFormat; + QScrollArea* scrollArea = nullptr; + QLabel* imgLabel = nullptr; + QAction* loadAction = nullptr; + QAction* zoomInAct = nullptr; + QAction* zoomOutAct = nullptr; + double currentZoom = 1.0; + + private slots: + void openFile(); + void saveFile(); + void zoomIn(); + void zoomOut(); + void resetZoom(); +}; + +class MULTIEDITORIMAGE_EXPORT MultiEditorImagePlugin : public GenericPlugin, public MultiEditorWidgetPlugin +{ + Q_OBJECT + + SQLITESTUDIO_PLUGIN("multieditorimage.json") + + public: + MultiEditorWidget* getInstance(); + bool validFor(const DataType& dataType); + int getPriority(const DataType& dataType); + QString getTabLabel(); + bool init(); + void deinit(); + + private: + QList instances; +}; + +#endif // MULTIEDITORIMAGE_H diff --git a/Plugins/MultiEditorImage/multieditorimage.json b/Plugins/MultiEditorImage/multieditorimage.json new file mode 100644 index 0000000..28348c9 --- /dev/null +++ b/Plugins/MultiEditorImage/multieditorimage.json @@ -0,0 +1,7 @@ +{ + "type": "MultiEditorWidgetPlugin", + "title": "Image editor/viewer", + "description": "Introduces image editor/viewer tab for cell editor and form view.", + "version": 10000, + "author": "SalSoft" +} diff --git a/Plugins/MultiEditorImage/multieditorimage.qrc b/Plugins/MultiEditorImage/multieditorimage.qrc new file mode 100644 index 0000000..0ab156b --- /dev/null +++ b/Plugins/MultiEditorImage/multieditorimage.qrc @@ -0,0 +1,15 @@ + + + + MultiEditorImage_de.qm + MultiEditorImage_es.qm + MultiEditorImage_fr.qm + MultiEditorImage_it.qm + MultiEditorImage_pl.qm + MultiEditorImage_pt_BR.qm + MultiEditorImage_ro_RO.qm + MultiEditorImage_ru.qm + MultiEditorImage_sk.qm + MultiEditorImage_zh_CN.qm + + diff --git a/Plugins/MultiEditorImage/multieditorimage_global.h b/Plugins/MultiEditorImage/multieditorimage_global.h new file mode 100644 index 0000000..21e3502 --- /dev/null +++ b/Plugins/MultiEditorImage/multieditorimage_global.h @@ -0,0 +1,12 @@ +#ifndef MULTIEDITORIMAGE_GLOBAL_H +#define MULTIEDITORIMAGE_GLOBAL_H + +#include + +#if defined(MULTIEDITORIMAGE_LIBRARY) +# define MULTIEDITORIMAGE_EXPORT Q_DECL_EXPORT +#else +# define MULTIEDITORIMAGE_EXPORT Q_DECL_IMPORT +#endif + +#endif // MULTIEDITORIMAGE_GLOBAL_H diff --git a/Plugins/MultiEditorImage/package.xml b/Plugins/MultiEditorImage/package.xml new file mode 100644 index 0000000..c638c22 --- /dev/null +++ b/Plugins/MultiEditorImage/package.xml @@ -0,0 +1,10 @@ + + + Image editor/viewer plugin + Plugin that introduces image editor/viewer tab for cell editor and form view. + %VERSION% + %DATE% + pl.com.salsoft.sqlitestudio.plugins.multieditorimage + pl.com.salsoft.sqlitestudio.plugins + true + \ No newline at end of file -- cgit v1.2.3