Skip to content

Commit

Permalink
support system theme + updated changelog
Browse files Browse the repository at this point in the history
Issue #75
  • Loading branch information
rodlie committed Nov 2, 2019
1 parent c4c5874 commit 124bb4b
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 38 deletions.
14 changes: 10 additions & 4 deletions docs/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
## 1.2.2 - 20191103

* Fixed GIMP support on Linux
* Added support for ImageMagick 7
* Support for system theme

## 1.2.1 - 20181204

* Fixed GIMP 2.10 Windows support
* Fixed broken Cyan Python plug-in
* Support XCF (GIMP image format)
* Support reading layers from XCF, TIFF, PSD
* Fixed GIMP 2.10 Windows support
* Fixed broken Cyan Python plug-in
* Support XCF (GIMP image format)
* Support reading layers from XCF, TIFF, PSD

## 1.2.0 - 20181203

Expand Down
107 changes: 74 additions & 33 deletions src/cyan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,28 +93,37 @@ Cyan::Cyan(QWidget *parent)
, imageInfoTree(Q_NULLPTR)
, ignoreConvertAction(false)
, progBar(Q_NULLPTR)
, prefsMenu(Q_NULLPTR)
, nativeStyle(false)
{
// get style settings
QSettings settings;
settings.beginGroup("ui");
nativeStyle = settings.value("native", false).toBool();
settings.endGroup();

// style app
qApp->setStyle(QStyleFactory::create("fusion"));
QPalette palette;
palette.setColor(QPalette::Window, QColor(53,53,53));
palette.setColor(QPalette::WindowText, Qt::white);
palette.setColor(QPalette::Base, QColor(15,15,15));
palette.setColor(QPalette::AlternateBase, QColor(53,53,53));
palette.setColor(QPalette::Link, Qt::white);
palette.setColor(QPalette::LinkVisited, Qt::white);
palette.setColor(QPalette::ToolTipText, Qt::black);
palette.setColor(QPalette::Text, Qt::white);
palette.setColor(QPalette::Button, QColor(53,53,53));
palette.setColor(QPalette::ButtonText, Qt::white);
palette.setColor(QPalette::BrightText, Qt::red);
palette.setColor(QPalette::Highlight, QColor(0,124,151));
palette.setColor(QPalette::HighlightedText, Qt::black);
palette.setColor(QPalette::Disabled, QPalette::Text, Qt::darkGray);
palette.setColor(QPalette::Disabled, QPalette::ButtonText, Qt::darkGray);
qApp->setPalette(palette);
setStyleSheet(QString("*{ font-size: %1pt; }").arg(QString::number(CYAN_FONT_SIZE)));
QString padding = "margin-right:5px;";
if (!nativeStyle) {
qApp->setStyle(QStyleFactory::create("fusion"));
QPalette palette;
palette.setColor(QPalette::Window, QColor(53,53,53));
palette.setColor(QPalette::WindowText, Qt::white);
palette.setColor(QPalette::Base, QColor(15,15,15));
palette.setColor(QPalette::AlternateBase, QColor(53,53,53));
palette.setColor(QPalette::Link, Qt::white);
palette.setColor(QPalette::LinkVisited, Qt::white);
palette.setColor(QPalette::ToolTipText, Qt::black);
palette.setColor(QPalette::Text, Qt::white);
palette.setColor(QPalette::Button, QColor(53,53,53));
palette.setColor(QPalette::ButtonText, Qt::white);
palette.setColor(QPalette::BrightText, Qt::red);
palette.setColor(QPalette::Highlight, QColor(0,124,151));
palette.setColor(QPalette::HighlightedText, Qt::black);
palette.setColor(QPalette::Disabled, QPalette::Text, Qt::darkGray);
palette.setColor(QPalette::Disabled, QPalette::ButtonText, Qt::darkGray);
qApp->setPalette(palette);
setStyleSheet(QString("*{ font-size: %1pt; }").arg(QString::number(CYAN_FONT_SIZE)));
}
setWindowTitle(qApp->applicationName());
setWindowIcon(QIcon(":/cyan.png"));
setAttribute(Qt::WA_QuitOnClose);
Expand Down Expand Up @@ -244,15 +253,18 @@ Cyan::Cyan(QWidget *parent)
grayLabel->setText(tr("GRAY"));
bitDepthLabel->setText(tr("Depth"));

inputLabel->setStyleSheet(padding);
outputLabel->setStyleSheet(padding);
monitorLabel->setStyleSheet(padding);
renderLabel->setStyleSheet(padding);
blackLabel->setStyleSheet(padding);
rgbLabel->setStyleSheet(padding);
cmykLabel->setStyleSheet(padding);
grayLabel->setStyleSheet(padding);
bitDepthLabel->setStyleSheet(padding);
if (!nativeStyle) {
QString padding = "margin-right:5px;";
inputLabel->setStyleSheet(padding);
outputLabel->setStyleSheet(padding);
monitorLabel->setStyleSheet(padding);
renderLabel->setStyleSheet(padding);
blackLabel->setStyleSheet(padding);
rgbLabel->setStyleSheet(padding);
cmykLabel->setStyleSheet(padding);
grayLabel->setStyleSheet(padding);
bitDepthLabel->setStyleSheet(padding);
}

inputLabel->setToolTip(tr("Input profile for image"));
outputLabel->setToolTip(tr("Profile used to convert image"));
Expand Down Expand Up @@ -317,8 +329,10 @@ Cyan::Cyan(QWidget *parent)
menuBar = new QMenuBar(this);
setMenuBar(menuBar);

fileMenu = new QMenu(tr("File"));
helpMenu = new QMenu(tr("Help"));
fileMenu = new QMenu(tr("File"), this);
helpMenu = new QMenu(tr("Help"), this);
prefsMenu = new QMenu(tr("Preferences"), this);

menuBar->addMenu(fileMenu);
menuBar->addMenu(helpMenu);
menuBar->setMaximumHeight(20);
Expand Down Expand Up @@ -351,6 +365,16 @@ Cyan::Cyan(QWidget *parent)

fileMenu->addSeparator();

fileMenu->addMenu(prefsMenu);
QAction *nativeAction = new QAction(tr("Use System Theme"), this);
nativeAction->setCheckable(true);
nativeAction->setChecked(nativeStyle);
connect(nativeAction, SIGNAL(triggered(bool)),
this, SLOT(handleNativeStyleChanged(bool)));
prefsMenu->addAction(nativeAction);

fileMenu->addSeparator();

quitAction = new QAction(tr("Quit"),this);
quitAction->setIcon(QIcon(":/cyan-quit.png"));
quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
Expand Down Expand Up @@ -544,8 +568,10 @@ void Cyan::aboutCyan()
"font-family: sans-serif; }"
"h1, h2, h3, h4 { font-weight: normal; }"
"p, pre, li { font-size: 10pt; }"
"h1#devel { font-size: small; }"
".highlighter-rouge, pre, h1#devel { background-color: #1d1d1d; }";
"h1#devel { font-size: small; }";
if (!nativeStyle) {
style.append(".highlighter-rouge, pre, h1#devel { background-color: #1d1d1d; }");
}
if (!html.isEmpty()) {
HelpDialog *dialog = new HelpDialog(this, tr("About Cyan"), html, style);
dialog->exec();
Expand Down Expand Up @@ -1510,3 +1536,18 @@ void Cyan::handleLoadImageLayer(Magick::Image image)
qDebug() << "handle load image layer";
openImage(image);
}

void Cyan::handleNativeStyleChanged(bool triggered)
{
Q_UNUSED(triggered)
QAction *action = qobject_cast<QAction*>(sender());
if (!action) { return; }
QSettings settings;
settings.beginGroup("ui");
settings.setValue("native", action->isChecked());
settings.endGroup();
settings.sync();
QMessageBox::information(this,
tr("Restart is required"),
tr("Restart Cyan to apply settings."));
}
4 changes: 4 additions & 0 deletions src/cyan.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class Cyan : public QMainWindow
QTreeWidget *imageInfoTree;
bool ignoreConvertAction;
QProgressBar *progBar;
QMenu *prefsMenu;
bool nativeStyle;

private slots:
void readConfig();
Expand Down Expand Up @@ -177,6 +179,8 @@ private slots:

void handleImageHasLayers(std::vector<Magick::Image> layers);
void handleLoadImageLayer(Magick::Image image);

void handleNativeStyleChanged(bool triggered);
};

#endif // CYAN_H
11 changes: 10 additions & 1 deletion src/imageview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,20 @@
#include <QMimeData>
#include <QMimeDatabase>
#include <QMimeType>
#include <QSettings>

ImageView::ImageView(QWidget* parent) : QGraphicsView(parent)
, fit(false) {
setAcceptDrops(true);
setBackgroundBrush(QColor(30,30,30));

// set style
QSettings settings;
settings.beginGroup("ui");
bool nativeStyle = settings.value("native", false).toBool();
settings.endGroup();
if (!nativeStyle) {
setBackgroundBrush(QColor(30,30,30));
}
setDragMode(QGraphicsView::ScrollHandDrag);
}

Expand Down

0 comments on commit 124bb4b

Please sign in to comment.