mirror of
https://github.com/fergalmoran/flameshot.git
synced 2026-02-15 15:03:58 +00:00
resolving merge conflicts
This commit is contained in:
@@ -60,7 +60,10 @@ QVector<CaptureToolButton::ButtonType> ConfigHandler::getButtons()
|
||||
<< CaptureToolButton::TYPE_COPY << CaptureToolButton::TYPE_SAVE
|
||||
<< CaptureToolButton::TYPE_EXIT
|
||||
<< CaptureToolButton::TYPE_IMAGEUPLOADER
|
||||
#if not(defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
|
||||
defined(Q_OS_MACX))
|
||||
<< CaptureToolButton::TYPE_OPEN_APP
|
||||
#endif
|
||||
<< CaptureToolButton::TYPE_PIN << CaptureToolButton::TYPE_TEXT
|
||||
<< CaptureToolButton::TYPE_CIRCLECOUNT;
|
||||
}
|
||||
@@ -230,6 +233,16 @@ void ConfigHandler::setShowSidePanelButton(const bool showSidePanelButton)
|
||||
showSidePanelButton);
|
||||
}
|
||||
|
||||
void ConfigHandler::setIgnoreUpdateToVersion(const QString& text)
|
||||
{
|
||||
m_settings.setValue(QStringLiteral("ignoreUpdateToVersion"), text);
|
||||
}
|
||||
|
||||
QString ConfigHandler::ignoreUpdateToVersion()
|
||||
{
|
||||
return m_settings.value(QStringLiteral("ignoreUpdateToVersion")).toString();
|
||||
}
|
||||
|
||||
bool ConfigHandler::desktopNotificationValue()
|
||||
{
|
||||
bool res = true;
|
||||
@@ -559,3 +572,28 @@ const QString& ConfigHandler::shortcut(const QString& shortcutName)
|
||||
m_settings.endGroup();
|
||||
return m_strRes;
|
||||
}
|
||||
|
||||
void ConfigHandler::setValue(const QString& group,
|
||||
const QString& key,
|
||||
const QVariant& value)
|
||||
{
|
||||
if (!group.isEmpty()) {
|
||||
m_settings.beginGroup(group);
|
||||
}
|
||||
m_settings.setValue(key, value);
|
||||
if (!group.isEmpty()) {
|
||||
m_settings.endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
QVariant& ConfigHandler::value(const QString& group, const QString& key)
|
||||
{
|
||||
if (!group.isEmpty()) {
|
||||
m_settings.beginGroup(group);
|
||||
}
|
||||
m_varRes = m_settings.value(key);
|
||||
if (!group.isEmpty()) {
|
||||
m_settings.endGroup();
|
||||
}
|
||||
return m_varRes;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "src/widgets/capture/capturetoolbutton.h"
|
||||
#include <QSettings>
|
||||
#include <QStringList>
|
||||
#include <QVariant>
|
||||
#include <QVector>
|
||||
|
||||
class ConfigHandler
|
||||
@@ -88,6 +89,9 @@ public:
|
||||
void setDefaults();
|
||||
void setAllTheButtons();
|
||||
|
||||
void setIgnoreUpdateToVersion(const QString& text);
|
||||
QString ignoreUpdateToVersion();
|
||||
|
||||
QVector<QStringList> shortcuts();
|
||||
void setShortcutsDefault();
|
||||
bool setShortcut(const QString&, const QString&);
|
||||
@@ -95,8 +99,14 @@ public:
|
||||
|
||||
QString configFilePath() const;
|
||||
|
||||
void setValue(const QString& group,
|
||||
const QString& key,
|
||||
const QVariant& value);
|
||||
QVariant& value(const QString& group, const QString& key);
|
||||
|
||||
private:
|
||||
QString m_strRes;
|
||||
QVariant m_varRes;
|
||||
QSettings m_settings;
|
||||
QVector<QStringList> m_shortcuts;
|
||||
|
||||
|
||||
@@ -58,10 +58,18 @@ const QVector<QStringList>& ConfigShortcuts::captureShortcutsDefault(
|
||||
|
||||
m_shortcuts << (QStringList() << "" << QObject::tr("Quit capture")
|
||||
<< QKeySequence(Qt::Key_Escape).toString());
|
||||
#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
|
||||
defined(Q_OS_MACX))
|
||||
m_shortcuts << (QStringList()
|
||||
<< "" << QObject::tr("Screenshot history") << "⇧⌘⌥H");
|
||||
m_shortcuts << (QStringList()
|
||||
<< "" << QObject::tr("Capture screen") << "⇧⌘⌥4");
|
||||
#else
|
||||
m_shortcuts << (QStringList() << "" << QObject::tr("Screenshot history")
|
||||
<< "Shift+Print Screen");
|
||||
m_shortcuts << (QStringList()
|
||||
<< "" << QObject::tr("Capture screen") << "Print Screen");
|
||||
#endif
|
||||
m_shortcuts << (QStringList()
|
||||
<< "" << QObject::tr("Show color picker") << "Right Click");
|
||||
m_shortcuts << (QStringList()
|
||||
@@ -116,9 +124,12 @@ const QKeySequence& ConfigShortcuts::captureShortcutDefault(
|
||||
case CaptureToolButton::ButtonType::TYPE_IMAGEUPLOADER:
|
||||
m_ks = QKeySequence(Qt::Key_Return);
|
||||
break;
|
||||
#if not(defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
|
||||
defined(Q_OS_MACX))
|
||||
case CaptureToolButton::ButtonType::TYPE_OPEN_APP:
|
||||
m_ks = QKeySequence(Qt::CTRL + Qt::Key_O);
|
||||
break;
|
||||
#endif
|
||||
case CaptureToolButton::ButtonType::TYPE_PIXELATE:
|
||||
m_ks = QKeySequence(Qt::Key_B);
|
||||
break;
|
||||
|
||||
@@ -30,9 +30,20 @@ const QString& History::path()
|
||||
|
||||
void History::save(const QPixmap& pixmap, const QString& fileName)
|
||||
{
|
||||
// scale preview only in local disk
|
||||
QPixmap pixmapScaled = QPixmap(pixmap);
|
||||
if (pixmap.height() / HISTORYPIXMAP_MAX_PREVIEW_HEIGHT >=
|
||||
pixmap.width() / HISTORYPIXMAP_MAX_PREVIEW_WIDTH) {
|
||||
pixmapScaled = pixmap.scaledToHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT);
|
||||
} else {
|
||||
pixmapScaled = pixmap.scaledToWidth(HISTORYPIXMAP_MAX_PREVIEW_WIDTH);
|
||||
}
|
||||
|
||||
// save preview
|
||||
QFile file(path() + fileName);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
pixmap.save(&file, "PNG");
|
||||
pixmapScaled.save(&file, "PNG");
|
||||
|
||||
history();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
#define HISTORY_MAX_SIZE 25
|
||||
|
||||
#define HISTORYPIXMAP_MAX_PREVIEW_WIDTH 160
|
||||
#define HISTORYPIXMAP_MAX_PREVIEW_HEIGHT 90
|
||||
|
||||
#include <QList>
|
||||
#include <QPixmap>
|
||||
#include <QString>
|
||||
|
||||
@@ -37,7 +37,18 @@ ScreenGrabber::ScreenGrabber(QObject* parent)
|
||||
QPixmap ScreenGrabber::grabEntireDesktop(bool& ok)
|
||||
{
|
||||
ok = true;
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
|
||||
#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
|
||||
defined(Q_OS_MACX))
|
||||
QScreen* currentScreen = QGuiApplication::screenAt(QCursor::pos());
|
||||
QPixmap screenPixmap(
|
||||
currentScreen->grabWindow(QApplication::desktop()->winId(),
|
||||
currentScreen->geometry().x(),
|
||||
currentScreen->geometry().y(),
|
||||
currentScreen->geometry().width(),
|
||||
currentScreen->geometry().height()));
|
||||
screenPixmap.setDevicePixelRatio(currentScreen->devicePixelRatio());
|
||||
return screenPixmap;
|
||||
#elif defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
|
||||
if (m_info.waylandDectected()) {
|
||||
QPixmap res;
|
||||
// handle screenshot based on DE
|
||||
@@ -87,7 +98,7 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool& ok)
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) || defined(Q_OS_WIN)
|
||||
QRect geometry;
|
||||
for (QScreen* const screen : QGuiApplication::screens()) {
|
||||
QRect scrRect = screen->geometry();
|
||||
@@ -106,6 +117,7 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool& ok)
|
||||
QScreen* screen = QApplication::screens()[screenNumber];
|
||||
p.setDevicePixelRatio(screen->devicePixelRatio());
|
||||
return p;
|
||||
#endif
|
||||
}
|
||||
|
||||
QPixmap ScreenGrabber::grabScreen(int screenNumber, bool& ok)
|
||||
|
||||
@@ -35,9 +35,9 @@ void ScreenshotSaver::saveToClipboard(const QPixmap& capture)
|
||||
// If we are able to properly save the file, save the file and copy to
|
||||
// clipboard.
|
||||
if ((ConfigHandler().saveAfterCopyValue()) &&
|
||||
(!ConfigHandler().saveAfterCopyPathValue().isEmpty())) {
|
||||
(!ConfigHandler().savePath().isEmpty())) {
|
||||
saveToFilesystem(capture,
|
||||
ConfigHandler().saveAfterCopyPathValue(),
|
||||
ConfigHandler().savePath(),
|
||||
QObject::tr("Capture saved to clipboard."));
|
||||
QApplication::clipboard()->setPixmap(capture);
|
||||
}
|
||||
|
||||
@@ -1,34 +1,30 @@
|
||||
#include "systemnotification.h"
|
||||
#include "src/core/controller.h"
|
||||
#include "src/utils/confighandler.h"
|
||||
#include <QApplication>
|
||||
#include <QUrl>
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
#if not(defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
|
||||
defined(Q_OS_MACX) || defined(Q_OS_WIN))
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusMessage>
|
||||
#else
|
||||
#endif
|
||||
#include "src/core/controller.h"
|
||||
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
|
||||
SystemNotification::SystemNotification(QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_interface(nullptr)
|
||||
{
|
||||
#if not(defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
|
||||
defined(Q_OS_MACX) || defined(Q_OS_WIN))
|
||||
m_interface =
|
||||
new QDBusInterface(QStringLiteral("org.freedesktop.Notifications"),
|
||||
QStringLiteral("/org/freedesktop/Notifications"),
|
||||
QStringLiteral("org.freedesktop.Notifications"),
|
||||
QDBusConnection::sessionBus(),
|
||||
this);
|
||||
}
|
||||
#else
|
||||
SystemNotification::SystemNotification(QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
m_interface = nullptr;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SystemNotification::sendMessage(const QString& text,
|
||||
const QString& savePath)
|
||||
@@ -45,7 +41,10 @@ void SystemNotification::sendMessage(const QString& text,
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
|
||||
defined(Q_OS_MACX) || defined(Q_OS_WIN)
|
||||
Controller::getInstance()->sendTrayNotification(text, title, timeout);
|
||||
#else
|
||||
QList<QVariant> args;
|
||||
QVariantMap hintsMap;
|
||||
if (!savePath.isEmpty()) {
|
||||
@@ -64,8 +63,5 @@ void SystemNotification::sendMessage(const QString& text,
|
||||
<< timeout; // timeout
|
||||
m_interface->callWithArgumentList(
|
||||
QDBus::AutoDetect, QStringLiteral("Notify"), args);
|
||||
#else
|
||||
auto c = Controller::getInstance();
|
||||
c->sendTrayNotification(text, title, timeout);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user