Skip to content

Commit

Permalink
Add option for using large color palette on right button click (#2171)
Browse files Browse the repository at this point in the history
(cherry picked from commit 403a647)

Co-authored-by: Yuriy Puchkov <[email protected]>
  • Loading branch information
2 people authored and borgmanJeremy committed Dec 21, 2021
1 parent 1bd8857 commit 8b08c7f
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 13 deletions.
15 changes: 12 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ if (APPLE)
COMMAND bash "-c" "sips -z 512 512 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome-1024.png --out flameshot.iconset/[email protected]"
COMMAND bash "-c" "sips -z 512 512 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome-1024.png --out flameshot.iconset/icon_512x512.png"
COMMAND bash "-c" "sips -z 1024 1024 \"${CMAKE_SOURCE_DIR}\"/data/img/app/flameshot.monochrome-1024.png --out flameshot.iconset/[email protected]"


COMMAND bash "-c" "iconutil -c icns flameshot.iconset"
)

Expand Down Expand Up @@ -215,6 +215,15 @@ if (WIN32)
endif ()
endif ()

# Choose default color palette (small or large)
if($ENV{FLAMESHOT_PREDEFINED_COLOR_PALETTE_LARGE})
set(FLAMESHOT_PREDEFINED_COLOR_PALETTE_LARGE true)
else()
set(FLAMESHOT_PREDEFINED_COLOR_PALETTE_LARGE false)
endif()
message("Flameshot predefined color palette large: " ${FLAMESHOT_PREDEFINED_COLOR_PALETTE_LARGE})
target_compile_definitions(flameshot PRIVATE PREDEFINED_COLOR_PALETTE_LARGE=${FLAMESHOT_PREDEFINED_COLOR_PALETTE_LARGE})

find_package (Git)
if (GIT_FOUND)
message("git found: ${GIT_EXECUTABLE} in version ${GIT_VERSION_STRING}")
Expand Down Expand Up @@ -347,7 +356,7 @@ if (WIN32)
if (ENABLE_OPENSSL)
if (EXISTS ${OPENSSL_ROOT_DIR}/bin)

install(
install(
DIRECTORY ${OPENSSL_ROOT_DIR}/bin/
DESTINATION bin
FILES_MATCHING
Expand Down
15 changes: 15 additions & 0 deletions src/config/generalconf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ GeneralConf::GeneralConf(QWidget* parent)
#if !defined(Q_OS_WIN)
initAutoCloseIdleDaemon();
#endif
initPredefinedColorPaletteLarge();

m_layout->addStretch();

Expand Down Expand Up @@ -369,6 +370,20 @@ void GeneralConf::initShowStartupLaunchMessage()
});
}

void GeneralConf::initPredefinedColorPaletteLarge()
{
m_predefinedColorPaletteLarge =
new QCheckBox(tr("Use large predefined color palette"), this);
m_predefinedColorPaletteLarge->setToolTip(
tr("Use large predefined color palette"));
m_scrollAreaLayout->addWidget(m_predefinedColorPaletteLarge);

connect(
m_predefinedColorPaletteLarge, &QCheckBox::clicked, [](bool checked) {
ConfigHandler().setPredefinedColorPaletteLarge(checked);
});
}

void GeneralConf::initCopyAndCloseAfterUpload()
{
m_copyAndCloseAfterUpload =
Expand Down
2 changes: 2 additions & 0 deletions src/config/generalconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private slots:
void initAntialiasingPinZoom();
void initUseJpgForClipboard();
void initUploadWithoutConfirmation();
void initPredefinedColorPaletteLarge();

void _updateComponents(bool allowEmptySavePath);

Expand Down Expand Up @@ -98,4 +99,5 @@ private slots:
QSpinBox* m_uploadHistoryMax;
QSpinBox* m_undoLimit;
QComboBox* m_setSaveAsFileExtension;
QCheckBox* m_predefinedColorPaletteLarge;
};
2 changes: 2 additions & 0 deletions src/utils/confighandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ static QMap<class QString, QSharedPointer<ValueHandler>>
OPTION("ignoreUpdateToVersion" ,String ( "" )),
OPTION("keepOpenAppLauncher" ,Bool ( false )),
OPTION("fontFamily" ,String ( "" )),
// PREDEFINED_COLOR_PALETTE_LARGE is defined in src/CMakeList.txt file and can be overwritten in GitHub actions
OPTION("predefinedColorPaletteLarge", Bool ( PREDEFINED_COLOR_PALETTE_LARGE )),
// NOTE: If another tool size is added besides drawThickness and
// drawFontSize, remember to update ConfigHandler::toolSize
};
Expand Down
3 changes: 3 additions & 0 deletions src/utils/confighandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ class ConfigHandler : public QObject
CONFIG_GETTER_SETTER(uiColor, setUiColor, QColor)
CONFIG_GETTER_SETTER(contrastUiColor, setContrastUiColor, QColor)
CONFIG_GETTER_SETTER(drawColor, setDrawColor, QColor)
CONFIG_GETTER_SETTER(predefinedColorPaletteLarge,
setPredefinedColorPaletteLarge,
bool)
CONFIG_GETTER_SETTER(fontFamily, setFontFamily, QString)
CONFIG_GETTER_SETTER(showHelp, setShowHelp, bool)
CONFIG_GETTER_SETTER(showSidePanelButton, setShowSidePanelButton, bool)
Expand Down
40 changes: 30 additions & 10 deletions src/utils/valuehandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,16 +417,36 @@ QVariant UserColors::process(const QVariant& val)

QVariant UserColors::fallback()
{
return QVariant::fromValue(QVector<QColor>{ Qt::darkRed,
Qt::red,
Qt::yellow,
Qt::green,
Qt::darkGreen,
Qt::cyan,
Qt::blue,
Qt::magenta,
Qt::darkMagenta,
QColor() });
if (ConfigHandler().predefinedColorPaletteLarge()) {
return QVariant::fromValue(QVector<QColor>{ Qt::white,
Qt::red,
Qt::green,
Qt::blue,
Qt::black,
Qt::darkRed,
Qt::darkGreen,
Qt::darkBlue,
Qt::darkGray,
Qt::cyan,
Qt::magenta,
Qt::yellow,
Qt::lightGray,
Qt::darkCyan,
Qt::darkMagenta,
Qt::darkYellow,
QColor() });
} else {
return QVariant::fromValue(QVector<QColor>{ Qt::darkRed,
Qt::red,
Qt::yellow,
Qt::green,
Qt::darkGreen,
Qt::cyan,
Qt::blue,
Qt::magenta,
Qt::darkMagenta,
QColor() });
}
}

QString UserColors::expected()
Expand Down

0 comments on commit 8b08c7f

Please sign in to comment.