Skip to content

Commit

Permalink
ugly qt4 hack #115
Browse files Browse the repository at this point in the history
Just testing
  • Loading branch information
rodlie committed Apr 21, 2024
1 parent b78f14b commit ff59eae
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 59 deletions.
12 changes: 6 additions & 6 deletions cyan.pro
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ OBJECTS_DIR = $${DESTDIR}/.obj
MOC_DIR = $${DESTDIR}/.moc
RCC_DIR = $${DESTDIR}/.qrc

QT += widgets concurrent
QT += core gui concurrent
TEMPLATE = app

CONFIG += c++11
Expand Down Expand Up @@ -137,11 +137,11 @@ mac {
ICON = res/Cyan.icns
QMAKE_INFO_PLIST = res/Info.plist
# ugly workaround for static build:
QMAKE_MACOSX_DEPLOYMENT_TARGET = $${OSX_COMPAT}
QMAKE_CFLAGS += -fopenmp
QMAKE_CXXFLAGS += -fopenmp
QMAKE_LFLAGS += -lomp -liconv
LIBS += -L /opt/local/lib/libomp
#QMAKE_MACOSX_DEPLOYMENT_TARGET = $${OSX_COMPAT}
#QMAKE_CFLAGS += -fopenmp
#QMAKE_CXXFLAGS += -fopenmp
#QMAKE_LFLAGS += -lomp -liconv
#LIBS += -L /opt/local/lib/libomp
}

win32 {
Expand Down
6 changes: 3 additions & 3 deletions src/FXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

FXX::FXX()
{
Magick::InitializeMagick(nullptr);
Magick::InitializeMagick(NULL);
}

FXX::Image FXX::readImage(const std::string &file,
Expand Down Expand Up @@ -455,7 +455,7 @@ bool FXX::editProfile(std::string file,
{
bool result = false;
if (!file.empty()) {
cmsHPROFILE lcmsProfile = nullptr;
cmsHPROFILE lcmsProfile = NULL;
lcmsProfile = cmsOpenProfileFromFile(file.c_str(), "w");
if (lcmsProfile) {
cmsContext ContextID = cmsGetProfileContextID(lcmsProfile);
Expand Down Expand Up @@ -520,7 +520,7 @@ std::string FXX::getProfileTag(cmsHPROFILE profile,
cmsSelectedType = cmsInfoDescription;
}
size = cmsGetProfileInfoASCII(profile, cmsSelectedType,
"en", "US", nullptr, 0);
"en", "US", NULL, 0);
if (size > 0) {
std::vector<char> buffer(size);
cmsUInt32Number newsize = cmsGetProfileInfoASCII(profile, cmsSelectedType,
Expand Down
80 changes: 46 additions & 34 deletions src/cyan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
#include <QStyleFactory>
#include <QHeaderView>
#include <QMimeData>
#include <QMimeDatabase>
#include <QMimeType>
//#include <QMimeDatabase>
//#include <QMimeType>
#include <QTreeWidgetItem>
#include <qtconcurrentrun.h>

Expand All @@ -72,35 +72,35 @@ extern "C" WINBASEAPI BOOL WINAPI GetPhysicallyInstalledSystemMemory (PULONGLONG

Cyan::Cyan(QWidget *parent)
: QMainWindow(parent)
, scene(Q_NULLPTR)
, view(Q_NULLPTR)
, mainBar(Q_NULLPTR)
, profileBar(Q_NULLPTR)
, rgbProfile(Q_NULLPTR)
, cmykProfile(Q_NULLPTR)
, grayProfile(Q_NULLPTR)
, inputProfile(Q_NULLPTR)
, outputProfile(Q_NULLPTR)
, monitorProfile(Q_NULLPTR)
, renderingIntent(Q_NULLPTR)
, blackPoint(Q_NULLPTR)
, menuBar(Q_NULLPTR)
, fileMenu(Q_NULLPTR)
, helpMenu(Q_NULLPTR)
, openImageAction(Q_NULLPTR)
, saveImageAction(Q_NULLPTR)
, infoImageAction(Q_NULLPTR)
, quitAction(Q_NULLPTR)
, exportEmbeddedProfileAction(Q_NULLPTR)
, bitDepth(Q_NULLPTR)
, scene(NULL)
, view(NULL)
, mainBar(NULL)
, profileBar(NULL)
, rgbProfile(NULL)
, cmykProfile(NULL)
, grayProfile(NULL)
, inputProfile(NULL)
, outputProfile(NULL)
, monitorProfile(NULL)
, renderingIntent(NULL)
, blackPoint(NULL)
, menuBar(NULL)
, fileMenu(NULL)
, helpMenu(NULL)
, openImageAction(NULL)
, saveImageAction(NULL)
, infoImageAction(NULL)
, quitAction(NULL)
, exportEmbeddedProfileAction(NULL)
, bitDepth(NULL)
, ignoreConvertAction(false)
, progBar(Q_NULLPTR)
, prefsMenu(Q_NULLPTR)
, progBar(NULL)
, prefsMenu(NULL)
, nativeStyle(false)
, qualityBox(Q_NULLPTR)
, qualityBox(NULL)
, activeLayer(-1)
, selectedLayer(Q_NULLPTR)
, selectedLayerLabel(Q_NULLPTR)
, selectedLayer(NULL)
, selectedLayerLabel(NULL)
{
// get style settings
QSettings settings;
Expand All @@ -110,7 +110,7 @@ Cyan::Cyan(QWidget *parent)

// style app
if (!nativeStyle) {
qApp->setStyle(QStyleFactory::create("fusion"));
qApp->setStyle(QStyleFactory::create("plastique"));
QPalette palette;
palette.setColor(QPalette::Window, QColor(53,53,53));
palette.setColor(QPalette::WindowText, Qt::white);
Expand Down Expand Up @@ -586,11 +586,21 @@ void Cyan::openImageDialog()
" (*.png *.jpg *.jpeg *.tif *.tiff *.psd *.xcf *.icc *.icm)")
.arg(tr("Image files")));
if (!file.isEmpty()) {
QMimeDatabase db;
QMimeType type = db.mimeTypeForFile(file);
if (type.name().startsWith("image")) { openImage(file); }
else if (type.name().contains("iccprofile")) { openProfile(file); }
//QMimeDatabase db;
//QMimeType type = db.mimeTypeForFile(file);
//if (type.name().startsWith("image")) { openImage(file); }
//else if (type.name().contains("iccprofile")) { openProfile(file); }
QFileInfo imageFile(file);
if (imageFile.suffix().endsWith("jpg", Qt::CaseInsensitive) ||
imageFile.suffix().endsWith("jpeg", Qt::CaseInsensitive) ||
imageFile.suffix().endsWith("tif", Qt::CaseInsensitive) ||
imageFile.suffix().endsWith("tiff", Qt::CaseInsensitive) ||
imageFile.suffix().endsWith("png", Qt::CaseInsensitive)) {
openImage(file);
} else if(imageFile.suffix().endsWith("icc", Qt::CaseInsensitive)) {
openProfile(file);
}

settings.setValue("lastDir",
imageFile.absoluteDir().absolutePath());
}
Expand Down Expand Up @@ -1288,6 +1298,7 @@ void Cyan::bitDepthChanged(int index)

void Cyan::gimpPlugin()
{
/*
QStringList versions,folders,gimps;
versions << "2.4" << "2.6" << "2.7" << "2.8" << "2.9" << "2.10" << "2.99" << "3.0";
gimps << ".gimp-" << ".config/GIMP-AppImage/" << ".config/GIMP/" << "AppData/Roaming/GIMP/" << "Library/Application Support/GIMP/" << ".var/app/org.gimp.GIMP/config/GIMP/";
Expand Down Expand Up @@ -1362,6 +1373,7 @@ void Cyan::gimpPlugin()
}
}
if (reloadPlug) { gimpPlugin(); }
*/
}

void Cyan::openProfile(QString file)
Expand Down Expand Up @@ -1570,7 +1582,7 @@ void Cyan::handleReadWatcher()
getConvertProfiles();
QFileInfo fileinfo(QString::fromStdString(image.filename));
setWindowTitle(fileinfo.fileName());
if (!monitorProfile->currentData().toString().isEmpty()) { updateImage(); }
if (!monitorProfile->itemData(monitorProfile->currentIndex()).toString().isEmpty()) { updateImage(); }
} else {
QMessageBox::warning(this, tr("Image error"),
QString::fromStdString(image.error));
Expand Down
2 changes: 1 addition & 1 deletion src/cyan.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Cyan : public QMainWindow
Q_OBJECT

public:
Cyan(QWidget *parent = Q_NULLPTR);
Cyan(QWidget *parent = NULL);
~Cyan();

signals:
Expand Down
2 changes: 1 addition & 1 deletion src/helpdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ HelpDialog::HelpDialog(QWidget *parent,
QString css,
bool enableCloseButton)
: QDialog(parent)
, browser(Q_NULLPTR)
, browser(NULL)
{
setWindowTitle(title);
setWindowIcon(QIcon(":/cyan.png"));
Expand Down
2 changes: 1 addition & 1 deletion src/helpdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class HelpDialog : public QDialog
Q_OBJECT

public:
HelpDialog(QWidget *parent = Q_NULLPTR,
HelpDialog(QWidget *parent = NULL,
QString title = QString(),
QString html = QString(),
QString css = QString(),
Expand Down
22 changes: 17 additions & 5 deletions src/imageview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@

#include "imageview.h"
#include <QMimeData>
#include <QMimeDatabase>
#include <QMimeType>
//#include <QMimeDatabase>
//#include <QMimeType>
#include <QMimeData>
#include <QUrl>
#include <QSettings>

ImageView::ImageView(QWidget* parent) : QGraphicsView(parent)
Expand All @@ -54,7 +56,7 @@ ImageView::ImageView(QWidget* parent) : QGraphicsView(parent)
void ImageView::wheelEvent(QWheelEvent* event) {
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
double scaleFactor = 1.15;
if(event->angleDelta().y() > 0) { // up
if(event->delta() > 0) { // up
fit = false;
scale(scaleFactor, scaleFactor);
emit myZoom(scaleFactor, scaleFactor);
Expand Down Expand Up @@ -99,10 +101,20 @@ void ImageView::dropEvent(QDropEvent *event)
if (!mimeData->hasUrls()) { return; }
if (mimeData->urls().at(0).isEmpty()) { return; }
QUrl url = mimeData->urls().at(0);
QMimeDatabase db;

if (url.toLocalFile().endsWith(".jpg", Qt::CaseInsensitive) ||
url.toLocalFile().endsWith(".jpeg", Qt::CaseInsensitive) ||
url.toLocalFile().endsWith(".tif", Qt::CaseInsensitive) ||
url.toLocalFile().endsWith(".tiff", Qt::CaseInsensitive) ||
url.toLocalFile().endsWith(".png", Qt::CaseInsensitive)) {
emit openImage(url.toLocalFile());
} else if(url.toLocalFile().endsWith(".icc", Qt::CaseInsensitive)) {
emit openProfile(url.toLocalFile());
}
/*QMimeDatabase db;
QMimeType type = db.mimeTypeForFile(url.toLocalFile());
if (type.name().startsWith("image")) { emit openImage(url.toLocalFile()); }
else if (type.name().contains("iccprofile")) { emit openProfile(url.toLocalFile()); }
else if (type.name().contains("iccprofile")) { emit openProfile(url.toLocalFile()); }*/
}

void ImageView::resizeEvent(QResizeEvent */*event*/)
Expand Down
2 changes: 1 addition & 1 deletion src/imageview.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ImageView : public QGraphicsView
Q_OBJECT

public:
explicit ImageView(QWidget* parent = Q_NULLPTR);
explicit ImageView(QWidget* parent = NULL);
bool fit;

signals:
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int main(int argc, char *argv[])
QApplication a(argc, argv);
QCoreApplication::setApplicationName("Cyan");
QCoreApplication::setOrganizationName("Cyan");
QGuiApplication::setApplicationDisplayName("Cyan");
//QGuiApplication::setApplicationDisplayName("Cyan");
QCoreApplication::setOrganizationDomain("net.fxarena");
QCoreApplication::setApplicationVersion(CYAN_VERSION);
Cyan w;
Expand Down
10 changes: 5 additions & 5 deletions src/profiledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@

ProfileDialog::ProfileDialog(QWidget *parent, const QString &inputProfile)
: QDialog(parent)
, profileFileName(Q_NULLPTR)
, profileDescription(Q_NULLPTR)
, profileCopyright(Q_NULLPTR)
, profileSaveButton(Q_NULLPTR)
, profileCloseButton(Q_NULLPTR)
, profileFileName(NULL)
, profileDescription(NULL)
, profileCopyright(NULL)
, profileSaveButton(NULL)
, profileCloseButton(NULL)
{
setWindowTitle(tr("Edit Color Profile"));
setWindowIcon(QIcon(":/cyan.png"));
Expand Down
2 changes: 1 addition & 1 deletion src/profiledialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ProfileDialog : public QDialog
Q_OBJECT

public:
ProfileDialog(QWidget *parent = Q_NULLPTR,
ProfileDialog(QWidget *parent = NULL,
const QString &inputProfile = QString());
QLineEdit *profileFileName;
QLineEdit *profileDescription;
Expand Down

0 comments on commit ff59eae

Please sign in to comment.