Merge 0.8.3 upstream

This commit is contained in:
Yuriy Puchkov
2020-10-02 10:13:04 +03:00
37 changed files with 1293 additions and 1550 deletions

View File

@@ -67,7 +67,7 @@ target_sources(
${CMAKE_CURRENT_SOURCE_DIR}/../external/Qt-Color-Widgets/src/color_wheel.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../external/Qt-Color-Widgets/include/color_wheel.hpp
${CMAKE_CURRENT_SOURCE_DIR}/../data/graphics.qrc
${CMAKE_CURRENT_SOURCE_DIR}/../data/icon.rc # windows binary icon resource file
${CMAKE_CURRENT_SOURCE_DIR}/../data/flameshot.rc # windows binary icon resource file
${QM_FILES}
main.cpp)

View File

@@ -7,6 +7,7 @@ target_sources(
filenameeditor.cpp
geneneralconf.cpp
strftimechooserwidget.cpp
styleoverride.cpp
uicoloreditor.cpp
visualseditor.cpp
shortcutswidget.cpp

View File

@@ -0,0 +1,16 @@
//
// Created by jeremy on 9/24/20.
//
#include "styleoverride.h"
int StyleOverride::styleHint(StyleHint hint,
const QStyleOption* option,
const QWidget* widget,
QStyleHintReturn* returnData) const
{
if (hint == SH_ToolTip_WakeUpDelay) {
return 600;
} else {
return baseStyle()->styleHint(hint, option, widget, returnData);
}
}

View File

@@ -0,0 +1,21 @@
//
// Created by jeremy on 9/24/20.
//
#ifndef FLAMESHOT_STYLEOVERRIDE_H
#define FLAMESHOT_STYLEOVERRIDE_H
#include <QObject>
#include <QProxyStyle>
class StyleOverride : public QProxyStyle
{
Q_OBJECT
public:
int styleHint(StyleHint hint,
const QStyleOption* option = Q_NULLPTR,
const QWidget* widget = Q_NULLPTR,
QStyleHintReturn* returnData = Q_NULLPTR) const;
};
#endif // FLAMESHOT_STYLEOVERRIDE_H

View File

@@ -277,7 +277,7 @@ void Controller::sendTrayNotification(const QString& text,
{
if (m_trayIcon) {
m_trayIcon->showMessage(
title, text, QSystemTrayIcon::Information, timeout);
title, text, QIcon(":img/app/flameshot.svg"), timeout);
}
}

View File

@@ -17,6 +17,7 @@
#include "singleapplication.h"
#include "src/cli/commandlineparser.h"
#include "src/config/styleoverride.h"
#include "src/core/capturerequest.h"
#include "src/core/controller.h"
#include "src/utils/confighandler.h"
@@ -47,6 +48,7 @@ int main(int argc, char* argv[])
// no arguments, just launch Flameshot
if (argc == 1) {
SingleApplication app(argc, argv);
QApplication::setStyle(new StyleOverride);
QTranslator translator, qtTranslator;
QStringList trPaths = PathInfo::translationsPaths();

View File

@@ -16,6 +16,7 @@
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
#include "circlecounttool.h"
#include "colorutils.h"
#include <QPainter>
namespace {
#define PADDING_VALUE 2
@@ -72,6 +73,7 @@ void CircleCountTool::process(QPainter& painter,
auto new_font = orig_font;
auto fontSize = bubble_size;
new_font.setPixelSize(fontSize);
new_font.setBold(true);
painter.setFont(new_font);
QRect bRect =
@@ -89,8 +91,7 @@ void CircleCountTool::process(QPainter& painter,
textRect, Qt::AlignCenter, QString::number(m_count));
}
// Lightness value ranges from 0-255, we split at 75 as this looks best
if (m_color.lightness() <= 75) {
if (ColorUtils::colorIsDark(m_color)) {
painter.setPen(Qt::white);
} else {
painter.setPen(Qt::black);

View File

@@ -22,15 +22,18 @@
#include "src/widgets/notificationwidget.h"
#include <QApplication>
#include <QClipboard>
#include <QCursor>
#include <QDesktopServices>
#include <QDrag>
#include <QHBoxLayout>
#include <QGuiApplication>
#include <QJsonDocument>
#include <QJsonObject>
#include <QLabel>
#include <QMimeData>
#include <QNetworkAccessManager>
#include <QPushButton>
#include <QRect>
#include <QScreen>
#include <QShortcut>
#include <QTimer>
#include <QUrlQuery>
@@ -58,6 +61,13 @@ void ImgUploader::init(const QString& title, const QString& label)
setWindowTitle(title);
setWindowIcon(QIcon(":img/app/flameshot.svg"));
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QRect position = frameGeometry();
QScreen* screen = QGuiApplication::screenAt(QCursor::pos());
position.moveCenter(screen->availableGeometry().center());
move(position.topLeft());
#endif
m_spinner = new LoadSpinner(this);
m_spinner->setColor(ConfigHandler().uiMainColorValue());
m_spinner->start();

View File

@@ -24,11 +24,8 @@ inline qreal getColorLuma(const QColor& c)
bool ColorUtils::colorIsDark(const QColor& c)
{
bool isWhite = false;
if (getColorLuma(c) <= 0.60) {
isWhite = true;
}
return isWhite;
// when luma <= 0.5, we considor it as a dark color
return getColorLuma(c) <= 0.5;
}
QColor ColorUtils::contrastColor(const QColor& c)

View File

@@ -90,7 +90,10 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool& ok)
QRect geometry;
for (QScreen* const screen : QGuiApplication::screens()) {
geometry = geometry.united(screen->geometry());
QRect scrRect = screen->geometry();
scrRect.moveTo(scrRect.x() / screen->devicePixelRatio(),
scrRect.y() / screen->devicePixelRatio());
geometry = geometry.united(scrRect);
}
QPixmap p(QApplication::primaryScreen()->grabWindow(

View File

@@ -108,6 +108,7 @@ CaptureTool* CaptureToolButton::tool() const
void CaptureToolButton::setColor(const QColor& c)
{
m_mainColor = c;
CaptureButton::setColor(c);
updateIcon();
}

View File

@@ -28,7 +28,6 @@
#include "src/tools/storage/storagemanager.h"
#include "src/tools/toolfactory.h"
#include "src/utils/colorutils.h"
#include "src/utils/globalvalues.h"
#include "src/utils/screengrabber.h"
#include "src/utils/screenshotsaver.h"
#include "src/utils/systemnotification.h"
@@ -39,17 +38,14 @@
#include "src/widgets/orientablepushbutton.h"
#include "src/widgets/panel/sidepanelwidget.h"
#include <QApplication>
#include <QBuffer>
#include <QDesktopWidget>
#include <QGuiApplication>
#include <QMouseEvent>
#include <QPaintEvent>
#include <QPainter>
#include <QScreen>
#include <QShortcut>
#include <QUndoView>
#include <draggablewidgetmaker.h>
// CaptureWidget is the main component used to capture the screen. It contains
// an area of selection with its respective buttons.
@@ -128,6 +124,8 @@ CaptureWidget::CaptureWidget(const uint id,
if (m_context.fullscreen) {
for (QScreen* const screen : QGuiApplication::screens()) {
QRect r = screen->geometry();
r.moveTo(r.x() / screen->devicePixelRatio(),
r.y() / screen->devicePixelRatio());
#ifdef Q_OS_WIN
r.moveTo(r.topLeft() - topLeft);
#endif
@@ -655,6 +653,10 @@ void CaptureWidget::initPanel()
QRect panelRect = rect();
if (m_context.fullscreen) {
panelRect = QGuiApplication::primaryScreen()->geometry();
auto devicePixelRatio =
QGuiApplication::primaryScreen()->devicePixelRatio();
panelRect.moveTo(panelRect.x() / devicePixelRatio,
panelRect.y() / devicePixelRatio);
}
ConfigHandler config;
@@ -663,6 +665,7 @@ void CaptureWidget::initPanel()
auto* panelToggleButton =
new OrientablePushButton(tr("Tool Settings"), this);
makeChild(panelToggleButton);
panelToggleButton->setColor(m_uiColor);
panelToggleButton->setOrientation(
OrientablePushButton::VerticalBottomToTop);
panelToggleButton->move(panelRect.x(),
@@ -1104,6 +1107,11 @@ void CaptureWidget::uploadScreenshot()
void CaptureWidget::copyScreenshot()
{
m_captureDone = true;
if (m_activeTool != nullptr) {
QPainter painter(&m_context.screenshot);
m_activeTool->process(painter, m_context.screenshot, true);
}
ScreenshotSaver().saveToClipboard(pixmap());
close();
}
@@ -1111,6 +1119,10 @@ void CaptureWidget::copyScreenshot()
void CaptureWidget::saveScreenshot()
{
m_captureDone = true;
if (m_activeTool != nullptr) {
QPainter painter(&m_context.screenshot);
m_activeTool->process(painter, m_context.screenshot, true);
}
hide();
if (m_context.savePath.isEmpty()) {
ScreenshotSaver().saveToFilesystemGUI(pixmap());
@@ -1145,4 +1157,4 @@ QRect CaptureWidget::extendedRect(QRect* r) const
r->top() * devicePixelRatio,
r->width() * devicePixelRatio,
r->height() * devicePixelRatio);
}
}