Skip to content

Commit

Permalink
ImageViewrPlugin: new widget
Browse files Browse the repository at this point in the history
Found a better implementation for the image viewer. Has more features,
and suites more the "vibe" of this IDE.

Removed the old image viewer.

The image viewers are now full qmdiClients. We can at least restore
loaded files.
  • Loading branch information
diegoiast committed Sep 14, 2024
1 parent d6d6dd4 commit 6aed631
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 237 deletions.
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set(DISABLE_QUTEPART_TESTS on)
CPMAddPackage("gh:diegoiast/qmdilib#main")
CPMAddPackage("gh:diegoiast/qutepart-cpp#qt6-port-take2")
CPMAddPackage("gh:diegoiast/command-palette-widget#main")
CPMAddPackage("gh:palacaze/image-viewer#master")
download_breeze_icons(6.4.0)

find_package(Qt6 COMPONENTS Widgets PrintSupport Network)
Expand Down Expand Up @@ -47,8 +48,6 @@ set(qtedit4_sources
src/plugins/texteditor/texteditor_plg.h
src/plugins/help/help_plg.cpp
src/plugins/help/help_plg.h
src/plugins/imageviewer/QImageViewer.h
src/plugins/imageviewer/QImageViewer.cpp
src/plugins/imageviewer/imageviewer_plg.cpp
src/plugins/imageviewer/imageviewer_plg.h
src/plugins/ProjectManager/ProjectBuildConfig.cpp
Expand Down Expand Up @@ -84,7 +83,7 @@ target_include_directories(qtedit4 PUBLIC
${qutepart_SOURCE_DIR}/include
src/widgets
)
target_link_libraries(qtedit4 PUBLIC qmdilib qutepart CommandPaletteWidget Qt6::PrintSupport)
target_link_libraries(qtedit4 PUBLIC qmdilib qutepart CommandPaletteWidget Qt6::PrintSupport Pal::ImageViewer)

if(MSVC)
# if we don't do this - file will be under Debug/Relase subdir
Expand Down
172 changes: 0 additions & 172 deletions src/plugins/imageviewer/QImageViewer.cpp

This file was deleted.

45 changes: 0 additions & 45 deletions src/plugins/imageviewer/QImageViewer.h

This file was deleted.

40 changes: 31 additions & 9 deletions src/plugins/imageviewer/imageviewer_plg.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
#include "imageviewer_plg.h"
#include "QImageViewer.h"
/**
* \file imageviewer_plg
* \brief Definition of
* \author Diego Iastrubni [email protected]
* License MIT
* \see class name
*/


#include <QFileInfo>
#include <pal/image-viewer.h>
#include "imageviewer_plg.h"

class qmdiImageViewer : public pal::ImageViewer, public qmdiClient {
public:
QString thisFileName;
qmdiImageViewer(QWidget *p, const QString &fileName) : pal::ImageViewer(p) {
this->setImage(QImage(fileName));
auto fi = QFileInfo(fileName);
this->mdiClientName = fi.fileName();
this->thisFileName = fileName;
}

virtual QString mdiClientFileName() override {
return thisFileName;
}

virtual std::optional<std::tuple<int, int, int>> get_coordinates() const override {
return {};
}
};

ImageViewrPlugin::ImageViewrPlugin() {
name = tr("Image viewer plugin - based on QutePart");
Expand Down Expand Up @@ -40,13 +67,8 @@ int ImageViewrPlugin::canOpenFile(const QString fileName) {

bool ImageViewrPlugin::openFile(const QString fileName, int x, int y, int z) {
auto tabWidget = dynamic_cast<QTabWidget *>(mdiServer);
auto viewer = new QImageViewer(getManager());
viewer->loadFile(fileName);
auto fi = QFileInfo(fileName);
tabWidget->addTab(viewer, fi.fileName());
auto viewer = new qmdiImageViewer(tabWidget, fileName);
mdiServer->addClient(viewer);
return true;
}

void ImageViewrPlugin::showAbout() {}

void ImageViewrPlugin::actionAbout_triggered() {}
9 changes: 1 addition & 8 deletions src/plugins/imageviewer/imageviewer_plg.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \file imageviewer_plg.h
* \brief Definition of the image viewer system plugin
* \author Diego Iastrubni ([email protected])
* License LGPL
* License MIT
* \see ImageViewer plugin
*/

Expand All @@ -21,11 +21,4 @@ class ImageViewrPlugin : public IPlugin {
QStringList myExtensions() override;
int canOpenFile(const QString fileName) override;
bool openFile(const QString fileName, int x = -1, int y = -1, int z = -1) override;

void showAbout() override;
public slots:
void actionAbout_triggered();

private:
QAction *actionAbout;
};

0 comments on commit 6aed631

Please sign in to comment.