mirror of
https://github.com/fergalmoran/flameshot.git
synced 2025-12-22 09:51:06 +00:00
Changed clang format to new agreement
This commit is contained in:
committed by
borgmanJeremy
parent
2cbccc3d0a
commit
0d5386edd4
@@ -1,2 +1,6 @@
|
||||
Language: Cpp
|
||||
BasedOnStyle: Mozilla
|
||||
IndentWidth: 4
|
||||
AccessModifierOffset: -4
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
|
||||
2
.github/workflows/clang-format.yml
vendored
2
.github/workflows/clang-format.yml
vendored
@@ -14,4 +14,4 @@ jobs:
|
||||
#exclude: './third_party ./external'
|
||||
extensions: 'h,cpp'
|
||||
clangFormatVersion: 11
|
||||
style: mozilla
|
||||
style: file
|
||||
|
||||
@@ -24,8 +24,7 @@
|
||||
namespace color_widgets {
|
||||
namespace detail {
|
||||
|
||||
QColor
|
||||
color_from_lch(qreal hue, qreal chroma, qreal luma, qreal alpha)
|
||||
QColor color_from_lch(qreal hue, qreal chroma, qreal luma, qreal alpha)
|
||||
{
|
||||
qreal h1 = hue * 6;
|
||||
qreal x = chroma * (1 - qAbs(std::fmod(h1, 2) - 1));
|
||||
@@ -51,8 +50,7 @@ color_from_lch(qreal hue, qreal chroma, qreal luma, qreal alpha)
|
||||
alpha);
|
||||
}
|
||||
|
||||
QColor
|
||||
color_from_hsl(qreal hue, qreal sat, qreal lig, qreal alpha)
|
||||
QColor color_from_hsl(qreal hue, qreal sat, qreal lig, qreal alpha)
|
||||
{
|
||||
qreal chroma = (1 - qAbs(2 * lig - 1)) * sat;
|
||||
qreal h1 = hue * 6;
|
||||
|
||||
80
external/Qt-Color-Widgets/src/color_wheel.cpp
vendored
80
external/Qt-Color-Widgets/src/color_wheel.cpp
vendored
@@ -111,7 +111,10 @@ public:
|
||||
for (int y = 0; y < width; ++y) {
|
||||
for (int x = 0; x < width; ++x) {
|
||||
inner_selector.setPixel(
|
||||
x, y, color_from(hue, double(x) / width, double(y) / width, 1).rgb());
|
||||
x,
|
||||
y,
|
||||
color_from(hue, double(x) / width, double(y) / width, 1)
|
||||
.rgb());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,7 +140,8 @@ public:
|
||||
qreal ymin = ycenter - slice_h / 2;
|
||||
qreal psat = qBound(0.0, (y - ymin) / slice_h, 1.0);
|
||||
|
||||
inner_selector.setPixel(x, y, color_from(hue, psat, pval, 1).rgb());
|
||||
inner_selector.setPixel(
|
||||
x, y, color_from(hue, psat, pval, 1).rgb());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -243,54 +247,46 @@ ColorWheel::~ColorWheel()
|
||||
delete p;
|
||||
}
|
||||
|
||||
QColor
|
||||
ColorWheel::color() const
|
||||
QColor ColorWheel::color() const
|
||||
{
|
||||
return p->color_from(p->hue, p->sat, p->val, 1);
|
||||
}
|
||||
|
||||
QSize
|
||||
ColorWheel::sizeHint() const
|
||||
QSize ColorWheel::sizeHint() const
|
||||
{
|
||||
return QSize(p->wheel_width * 5, p->wheel_width * 5);
|
||||
}
|
||||
|
||||
qreal
|
||||
ColorWheel::hue() const
|
||||
qreal ColorWheel::hue() const
|
||||
{
|
||||
if ((p->display_flags & COLOR_LCH) && p->sat > 0.01)
|
||||
return color().hueF();
|
||||
return p->hue;
|
||||
}
|
||||
|
||||
qreal
|
||||
ColorWheel::saturation() const
|
||||
qreal ColorWheel::saturation() const
|
||||
{
|
||||
return color().hsvSaturationF();
|
||||
}
|
||||
|
||||
qreal
|
||||
ColorWheel::value() const
|
||||
qreal ColorWheel::value() const
|
||||
{
|
||||
return color().valueF();
|
||||
}
|
||||
|
||||
unsigned int
|
||||
ColorWheel::wheelWidth() const
|
||||
unsigned int ColorWheel::wheelWidth() const
|
||||
{
|
||||
return p->wheel_width;
|
||||
}
|
||||
|
||||
void
|
||||
ColorWheel::setWheelWidth(unsigned int w)
|
||||
void ColorWheel::setWheelWidth(unsigned int w)
|
||||
{
|
||||
p->wheel_width = w;
|
||||
p->render_inner_selector();
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
ColorWheel::paintEvent(QPaintEvent*)
|
||||
void ColorWheel::paintEvent(QPaintEvent*)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
@@ -361,8 +357,7 @@ ColorWheel::paintEvent(QPaintEvent*)
|
||||
painter.drawEllipse(selector_position, selector_radius, selector_radius);
|
||||
}
|
||||
|
||||
void
|
||||
ColorWheel::mouseMoveEvent(QMouseEvent* ev)
|
||||
void ColorWheel::mouseMoveEvent(QMouseEvent* ev)
|
||||
{
|
||||
if (p->mouse_status == DragCircle) {
|
||||
p->hue = p->line_to_point(ev->pos()).angle() / 360.0;
|
||||
@@ -378,7 +373,8 @@ ColorWheel::mouseMoveEvent(QMouseEvent* ev)
|
||||
|
||||
center_mouse_ln.setAngle(center_mouse_ln.angle() +
|
||||
p->selector_image_angle());
|
||||
center_mouse_ln.setP2(center_mouse_ln.p2() - p->selector_image_offset());
|
||||
center_mouse_ln.setP2(center_mouse_ln.p2() -
|
||||
p->selector_image_offset());
|
||||
|
||||
if (p->display_flags & SHAPE_SQUARE) {
|
||||
p->sat = qBound(0.0, center_mouse_ln.x2() / p->square_size(), 1.0);
|
||||
@@ -403,8 +399,7 @@ ColorWheel::mouseMoveEvent(QMouseEvent* ev)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ColorWheel::mousePressEvent(QMouseEvent* ev)
|
||||
void ColorWheel::mousePressEvent(QMouseEvent* ev)
|
||||
{
|
||||
if (ev->buttons() & Qt::LeftButton) {
|
||||
setFocus();
|
||||
@@ -419,23 +414,20 @@ ColorWheel::mousePressEvent(QMouseEvent* ev)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ColorWheel::mouseReleaseEvent(QMouseEvent* ev)
|
||||
void ColorWheel::mouseReleaseEvent(QMouseEvent* ev)
|
||||
{
|
||||
mouseMoveEvent(ev);
|
||||
p->mouse_status = Nothing;
|
||||
emit mouseReleaseOnColor(color());
|
||||
}
|
||||
|
||||
void
|
||||
ColorWheel::resizeEvent(QResizeEvent*)
|
||||
void ColorWheel::resizeEvent(QResizeEvent*)
|
||||
{
|
||||
p->render_ring();
|
||||
p->render_inner_selector();
|
||||
}
|
||||
|
||||
void
|
||||
ColorWheel::setColor(QColor c)
|
||||
void ColorWheel::setColor(QColor c)
|
||||
{
|
||||
qreal oldh = p->hue;
|
||||
p->set_color(c);
|
||||
@@ -445,30 +437,26 @@ ColorWheel::setColor(QColor c)
|
||||
emit colorChanged(c);
|
||||
}
|
||||
|
||||
void
|
||||
ColorWheel::setHue(qreal h)
|
||||
void ColorWheel::setHue(qreal h)
|
||||
{
|
||||
p->hue = qBound(0.0, h, 1.0);
|
||||
p->render_inner_selector();
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
ColorWheel::setSaturation(qreal s)
|
||||
void ColorWheel::setSaturation(qreal s)
|
||||
{
|
||||
p->sat = qBound(0.0, s, 1.0);
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
ColorWheel::setValue(qreal v)
|
||||
void ColorWheel::setValue(qreal v)
|
||||
{
|
||||
p->val = qBound(0.0, v, 1.0);
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
ColorWheel::setDisplayFlags(DisplayFlags flags)
|
||||
void ColorWheel::setDisplayFlags(DisplayFlags flags)
|
||||
{
|
||||
if (!(flags & COLOR_FLAGS))
|
||||
flags |= default_flags & COLOR_FLAGS;
|
||||
@@ -507,14 +495,12 @@ ColorWheel::setDisplayFlags(DisplayFlags flags)
|
||||
emit displayFlagsChanged(flags);
|
||||
}
|
||||
|
||||
ColorWheel::DisplayFlags
|
||||
ColorWheel::displayFlags(DisplayFlags mask) const
|
||||
ColorWheel::DisplayFlags ColorWheel::displayFlags(DisplayFlags mask) const
|
||||
{
|
||||
return p->display_flags & mask;
|
||||
}
|
||||
|
||||
void
|
||||
ColorWheel::setDefaultDisplayFlags(DisplayFlags flags)
|
||||
void ColorWheel::setDefaultDisplayFlags(DisplayFlags flags)
|
||||
{
|
||||
if (!(flags & COLOR_FLAGS))
|
||||
flags |= hard_default_flags & COLOR_FLAGS;
|
||||
@@ -525,20 +511,17 @@ ColorWheel::setDefaultDisplayFlags(DisplayFlags flags)
|
||||
default_flags = flags;
|
||||
}
|
||||
|
||||
ColorWheel::DisplayFlags
|
||||
ColorWheel::defaultDisplayFlags(DisplayFlags mask)
|
||||
ColorWheel::DisplayFlags ColorWheel::defaultDisplayFlags(DisplayFlags mask)
|
||||
{
|
||||
return default_flags & mask;
|
||||
}
|
||||
|
||||
void
|
||||
ColorWheel::setDisplayFlag(DisplayFlags flag, DisplayFlags mask)
|
||||
void ColorWheel::setDisplayFlag(DisplayFlags flag, DisplayFlags mask)
|
||||
{
|
||||
setDisplayFlags((p->display_flags & ~mask) | flag);
|
||||
}
|
||||
|
||||
void
|
||||
ColorWheel::dragEnterEvent(QDragEnterEvent* event)
|
||||
void ColorWheel::dragEnterEvent(QDragEnterEvent* event)
|
||||
{
|
||||
if (event->mimeData()->hasColor() ||
|
||||
(event->mimeData()->hasText() &&
|
||||
@@ -546,8 +529,7 @@ ColorWheel::dragEnterEvent(QDragEnterEvent* event)
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
|
||||
void
|
||||
ColorWheel::dropEvent(QDropEvent* event)
|
||||
void ColorWheel::dropEvent(QDropEvent* event)
|
||||
{
|
||||
if (event->mimeData()->hasColor()) {
|
||||
setColor(event->mimeData()->colorData().value<QColor>());
|
||||
|
||||
79
external/singleapplication/singleapplication.cpp
vendored
79
external/singleapplication/singleapplication.cpp
vendored
@@ -73,8 +73,7 @@ SingleApplicationPrivate::~SingleApplicationPrivate()
|
||||
delete memory;
|
||||
}
|
||||
|
||||
void
|
||||
SingleApplicationPrivate::genBlockServerName(int timeout)
|
||||
void SingleApplicationPrivate::genBlockServerName(int timeout)
|
||||
{
|
||||
QCryptographicHash appData(QCryptographicHash::Sha256);
|
||||
appData.addData("SingleApplication", 17);
|
||||
@@ -83,7 +82,8 @@ SingleApplicationPrivate::genBlockServerName(int timeout)
|
||||
appData.addData(SingleApplication::app_t::organizationDomain().toUtf8());
|
||||
|
||||
if (!(options & SingleApplication::Mode::ExcludeAppVersion)) {
|
||||
appData.addData(SingleApplication::app_t::applicationVersion().toUtf8());
|
||||
appData.addData(
|
||||
SingleApplication::app_t::applicationVersion().toUtf8());
|
||||
}
|
||||
|
||||
if (!(options & SingleApplication::Mode::ExcludeAppPath)) {
|
||||
@@ -91,7 +91,8 @@ SingleApplicationPrivate::genBlockServerName(int timeout)
|
||||
appData.addData(
|
||||
SingleApplication::app_t::applicationFilePath().toLower().toUtf8());
|
||||
#else
|
||||
appData.addData(SingleApplication::app_t::applicationFilePath().toUtf8());
|
||||
appData.addData(
|
||||
SingleApplication::app_t::applicationFilePath().toUtf8());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -119,8 +120,8 @@ SingleApplicationPrivate::genBlockServerName(int timeout)
|
||||
process.exitCode() == QProcess::NormalExit) {
|
||||
appData.addData(process.readLine());
|
||||
} else {
|
||||
appData.addData(
|
||||
QDir(QStandardPaths::standardLocations(QStandardPaths::HomeLocation)
|
||||
appData.addData(QDir(QStandardPaths::standardLocations(
|
||||
QStandardPaths::HomeLocation)
|
||||
.first())
|
||||
.absolutePath()
|
||||
.toUtf8());
|
||||
@@ -133,8 +134,7 @@ SingleApplicationPrivate::genBlockServerName(int timeout)
|
||||
blockServerName = appData.result().toBase64().replace("/", "_");
|
||||
}
|
||||
|
||||
void
|
||||
SingleApplicationPrivate::startPrimary(bool resetMemory)
|
||||
void SingleApplicationPrivate::startPrimary(bool resetMemory)
|
||||
{
|
||||
Q_Q(SingleApplication);
|
||||
|
||||
@@ -178,8 +178,7 @@ SingleApplicationPrivate::startPrimary(bool resetMemory)
|
||||
instanceNumber = 0;
|
||||
}
|
||||
|
||||
void
|
||||
SingleApplicationPrivate::startSecondary()
|
||||
void SingleApplicationPrivate::startSecondary()
|
||||
{
|
||||
#ifdef Q_OS_UNIX
|
||||
// Handle any further termination signals to ensure the
|
||||
@@ -188,8 +187,7 @@ SingleApplicationPrivate::startSecondary()
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
SingleApplicationPrivate::connectToPrimary(int msecs,
|
||||
void SingleApplicationPrivate::connectToPrimary(int msecs,
|
||||
ConnectionType connectionType)
|
||||
{
|
||||
// Connect to the Local Server of the Primary Instance if not already
|
||||
@@ -222,8 +220,8 @@ SingleApplicationPrivate::connectToPrimary(int msecs,
|
||||
writeStream << blockServerName.toLatin1();
|
||||
writeStream << static_cast<quint8>(connectionType);
|
||||
writeStream << instanceNumber;
|
||||
quint16 checksum =
|
||||
qChecksum(initMsg.constData(), static_cast<quint32>(initMsg.length()));
|
||||
quint16 checksum = qChecksum(initMsg.constData(),
|
||||
static_cast<quint32>(initMsg.length()));
|
||||
writeStream << checksum;
|
||||
|
||||
socket->write(initMsg);
|
||||
@@ -232,8 +230,7 @@ SingleApplicationPrivate::connectToPrimary(int msecs,
|
||||
}
|
||||
}
|
||||
|
||||
qint64
|
||||
SingleApplicationPrivate::primaryPid()
|
||||
qint64 SingleApplicationPrivate::primaryPid()
|
||||
{
|
||||
qint64 pid;
|
||||
|
||||
@@ -246,8 +243,7 @@ SingleApplicationPrivate::primaryPid()
|
||||
}
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
void
|
||||
SingleApplicationPrivate::crashHandler()
|
||||
void SingleApplicationPrivate::crashHandler()
|
||||
{
|
||||
// Handle any further termination signals to ensure the
|
||||
// QSharedMemory block is deleted even if the process crashes
|
||||
@@ -267,8 +263,7 @@ SingleApplicationPrivate::crashHandler()
|
||||
signal(SIGXFSZ, SingleApplicationPrivate::terminate); // 25
|
||||
}
|
||||
|
||||
void
|
||||
SingleApplicationPrivate::terminate(int signum)
|
||||
void SingleApplicationPrivate::terminate(int signum)
|
||||
{
|
||||
delete ((SingleApplication*)QCoreApplication::instance())->d_ptr;
|
||||
::exit(128 + signum);
|
||||
@@ -278,8 +273,7 @@ SingleApplicationPrivate::terminate(int signum)
|
||||
/**
|
||||
* @brief Executed when a connection has been made to the LocalServer
|
||||
*/
|
||||
void
|
||||
SingleApplicationPrivate::slotConnectionEstablished()
|
||||
void SingleApplicationPrivate::slotConnectionEstablished()
|
||||
{
|
||||
Q_Q(SingleApplication);
|
||||
|
||||
@@ -289,8 +283,9 @@ SingleApplicationPrivate::slotConnectionEstablished()
|
||||
ConnectionType connectionType = InvalidConnection;
|
||||
if (nextConnSocket->waitForReadyRead(100)) {
|
||||
// read all data from message in same order/format as written
|
||||
QByteArray msgBytes = nextConnSocket->read(
|
||||
nextConnSocket->bytesAvailable() - static_cast<qint64>(sizeof(quint16)));
|
||||
QByteArray msgBytes =
|
||||
nextConnSocket->read(nextConnSocket->bytesAvailable() -
|
||||
static_cast<qint64>(sizeof(quint16)));
|
||||
QByteArray checksumBytes = nextConnSocket->read(sizeof(quint16));
|
||||
QDataStream readStream(msgBytes);
|
||||
readStream.setVersion(QDataStream::Qt_5_2);
|
||||
@@ -310,8 +305,8 @@ SingleApplicationPrivate::slotConnectionEstablished()
|
||||
checksumStream.setVersion(QDataStream::Qt_5_2);
|
||||
checksumStream >> msgChecksum;
|
||||
|
||||
const quint16 actualChecksum =
|
||||
qChecksum(msgBytes.constData(), static_cast<quint32>(msgBytes.length()));
|
||||
const quint16 actualChecksum = qChecksum(
|
||||
msgBytes.constData(), static_cast<quint32>(msgBytes.length()));
|
||||
|
||||
if (readStream.status() != QDataStream::Ok ||
|
||||
QLatin1String(latin1Name) != blockServerName ||
|
||||
@@ -338,7 +333,8 @@ SingleApplicationPrivate::slotConnectionEstablished()
|
||||
&QLocalSocket::readyRead,
|
||||
this,
|
||||
[nextConnSocket, instanceId, this]() {
|
||||
emit this->slotDataAvailable(nextConnSocket, instanceId);
|
||||
emit this->slotDataAvailable(nextConnSocket,
|
||||
instanceId);
|
||||
});
|
||||
|
||||
if (connectionType == NewInstance ||
|
||||
@@ -352,16 +348,15 @@ SingleApplicationPrivate::slotConnectionEstablished()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SingleApplicationPrivate::slotDataAvailable(QLocalSocket* dataSocket,
|
||||
void SingleApplicationPrivate::slotDataAvailable(QLocalSocket* dataSocket,
|
||||
quint32 instanceId)
|
||||
{
|
||||
Q_Q(SingleApplication);
|
||||
emit q->receivedMessage(instanceId, dataSocket->readAll());
|
||||
}
|
||||
|
||||
void
|
||||
SingleApplicationPrivate::slotClientConnectionClosed(QLocalSocket* closedSocket,
|
||||
void SingleApplicationPrivate::slotClientConnectionClosed(
|
||||
QLocalSocket* closedSocket,
|
||||
quint32 instanceId)
|
||||
{
|
||||
if (closedSocket->bytesAvailable() > 0)
|
||||
@@ -411,7 +406,8 @@ SingleApplication::SingleApplication(int& argc,
|
||||
// Attempt to attach to the memory segment
|
||||
if (d->memory->attach()) {
|
||||
d->memory->lock();
|
||||
InstancesInfo* inst = static_cast<InstancesInfo*>(d->memory->data());
|
||||
InstancesInfo* inst =
|
||||
static_cast<InstancesInfo*>(d->memory->data());
|
||||
|
||||
if (!inst->primary) {
|
||||
d->startPrimary(false);
|
||||
@@ -425,8 +421,8 @@ SingleApplication::SingleApplication(int& argc,
|
||||
d->instanceNumber = inst->secondary;
|
||||
d->startSecondary();
|
||||
if (d->options & Mode::SecondaryNotification) {
|
||||
d->connectToPrimary(timeout,
|
||||
SingleApplicationPrivate::SecondaryInstance);
|
||||
d->connectToPrimary(
|
||||
timeout, SingleApplicationPrivate::SecondaryInstance);
|
||||
}
|
||||
d->memory->unlock();
|
||||
return;
|
||||
@@ -450,36 +446,31 @@ SingleApplication::~SingleApplication()
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool
|
||||
SingleApplication::isPrimary()
|
||||
bool SingleApplication::isPrimary()
|
||||
{
|
||||
Q_D(SingleApplication);
|
||||
return d->server != nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
SingleApplication::isSecondary()
|
||||
bool SingleApplication::isSecondary()
|
||||
{
|
||||
Q_D(SingleApplication);
|
||||
return d->server == nullptr;
|
||||
}
|
||||
|
||||
quint32
|
||||
SingleApplication::instanceId()
|
||||
quint32 SingleApplication::instanceId()
|
||||
{
|
||||
Q_D(SingleApplication);
|
||||
return d->instanceNumber;
|
||||
}
|
||||
|
||||
qint64
|
||||
SingleApplication::primaryPid()
|
||||
qint64 SingleApplication::primaryPid()
|
||||
{
|
||||
Q_D(SingleApplication);
|
||||
return d->primaryPid();
|
||||
}
|
||||
|
||||
bool
|
||||
SingleApplication::sendMessage(QByteArray message, int timeout)
|
||||
bool SingleApplication::sendMessage(QByteArray message, int timeout)
|
||||
{
|
||||
Q_D(SingleApplication);
|
||||
|
||||
|
||||
@@ -25,38 +25,32 @@ CommandArgument::CommandArgument(const QString& name,
|
||||
, m_description(description)
|
||||
{}
|
||||
|
||||
void
|
||||
CommandArgument::setName(const QString& name)
|
||||
void CommandArgument::setName(const QString& name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
QString
|
||||
CommandArgument::name() const
|
||||
QString CommandArgument::name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void
|
||||
CommandArgument::setDescription(const QString& description)
|
||||
void CommandArgument::setDescription(const QString& description)
|
||||
{
|
||||
m_description = description;
|
||||
}
|
||||
|
||||
QString
|
||||
CommandArgument::description() const
|
||||
QString CommandArgument::description() const
|
||||
{
|
||||
return m_description;
|
||||
}
|
||||
|
||||
bool
|
||||
CommandArgument::isRoot() const
|
||||
bool CommandArgument::isRoot() const
|
||||
{
|
||||
return m_name.isEmpty() && m_description.isEmpty();
|
||||
}
|
||||
|
||||
bool
|
||||
CommandArgument::operator==(const CommandArgument& arg) const
|
||||
bool CommandArgument::operator==(const CommandArgument& arg) const
|
||||
{
|
||||
return m_description == arg.m_description && m_name == arg.m_name;
|
||||
}
|
||||
|
||||
@@ -34,8 +34,7 @@ auto versionOption =
|
||||
auto helpOption =
|
||||
CommandOption({ "h", "help" }, QStringLiteral("Displays this help"));
|
||||
|
||||
QString
|
||||
optionsToString(const QList<CommandOption>& options,
|
||||
QString optionsToString(const QList<CommandOption>& options,
|
||||
const QList<CommandArgument>& arguments)
|
||||
{
|
||||
int size = 0; // track the largest size
|
||||
@@ -46,7 +45,8 @@ optionsToString(const QList<CommandOption>& options,
|
||||
QStringList dashedOptions = option.dashedNames();
|
||||
QString joinedDashedOptions = dashedOptions.join(QStringLiteral(", "));
|
||||
if (!option.valueName().isEmpty()) {
|
||||
joinedDashedOptions += QStringLiteral(" <%1>").arg(option.valueName());
|
||||
joinedDashedOptions +=
|
||||
QStringLiteral(" <%1>").arg(option.valueName());
|
||||
}
|
||||
if (joinedDashedOptions.length() > size) {
|
||||
size = joinedDashedOptions.length();
|
||||
@@ -62,12 +62,13 @@ optionsToString(const QList<CommandOption>& options,
|
||||
QString result;
|
||||
if (!dashedOptionList.isEmpty()) {
|
||||
result += QObject::tr("Options") + ":\n";
|
||||
QString linePadding = QStringLiteral(" ").repeated(size + 4).prepend("\n");
|
||||
QString linePadding =
|
||||
QStringLiteral(" ").repeated(size + 4).prepend("\n");
|
||||
for (int i = 0; i < options.length(); ++i) {
|
||||
result += QStringLiteral(" %1 %2\n")
|
||||
.arg(dashedOptionList.at(i).leftJustified(size, ' '))
|
||||
.arg(options.at(i).description().replace(QLatin1String("\n"),
|
||||
linePadding));
|
||||
.arg(options.at(i).description().replace(
|
||||
QLatin1String("\n"), linePadding));
|
||||
}
|
||||
if (!arguments.isEmpty()) {
|
||||
result += QLatin1String("\n");
|
||||
@@ -86,8 +87,7 @@ optionsToString(const QList<CommandOption>& options,
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
bool
|
||||
CommandLineParser::processArgs(const QStringList& args,
|
||||
bool CommandLineParser::processArgs(const QStringList& args,
|
||||
QStringList::const_iterator& actualIt,
|
||||
Node*& actualNode)
|
||||
{
|
||||
@@ -115,8 +115,7 @@ CommandLineParser::processArgs(const QStringList& args,
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
CommandLineParser::processOptions(const QStringList& args,
|
||||
bool CommandLineParser::processOptions(const QStringList& args,
|
||||
QStringList::const_iterator& actualIt,
|
||||
Node* const actualNode)
|
||||
{
|
||||
@@ -172,7 +171,8 @@ CommandLineParser::processOptions(const QStringList& args,
|
||||
if (actualIt + 1 != args.cend()) {
|
||||
++actualIt;
|
||||
} else {
|
||||
out << QStringLiteral("Expected value after the option '%1'.").arg(arg);
|
||||
out << QStringLiteral("Expected value after the option '%1'.")
|
||||
.arg(arg);
|
||||
ok = false;
|
||||
return ok;
|
||||
}
|
||||
@@ -194,8 +194,7 @@ CommandLineParser::processOptions(const QStringList& args,
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
CommandLineParser::parse(const QStringList& args)
|
||||
bool CommandLineParser::parse(const QStringList& args)
|
||||
{
|
||||
m_foundArgs.clear();
|
||||
m_foundOptions.clear();
|
||||
@@ -233,22 +232,19 @@ CommandLineParser::parse(const QStringList& args)
|
||||
return ok;
|
||||
}
|
||||
|
||||
CommandOption
|
||||
CommandLineParser::addVersionOption()
|
||||
CommandOption CommandLineParser::addVersionOption()
|
||||
{
|
||||
m_withVersion = true;
|
||||
return versionOption;
|
||||
}
|
||||
|
||||
CommandOption
|
||||
CommandLineParser::addHelpOption()
|
||||
CommandOption CommandLineParser::addHelpOption()
|
||||
{
|
||||
m_withHelp = true;
|
||||
return helpOption;
|
||||
}
|
||||
|
||||
bool
|
||||
CommandLineParser::AddArgument(const CommandArgument& arg,
|
||||
bool CommandLineParser::AddArgument(const CommandArgument& arg,
|
||||
const CommandArgument& parent)
|
||||
{
|
||||
bool res = true;
|
||||
@@ -263,8 +259,7 @@ CommandLineParser::AddArgument(const CommandArgument& arg,
|
||||
return res;
|
||||
}
|
||||
|
||||
bool
|
||||
CommandLineParser::AddOption(const CommandOption& option,
|
||||
bool CommandLineParser::AddOption(const CommandOption& option,
|
||||
const CommandArgument& parent)
|
||||
{
|
||||
bool res = true;
|
||||
@@ -277,8 +272,7 @@ CommandLineParser::AddOption(const CommandOption& option,
|
||||
return res;
|
||||
}
|
||||
|
||||
bool
|
||||
CommandLineParser::AddOptions(const QList<CommandOption>& options,
|
||||
bool CommandLineParser::AddOptions(const QList<CommandOption>& options,
|
||||
const CommandArgument& parent)
|
||||
{
|
||||
bool res = true;
|
||||
@@ -291,32 +285,27 @@ CommandLineParser::AddOptions(const QList<CommandOption>& options,
|
||||
return res;
|
||||
}
|
||||
|
||||
void
|
||||
CommandLineParser::setGeneralErrorMessage(const QString& msg)
|
||||
void CommandLineParser::setGeneralErrorMessage(const QString& msg)
|
||||
{
|
||||
m_generalErrorMessage = msg;
|
||||
}
|
||||
|
||||
void
|
||||
CommandLineParser::setDescription(const QString& description)
|
||||
void CommandLineParser::setDescription(const QString& description)
|
||||
{
|
||||
m_description = description;
|
||||
}
|
||||
|
||||
bool
|
||||
CommandLineParser::isSet(const CommandArgument& arg) const
|
||||
bool CommandLineParser::isSet(const CommandArgument& arg) const
|
||||
{
|
||||
return m_foundArgs.contains(arg);
|
||||
}
|
||||
|
||||
bool
|
||||
CommandLineParser::isSet(const CommandOption& option) const
|
||||
bool CommandLineParser::isSet(const CommandOption& option) const
|
||||
{
|
||||
return m_foundOptions.contains(option);
|
||||
}
|
||||
|
||||
QString
|
||||
CommandLineParser::value(const CommandOption& option) const
|
||||
QString CommandLineParser::value(const CommandOption& option) const
|
||||
{
|
||||
QString value = option.value();
|
||||
for (const CommandOption& fOption : m_foundOptions) {
|
||||
@@ -328,15 +317,13 @@ CommandLineParser::value(const CommandOption& option) const
|
||||
return value;
|
||||
}
|
||||
|
||||
void
|
||||
CommandLineParser::printVersion()
|
||||
void CommandLineParser::printVersion()
|
||||
{
|
||||
out << "Flameshot " << qApp->applicationVersion() << "\nCompiled with Qt "
|
||||
<< static_cast<QString>(QT_VERSION_STR) << "\n";
|
||||
}
|
||||
|
||||
void
|
||||
CommandLineParser::printHelp(QStringList args, const Node* node)
|
||||
void CommandLineParser::printHelp(QStringList args, const Node* node)
|
||||
{
|
||||
args.removeLast(); // remove the help, it's always the last
|
||||
QString helpText;
|
||||
@@ -374,8 +361,8 @@ CommandLineParser::printHelp(QStringList args, const Node* node)
|
||||
out << helpText;
|
||||
}
|
||||
|
||||
CommandLineParser::Node*
|
||||
CommandLineParser::findParent(const CommandArgument& parent)
|
||||
CommandLineParser::Node* CommandLineParser::findParent(
|
||||
const CommandArgument& parent)
|
||||
{
|
||||
if (parent == CommandArgument()) {
|
||||
return &m_parseTree;
|
||||
@@ -392,8 +379,8 @@ CommandLineParser::findParent(const CommandArgument& parent)
|
||||
return res;
|
||||
}
|
||||
|
||||
CommandLineParser::Node*
|
||||
CommandLineParser::recursiveParentSearch(const CommandArgument& parent,
|
||||
CommandLineParser::Node* CommandLineParser::recursiveParentSearch(
|
||||
const CommandArgument& parent,
|
||||
Node& node) const
|
||||
{
|
||||
Node* res = nullptr;
|
||||
@@ -410,8 +397,8 @@ CommandLineParser::recursiveParentSearch(const CommandArgument& parent,
|
||||
return res;
|
||||
}
|
||||
|
||||
bool
|
||||
CommandLineParser::processIfOptionIsHelp(const QStringList& args,
|
||||
bool CommandLineParser::processIfOptionIsHelp(
|
||||
const QStringList& args,
|
||||
QStringList::const_iterator& actualIt,
|
||||
Node*& actualNode)
|
||||
{
|
||||
|
||||
@@ -79,7 +79,8 @@ private:
|
||||
void printVersion();
|
||||
void printHelp(QStringList args, const Node* node);
|
||||
Node* findParent(const CommandArgument& parent);
|
||||
Node* recursiveParentSearch(const CommandArgument& parent, Node& node) const;
|
||||
Node* recursiveParentSearch(const CommandArgument& parent,
|
||||
Node& node) const;
|
||||
bool processIfOptionIsHelp(const QStringList& args,
|
||||
QStringList::const_iterator& actualIt,
|
||||
Node*& actualNode);
|
||||
|
||||
@@ -41,26 +41,22 @@ CommandOption::CommandOption(const QStringList& names,
|
||||
m_checker = [](QString const&) -> bool { return true; };
|
||||
}
|
||||
|
||||
void
|
||||
CommandOption::setName(const QString& name)
|
||||
void CommandOption::setName(const QString& name)
|
||||
{
|
||||
m_names = QStringList() << name;
|
||||
}
|
||||
|
||||
void
|
||||
CommandOption::setNames(const QStringList& names)
|
||||
void CommandOption::setNames(const QStringList& names)
|
||||
{
|
||||
m_names = names;
|
||||
}
|
||||
|
||||
QStringList
|
||||
CommandOption::names() const
|
||||
QStringList CommandOption::names() const
|
||||
{
|
||||
return m_names;
|
||||
}
|
||||
|
||||
QStringList
|
||||
CommandOption::dashedNames() const
|
||||
QStringList CommandOption::dashedNames() const
|
||||
{
|
||||
QStringList dashedNames;
|
||||
for (const QString& name : m_names) {
|
||||
@@ -73,20 +69,17 @@ CommandOption::dashedNames() const
|
||||
return dashedNames;
|
||||
}
|
||||
|
||||
void
|
||||
CommandOption::setValueName(const QString& name)
|
||||
void CommandOption::setValueName(const QString& name)
|
||||
{
|
||||
m_valueName = name;
|
||||
}
|
||||
|
||||
QString
|
||||
CommandOption::valueName() const
|
||||
QString CommandOption::valueName() const
|
||||
{
|
||||
return m_valueName;
|
||||
}
|
||||
|
||||
void
|
||||
CommandOption::setValue(const QString& value)
|
||||
void CommandOption::setValue(const QString& value)
|
||||
{
|
||||
if (m_valueName.isEmpty()) {
|
||||
m_valueName = QLatin1String("value");
|
||||
@@ -94,46 +87,39 @@ CommandOption::setValue(const QString& value)
|
||||
m_value = value;
|
||||
}
|
||||
|
||||
QString
|
||||
CommandOption::value() const
|
||||
QString CommandOption::value() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
void
|
||||
CommandOption::addChecker(const function<bool(const QString&)> checker,
|
||||
void CommandOption::addChecker(const function<bool(const QString&)> checker,
|
||||
const QString& errMsg)
|
||||
{
|
||||
m_checker = checker;
|
||||
m_errorMsg = errMsg;
|
||||
}
|
||||
|
||||
bool
|
||||
CommandOption::checkValue(const QString& value) const
|
||||
bool CommandOption::checkValue(const QString& value) const
|
||||
{
|
||||
return m_checker(value);
|
||||
}
|
||||
|
||||
QString
|
||||
CommandOption::description() const
|
||||
QString CommandOption::description() const
|
||||
{
|
||||
return m_description;
|
||||
}
|
||||
|
||||
void
|
||||
CommandOption::setDescription(const QString& description)
|
||||
void CommandOption::setDescription(const QString& description)
|
||||
{
|
||||
m_description = description;
|
||||
}
|
||||
|
||||
QString
|
||||
CommandOption::errorMsg() const
|
||||
QString CommandOption::errorMsg() const
|
||||
{
|
||||
return m_errorMsg;
|
||||
}
|
||||
|
||||
bool
|
||||
CommandOption::operator==(const CommandOption& option) const
|
||||
bool CommandOption::operator==(const CommandOption& option) const
|
||||
{
|
||||
return m_description == option.m_description && m_names == option.m_names &&
|
||||
m_valueName == option.m_valueName;
|
||||
|
||||
@@ -32,8 +32,7 @@ ButtonListView::ButtonListView(QWidget* parent)
|
||||
this, &QListWidget::itemClicked, this, &ButtonListView::reverseItemCheck);
|
||||
}
|
||||
|
||||
void
|
||||
ButtonListView::initButtonList()
|
||||
void ButtonListView::initButtonList()
|
||||
{
|
||||
ToolFactory factory;
|
||||
auto listTypes = CaptureToolButton::getIterableButtonTypes();
|
||||
@@ -52,7 +51,8 @@ ButtonListView::initButtonList()
|
||||
m_buttonItem->setIcon(tool->icon(bgColor, false));
|
||||
|
||||
m_buttonItem->setFlags(Qt::ItemIsUserCheckable);
|
||||
QColor foregroundColor = this->palette().color(QWidget::foregroundRole());
|
||||
QColor foregroundColor =
|
||||
this->palette().color(QWidget::foregroundRole());
|
||||
m_buttonItem->setForeground(foregroundColor);
|
||||
|
||||
m_buttonItem->setText(tool->name());
|
||||
@@ -61,8 +61,7 @@ ButtonListView::initButtonList()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ButtonListView::updateActiveButtons(QListWidgetItem* item)
|
||||
void ButtonListView::updateActiveButtons(QListWidgetItem* item)
|
||||
{
|
||||
CaptureToolButton::ButtonType bType = m_buttonTypeByName[item->text()];
|
||||
if (item->checkState() == Qt::Checked) {
|
||||
@@ -79,8 +78,7 @@ ButtonListView::updateActiveButtons(QListWidgetItem* item)
|
||||
ConfigHandler().setButtons(m_listButtons);
|
||||
}
|
||||
|
||||
void
|
||||
ButtonListView::reverseItemCheck(QListWidgetItem* item)
|
||||
void ButtonListView::reverseItemCheck(QListWidgetItem* item)
|
||||
{
|
||||
if (item->checkState() == Qt::Checked) {
|
||||
item->setCheckState(Qt::Unchecked);
|
||||
@@ -90,8 +88,7 @@ ButtonListView::reverseItemCheck(QListWidgetItem* item)
|
||||
updateActiveButtons(item);
|
||||
}
|
||||
|
||||
void
|
||||
ButtonListView::selectAll()
|
||||
void ButtonListView::selectAll()
|
||||
{
|
||||
ConfigHandler().setAllTheButtons();
|
||||
for (int i = 0; i < this->count(); ++i) {
|
||||
@@ -100,8 +97,7 @@ ButtonListView::selectAll()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ButtonListView::updateComponents()
|
||||
void ButtonListView::updateComponents()
|
||||
{
|
||||
m_listButtons = ConfigHandler().getButtons();
|
||||
auto listTypes = CaptureToolButton::getIterableButtonTypes();
|
||||
|
||||
@@ -27,8 +27,7 @@ ClickableLabel::ClickableLabel(QString s, QWidget* parent)
|
||||
setText(s);
|
||||
}
|
||||
|
||||
void
|
||||
ClickableLabel::mousePressEvent(QMouseEvent*)
|
||||
void ClickableLabel::mousePressEvent(QMouseEvent*)
|
||||
{
|
||||
emit clicked();
|
||||
}
|
||||
|
||||
@@ -51,7 +51,8 @@ ConfigWindow::ConfigWindow(QWidget* parent)
|
||||
};
|
||||
m_configWatcher = new QFileSystemWatcher(this);
|
||||
m_configWatcher->addPath(ConfigHandler().configFilePath());
|
||||
connect(m_configWatcher, &QFileSystemWatcher::fileChanged, this, changedSlot);
|
||||
connect(
|
||||
m_configWatcher, &QFileSystemWatcher::fileChanged, this, changedSlot);
|
||||
|
||||
QColor background = this->palette().window().color();
|
||||
bool isDark = ColorUtils::colorIsDark(background);
|
||||
@@ -87,8 +88,7 @@ ConfigWindow::ConfigWindow(QWidget* parent)
|
||||
&GeneneralConf::updateComponents);
|
||||
}
|
||||
|
||||
void
|
||||
ConfigWindow::keyPressEvent(QKeyEvent* e)
|
||||
void ConfigWindow::keyPressEvent(QKeyEvent* e)
|
||||
{
|
||||
if (e->key() == Qt::Key_Escape) {
|
||||
close();
|
||||
|
||||
@@ -20,38 +20,37 @@
|
||||
ExtendedSlider::ExtendedSlider(QWidget* parent)
|
||||
: QSlider(parent)
|
||||
{
|
||||
connect(this,
|
||||
&ExtendedSlider::valueChanged,
|
||||
this,
|
||||
&ExtendedSlider::updateTooltip);
|
||||
connect(
|
||||
this, &ExtendedSlider::valueChanged, this, &ExtendedSlider::updateTooltip);
|
||||
connect(this, &ExtendedSlider::sliderMoved, this, &ExtendedSlider::fireTimer);
|
||||
this, &ExtendedSlider::sliderMoved, this, &ExtendedSlider::fireTimer);
|
||||
m_timer.setSingleShot(true);
|
||||
connect(
|
||||
&m_timer, &QTimer::timeout, this, &ExtendedSlider::modificationsEnded);
|
||||
}
|
||||
|
||||
int
|
||||
ExtendedSlider::mappedValue(int min, int max)
|
||||
int ExtendedSlider::mappedValue(int min, int max)
|
||||
{
|
||||
qreal progress =
|
||||
((value() - minimum())) / static_cast<qreal>(maximum() - minimum());
|
||||
return min + (max - min) * progress;
|
||||
}
|
||||
|
||||
void
|
||||
ExtendedSlider::setMapedValue(int min, int val, int max)
|
||||
void ExtendedSlider::setMapedValue(int min, int val, int max)
|
||||
{
|
||||
qreal progress = ((val - min) + 1) / static_cast<qreal>(max - min);
|
||||
int value = minimum() + (maximum() - minimum()) * progress;
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
void
|
||||
ExtendedSlider::updateTooltip()
|
||||
void ExtendedSlider::updateTooltip()
|
||||
{
|
||||
setToolTip(QString::number(value()) + "%");
|
||||
}
|
||||
|
||||
void
|
||||
ExtendedSlider::fireTimer()
|
||||
void ExtendedSlider::fireTimer()
|
||||
{
|
||||
m_timer.start(500);
|
||||
}
|
||||
|
||||
@@ -32,8 +32,7 @@ FileNameEditor::FileNameEditor(QWidget* parent)
|
||||
initLayout();
|
||||
}
|
||||
|
||||
void
|
||||
FileNameEditor::initLayout()
|
||||
void FileNameEditor::initLayout()
|
||||
{
|
||||
m_layout = new QVBoxLayout(this);
|
||||
auto infoLabel = new QLabel(tr("Edit the name of your captures:"), this);
|
||||
@@ -52,8 +51,7 @@ FileNameEditor::initLayout()
|
||||
m_layout->addLayout(horizLayout);
|
||||
}
|
||||
|
||||
void
|
||||
FileNameEditor::initWidgets()
|
||||
void FileNameEditor::initWidgets()
|
||||
{
|
||||
m_nameHandler = new FileNameHandler(this);
|
||||
|
||||
@@ -67,7 +65,8 @@ FileNameEditor::initWidgets()
|
||||
QString foreground = this->palette().windowText().color().name();
|
||||
m_outputLabel->setStyleSheet(QStringLiteral("color: %1").arg(foreground));
|
||||
QPalette pal = m_outputLabel->palette();
|
||||
QColor color = pal.color(QPalette::Disabled, m_outputLabel->backgroundRole());
|
||||
QColor color =
|
||||
pal.color(QPalette::Disabled, m_outputLabel->backgroundRole());
|
||||
pal.setColor(QPalette::Active, m_outputLabel->backgroundRole(), color);
|
||||
m_outputLabel->setPalette(pal);
|
||||
|
||||
@@ -102,35 +101,30 @@ FileNameEditor::initWidgets()
|
||||
m_clearButton->setToolTip(tr("Deletes the name"));
|
||||
}
|
||||
|
||||
void
|
||||
FileNameEditor::savePattern()
|
||||
void FileNameEditor::savePattern()
|
||||
{
|
||||
QString pattern = m_nameEditor->text();
|
||||
m_nameHandler->setPattern(pattern);
|
||||
}
|
||||
|
||||
void
|
||||
FileNameEditor::showParsedPattern(const QString& p)
|
||||
void FileNameEditor::showParsedPattern(const QString& p)
|
||||
{
|
||||
QString output = m_nameHandler->parseFilename(p);
|
||||
m_outputLabel->setText(output);
|
||||
}
|
||||
|
||||
void
|
||||
FileNameEditor::resetName()
|
||||
void FileNameEditor::resetName()
|
||||
{
|
||||
m_nameEditor->setText(ConfigHandler().filenamePatternValue());
|
||||
}
|
||||
|
||||
void
|
||||
FileNameEditor::addToNameEditor(QString s)
|
||||
void FileNameEditor::addToNameEditor(QString s)
|
||||
{
|
||||
m_nameEditor->setText(m_nameEditor->text() + s);
|
||||
m_nameEditor->setFocus();
|
||||
}
|
||||
|
||||
void
|
||||
FileNameEditor::updateComponents()
|
||||
void FileNameEditor::updateComponents()
|
||||
{
|
||||
m_nameEditor->setText(ConfigHandler().filenamePatternValue());
|
||||
m_outputLabel->setText(m_nameHandler->parsedPattern());
|
||||
|
||||
@@ -49,8 +49,7 @@ GeneneralConf::GeneneralConf(QWidget* parent)
|
||||
updateComponents();
|
||||
}
|
||||
|
||||
void
|
||||
GeneneralConf::updateComponents()
|
||||
void GeneneralConf::updateComponents()
|
||||
{
|
||||
ConfigHandler config;
|
||||
m_helpMessage->setChecked(config.showHelpValue());
|
||||
@@ -74,26 +73,22 @@ GeneneralConf::updateComponents()
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
GeneneralConf::showHelpChanged(bool checked)
|
||||
void GeneneralConf::showHelpChanged(bool checked)
|
||||
{
|
||||
ConfigHandler().setShowHelp(checked);
|
||||
}
|
||||
|
||||
void
|
||||
GeneneralConf::showSidePanelButtonChanged(bool checked)
|
||||
void GeneneralConf::showSidePanelButtonChanged(bool checked)
|
||||
{
|
||||
ConfigHandler().setShowSidePanelButton(checked);
|
||||
}
|
||||
|
||||
void
|
||||
GeneneralConf::showDesktopNotificationChanged(bool checked)
|
||||
void GeneneralConf::showDesktopNotificationChanged(bool checked)
|
||||
{
|
||||
ConfigHandler().setDesktopNotification(checked);
|
||||
}
|
||||
|
||||
void
|
||||
GeneneralConf::showTrayIconChanged(bool checked)
|
||||
void GeneneralConf::showTrayIconChanged(bool checked)
|
||||
{
|
||||
auto controller = Controller::getInstance();
|
||||
if (checked) {
|
||||
@@ -103,20 +98,17 @@ GeneneralConf::showTrayIconChanged(bool checked)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GeneneralConf::autostartChanged(bool checked)
|
||||
void GeneneralConf::autostartChanged(bool checked)
|
||||
{
|
||||
ConfigHandler().setStartupLaunch(checked);
|
||||
}
|
||||
|
||||
void
|
||||
GeneneralConf::closeAfterCaptureChanged(bool checked)
|
||||
void GeneneralConf::closeAfterCaptureChanged(bool checked)
|
||||
{
|
||||
ConfigHandler().setCloseAfterScreenshot(checked);
|
||||
}
|
||||
|
||||
void
|
||||
GeneneralConf::importConfiguration()
|
||||
void GeneneralConf::importConfiguration()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Import"));
|
||||
if (fileName.isEmpty()) {
|
||||
@@ -140,8 +132,7 @@ GeneneralConf::importConfiguration()
|
||||
config.close();
|
||||
}
|
||||
|
||||
void
|
||||
GeneneralConf::exportFileConfiguration()
|
||||
void GeneneralConf::exportFileConfiguration()
|
||||
{
|
||||
QString fileName = QFileDialog::getSaveFileName(
|
||||
this, tr("Save File"), QStringLiteral("flameshot.conf"));
|
||||
@@ -161,8 +152,7 @@ GeneneralConf::exportFileConfiguration()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GeneneralConf::resetConfiguration()
|
||||
void GeneneralConf::resetConfiguration()
|
||||
{
|
||||
QMessageBox::StandardButton reply;
|
||||
reply = QMessageBox::question(
|
||||
@@ -175,8 +165,7 @@ GeneneralConf::resetConfiguration()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GeneneralConf::initShowHelp()
|
||||
void GeneneralConf::initShowHelp()
|
||||
{
|
||||
m_helpMessage = new QCheckBox(tr("Show help message"), this);
|
||||
ConfigHandler config;
|
||||
@@ -186,12 +175,13 @@ GeneneralConf::initShowHelp()
|
||||
"in the capture mode."));
|
||||
m_layout->addWidget(m_helpMessage);
|
||||
|
||||
connect(
|
||||
m_helpMessage, &QCheckBox::clicked, this, &GeneneralConf::showHelpChanged);
|
||||
connect(m_helpMessage,
|
||||
&QCheckBox::clicked,
|
||||
this,
|
||||
&GeneneralConf::showHelpChanged);
|
||||
}
|
||||
|
||||
void
|
||||
GeneneralConf::initShowSidePanelButton()
|
||||
void GeneneralConf::initShowSidePanelButton()
|
||||
{
|
||||
m_sidePanelButton = new QCheckBox(tr("Show the side panel button"), this);
|
||||
m_sidePanelButton->setChecked(ConfigHandler().showSidePanelButtonValue());
|
||||
@@ -204,8 +194,7 @@ GeneneralConf::initShowSidePanelButton()
|
||||
this,
|
||||
&GeneneralConf::showSidePanelButtonChanged);
|
||||
}
|
||||
void
|
||||
GeneneralConf::initShowDesktopNotification()
|
||||
void GeneneralConf::initShowDesktopNotification()
|
||||
{
|
||||
m_sysNotifications = new QCheckBox(tr("Show desktop notifications"), this);
|
||||
ConfigHandler config;
|
||||
@@ -220,8 +209,7 @@ GeneneralConf::initShowDesktopNotification()
|
||||
&GeneneralConf::showDesktopNotificationChanged);
|
||||
}
|
||||
|
||||
void
|
||||
GeneneralConf::initShowTrayIcon()
|
||||
void GeneneralConf::initShowTrayIcon()
|
||||
{
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
|
||||
m_showTray = new QCheckBox(tr("Show tray icon"), this);
|
||||
@@ -238,8 +226,7 @@ GeneneralConf::initShowTrayIcon()
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
GeneneralConf::initConfingButtons()
|
||||
void GeneneralConf::initConfingButtons()
|
||||
{
|
||||
QHBoxLayout* buttonLayout = new QHBoxLayout();
|
||||
m_layout->addStretch();
|
||||
@@ -270,8 +257,7 @@ GeneneralConf::initConfingButtons()
|
||||
&GeneneralConf::resetConfiguration);
|
||||
}
|
||||
|
||||
void
|
||||
GeneneralConf::initAutostart()
|
||||
void GeneneralConf::initAutostart()
|
||||
{
|
||||
m_autostart = new QCheckBox(tr("Launch at startup"), this);
|
||||
ConfigHandler config;
|
||||
@@ -284,8 +270,7 @@ GeneneralConf::initAutostart()
|
||||
m_autostart, &QCheckBox::clicked, this, &GeneneralConf::autostartChanged);
|
||||
}
|
||||
|
||||
void
|
||||
GeneneralConf::initCloseAfterCapture()
|
||||
void GeneneralConf::initCloseAfterCapture()
|
||||
{
|
||||
m_closeAfterCapture = new QCheckBox(tr("Close after capture"), this);
|
||||
ConfigHandler config;
|
||||
@@ -300,10 +285,10 @@ GeneneralConf::initCloseAfterCapture()
|
||||
&GeneneralConf::closeAfterCaptureChanged);
|
||||
}
|
||||
|
||||
void
|
||||
GeneneralConf::initCopyAndCloseAfterUpload()
|
||||
void GeneneralConf::initCopyAndCloseAfterUpload()
|
||||
{
|
||||
m_copyAndCloseAfterUpload = new QCheckBox(tr("Copy URL after upload"), this);
|
||||
m_copyAndCloseAfterUpload =
|
||||
new QCheckBox(tr("Copy URL after upload"), this);
|
||||
ConfigHandler config;
|
||||
m_copyAndCloseAfterUpload->setChecked(
|
||||
config.copyAndCloseAfterUploadEnabled());
|
||||
@@ -316,8 +301,7 @@ GeneneralConf::initCopyAndCloseAfterUpload()
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
GeneneralConf::initSaveAfterCopy()
|
||||
void GeneneralConf::initSaveAfterCopy()
|
||||
{
|
||||
m_saveAfterCopy = new QCheckBox(tr("Save image after copy"), this);
|
||||
m_saveAfterCopy->setToolTip(tr("Save image file after copying it"));
|
||||
@@ -349,14 +333,12 @@ GeneneralConf::initSaveAfterCopy()
|
||||
&GeneneralConf::changeSavePath);
|
||||
}
|
||||
|
||||
void
|
||||
GeneneralConf::saveAfterCopyChanged(bool checked)
|
||||
void GeneneralConf::saveAfterCopyChanged(bool checked)
|
||||
{
|
||||
ConfigHandler().setSaveAfterCopy(checked);
|
||||
}
|
||||
|
||||
void
|
||||
GeneneralConf::changeSavePath()
|
||||
void GeneneralConf::changeSavePath()
|
||||
{
|
||||
QString path = QFileDialog::getExistingDirectory(
|
||||
this,
|
||||
@@ -367,7 +349,8 @@ GeneneralConf::changeSavePath()
|
||||
return;
|
||||
}
|
||||
if (!QFileInfo(path).isWritable()) {
|
||||
QMessageBox::about(this, tr("Error"), tr("Unable to write to directory."));
|
||||
QMessageBox::about(
|
||||
this, tr("Error"), tr("Unable to write to directory."));
|
||||
return;
|
||||
}
|
||||
m_savePath->setText(path);
|
||||
|
||||
@@ -35,7 +35,8 @@ StrftimeChooserWidget::StrftimeChooserWidget(QWidget* parent)
|
||||
QPushButton* button = new QPushButton(this);
|
||||
button->setText(tr(key.toStdString().data()));
|
||||
button->setToolTip(variable);
|
||||
button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
button->setSizePolicy(QSizePolicy::Expanding,
|
||||
QSizePolicy::Expanding);
|
||||
button->setMinimumHeight(25);
|
||||
layout->addWidget(button, j, i);
|
||||
connect(button, &QPushButton::clicked, this, [variable, this]() {
|
||||
|
||||
@@ -48,8 +48,7 @@ UIcolorEditor::UIcolorEditor(QWidget* parent)
|
||||
updateComponents();
|
||||
}
|
||||
|
||||
void
|
||||
UIcolorEditor::updateComponents()
|
||||
void UIcolorEditor::updateComponents()
|
||||
{
|
||||
ConfigHandler config;
|
||||
m_uiColor = config.uiMainColorValue();
|
||||
@@ -64,8 +63,7 @@ UIcolorEditor::updateComponents()
|
||||
}
|
||||
|
||||
// updateUIcolor updates the appearance of the buttons
|
||||
void
|
||||
UIcolorEditor::updateUIcolor()
|
||||
void UIcolorEditor::updateUIcolor()
|
||||
{
|
||||
ConfigHandler config;
|
||||
if (m_lastButtonPressed == m_buttonMainColor) {
|
||||
@@ -76,8 +74,7 @@ UIcolorEditor::updateUIcolor()
|
||||
}
|
||||
|
||||
// updateLocalColor updates the local button
|
||||
void
|
||||
UIcolorEditor::updateLocalColor(const QColor c)
|
||||
void UIcolorEditor::updateLocalColor(const QColor c)
|
||||
{
|
||||
if (m_lastButtonPressed == m_buttonMainColor) {
|
||||
m_uiColor = c;
|
||||
@@ -87,8 +84,7 @@ UIcolorEditor::updateLocalColor(const QColor c)
|
||||
m_lastButtonPressed->setColor(c);
|
||||
}
|
||||
|
||||
void
|
||||
UIcolorEditor::initColorWheel()
|
||||
void UIcolorEditor::initColorWheel()
|
||||
{
|
||||
m_colorWheel = new color_widgets::ColorWheel(this);
|
||||
connect(m_colorWheel,
|
||||
@@ -110,8 +106,7 @@ UIcolorEditor::initColorWheel()
|
||||
m_hLayout->addWidget(m_colorWheel);
|
||||
}
|
||||
|
||||
void
|
||||
UIcolorEditor::initButtons()
|
||||
void UIcolorEditor::initButtons()
|
||||
{
|
||||
const int extraSize = GlobalValues::buttonBaseSize() / 3;
|
||||
int frameSize = GlobalValues::buttonBaseSize() + extraSize;
|
||||
@@ -168,8 +163,7 @@ UIcolorEditor::initButtons()
|
||||
}
|
||||
|
||||
// visual update for the selected button
|
||||
void
|
||||
UIcolorEditor::changeLastButton(CaptureToolButton* b)
|
||||
void UIcolorEditor::changeLastButton(CaptureToolButton* b)
|
||||
{
|
||||
if (m_lastButtonPressed != b) {
|
||||
m_lastButtonPressed = b;
|
||||
|
||||
@@ -32,8 +32,7 @@ VisualsEditor::VisualsEditor(QWidget* parent)
|
||||
initWidgets();
|
||||
}
|
||||
|
||||
void
|
||||
VisualsEditor::updateComponents()
|
||||
void VisualsEditor::updateComponents()
|
||||
{
|
||||
m_buttonList->updateComponents();
|
||||
m_colorEditor->updateComponents();
|
||||
@@ -41,8 +40,7 @@ VisualsEditor::updateComponents()
|
||||
m_opacitySlider->setMapedValue(0, opacity, 255);
|
||||
}
|
||||
|
||||
void
|
||||
VisualsEditor::initOpacitySlider()
|
||||
void VisualsEditor::initOpacitySlider()
|
||||
{
|
||||
m_opacitySlider = new ExtendedSlider();
|
||||
m_opacitySlider->setFocusPolicy(Qt::NoFocus);
|
||||
@@ -70,15 +68,13 @@ VisualsEditor::initOpacitySlider()
|
||||
m_opacitySlider->setMapedValue(0, opacity, 255);
|
||||
}
|
||||
|
||||
void
|
||||
VisualsEditor::saveOpacity()
|
||||
void VisualsEditor::saveOpacity()
|
||||
{
|
||||
int value = m_opacitySlider->mappedValue(0, 255);
|
||||
ConfigHandler().setContrastOpacity(value);
|
||||
}
|
||||
|
||||
void
|
||||
VisualsEditor::initWidgets()
|
||||
void VisualsEditor::initWidgets()
|
||||
{
|
||||
m_colorEditor = new UIcolorEditor();
|
||||
m_layout->addWidget(m_colorEditor);
|
||||
|
||||
@@ -34,15 +34,13 @@ CaptureRequest::CaptureRequest(CaptureRequest::CaptureMode mode,
|
||||
, m_id(0)
|
||||
{}
|
||||
|
||||
void
|
||||
CaptureRequest::setStaticID(uint id)
|
||||
void CaptureRequest::setStaticID(uint id)
|
||||
{
|
||||
m_forcedID = true;
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
uint
|
||||
CaptureRequest::id() const
|
||||
uint CaptureRequest::id() const
|
||||
{
|
||||
if (m_forcedID) {
|
||||
return m_id;
|
||||
@@ -58,38 +56,32 @@ CaptureRequest::id() const
|
||||
return id;
|
||||
}
|
||||
|
||||
CaptureRequest::CaptureMode
|
||||
CaptureRequest::captureMode() const
|
||||
CaptureRequest::CaptureMode CaptureRequest::captureMode() const
|
||||
{
|
||||
return m_mode;
|
||||
}
|
||||
|
||||
uint
|
||||
CaptureRequest::delay() const
|
||||
uint CaptureRequest::delay() const
|
||||
{
|
||||
return m_delay;
|
||||
}
|
||||
|
||||
QString
|
||||
CaptureRequest::path() const
|
||||
QString CaptureRequest::path() const
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
|
||||
QVariant
|
||||
CaptureRequest::data() const
|
||||
QVariant CaptureRequest::data() const
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
|
||||
void
|
||||
CaptureRequest::addTask(CaptureRequest::ExportTask task)
|
||||
void CaptureRequest::addTask(CaptureRequest::ExportTask task)
|
||||
{
|
||||
m_tasks |= task;
|
||||
}
|
||||
|
||||
void
|
||||
CaptureRequest::exportCapture(const QPixmap& p)
|
||||
void CaptureRequest::exportCapture(const QPixmap& p)
|
||||
{
|
||||
if ((m_tasks & ExportTask::FILESYSTEM_SAVE_TASK) != ExportTask::NO_TASK) {
|
||||
if (m_path.isEmpty()) {
|
||||
|
||||
@@ -68,20 +68,17 @@ private:
|
||||
|
||||
using eTask = CaptureRequest::ExportTask;
|
||||
|
||||
inline eTask
|
||||
operator|(const eTask& a, const eTask& b)
|
||||
inline eTask operator|(const eTask& a, const eTask& b)
|
||||
{
|
||||
return static_cast<eTask>(static_cast<int>(a) | static_cast<int>(b));
|
||||
}
|
||||
|
||||
inline eTask
|
||||
operator&(const eTask& a, const eTask& b)
|
||||
inline eTask operator&(const eTask& a, const eTask& b)
|
||||
{
|
||||
return static_cast<eTask>(static_cast<int>(a) & static_cast<int>(b));
|
||||
}
|
||||
|
||||
inline eTask&
|
||||
operator|=(eTask& a, const eTask& b)
|
||||
inline eTask& operator|=(eTask& a, const eTask& b)
|
||||
{
|
||||
a = static_cast<eTask>(static_cast<int>(a) | static_cast<int>(b));
|
||||
return a;
|
||||
|
||||
@@ -62,15 +62,13 @@ Controller::Controller()
|
||||
qApp->setStyleSheet(StyleSheet);
|
||||
}
|
||||
|
||||
Controller*
|
||||
Controller::getInstance()
|
||||
Controller* Controller::getInstance()
|
||||
{
|
||||
static Controller c;
|
||||
return &c;
|
||||
}
|
||||
|
||||
void
|
||||
Controller::enableExports()
|
||||
void Controller::enableExports()
|
||||
{
|
||||
connect(
|
||||
this, &Controller::captureTaken, this, &Controller::handleCaptureTaken);
|
||||
@@ -78,8 +76,7 @@ Controller::enableExports()
|
||||
this, &Controller::captureFailed, this, &Controller::handleCaptureFailed);
|
||||
}
|
||||
|
||||
void
|
||||
Controller::requestCapture(const CaptureRequest& request)
|
||||
void Controller::requestCapture(const CaptureRequest& request)
|
||||
{
|
||||
uint id = request.id();
|
||||
m_requestMap.insert(id, request);
|
||||
@@ -90,8 +87,8 @@ Controller::requestCapture(const CaptureRequest& request)
|
||||
this->startFullscreenCapture(id);
|
||||
});
|
||||
break;
|
||||
// TODO: Figure out the code path that gets here so the deprated warning can
|
||||
// be fixed
|
||||
// TODO: Figure out the code path that gets here so the deprated warning
|
||||
// can be fixed
|
||||
case CaptureRequest::SCREEN_MODE: {
|
||||
int&& number = request.data().toInt();
|
||||
doLater(request.delay(), this, [this, id, number]() {
|
||||
@@ -113,8 +110,8 @@ Controller::requestCapture(const CaptureRequest& request)
|
||||
}
|
||||
|
||||
// creation of a new capture in GUI mode
|
||||
void
|
||||
Controller::startVisualCapture(const uint id, const QString& forcedSavePath)
|
||||
void Controller::startVisualCapture(const uint id,
|
||||
const QString& forcedSavePath)
|
||||
{
|
||||
if (!m_captureWindow) {
|
||||
QWidget* modalWidget = nullptr;
|
||||
@@ -127,7 +124,8 @@ Controller::startVisualCapture(const uint id, const QString& forcedSavePath)
|
||||
} while (modalWidget);
|
||||
|
||||
m_captureWindow = new CaptureWidget(id, forcedSavePath);
|
||||
// m_captureWindow = new CaptureWidget(id, forcedSavePath, false); // debug
|
||||
// m_captureWindow = new CaptureWidget(id, forcedSavePath, false); //
|
||||
// debug
|
||||
connect(m_captureWindow,
|
||||
&CaptureWidget::captureFailed,
|
||||
this,
|
||||
@@ -148,8 +146,7 @@ Controller::startVisualCapture(const uint id, const QString& forcedSavePath)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Controller::startScreenGrab(const uint id, const int screenNumber)
|
||||
void Controller::startScreenGrab(const uint id, const int screenNumber)
|
||||
{
|
||||
bool ok = true;
|
||||
int n = screenNumber;
|
||||
@@ -167,8 +164,7 @@ Controller::startScreenGrab(const uint id, const int screenNumber)
|
||||
}
|
||||
|
||||
// creation of the configuration window
|
||||
void
|
||||
Controller::openConfigWindow()
|
||||
void Controller::openConfigWindow()
|
||||
{
|
||||
if (!m_configWindow) {
|
||||
m_configWindow = new ConfigWindow();
|
||||
@@ -177,16 +173,14 @@ Controller::openConfigWindow()
|
||||
}
|
||||
|
||||
// creation of the window of information
|
||||
void
|
||||
Controller::openInfoWindow()
|
||||
void Controller::openInfoWindow()
|
||||
{
|
||||
if (!m_infoWindow) {
|
||||
m_infoWindow = new InfoWindow();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Controller::openLauncherWindow()
|
||||
void Controller::openLauncherWindow()
|
||||
{
|
||||
if (!m_launcherWindow) {
|
||||
m_launcherWindow = new CaptureLauncher();
|
||||
@@ -194,8 +188,7 @@ Controller::openLauncherWindow()
|
||||
m_launcherWindow->show();
|
||||
}
|
||||
|
||||
void
|
||||
Controller::enableTrayIcon()
|
||||
void Controller::enableTrayIcon()
|
||||
{
|
||||
if (m_trayIcon) {
|
||||
return;
|
||||
@@ -207,8 +200,10 @@ Controller::enableTrayIcon()
|
||||
doLater(400, this, [this]() { this->startVisualCapture(); });
|
||||
});
|
||||
QAction* launcherAction = new QAction(tr("&Open Launcher"), this);
|
||||
connect(
|
||||
launcherAction, &QAction::triggered, this, &Controller::openLauncherWindow);
|
||||
connect(launcherAction,
|
||||
&QAction::triggered,
|
||||
this,
|
||||
&Controller::openLauncherWindow);
|
||||
QAction* configAction = new QAction(tr("&Configuration"), this);
|
||||
connect(
|
||||
configAction, &QAction::triggered, this, &Controller::openConfigWindow);
|
||||
@@ -242,8 +237,7 @@ Controller::enableTrayIcon()
|
||||
m_trayIcon->show();
|
||||
}
|
||||
|
||||
void
|
||||
Controller::disableTrayIcon()
|
||||
void Controller::disableTrayIcon()
|
||||
{
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
|
||||
if (m_trayIcon) {
|
||||
@@ -253,26 +247,24 @@ Controller::disableTrayIcon()
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
Controller::sendTrayNotification(const QString& text,
|
||||
void Controller::sendTrayNotification(const QString& text,
|
||||
const QString& title,
|
||||
const int timeout)
|
||||
{
|
||||
if (m_trayIcon) {
|
||||
m_trayIcon->showMessage(title, text, QSystemTrayIcon::Information, timeout);
|
||||
m_trayIcon->showMessage(
|
||||
title, text, QSystemTrayIcon::Information, timeout);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Controller::updateConfigComponents()
|
||||
void Controller::updateConfigComponents()
|
||||
{
|
||||
if (m_configWindow) {
|
||||
m_configWindow->updateChildren();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Controller::startFullscreenCapture(const uint id)
|
||||
void Controller::startFullscreenCapture(const uint id)
|
||||
{
|
||||
bool ok = true;
|
||||
QPixmap p(ScreenGrabber().grabEntireDesktop(ok));
|
||||
@@ -283,8 +275,7 @@ Controller::startFullscreenCapture(const uint id)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Controller::handleCaptureTaken(uint id, QPixmap p)
|
||||
void Controller::handleCaptureTaken(uint id, QPixmap p)
|
||||
{
|
||||
auto it = m_requestMap.find(id);
|
||||
if (it != m_requestMap.end()) {
|
||||
@@ -296,8 +287,7 @@ Controller::handleCaptureTaken(uint id, QPixmap p)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Controller::handleCaptureFailed(uint id)
|
||||
void Controller::handleCaptureFailed(uint id)
|
||||
{
|
||||
m_requestMap.remove(id);
|
||||
|
||||
@@ -306,8 +296,7 @@ Controller::handleCaptureFailed(uint id)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Controller::doLater(int msec, QObject* receiver, lambda func)
|
||||
void Controller::doLater(int msec, QObject* receiver, lambda func)
|
||||
{
|
||||
QTimer* timer = new QTimer(receiver);
|
||||
QObject::connect(timer, &QTimer::timeout, receiver, [timer, func]() {
|
||||
|
||||
@@ -38,8 +38,7 @@ FlameshotDBusAdapter::FlameshotDBusAdapter(QObject* parent)
|
||||
|
||||
FlameshotDBusAdapter::~FlameshotDBusAdapter() {}
|
||||
|
||||
void
|
||||
FlameshotDBusAdapter::graphicCapture(QString path, int delay, uint id)
|
||||
void FlameshotDBusAdapter::graphicCapture(QString path, int delay, uint id)
|
||||
{
|
||||
CaptureRequest req(CaptureRequest::GRAPHICAL_MODE, delay, path);
|
||||
// if (toClipboard) {
|
||||
@@ -49,8 +48,7 @@ FlameshotDBusAdapter::graphicCapture(QString path, int delay, uint id)
|
||||
Controller::getInstance()->requestCapture(req);
|
||||
}
|
||||
|
||||
void
|
||||
FlameshotDBusAdapter::fullScreen(QString path,
|
||||
void FlameshotDBusAdapter::fullScreen(QString path,
|
||||
bool toClipboard,
|
||||
int delay,
|
||||
uint id)
|
||||
@@ -66,14 +64,12 @@ FlameshotDBusAdapter::fullScreen(QString path,
|
||||
Controller::getInstance()->requestCapture(req);
|
||||
}
|
||||
|
||||
void
|
||||
FlameshotDBusAdapter::openLauncher()
|
||||
void FlameshotDBusAdapter::openLauncher()
|
||||
{
|
||||
Controller::getInstance()->openLauncherWindow();
|
||||
}
|
||||
|
||||
void
|
||||
FlameshotDBusAdapter::captureScreen(int number,
|
||||
void FlameshotDBusAdapter::captureScreen(int number,
|
||||
QString path,
|
||||
bool toClipboard,
|
||||
int delay,
|
||||
@@ -90,14 +86,12 @@ FlameshotDBusAdapter::captureScreen(int number,
|
||||
Controller::getInstance()->requestCapture(req);
|
||||
}
|
||||
|
||||
void
|
||||
FlameshotDBusAdapter::openConfig()
|
||||
void FlameshotDBusAdapter::openConfig()
|
||||
{
|
||||
Controller::getInstance()->openConfigWindow();
|
||||
}
|
||||
|
||||
void
|
||||
FlameshotDBusAdapter::trayIconEnabled(bool enabled)
|
||||
void FlameshotDBusAdapter::trayIconEnabled(bool enabled)
|
||||
{
|
||||
auto controller = Controller::getInstance();
|
||||
if (enabled) {
|
||||
@@ -107,8 +101,7 @@ FlameshotDBusAdapter::trayIconEnabled(bool enabled)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
FlameshotDBusAdapter::autostartEnabled(bool enabled)
|
||||
void FlameshotDBusAdapter::autostartEnabled(bool enabled)
|
||||
{
|
||||
ConfigHandler().setStartupLaunch(enabled);
|
||||
auto controller = Controller::getInstance();
|
||||
@@ -116,8 +109,7 @@ FlameshotDBusAdapter::autostartEnabled(bool enabled)
|
||||
controller->updateConfigComponents();
|
||||
}
|
||||
|
||||
void
|
||||
FlameshotDBusAdapter::handleCaptureTaken(uint id, const QPixmap& p)
|
||||
void FlameshotDBusAdapter::handleCaptureTaken(uint id, const QPixmap& p)
|
||||
{
|
||||
QByteArray byteArray;
|
||||
QBuffer buffer(&byteArray);
|
||||
|
||||
@@ -35,7 +35,10 @@ signals:
|
||||
|
||||
public slots:
|
||||
Q_NOREPLY void graphicCapture(QString path, int delay, uint id);
|
||||
Q_NOREPLY void fullScreen(QString path, bool toClipboard, int delay, uint id);
|
||||
Q_NOREPLY void fullScreen(QString path,
|
||||
bool toClipboard,
|
||||
int delay,
|
||||
uint id);
|
||||
Q_NOREPLY void captureScreen(int number,
|
||||
QString path,
|
||||
bool toClipboard,
|
||||
|
||||
@@ -28,8 +28,7 @@ GlobalShortcutFilter::GlobalShortcutFilter(QObject* parent)
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
GlobalShortcutFilter::nativeEventFilter(const QByteArray& eventType,
|
||||
bool GlobalShortcutFilter::nativeEventFilter(const QByteArray& eventType,
|
||||
void* message,
|
||||
long* result)
|
||||
{
|
||||
|
||||
73
src/main.cpp
73
src/main.cpp
@@ -37,8 +37,7 @@
|
||||
#include <QDBusMessage>
|
||||
#endif
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// required for the button serialization
|
||||
// TODO: change to QVector in v1.0
|
||||
@@ -62,7 +61,8 @@ main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
qtTranslator.load(QLocale::system(),
|
||||
qtTranslator.load(
|
||||
QLocale::system(),
|
||||
"qt",
|
||||
"_",
|
||||
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
@@ -109,14 +109,16 @@ main(int argc, char* argv[])
|
||||
CommandArgument launcherArgument(QStringLiteral("launcher"),
|
||||
QObject::tr("Open the capture launcher."));
|
||||
CommandArgument guiArgument(
|
||||
QStringLiteral("gui"), QObject::tr("Start a manual capture in GUI mode."));
|
||||
QStringLiteral("gui"),
|
||||
QObject::tr("Start a manual capture in GUI mode."));
|
||||
CommandArgument configArgument(QStringLiteral("config"),
|
||||
QObject::tr("Configure") + " flameshot.");
|
||||
CommandArgument screenArgument(QStringLiteral("screen"),
|
||||
QObject::tr("Capture a single screen."));
|
||||
|
||||
// Options
|
||||
CommandOption pathOption({ "p", "path" },
|
||||
CommandOption pathOption(
|
||||
{ "p", "path" },
|
||||
QObject::tr("Path where the capture will be saved"),
|
||||
QStringLiteral("path"));
|
||||
CommandOption clipboardOption(
|
||||
@@ -130,7 +132,8 @@ main(int argc, char* argv[])
|
||||
CommandOption trayOption({ "t", "trayicon" },
|
||||
QObject::tr("Enable or disable the trayicon"),
|
||||
QStringLiteral("bool"));
|
||||
CommandOption autostartOption({ "a", "autostart" },
|
||||
CommandOption autostartOption(
|
||||
{ "a", "autostart" },
|
||||
QObject::tr("Enable or disable run at startup"),
|
||||
QStringLiteral("bool"));
|
||||
CommandOption showHelpOption(
|
||||
@@ -140,7 +143,8 @@ main(int argc, char* argv[])
|
||||
CommandOption mainColorOption({ "m", "maincolor" },
|
||||
QObject::tr("Define the main UI color"),
|
||||
QStringLiteral("color-code"));
|
||||
CommandOption contrastColorOption({ "k", "contrastcolor" },
|
||||
CommandOption contrastColorOption(
|
||||
{ "k", "contrastcolor" },
|
||||
QObject::tr("Define the contrast UI color"),
|
||||
QStringLiteral("color-code"));
|
||||
CommandOption rawImageOption({ "r", "raw" },
|
||||
@@ -180,7 +184,8 @@ main(int argc, char* argv[])
|
||||
auto pathChecker = [pathErr](const QString& pathValue) -> bool {
|
||||
bool res = QDir(pathValue).exists();
|
||||
if (!res) {
|
||||
SystemNotification().sendMessage(QObject::tr(pathErr.toLatin1().data()));
|
||||
SystemNotification().sendMessage(
|
||||
QObject::tr(pathErr.toLatin1().data()));
|
||||
}
|
||||
return res;
|
||||
};
|
||||
@@ -188,7 +193,8 @@ main(int argc, char* argv[])
|
||||
const QString booleanErr =
|
||||
QObject::tr("Invalid value, it must be defined as 'true' or 'false'");
|
||||
auto booleanChecker = [](const QString& value) -> bool {
|
||||
return value == QLatin1String("true") || value == QLatin1String("false");
|
||||
return value == QLatin1String("true") ||
|
||||
value == QLatin1String("false");
|
||||
};
|
||||
|
||||
contrastColorOption.addChecker(colorChecker, colorErr);
|
||||
@@ -216,7 +222,8 @@ main(int argc, char* argv[])
|
||||
rawImageOption },
|
||||
screenArgument);
|
||||
parser.AddOptions(
|
||||
{ pathOption, clipboardOption, delayOption, rawImageOption }, fullArgument);
|
||||
{ pathOption, clipboardOption, delayOption, rawImageOption },
|
||||
fullArgument);
|
||||
parser.AddOptions({ autostartOption,
|
||||
filenameOption,
|
||||
trayOption,
|
||||
@@ -233,8 +240,8 @@ main(int argc, char* argv[])
|
||||
//--------------
|
||||
if (parser.isSet(helpOption) || parser.isSet(versionOption)) {
|
||||
} else if (parser.isSet(launcherArgument)) { // LAUNCHER
|
||||
QDBusMessage m =
|
||||
QDBusMessage::createMethodCall(QStringLiteral("org.flameshot.Flameshot"),
|
||||
QDBusMessage m = QDBusMessage::createMethodCall(
|
||||
QStringLiteral("org.flameshot.Flameshot"),
|
||||
QStringLiteral("/"),
|
||||
QLatin1String(""),
|
||||
QStringLiteral("openLauncher"));
|
||||
@@ -253,8 +260,8 @@ main(int argc, char* argv[])
|
||||
uint id = req.id();
|
||||
|
||||
// Send message
|
||||
QDBusMessage m =
|
||||
QDBusMessage::createMethodCall(QStringLiteral("org.flameshot.Flameshot"),
|
||||
QDBusMessage m = QDBusMessage::createMethodCall(
|
||||
QStringLiteral("org.flameshot.Flameshot"),
|
||||
QStringLiteral("/"),
|
||||
QLatin1String(""),
|
||||
QStringLiteral("graphicCapture"));
|
||||
@@ -267,7 +274,8 @@ main(int argc, char* argv[])
|
||||
dbusUtils.connectPrintCapture(sessionBus, id);
|
||||
QTimer t;
|
||||
t.setInterval(delay + 1000 * 60 * 15); // 15 minutes timeout
|
||||
QObject::connect(&t, &QTimer::timeout, qApp, &QCoreApplication::quit);
|
||||
QObject::connect(
|
||||
&t, &QTimer::timeout, qApp, &QCoreApplication::quit);
|
||||
t.start();
|
||||
// wait
|
||||
return app.exec();
|
||||
@@ -283,8 +291,10 @@ main(int argc, char* argv[])
|
||||
out << "Invalid format, set where to save the content with one of "
|
||||
<< "the following flags:\n "
|
||||
<< pathOption.dashedNames().join(QStringLiteral(", ")) << "\n "
|
||||
<< rawImageOption.dashedNames().join(QStringLiteral(", ")) << "\n "
|
||||
<< clipboardOption.dashedNames().join(QStringLiteral(", ")) << "\n\n";
|
||||
<< rawImageOption.dashedNames().join(QStringLiteral(", "))
|
||||
<< "\n "
|
||||
<< clipboardOption.dashedNames().join(QStringLiteral(", "))
|
||||
<< "\n\n";
|
||||
parser.parse(QStringList() << argv[0] << QStringLiteral("full")
|
||||
<< QStringLiteral("-h"));
|
||||
goto finish;
|
||||
@@ -301,8 +311,8 @@ main(int argc, char* argv[])
|
||||
DBusUtils dbusUtils;
|
||||
|
||||
// Send message
|
||||
QDBusMessage m =
|
||||
QDBusMessage::createMethodCall(QStringLiteral("org.flameshot.Flameshot"),
|
||||
QDBusMessage m = QDBusMessage::createMethodCall(
|
||||
QStringLiteral("org.flameshot.Flameshot"),
|
||||
QStringLiteral("/"),
|
||||
QLatin1String(""),
|
||||
QStringLiteral("fullScreen"));
|
||||
@@ -316,7 +326,8 @@ main(int argc, char* argv[])
|
||||
// timeout just in case
|
||||
QTimer t;
|
||||
t.setInterval(delay + 2000);
|
||||
QObject::connect(&t, &QTimer::timeout, qApp, &QCoreApplication::quit);
|
||||
QObject::connect(
|
||||
&t, &QTimer::timeout, qApp, &QCoreApplication::quit);
|
||||
t.start();
|
||||
// wait
|
||||
return app.exec();
|
||||
@@ -335,14 +346,17 @@ main(int argc, char* argv[])
|
||||
out << "Invalid format, set where to save the content with one of "
|
||||
<< "the following flags:\n "
|
||||
<< pathOption.dashedNames().join(QStringLiteral(", ")) << "\n "
|
||||
<< rawImageOption.dashedNames().join(QStringLiteral(", ")) << "\n "
|
||||
<< clipboardOption.dashedNames().join(QStringLiteral(", ")) << "\n\n";
|
||||
<< rawImageOption.dashedNames().join(QStringLiteral(", "))
|
||||
<< "\n "
|
||||
<< clipboardOption.dashedNames().join(QStringLiteral(", "))
|
||||
<< "\n\n";
|
||||
parser.parse(QStringList() << argv[0] << QStringLiteral("screen")
|
||||
<< QStringLiteral("-h"));
|
||||
goto finish;
|
||||
}
|
||||
|
||||
CaptureRequest req(CaptureRequest::SCREEN_MODE, delay, pathValue, number);
|
||||
CaptureRequest req(
|
||||
CaptureRequest::SCREEN_MODE, delay, pathValue, number);
|
||||
if (toClipboard) {
|
||||
req.addTask(CaptureRequest::CLIPBOARD_SAVE_TASK);
|
||||
}
|
||||
@@ -353,8 +367,8 @@ main(int argc, char* argv[])
|
||||
DBusUtils dbusUtils;
|
||||
|
||||
// Send message
|
||||
QDBusMessage m =
|
||||
QDBusMessage::createMethodCall(QStringLiteral("org.flameshot.Flameshot"),
|
||||
QDBusMessage m = QDBusMessage::createMethodCall(
|
||||
QStringLiteral("org.flameshot.Flameshot"),
|
||||
QStringLiteral("/"),
|
||||
QLatin1String(""),
|
||||
QStringLiteral("captureScreen"));
|
||||
@@ -368,7 +382,8 @@ main(int argc, char* argv[])
|
||||
// timeout just in case
|
||||
QTimer t;
|
||||
t.setInterval(delay + 2000);
|
||||
QObject::connect(&t, &QTimer::timeout, qApp, &QCoreApplication::quit);
|
||||
QObject::connect(
|
||||
&t, &QTimer::timeout, qApp, &QCoreApplication::quit);
|
||||
t.start();
|
||||
// wait
|
||||
return app.exec();
|
||||
@@ -380,7 +395,8 @@ main(int argc, char* argv[])
|
||||
bool help = parser.isSet(showHelpOption);
|
||||
bool mainColor = parser.isSet(mainColorOption);
|
||||
bool contrastColor = parser.isSet(contrastColorOption);
|
||||
bool someFlagSet = (filename || tray || help || mainColor || contrastColor);
|
||||
bool someFlagSet =
|
||||
(filename || tray || help || mainColor || contrastColor);
|
||||
ConfigHandler config;
|
||||
if (autostart) {
|
||||
QDBusMessage m = QDBusMessage::createMethodCall(
|
||||
@@ -404,7 +420,8 @@ main(int argc, char* argv[])
|
||||
QString newFilename(parser.value(filenameOption));
|
||||
config.setFilenamePattern(newFilename);
|
||||
FileNameHandler fh;
|
||||
QTextStream(stdout) << QStringLiteral("The new pattern is '%1'\n"
|
||||
QTextStream(stdout)
|
||||
<< QStringLiteral("The new pattern is '%1'\n"
|
||||
"Parsed pattern example: %2\n")
|
||||
.arg(newFilename)
|
||||
.arg(fh.parsedPattern());
|
||||
|
||||
@@ -21,32 +21,27 @@ AbstractActionTool::AbstractActionTool(QObject* parent)
|
||||
: CaptureTool(parent)
|
||||
{}
|
||||
|
||||
bool
|
||||
AbstractActionTool::isValid() const
|
||||
bool AbstractActionTool::isValid() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
AbstractActionTool::isSelectable() const
|
||||
bool AbstractActionTool::isSelectable() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
AbstractActionTool::showMousePreview() const
|
||||
bool AbstractActionTool::showMousePreview() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
AbstractActionTool::undo(QPixmap& pixmap)
|
||||
void AbstractActionTool::undo(QPixmap& pixmap)
|
||||
{
|
||||
Q_UNUSED(pixmap);
|
||||
}
|
||||
|
||||
void
|
||||
AbstractActionTool::process(QPainter& painter,
|
||||
void AbstractActionTool::process(QPainter& painter,
|
||||
const QPixmap& pixmap,
|
||||
bool recordUndo)
|
||||
{
|
||||
@@ -55,40 +50,34 @@ AbstractActionTool::process(QPainter& painter,
|
||||
Q_UNUSED(recordUndo);
|
||||
}
|
||||
|
||||
void
|
||||
AbstractActionTool::paintMousePreview(QPainter& painter,
|
||||
void AbstractActionTool::paintMousePreview(QPainter& painter,
|
||||
const CaptureContext& context)
|
||||
{
|
||||
Q_UNUSED(painter);
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
|
||||
void
|
||||
AbstractActionTool::drawEnd(const QPoint& p)
|
||||
void AbstractActionTool::drawEnd(const QPoint& p)
|
||||
{
|
||||
Q_UNUSED(p);
|
||||
}
|
||||
|
||||
void
|
||||
AbstractActionTool::drawMove(const QPoint& p)
|
||||
void AbstractActionTool::drawMove(const QPoint& p)
|
||||
{
|
||||
Q_UNUSED(p);
|
||||
}
|
||||
|
||||
void
|
||||
AbstractActionTool::drawStart(const CaptureContext& context)
|
||||
void AbstractActionTool::drawStart(const CaptureContext& context)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
|
||||
void
|
||||
AbstractActionTool::colorChanged(const QColor& c)
|
||||
void AbstractActionTool::colorChanged(const QColor& c)
|
||||
{
|
||||
Q_UNUSED(c);
|
||||
}
|
||||
|
||||
void
|
||||
AbstractActionTool::thicknessChanged(const int th)
|
||||
void AbstractActionTool::thicknessChanged(const int th)
|
||||
{
|
||||
Q_UNUSED(th);
|
||||
}
|
||||
|
||||
@@ -23,32 +23,27 @@ AbstractPathTool::AbstractPathTool(QObject* parent)
|
||||
, m_padding(0)
|
||||
{}
|
||||
|
||||
bool
|
||||
AbstractPathTool::isValid() const
|
||||
bool AbstractPathTool::isValid() const
|
||||
{
|
||||
return m_points.length() > 1;
|
||||
}
|
||||
|
||||
bool
|
||||
AbstractPathTool::closeOnButtonPressed() const
|
||||
bool AbstractPathTool::closeOnButtonPressed() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
AbstractPathTool::isSelectable() const
|
||||
bool AbstractPathTool::isSelectable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
AbstractPathTool::showMousePreview() const
|
||||
bool AbstractPathTool::showMousePreview() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
AbstractPathTool::undo(QPixmap& pixmap)
|
||||
void AbstractPathTool::undo(QPixmap& pixmap)
|
||||
{
|
||||
QPainter p(&pixmap);
|
||||
const int val = m_thickness + m_padding;
|
||||
@@ -56,40 +51,34 @@ AbstractPathTool::undo(QPixmap& pixmap)
|
||||
p.drawPixmap(area.intersected(pixmap.rect()).topLeft(), m_pixmapBackup);
|
||||
}
|
||||
|
||||
void
|
||||
AbstractPathTool::drawEnd(const QPoint& p)
|
||||
void AbstractPathTool::drawEnd(const QPoint& p)
|
||||
{
|
||||
Q_UNUSED(p);
|
||||
}
|
||||
|
||||
void
|
||||
AbstractPathTool::drawMove(const QPoint& p)
|
||||
void AbstractPathTool::drawMove(const QPoint& p)
|
||||
{
|
||||
addPoint(p);
|
||||
}
|
||||
|
||||
void
|
||||
AbstractPathTool::colorChanged(const QColor& c)
|
||||
void AbstractPathTool::colorChanged(const QColor& c)
|
||||
{
|
||||
m_color = c;
|
||||
}
|
||||
|
||||
void
|
||||
AbstractPathTool::thicknessChanged(const int th)
|
||||
void AbstractPathTool::thicknessChanged(const int th)
|
||||
{
|
||||
m_thickness = th;
|
||||
}
|
||||
|
||||
void
|
||||
AbstractPathTool::updateBackup(const QPixmap& pixmap)
|
||||
void AbstractPathTool::updateBackup(const QPixmap& pixmap)
|
||||
{
|
||||
const int val = m_thickness + m_padding;
|
||||
QRect area = m_backupArea.normalized() + QMargins(val, val, val, val);
|
||||
m_pixmapBackup = pixmap.copy(area);
|
||||
}
|
||||
|
||||
void
|
||||
AbstractPathTool::addPoint(const QPoint& point)
|
||||
void AbstractPathTool::addPoint(const QPoint& point)
|
||||
{
|
||||
if (m_backupArea.left() > point.x()) {
|
||||
m_backupArea.setLeft(point.x());
|
||||
|
||||
@@ -48,32 +48,27 @@ AbstractTwoPointTool::AbstractTwoPointTool(QObject* parent)
|
||||
, m_padding(0)
|
||||
{}
|
||||
|
||||
bool
|
||||
AbstractTwoPointTool::isValid() const
|
||||
bool AbstractTwoPointTool::isValid() const
|
||||
{
|
||||
return (m_points.first != m_points.second);
|
||||
}
|
||||
|
||||
bool
|
||||
AbstractTwoPointTool::closeOnButtonPressed() const
|
||||
bool AbstractTwoPointTool::closeOnButtonPressed() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
AbstractTwoPointTool::isSelectable() const
|
||||
bool AbstractTwoPointTool::isSelectable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
AbstractTwoPointTool::showMousePreview() const
|
||||
bool AbstractTwoPointTool::showMousePreview() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
AbstractTwoPointTool::undo(QPixmap& pixmap)
|
||||
void AbstractTwoPointTool::undo(QPixmap& pixmap)
|
||||
{
|
||||
QPainter p(&pixmap);
|
||||
p.drawPixmap(backupRect(pixmap.rect()).topLeft(), m_pixmapBackup);
|
||||
@@ -82,44 +77,37 @@ AbstractTwoPointTool::undo(QPixmap& pixmap)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AbstractTwoPointTool::drawEnd(const QPoint& p)
|
||||
void AbstractTwoPointTool::drawEnd(const QPoint& p)
|
||||
{
|
||||
Q_UNUSED(p);
|
||||
}
|
||||
|
||||
void
|
||||
AbstractTwoPointTool::drawMove(const QPoint& p)
|
||||
void AbstractTwoPointTool::drawMove(const QPoint& p)
|
||||
{
|
||||
m_points.second = p;
|
||||
}
|
||||
|
||||
void
|
||||
AbstractTwoPointTool::drawMoveWithAdjustment(const QPoint& p)
|
||||
void AbstractTwoPointTool::drawMoveWithAdjustment(const QPoint& p)
|
||||
{
|
||||
m_points.second = m_points.first + adjustedVector(p - m_points.first);
|
||||
}
|
||||
|
||||
void
|
||||
AbstractTwoPointTool::colorChanged(const QColor& c)
|
||||
void AbstractTwoPointTool::colorChanged(const QColor& c)
|
||||
{
|
||||
m_color = c;
|
||||
}
|
||||
|
||||
void
|
||||
AbstractTwoPointTool::thicknessChanged(const int th)
|
||||
void AbstractTwoPointTool::thicknessChanged(const int th)
|
||||
{
|
||||
m_thickness = th;
|
||||
}
|
||||
|
||||
void
|
||||
AbstractTwoPointTool::updateBackup(const QPixmap& pixmap)
|
||||
void AbstractTwoPointTool::updateBackup(const QPixmap& pixmap)
|
||||
{
|
||||
m_pixmapBackup = pixmap.copy(backupRect(pixmap.rect()));
|
||||
}
|
||||
|
||||
QRect
|
||||
AbstractTwoPointTool::backupRect(const QRect& limits) const
|
||||
QRect AbstractTwoPointTool::backupRect(const QRect& limits) const
|
||||
{
|
||||
QRect r = QRect(m_points.first, m_points.second).normalized();
|
||||
const int val = m_thickness + m_padding;
|
||||
@@ -127,12 +115,11 @@ AbstractTwoPointTool::backupRect(const QRect& limits) const
|
||||
return r.intersected(limits);
|
||||
}
|
||||
|
||||
QPoint
|
||||
AbstractTwoPointTool::adjustedVector(QPoint v) const
|
||||
QPoint AbstractTwoPointTool::adjustedVector(QPoint v) const
|
||||
{
|
||||
if (m_supportsOrthogonalAdj && m_supportsDiagonalAdj) {
|
||||
int dir =
|
||||
(static_cast<int>(round(atan2(-v.y(), v.x()) / ADJ_UNIT)) + DIRS_NUMBER) %
|
||||
int dir = (static_cast<int>(round(atan2(-v.y(), v.x()) / ADJ_UNIT)) +
|
||||
DIRS_NUMBER) %
|
||||
DIRS_NUMBER;
|
||||
if (dir == UNIT::HORIZ_DIR) {
|
||||
v.setY(0);
|
||||
@@ -150,8 +137,9 @@ AbstractTwoPointTool::adjustedVector(QPoint v) const
|
||||
v.setY(newY);
|
||||
}
|
||||
} else if (m_supportsDiagonalAdj) {
|
||||
int dir = (static_cast<int>(round(
|
||||
(atan2(-v.y(), v.x()) - ADJ_DIAG_UNIT / 2) / ADJ_DIAG_UNIT)) +
|
||||
int dir =
|
||||
(static_cast<int>(round((atan2(-v.y(), v.x()) - ADJ_DIAG_UNIT / 2) /
|
||||
ADJ_DIAG_UNIT)) +
|
||||
DIAG_DIRS_NUMBER) %
|
||||
DIAG_DIRS_NUMBER;
|
||||
if (dir == DIAG_UNIT::DIR1) {
|
||||
|
||||
@@ -24,8 +24,7 @@ namespace {
|
||||
const int ArrowWidth = 10;
|
||||
const int ArrowHeight = 18;
|
||||
|
||||
QPainterPath
|
||||
getArrowHead(QPoint p1, QPoint p2, const int thickness)
|
||||
QPainterPath getArrowHead(QPoint p1, QPoint p2, const int thickness)
|
||||
{
|
||||
QLineF base(p1, p2);
|
||||
// Create the vector for the position of the base of the arrowhead
|
||||
@@ -58,8 +57,7 @@ getArrowHead(QPoint p1, QPoint p2, const int thickness)
|
||||
}
|
||||
|
||||
// gets a shorter line to prevent overlap in the point of the arrow
|
||||
QLine
|
||||
getShorterLine(QPoint p1, QPoint p2, const int thickness)
|
||||
QLine getShorterLine(QPoint p1, QPoint p2, const int thickness)
|
||||
{
|
||||
QLineF l(p1, p2);
|
||||
int val = ArrowHeight + thickness * 4;
|
||||
@@ -80,38 +78,34 @@ ArrowTool::ArrowTool(QObject* parent)
|
||||
m_supportsDiagonalAdj = true;
|
||||
}
|
||||
|
||||
QIcon
|
||||
ArrowTool::icon(const QColor& background, bool inEditor) const
|
||||
QIcon ArrowTool::icon(const QColor& background, bool inEditor) const
|
||||
{
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "arrow-bottom-left.svg");
|
||||
}
|
||||
QString
|
||||
ArrowTool::name() const
|
||||
QString ArrowTool::name() const
|
||||
{
|
||||
return tr("Arrow");
|
||||
}
|
||||
|
||||
ToolType
|
||||
ArrowTool::nameID() const
|
||||
ToolType ArrowTool::nameID() const
|
||||
{
|
||||
return ToolType::ARROW;
|
||||
}
|
||||
|
||||
QString
|
||||
ArrowTool::description() const
|
||||
QString ArrowTool::description() const
|
||||
{
|
||||
return tr("Set the Arrow as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
ArrowTool::copy(QObject* parent)
|
||||
CaptureTool* ArrowTool::copy(QObject* parent)
|
||||
{
|
||||
return new ArrowTool(parent);
|
||||
}
|
||||
|
||||
void
|
||||
ArrowTool::process(QPainter& painter, const QPixmap& pixmap, bool recordUndo)
|
||||
void ArrowTool::process(QPainter& painter,
|
||||
const QPixmap& pixmap,
|
||||
bool recordUndo)
|
||||
{
|
||||
if (recordUndo) {
|
||||
updateBackup(pixmap);
|
||||
@@ -123,15 +117,14 @@ ArrowTool::process(QPainter& painter, const QPixmap& pixmap, bool recordUndo)
|
||||
QBrush(m_color));
|
||||
}
|
||||
|
||||
void
|
||||
ArrowTool::paintMousePreview(QPainter& painter, const CaptureContext& context)
|
||||
void ArrowTool::paintMousePreview(QPainter& painter,
|
||||
const CaptureContext& context)
|
||||
{
|
||||
painter.setPen(QPen(context.color, PADDING_VALUE + context.thickness));
|
||||
painter.drawLine(context.mousePos, context.mousePos);
|
||||
}
|
||||
|
||||
void
|
||||
ArrowTool::drawStart(const CaptureContext& context)
|
||||
void ArrowTool::drawStart(const CaptureContext& context)
|
||||
{
|
||||
m_color = context.color;
|
||||
m_thickness = context.thickness + PADDING_VALUE;
|
||||
@@ -139,8 +132,7 @@ ArrowTool::drawStart(const CaptureContext& context)
|
||||
m_points.second = context.mousePos;
|
||||
}
|
||||
|
||||
void
|
||||
ArrowTool::pressed(const CaptureContext& context)
|
||||
void ArrowTool::pressed(const CaptureContext& context)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
|
||||
#include "capturecontext.h"
|
||||
|
||||
QPixmap
|
||||
CaptureContext::selectedScreenshotArea() const
|
||||
QPixmap CaptureContext::selectedScreenshotArea() const
|
||||
{
|
||||
if (selection.isNull()) {
|
||||
return screenshot;
|
||||
|
||||
@@ -28,38 +28,34 @@ CircleTool::CircleTool(QObject* parent)
|
||||
m_supportsDiagonalAdj = true;
|
||||
}
|
||||
|
||||
QIcon
|
||||
CircleTool::icon(const QColor& background, bool inEditor) const
|
||||
QIcon CircleTool::icon(const QColor& background, bool inEditor) const
|
||||
{
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "circle-outline.svg");
|
||||
}
|
||||
QString
|
||||
CircleTool::name() const
|
||||
QString CircleTool::name() const
|
||||
{
|
||||
return tr("Circle");
|
||||
}
|
||||
|
||||
ToolType
|
||||
CircleTool::nameID() const
|
||||
ToolType CircleTool::nameID() const
|
||||
{
|
||||
return ToolType::CIRCLE;
|
||||
}
|
||||
|
||||
QString
|
||||
CircleTool::description() const
|
||||
QString CircleTool::description() const
|
||||
{
|
||||
return tr("Set the Circle as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
CircleTool::copy(QObject* parent)
|
||||
CaptureTool* CircleTool::copy(QObject* parent)
|
||||
{
|
||||
return new CircleTool(parent);
|
||||
}
|
||||
|
||||
void
|
||||
CircleTool::process(QPainter& painter, const QPixmap& pixmap, bool recordUndo)
|
||||
void CircleTool::process(QPainter& painter,
|
||||
const QPixmap& pixmap,
|
||||
bool recordUndo)
|
||||
{
|
||||
if (recordUndo) {
|
||||
updateBackup(pixmap);
|
||||
@@ -68,15 +64,14 @@ CircleTool::process(QPainter& painter, const QPixmap& pixmap, bool recordUndo)
|
||||
painter.drawEllipse(QRect(m_points.first, m_points.second));
|
||||
}
|
||||
|
||||
void
|
||||
CircleTool::paintMousePreview(QPainter& painter, const CaptureContext& context)
|
||||
void CircleTool::paintMousePreview(QPainter& painter,
|
||||
const CaptureContext& context)
|
||||
{
|
||||
painter.setPen(QPen(context.color, PADDING_VALUE + context.thickness));
|
||||
painter.drawLine(context.mousePos, context.mousePos);
|
||||
}
|
||||
|
||||
void
|
||||
CircleTool::drawStart(const CaptureContext& context)
|
||||
void CircleTool::drawStart(const CaptureContext& context)
|
||||
{
|
||||
m_color = context.color;
|
||||
m_thickness = context.thickness + PADDING_VALUE;
|
||||
@@ -84,8 +79,7 @@ CircleTool::drawStart(const CaptureContext& context)
|
||||
m_points.second = context.mousePos;
|
||||
}
|
||||
|
||||
void
|
||||
CircleTool::pressed(const CaptureContext& context)
|
||||
void CircleTool::pressed(const CaptureContext& context)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
|
||||
@@ -27,38 +27,32 @@ CircleCountTool::CircleCountTool(QObject* parent)
|
||||
m_count = 0;
|
||||
}
|
||||
|
||||
QIcon
|
||||
CircleCountTool::icon(const QColor& background, bool inEditor) const
|
||||
QIcon CircleCountTool::icon(const QColor& background, bool inEditor) const
|
||||
{
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "circlecount-outline.svg");
|
||||
}
|
||||
QString
|
||||
CircleCountTool::name() const
|
||||
QString CircleCountTool::name() const
|
||||
{
|
||||
return tr("Circle Counter");
|
||||
}
|
||||
|
||||
ToolType
|
||||
CircleCountTool::nameID() const
|
||||
ToolType CircleCountTool::nameID() const
|
||||
{
|
||||
return ToolType::CIRCLECOUNT;
|
||||
}
|
||||
|
||||
QString
|
||||
CircleCountTool::description() const
|
||||
QString CircleCountTool::description() const
|
||||
{
|
||||
return tr("Add an autoincrementing counter bubble");
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
CircleCountTool::copy(QObject* parent)
|
||||
CaptureTool* CircleCountTool::copy(QObject* parent)
|
||||
{
|
||||
return new CircleCountTool(parent);
|
||||
}
|
||||
|
||||
void
|
||||
CircleCountTool::process(QPainter& painter,
|
||||
void CircleCountTool::process(QPainter& painter,
|
||||
const QPixmap& pixmap,
|
||||
bool recordUndo)
|
||||
{
|
||||
@@ -91,8 +85,8 @@ CircleCountTool::process(QPainter& painter,
|
||||
new_font.setPixelSize(fontSize);
|
||||
painter.setFont(new_font);
|
||||
|
||||
bRect =
|
||||
painter.boundingRect(textRect, Qt::AlignCenter, QString::number(m_count));
|
||||
bRect = painter.boundingRect(
|
||||
textRect, Qt::AlignCenter, QString::number(m_count));
|
||||
}
|
||||
|
||||
// Lightness value ranges from 0-255, we split at 75 as this looks best
|
||||
@@ -106,8 +100,7 @@ CircleCountTool::process(QPainter& painter,
|
||||
painter.setFont(orig_font);
|
||||
}
|
||||
|
||||
void
|
||||
CircleCountTool::paintMousePreview(QPainter& painter,
|
||||
void CircleCountTool::paintMousePreview(QPainter& painter,
|
||||
const CaptureContext& context)
|
||||
{
|
||||
m_thickness = context.thickness + PADDING_VALUE;
|
||||
@@ -123,8 +116,7 @@ CircleCountTool::paintMousePreview(QPainter& painter,
|
||||
{ context.mousePos.x() + 1, context.mousePos.y() + 1 });
|
||||
}
|
||||
|
||||
void
|
||||
CircleCountTool::drawStart(const CaptureContext& context)
|
||||
void CircleCountTool::drawStart(const CaptureContext& context)
|
||||
{
|
||||
m_color = context.color;
|
||||
m_thickness = context.thickness + PADDING_VALUE;
|
||||
@@ -136,8 +128,7 @@ CircleCountTool::drawStart(const CaptureContext& context)
|
||||
emit requestAction(REQ_INCREMENT_CIRCLE_COUNT);
|
||||
}
|
||||
|
||||
void
|
||||
CircleCountTool::pressed(const CaptureContext& context)
|
||||
void CircleCountTool::pressed(const CaptureContext& context)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
|
||||
@@ -23,44 +23,37 @@ CopyTool::CopyTool(QObject* parent)
|
||||
: AbstractActionTool(parent)
|
||||
{}
|
||||
|
||||
bool
|
||||
CopyTool::closeOnButtonPressed() const
|
||||
bool CopyTool::closeOnButtonPressed() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QIcon
|
||||
CopyTool::icon(const QColor& background, bool inEditor) const
|
||||
QIcon CopyTool::icon(const QColor& background, bool inEditor) const
|
||||
{
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "content-copy.svg");
|
||||
}
|
||||
QString
|
||||
CopyTool::name() const
|
||||
QString CopyTool::name() const
|
||||
{
|
||||
return tr("Copy");
|
||||
}
|
||||
|
||||
ToolType
|
||||
CopyTool::nameID() const
|
||||
ToolType CopyTool::nameID() const
|
||||
{
|
||||
return ToolType::COPY;
|
||||
}
|
||||
|
||||
QString
|
||||
CopyTool::description() const
|
||||
QString CopyTool::description() const
|
||||
{
|
||||
return tr("Copy the selection into the clipboard");
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
CopyTool::copy(QObject* parent)
|
||||
CaptureTool* CopyTool::copy(QObject* parent)
|
||||
{
|
||||
return new CopyTool(parent);
|
||||
}
|
||||
|
||||
void
|
||||
CopyTool::pressed(const CaptureContext& context)
|
||||
void CopyTool::pressed(const CaptureContext& context)
|
||||
{
|
||||
emit requestAction(REQ_CAPTURE_DONE_OK);
|
||||
ScreenshotSaver().saveToClipboard(context.selectedScreenshotArea());
|
||||
|
||||
@@ -22,44 +22,37 @@ ExitTool::ExitTool(QObject* parent)
|
||||
: AbstractActionTool(parent)
|
||||
{}
|
||||
|
||||
bool
|
||||
ExitTool::closeOnButtonPressed() const
|
||||
bool ExitTool::closeOnButtonPressed() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QIcon
|
||||
ExitTool::icon(const QColor& background, bool inEditor) const
|
||||
QIcon ExitTool::icon(const QColor& background, bool inEditor) const
|
||||
{
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "close.svg");
|
||||
}
|
||||
QString
|
||||
ExitTool::name() const
|
||||
QString ExitTool::name() const
|
||||
{
|
||||
return tr("Exit");
|
||||
}
|
||||
|
||||
ToolType
|
||||
ExitTool::nameID() const
|
||||
ToolType ExitTool::nameID() const
|
||||
{
|
||||
return ToolType::EXIT;
|
||||
}
|
||||
|
||||
QString
|
||||
ExitTool::description() const
|
||||
QString ExitTool::description() const
|
||||
{
|
||||
return tr("Leave the capture screen");
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
ExitTool::copy(QObject* parent)
|
||||
CaptureTool* ExitTool::copy(QObject* parent)
|
||||
{
|
||||
return new ExitTool(parent);
|
||||
}
|
||||
|
||||
void
|
||||
ExitTool::pressed(const CaptureContext& context)
|
||||
void ExitTool::pressed(const CaptureContext& context)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
emit requestAction(REQ_CLOSE_GUI);
|
||||
|
||||
@@ -71,8 +71,7 @@ ImgurUploader::ImgurUploader(const QPixmap& capture, QWidget* parent)
|
||||
// QTimer::singleShot(2000, this, &ImgurUploader::onUploadOk); // testing
|
||||
}
|
||||
|
||||
void
|
||||
ImgurUploader::handleReply(QNetworkReply* reply)
|
||||
void ImgurUploader::handleReply(QNetworkReply* reply)
|
||||
{
|
||||
m_spinner->deleteLater();
|
||||
if (reply->error() == QNetworkReply::NoError) {
|
||||
@@ -85,7 +84,8 @@ ImgurUploader::handleReply(QNetworkReply* reply)
|
||||
.arg(data[QStringLiteral("deletehash")].toString()));
|
||||
if (ConfigHandler().copyAndCloseAfterUploadEnabled()) {
|
||||
QApplication::clipboard()->setText(m_imageURL.toString());
|
||||
SystemNotification().sendMessage(QObject::tr("URL copied to clipboard."));
|
||||
SystemNotification().sendMessage(
|
||||
QObject::tr("URL copied to clipboard."));
|
||||
close();
|
||||
} else {
|
||||
onUploadOk();
|
||||
@@ -96,8 +96,7 @@ ImgurUploader::handleReply(QNetworkReply* reply)
|
||||
new QShortcut(Qt::Key_Escape, this, SLOT(close()));
|
||||
}
|
||||
|
||||
void
|
||||
ImgurUploader::startDrag()
|
||||
void ImgurUploader::startDrag()
|
||||
{
|
||||
QMimeData* mimeData = new QMimeData;
|
||||
mimeData->setUrls(QList<QUrl>{ m_imageURL });
|
||||
@@ -110,8 +109,7 @@ ImgurUploader::startDrag()
|
||||
dragHandler->exec();
|
||||
}
|
||||
|
||||
void
|
||||
ImgurUploader::upload()
|
||||
void ImgurUploader::upload()
|
||||
{
|
||||
QByteArray byteArray;
|
||||
QBuffer buffer(&byteArray);
|
||||
@@ -135,8 +133,7 @@ ImgurUploader::upload()
|
||||
m_NetworkAM->post(request, byteArray);
|
||||
}
|
||||
|
||||
void
|
||||
ImgurUploader::onUploadOk()
|
||||
void ImgurUploader::onUploadOk()
|
||||
{
|
||||
m_infoLabel->deleteLater();
|
||||
|
||||
@@ -176,8 +173,7 @@ ImgurUploader::onUploadOk()
|
||||
&ImgurUploader::copyImage);
|
||||
}
|
||||
|
||||
void
|
||||
ImgurUploader::openURL()
|
||||
void ImgurUploader::openURL()
|
||||
{
|
||||
bool successful = QDesktopServices::openUrl(m_imageURL);
|
||||
if (!successful) {
|
||||
@@ -185,15 +181,13 @@ ImgurUploader::openURL()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ImgurUploader::copyURL()
|
||||
void ImgurUploader::copyURL()
|
||||
{
|
||||
QApplication::clipboard()->setText(m_imageURL.toString());
|
||||
m_notification->showMessage(tr("URL copied to clipboard."));
|
||||
}
|
||||
|
||||
void
|
||||
ImgurUploader::openDeleteURL()
|
||||
void ImgurUploader::openDeleteURL()
|
||||
{
|
||||
bool successful = QDesktopServices::openUrl(m_deleteImageURL);
|
||||
if (!successful) {
|
||||
@@ -201,8 +195,7 @@ ImgurUploader::openDeleteURL()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ImgurUploader::copyImage()
|
||||
void ImgurUploader::copyImage()
|
||||
{
|
||||
QApplication::clipboard()->setPixmap(m_pixmap);
|
||||
m_notification->showMessage(tr("Screenshot copied to clipboard."));
|
||||
|
||||
@@ -23,50 +23,42 @@ ImgurUploaderTool::ImgurUploaderTool(QObject* parent)
|
||||
: AbstractActionTool(parent)
|
||||
{}
|
||||
|
||||
bool
|
||||
ImgurUploaderTool::closeOnButtonPressed() const
|
||||
bool ImgurUploaderTool::closeOnButtonPressed() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QIcon
|
||||
ImgurUploaderTool::icon(const QColor& background, bool inEditor) const
|
||||
QIcon ImgurUploaderTool::icon(const QColor& background, bool inEditor) const
|
||||
{
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "cloud-upload.svg");
|
||||
}
|
||||
QString
|
||||
ImgurUploaderTool::name() const
|
||||
QString ImgurUploaderTool::name() const
|
||||
{
|
||||
return tr("Image Uploader");
|
||||
}
|
||||
|
||||
ToolType
|
||||
ImgurUploaderTool::nameID() const
|
||||
ToolType ImgurUploaderTool::nameID() const
|
||||
{
|
||||
return ToolType::IMGUR;
|
||||
}
|
||||
|
||||
QString
|
||||
ImgurUploaderTool::description() const
|
||||
QString ImgurUploaderTool::description() const
|
||||
{
|
||||
return tr("Upload the selection to Imgur");
|
||||
}
|
||||
|
||||
QWidget*
|
||||
ImgurUploaderTool::widget()
|
||||
QWidget* ImgurUploaderTool::widget()
|
||||
{
|
||||
return new ImgurUploader(capture);
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
ImgurUploaderTool::copy(QObject* parent)
|
||||
CaptureTool* ImgurUploaderTool::copy(QObject* parent)
|
||||
{
|
||||
return new ImgurUploaderTool(parent);
|
||||
}
|
||||
|
||||
void
|
||||
ImgurUploaderTool::pressed(const CaptureContext& context)
|
||||
void ImgurUploaderTool::pressed(const CaptureContext& context)
|
||||
{
|
||||
capture = context.selectedScreenshotArea();
|
||||
emit requestAction(REQ_CAPTURE_DONE_OK);
|
||||
|
||||
@@ -22,50 +22,42 @@ AppLauncher::AppLauncher(QObject* parent)
|
||||
: AbstractActionTool(parent)
|
||||
{}
|
||||
|
||||
bool
|
||||
AppLauncher::closeOnButtonPressed() const
|
||||
bool AppLauncher::closeOnButtonPressed() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QIcon
|
||||
AppLauncher::icon(const QColor& background, bool inEditor) const
|
||||
QIcon AppLauncher::icon(const QColor& background, bool inEditor) const
|
||||
{
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "open_with.svg");
|
||||
}
|
||||
QString
|
||||
AppLauncher::name() const
|
||||
QString AppLauncher::name() const
|
||||
{
|
||||
return tr("App Launcher");
|
||||
}
|
||||
|
||||
ToolType
|
||||
AppLauncher::nameID() const
|
||||
ToolType AppLauncher::nameID() const
|
||||
{
|
||||
return ToolType::LAUNCHER;
|
||||
}
|
||||
|
||||
QString
|
||||
AppLauncher::description() const
|
||||
QString AppLauncher::description() const
|
||||
{
|
||||
return tr("Choose an app to open the capture");
|
||||
}
|
||||
|
||||
QWidget*
|
||||
AppLauncher::widget()
|
||||
QWidget* AppLauncher::widget()
|
||||
{
|
||||
return new AppLauncherWidget(capture);
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
AppLauncher::copy(QObject* parent)
|
||||
CaptureTool* AppLauncher::copy(QObject* parent)
|
||||
{
|
||||
return new AppLauncher(parent);
|
||||
}
|
||||
|
||||
void
|
||||
AppLauncher::pressed(const CaptureContext& context)
|
||||
void AppLauncher::pressed(const CaptureContext& context)
|
||||
{
|
||||
capture = context.selectedScreenshotArea();
|
||||
emit requestAction(REQ_CAPTURE_DONE_OK);
|
||||
|
||||
@@ -97,8 +97,7 @@ AppLauncherWidget::AppLauncherWidget(const QPixmap& p, QWidget* parent)
|
||||
m_lineEdit->setFocus();
|
||||
}
|
||||
|
||||
void
|
||||
AppLauncherWidget::launch(const QModelIndex& index)
|
||||
void AppLauncherWidget::launch(const QModelIndex& index)
|
||||
{
|
||||
if (!QFileInfo(m_tempFile).isReadable()) {
|
||||
m_tempFile =
|
||||
@@ -131,16 +130,14 @@ AppLauncherWidget::launch(const QModelIndex& index)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AppLauncherWidget::checkboxClicked(const bool enabled)
|
||||
void AppLauncherWidget::checkboxClicked(const bool enabled)
|
||||
{
|
||||
m_keepOpen = enabled;
|
||||
ConfigHandler().setKeepOpenAppLauncher(enabled);
|
||||
m_keepOpenCheckbox->setChecked(enabled);
|
||||
}
|
||||
|
||||
void
|
||||
AppLauncherWidget::searchChanged(const QString& text)
|
||||
void AppLauncherWidget::searchChanged(const QString& text)
|
||||
{
|
||||
if (text.isEmpty()) {
|
||||
m_filterList->hide();
|
||||
@@ -159,8 +156,8 @@ AppLauncherWidget::searchChanged(const QString& text)
|
||||
}
|
||||
const QVector<DesktopAppData>& appList = m_appsMap[cat];
|
||||
for (const DesktopAppData& app : appList) {
|
||||
if (!apps.contains(app) &&
|
||||
(app.name.contains(regexp) || app.description.contains(regexp))) {
|
||||
if (!apps.contains(app) && (app.name.contains(regexp) ||
|
||||
app.description.contains(regexp))) {
|
||||
apps.append(app);
|
||||
}
|
||||
}
|
||||
@@ -169,8 +166,7 @@ AppLauncherWidget::searchChanged(const QString& text)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AppLauncherWidget::initListWidget()
|
||||
void AppLauncherWidget::initListWidget()
|
||||
{
|
||||
m_tabWidget = new QTabWidget;
|
||||
const int size = GlobalValues::buttonBaseSize();
|
||||
@@ -199,8 +195,7 @@ AppLauncherWidget::initListWidget()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AppLauncherWidget::initAppMap()
|
||||
void AppLauncherWidget::initAppMap()
|
||||
{
|
||||
QStringList categories({ "AudioVideo",
|
||||
"Audio",
|
||||
@@ -235,8 +230,7 @@ AppLauncherWidget::initAppMap()
|
||||
m_appsMap.insert(QStringLiteral("Multimedia"), multimediaList);
|
||||
}
|
||||
|
||||
void
|
||||
AppLauncherWidget::configureListView(QListWidget* widget)
|
||||
void AppLauncherWidget::configureListView(QListWidget* widget)
|
||||
{
|
||||
widget->setItemDelegate(new LauncherItemDelegate());
|
||||
widget->setViewMode(QListWidget::IconMode);
|
||||
@@ -248,8 +242,8 @@ AppLauncherWidget::configureListView(QListWidget* widget)
|
||||
connect(widget, &QListWidget::clicked, this, &AppLauncherWidget::launch);
|
||||
}
|
||||
|
||||
void
|
||||
AppLauncherWidget::addAppsToListWidget(QListWidget* widget,
|
||||
void AppLauncherWidget::addAppsToListWidget(
|
||||
QListWidget* widget,
|
||||
const QVector<DesktopAppData>& appList)
|
||||
{
|
||||
for (const DesktopAppData& app : appList) {
|
||||
@@ -258,7 +252,8 @@ AppLauncherWidget::addAppsToListWidget(QListWidget* widget,
|
||||
buttonItem->setData(Qt::DisplayRole, app.name);
|
||||
buttonItem->setData(Qt::UserRole, app.exec);
|
||||
buttonItem->setData(Qt::UserRole + 1, app.showInTerminal);
|
||||
QColor foregroundColor = this->palette().color(QWidget::foregroundRole());
|
||||
QColor foregroundColor =
|
||||
this->palette().color(QWidget::foregroundRole());
|
||||
buttonItem->setForeground(foregroundColor);
|
||||
|
||||
buttonItem->setIcon(app.icon);
|
||||
|
||||
@@ -23,8 +23,7 @@ LauncherItemDelegate::LauncherItemDelegate(QObject* parent)
|
||||
: QStyledItemDelegate(parent)
|
||||
{}
|
||||
|
||||
void
|
||||
LauncherItemDelegate::paint(QPainter* painter,
|
||||
void LauncherItemDelegate::paint(QPainter* painter,
|
||||
const QStyleOptionViewItem& option,
|
||||
const QModelIndex& index) const
|
||||
{
|
||||
@@ -33,7 +32,8 @@ LauncherItemDelegate::paint(QPainter* painter,
|
||||
painter->save();
|
||||
painter->setPen(Qt::transparent);
|
||||
painter->setBrush(QPalette().highlight());
|
||||
painter->drawRect(rect.x(), rect.y(), rect.width() - 1, rect.height() - 1);
|
||||
painter->drawRect(
|
||||
rect.x(), rect.y(), rect.width() - 1, rect.height() - 1);
|
||||
painter->restore();
|
||||
}
|
||||
QIcon icon = index.data(Qt::DecorationRole).value<QIcon>();
|
||||
@@ -56,8 +56,7 @@ LauncherItemDelegate::paint(QPainter* painter,
|
||||
index.data(Qt::DisplayRole).toString());
|
||||
}
|
||||
|
||||
QSize
|
||||
LauncherItemDelegate::sizeHint(const QStyleOptionViewItem& option,
|
||||
QSize LauncherItemDelegate::sizeHint(const QStyleOptionViewItem& option,
|
||||
const QModelIndex& index) const
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
|
||||
@@ -33,8 +33,7 @@
|
||||
#include "src/tools/launcher/applauncherwidget.h"
|
||||
#endif
|
||||
|
||||
void
|
||||
showOpenWithMenu(const QPixmap& capture)
|
||||
void showOpenWithMenu(const QPixmap& capture)
|
||||
{
|
||||
#if defined(Q_OS_WIN)
|
||||
QString tempFile =
|
||||
@@ -43,7 +42,8 @@ showOpenWithMenu(const QPixmap& capture)
|
||||
if (!ok) {
|
||||
QMessageBox::about(nullptr,
|
||||
QObject::tr("Error"),
|
||||
QObject::tr("Unable to write in") + QDir::tempPath());
|
||||
QObject::tr("Unable to write in") +
|
||||
QDir::tempPath());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,5 +19,4 @@
|
||||
|
||||
#include <QPixmap>
|
||||
|
||||
void
|
||||
showOpenWithMenu(const QPixmap& capture);
|
||||
void showOpenWithMenu(const QPixmap& capture);
|
||||
|
||||
@@ -42,8 +42,7 @@ TerminalLauncher::TerminalLauncher(QObject* parent)
|
||||
: QObject(parent)
|
||||
{}
|
||||
|
||||
TerminalApp
|
||||
TerminalLauncher::getPreferedTerminal()
|
||||
TerminalApp TerminalLauncher::getPreferedTerminal()
|
||||
{
|
||||
TerminalApp res;
|
||||
for (const TerminalApp& app : terminalApps) {
|
||||
@@ -56,8 +55,7 @@ TerminalLauncher::getPreferedTerminal()
|
||||
return res;
|
||||
}
|
||||
|
||||
bool
|
||||
TerminalLauncher::launchDetached(const QString& command)
|
||||
bool TerminalLauncher::launchDetached(const QString& command)
|
||||
{
|
||||
TerminalApp app = getPreferedTerminal();
|
||||
QString s = app.name + " " + app.arg + " " + command;
|
||||
|
||||
@@ -31,38 +31,34 @@ LineTool::LineTool(QObject* parent)
|
||||
m_supportsDiagonalAdj = true;
|
||||
}
|
||||
|
||||
QIcon
|
||||
LineTool::icon(const QColor& background, bool inEditor) const
|
||||
QIcon LineTool::icon(const QColor& background, bool inEditor) const
|
||||
{
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "line.svg");
|
||||
}
|
||||
QString
|
||||
LineTool::name() const
|
||||
QString LineTool::name() const
|
||||
{
|
||||
return tr("Line");
|
||||
}
|
||||
|
||||
ToolType
|
||||
LineTool::nameID() const
|
||||
ToolType LineTool::nameID() const
|
||||
{
|
||||
return ToolType::LINE;
|
||||
}
|
||||
|
||||
QString
|
||||
LineTool::description() const
|
||||
QString LineTool::description() const
|
||||
{
|
||||
return tr("Set the Line as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
LineTool::copy(QObject* parent)
|
||||
CaptureTool* LineTool::copy(QObject* parent)
|
||||
{
|
||||
return new LineTool(parent);
|
||||
}
|
||||
|
||||
void
|
||||
LineTool::process(QPainter& painter, const QPixmap& pixmap, bool recordUndo)
|
||||
void LineTool::process(QPainter& painter,
|
||||
const QPixmap& pixmap,
|
||||
bool recordUndo)
|
||||
{
|
||||
if (recordUndo) {
|
||||
updateBackup(pixmap);
|
||||
@@ -71,15 +67,14 @@ LineTool::process(QPainter& painter, const QPixmap& pixmap, bool recordUndo)
|
||||
painter.drawLine(m_points.first, m_points.second);
|
||||
}
|
||||
|
||||
void
|
||||
LineTool::paintMousePreview(QPainter& painter, const CaptureContext& context)
|
||||
void LineTool::paintMousePreview(QPainter& painter,
|
||||
const CaptureContext& context)
|
||||
{
|
||||
painter.setPen(QPen(context.color, PADDING_VALUE + context.thickness));
|
||||
painter.drawLine(context.mousePos, context.mousePos);
|
||||
}
|
||||
|
||||
void
|
||||
LineTool::drawStart(const CaptureContext& context)
|
||||
void LineTool::drawStart(const CaptureContext& context)
|
||||
{
|
||||
m_color = context.color;
|
||||
m_thickness = context.thickness + PADDING_VALUE;
|
||||
@@ -87,8 +82,7 @@ LineTool::drawStart(const CaptureContext& context)
|
||||
m_points.second = context.mousePos;
|
||||
}
|
||||
|
||||
void
|
||||
LineTool::pressed(const CaptureContext& context)
|
||||
void LineTool::pressed(const CaptureContext& context)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
|
||||
@@ -31,38 +31,34 @@ MarkerTool::MarkerTool(QObject* parent)
|
||||
m_supportsDiagonalAdj = true;
|
||||
}
|
||||
|
||||
QIcon
|
||||
MarkerTool::icon(const QColor& background, bool inEditor) const
|
||||
QIcon MarkerTool::icon(const QColor& background, bool inEditor) const
|
||||
{
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "marker.svg");
|
||||
}
|
||||
QString
|
||||
MarkerTool::name() const
|
||||
QString MarkerTool::name() const
|
||||
{
|
||||
return tr("Marker");
|
||||
}
|
||||
|
||||
ToolType
|
||||
MarkerTool::nameID() const
|
||||
ToolType MarkerTool::nameID() const
|
||||
{
|
||||
return ToolType::MARKER;
|
||||
}
|
||||
|
||||
QString
|
||||
MarkerTool::description() const
|
||||
QString MarkerTool::description() const
|
||||
{
|
||||
return tr("Set the Marker as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
MarkerTool::copy(QObject* parent)
|
||||
CaptureTool* MarkerTool::copy(QObject* parent)
|
||||
{
|
||||
return new MarkerTool(parent);
|
||||
}
|
||||
|
||||
void
|
||||
MarkerTool::process(QPainter& painter, const QPixmap& pixmap, bool recordUndo)
|
||||
void MarkerTool::process(QPainter& painter,
|
||||
const QPixmap& pixmap,
|
||||
bool recordUndo)
|
||||
{
|
||||
if (recordUndo) {
|
||||
updateBackup(pixmap);
|
||||
@@ -73,8 +69,8 @@ MarkerTool::process(QPainter& painter, const QPixmap& pixmap, bool recordUndo)
|
||||
painter.drawLine(m_points.first, m_points.second);
|
||||
}
|
||||
|
||||
void
|
||||
MarkerTool::paintMousePreview(QPainter& painter, const CaptureContext& context)
|
||||
void MarkerTool::paintMousePreview(QPainter& painter,
|
||||
const CaptureContext& context)
|
||||
{
|
||||
painter.setCompositionMode(QPainter::CompositionMode_Multiply);
|
||||
painter.setOpacity(0.35);
|
||||
@@ -82,8 +78,7 @@ MarkerTool::paintMousePreview(QPainter& painter, const CaptureContext& context)
|
||||
painter.drawLine(context.mousePos, context.mousePos);
|
||||
}
|
||||
|
||||
void
|
||||
MarkerTool::drawStart(const CaptureContext& context)
|
||||
void MarkerTool::drawStart(const CaptureContext& context)
|
||||
{
|
||||
m_color = context.color;
|
||||
m_thickness = context.thickness + PADDING_VALUE;
|
||||
@@ -91,14 +86,12 @@ MarkerTool::drawStart(const CaptureContext& context)
|
||||
m_points.second = context.mousePos;
|
||||
}
|
||||
|
||||
void
|
||||
MarkerTool::pressed(const CaptureContext& context)
|
||||
void MarkerTool::pressed(const CaptureContext& context)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
|
||||
void
|
||||
MarkerTool::thicknessChanged(const int th)
|
||||
void MarkerTool::thicknessChanged(const int th)
|
||||
{
|
||||
m_thickness = th + PADDING_VALUE;
|
||||
}
|
||||
|
||||
@@ -22,44 +22,37 @@ MoveTool::MoveTool(QObject* parent)
|
||||
: AbstractActionTool(parent)
|
||||
{}
|
||||
|
||||
bool
|
||||
MoveTool::closeOnButtonPressed() const
|
||||
bool MoveTool::closeOnButtonPressed() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QIcon
|
||||
MoveTool::icon(const QColor& background, bool inEditor) const
|
||||
QIcon MoveTool::icon(const QColor& background, bool inEditor) const
|
||||
{
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "cursor-move.svg");
|
||||
}
|
||||
QString
|
||||
MoveTool::name() const
|
||||
QString MoveTool::name() const
|
||||
{
|
||||
return tr("Move");
|
||||
}
|
||||
|
||||
ToolType
|
||||
MoveTool::nameID() const
|
||||
ToolType MoveTool::nameID() const
|
||||
{
|
||||
return ToolType::MOVE;
|
||||
}
|
||||
|
||||
QString
|
||||
MoveTool::description() const
|
||||
QString MoveTool::description() const
|
||||
{
|
||||
return tr("Move the selection area");
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
MoveTool::copy(QObject* parent)
|
||||
CaptureTool* MoveTool::copy(QObject* parent)
|
||||
{
|
||||
return new MoveTool(parent);
|
||||
}
|
||||
|
||||
void
|
||||
MoveTool::pressed(const CaptureContext& context)
|
||||
void MoveTool::pressed(const CaptureContext& context)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
emit requestAction(REQ_MOVE_MODE);
|
||||
|
||||
@@ -22,38 +22,34 @@ PencilTool::PencilTool(QObject* parent)
|
||||
: AbstractPathTool(parent)
|
||||
{}
|
||||
|
||||
QIcon
|
||||
PencilTool::icon(const QColor& background, bool inEditor) const
|
||||
QIcon PencilTool::icon(const QColor& background, bool inEditor) const
|
||||
{
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "pencil.svg");
|
||||
}
|
||||
QString
|
||||
PencilTool::name() const
|
||||
QString PencilTool::name() const
|
||||
{
|
||||
return tr("Pencil");
|
||||
}
|
||||
|
||||
ToolType
|
||||
PencilTool::nameID() const
|
||||
ToolType PencilTool::nameID() const
|
||||
{
|
||||
return ToolType::PENCIL;
|
||||
}
|
||||
|
||||
QString
|
||||
PencilTool::description() const
|
||||
QString PencilTool::description() const
|
||||
{
|
||||
return tr("Set the Pencil as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
PencilTool::copy(QObject* parent)
|
||||
CaptureTool* PencilTool::copy(QObject* parent)
|
||||
{
|
||||
return new PencilTool(parent);
|
||||
}
|
||||
|
||||
void
|
||||
PencilTool::process(QPainter& painter, const QPixmap& pixmap, bool recordUndo)
|
||||
void PencilTool::process(QPainter& painter,
|
||||
const QPixmap& pixmap,
|
||||
bool recordUndo)
|
||||
{
|
||||
if (recordUndo) {
|
||||
updateBackup(pixmap);
|
||||
@@ -62,15 +58,14 @@ PencilTool::process(QPainter& painter, const QPixmap& pixmap, bool recordUndo)
|
||||
painter.drawPolyline(m_points.data(), m_points.size());
|
||||
}
|
||||
|
||||
void
|
||||
PencilTool::paintMousePreview(QPainter& painter, const CaptureContext& context)
|
||||
void PencilTool::paintMousePreview(QPainter& painter,
|
||||
const CaptureContext& context)
|
||||
{
|
||||
painter.setPen(QPen(context.color, context.thickness + 2));
|
||||
painter.drawLine(context.mousePos, context.mousePos);
|
||||
}
|
||||
|
||||
void
|
||||
PencilTool::drawStart(const CaptureContext& context)
|
||||
void PencilTool::drawStart(const CaptureContext& context)
|
||||
{
|
||||
m_color = context.color;
|
||||
m_thickness = context.thickness + 2;
|
||||
@@ -79,8 +74,7 @@ PencilTool::drawStart(const CaptureContext& context)
|
||||
m_backupArea.setBottomRight(context.mousePos);
|
||||
}
|
||||
|
||||
void
|
||||
PencilTool::pressed(const CaptureContext& context)
|
||||
void PencilTool::pressed(const CaptureContext& context)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
|
||||
@@ -22,38 +22,32 @@ PinTool::PinTool(QObject* parent)
|
||||
: AbstractActionTool(parent)
|
||||
{}
|
||||
|
||||
bool
|
||||
PinTool::closeOnButtonPressed() const
|
||||
bool PinTool::closeOnButtonPressed() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QIcon
|
||||
PinTool::icon(const QColor& background, bool inEditor) const
|
||||
QIcon PinTool::icon(const QColor& background, bool inEditor) const
|
||||
{
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "pin.svg");
|
||||
}
|
||||
QString
|
||||
PinTool::name() const
|
||||
QString PinTool::name() const
|
||||
{
|
||||
return tr("Pin Tool");
|
||||
}
|
||||
|
||||
ToolType
|
||||
PinTool::nameID() const
|
||||
ToolType PinTool::nameID() const
|
||||
{
|
||||
return ToolType::PIN;
|
||||
}
|
||||
|
||||
QString
|
||||
PinTool::description() const
|
||||
QString PinTool::description() const
|
||||
{
|
||||
return tr("Pin image on the desktop");
|
||||
}
|
||||
|
||||
QWidget*
|
||||
PinTool::widget()
|
||||
QWidget* PinTool::widget()
|
||||
{
|
||||
PinWidget* w = new PinWidget(m_pixmap);
|
||||
const int&& m = w->margin();
|
||||
@@ -62,14 +56,12 @@ PinTool::widget()
|
||||
return w;
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
PinTool::copy(QObject* parent)
|
||||
CaptureTool* PinTool::copy(QObject* parent)
|
||||
{
|
||||
return new PinTool(parent);
|
||||
}
|
||||
|
||||
void
|
||||
PinTool::pressed(const CaptureContext& context)
|
||||
void PinTool::pressed(const CaptureContext& context)
|
||||
{
|
||||
emit requestAction(REQ_CAPTURE_DONE_OK);
|
||||
m_geometry = context.selection;
|
||||
|
||||
@@ -53,14 +53,12 @@ PinWidget::PinWidget(const QPixmap& pixmap, QWidget* parent)
|
||||
new QShortcut(Qt::Key_Escape, this, SLOT(close()));
|
||||
}
|
||||
|
||||
int
|
||||
PinWidget::margin() const
|
||||
int PinWidget::margin() const
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
void
|
||||
PinWidget::wheelEvent(QWheelEvent* e)
|
||||
void PinWidget::wheelEvent(QWheelEvent* e)
|
||||
{
|
||||
int val = e->angleDelta().y() > 0 ? 15 : -15;
|
||||
int newWidth = qBound(50, m_label->width() + val, maximumWidth());
|
||||
@@ -73,33 +71,28 @@ PinWidget::wheelEvent(QWheelEvent* e)
|
||||
e->accept();
|
||||
}
|
||||
|
||||
void
|
||||
PinWidget::enterEvent(QEvent*)
|
||||
void PinWidget::enterEvent(QEvent*)
|
||||
{
|
||||
m_shadowEffect->setColor(m_hoverColor);
|
||||
}
|
||||
void
|
||||
PinWidget::leaveEvent(QEvent*)
|
||||
void PinWidget::leaveEvent(QEvent*)
|
||||
{
|
||||
m_shadowEffect->setColor(m_baseColor);
|
||||
}
|
||||
|
||||
void
|
||||
PinWidget::mouseDoubleClickEvent(QMouseEvent*)
|
||||
void PinWidget::mouseDoubleClickEvent(QMouseEvent*)
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void
|
||||
PinWidget::mousePressEvent(QMouseEvent* e)
|
||||
void PinWidget::mousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
m_dragStart = e->globalPos();
|
||||
m_offsetX = e->localPos().x() / width();
|
||||
m_offsetY = e->localPos().y() / height();
|
||||
}
|
||||
|
||||
void
|
||||
PinWidget::mouseMoveEvent(QMouseEvent* e)
|
||||
void PinWidget::mouseMoveEvent(QMouseEvent* e)
|
||||
{
|
||||
const QPoint delta = e->globalPos() - m_dragStart;
|
||||
int offsetW = width() * m_offsetX;
|
||||
@@ -108,8 +101,7 @@ PinWidget::mouseMoveEvent(QMouseEvent* e)
|
||||
m_dragStart.y() + delta.y() - offsetH);
|
||||
}
|
||||
|
||||
void
|
||||
PinWidget::setScaledPixmap(const QSize& size)
|
||||
void PinWidget::setScaledPixmap(const QSize& size)
|
||||
{
|
||||
const qreal scale = qApp->devicePixelRatio();
|
||||
QPixmap scaledPixmap = m_pixmap.scaled(
|
||||
|
||||
@@ -28,38 +28,34 @@ PixelateTool::PixelateTool(QObject* parent)
|
||||
: AbstractTwoPointTool(parent)
|
||||
{}
|
||||
|
||||
QIcon
|
||||
PixelateTool::icon(const QColor& background, bool inEditor) const
|
||||
QIcon PixelateTool::icon(const QColor& background, bool inEditor) const
|
||||
{
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "pixelate.svg");
|
||||
}
|
||||
QString
|
||||
PixelateTool::name() const
|
||||
QString PixelateTool::name() const
|
||||
{
|
||||
return tr("Pixelate");
|
||||
}
|
||||
|
||||
ToolType
|
||||
PixelateTool::nameID() const
|
||||
ToolType PixelateTool::nameID() const
|
||||
{
|
||||
return ToolType::PIXELATE;
|
||||
}
|
||||
|
||||
QString
|
||||
PixelateTool::description() const
|
||||
QString PixelateTool::description() const
|
||||
{
|
||||
return tr("Set Pixelate as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
PixelateTool::copy(QObject* parent)
|
||||
CaptureTool* PixelateTool::copy(QObject* parent)
|
||||
{
|
||||
return new PixelateTool(parent);
|
||||
}
|
||||
|
||||
void
|
||||
PixelateTool::process(QPainter& painter, const QPixmap& pixmap, bool recordUndo)
|
||||
void PixelateTool::process(QPainter& painter,
|
||||
const QPixmap& pixmap,
|
||||
bool recordUndo)
|
||||
{
|
||||
|
||||
if (recordUndo) {
|
||||
@@ -99,24 +95,21 @@ PixelateTool::process(QPainter& painter, const QPixmap& pixmap, bool recordUndo)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PixelateTool::paintMousePreview(QPainter& painter,
|
||||
void PixelateTool::paintMousePreview(QPainter& painter,
|
||||
const CaptureContext& context)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
Q_UNUSED(painter);
|
||||
}
|
||||
|
||||
void
|
||||
PixelateTool::drawStart(const CaptureContext& context)
|
||||
void PixelateTool::drawStart(const CaptureContext& context)
|
||||
{
|
||||
m_thickness = context.thickness;
|
||||
m_points.first = context.mousePos;
|
||||
m_points.second = context.mousePos;
|
||||
}
|
||||
|
||||
void
|
||||
PixelateTool::pressed(const CaptureContext& context)
|
||||
void PixelateTool::pressed(const CaptureContext& context)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
|
||||
@@ -28,38 +28,32 @@ RectangleTool::RectangleTool(QObject* parent)
|
||||
m_supportsDiagonalAdj = true;
|
||||
}
|
||||
|
||||
QIcon
|
||||
RectangleTool::icon(const QColor& background, bool inEditor) const
|
||||
QIcon RectangleTool::icon(const QColor& background, bool inEditor) const
|
||||
{
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "square.svg");
|
||||
}
|
||||
QString
|
||||
RectangleTool::name() const
|
||||
QString RectangleTool::name() const
|
||||
{
|
||||
return tr("Rectangle");
|
||||
}
|
||||
|
||||
ToolType
|
||||
RectangleTool::nameID() const
|
||||
ToolType RectangleTool::nameID() const
|
||||
{
|
||||
return ToolType::RECTANGLE;
|
||||
}
|
||||
|
||||
QString
|
||||
RectangleTool::description() const
|
||||
QString RectangleTool::description() const
|
||||
{
|
||||
return tr("Set the Rectangle as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
RectangleTool::copy(QObject* parent)
|
||||
CaptureTool* RectangleTool::copy(QObject* parent)
|
||||
{
|
||||
return new RectangleTool(parent);
|
||||
}
|
||||
|
||||
void
|
||||
RectangleTool::process(QPainter& painter,
|
||||
void RectangleTool::process(QPainter& painter,
|
||||
const QPixmap& pixmap,
|
||||
bool recordUndo)
|
||||
{
|
||||
@@ -71,16 +65,14 @@ RectangleTool::process(QPainter& painter,
|
||||
painter.drawRect(QRect(m_points.first, m_points.second));
|
||||
}
|
||||
|
||||
void
|
||||
RectangleTool::paintMousePreview(QPainter& painter,
|
||||
void RectangleTool::paintMousePreview(QPainter& painter,
|
||||
const CaptureContext& context)
|
||||
{
|
||||
painter.setPen(QPen(context.color, PADDING_VALUE + context.thickness));
|
||||
painter.drawLine(context.mousePos, context.mousePos);
|
||||
}
|
||||
|
||||
void
|
||||
RectangleTool::drawStart(const CaptureContext& context)
|
||||
void RectangleTool::drawStart(const CaptureContext& context)
|
||||
{
|
||||
m_color = context.color;
|
||||
m_thickness = context.thickness + PADDING_VALUE;
|
||||
@@ -88,8 +80,7 @@ RectangleTool::drawStart(const CaptureContext& context)
|
||||
m_points.second = context.mousePos;
|
||||
}
|
||||
|
||||
void
|
||||
RectangleTool::pressed(const CaptureContext& context)
|
||||
void RectangleTool::pressed(const CaptureContext& context)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
|
||||
@@ -22,44 +22,37 @@ RedoTool::RedoTool(QObject* parent)
|
||||
: AbstractActionTool(parent)
|
||||
{}
|
||||
|
||||
bool
|
||||
RedoTool::closeOnButtonPressed() const
|
||||
bool RedoTool::closeOnButtonPressed() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QIcon
|
||||
RedoTool::icon(const QColor& background, bool inEditor) const
|
||||
QIcon RedoTool::icon(const QColor& background, bool inEditor) const
|
||||
{
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "redo-variant.svg");
|
||||
}
|
||||
QString
|
||||
RedoTool::name() const
|
||||
QString RedoTool::name() const
|
||||
{
|
||||
return tr("Redo");
|
||||
}
|
||||
|
||||
ToolType
|
||||
RedoTool::nameID() const
|
||||
ToolType RedoTool::nameID() const
|
||||
{
|
||||
return ToolType::REDO;
|
||||
}
|
||||
|
||||
QString
|
||||
RedoTool::description() const
|
||||
QString RedoTool::description() const
|
||||
{
|
||||
return tr("Redo the next modification");
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
RedoTool::copy(QObject* parent)
|
||||
CaptureTool* RedoTool::copy(QObject* parent)
|
||||
{
|
||||
return new RedoTool(parent);
|
||||
}
|
||||
|
||||
void
|
||||
RedoTool::pressed(const CaptureContext& context)
|
||||
void RedoTool::pressed(const CaptureContext& context)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
emit requestAction(REQ_REDO_MODIFICATION);
|
||||
|
||||
@@ -23,49 +23,42 @@ SaveTool::SaveTool(QObject* parent)
|
||||
: AbstractActionTool(parent)
|
||||
{}
|
||||
|
||||
bool
|
||||
SaveTool::closeOnButtonPressed() const
|
||||
bool SaveTool::closeOnButtonPressed() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QIcon
|
||||
SaveTool::icon(const QColor& background, bool inEditor) const
|
||||
QIcon SaveTool::icon(const QColor& background, bool inEditor) const
|
||||
{
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "content-save.svg");
|
||||
}
|
||||
QString
|
||||
SaveTool::name() const
|
||||
QString SaveTool::name() const
|
||||
{
|
||||
return tr("Save");
|
||||
}
|
||||
|
||||
ToolType
|
||||
SaveTool::nameID() const
|
||||
ToolType SaveTool::nameID() const
|
||||
{
|
||||
return ToolType::SAVE;
|
||||
}
|
||||
|
||||
QString
|
||||
SaveTool::description() const
|
||||
QString SaveTool::description() const
|
||||
{
|
||||
return tr("Save the capture");
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
SaveTool::copy(QObject* parent)
|
||||
CaptureTool* SaveTool::copy(QObject* parent)
|
||||
{
|
||||
return new SaveTool(parent);
|
||||
}
|
||||
|
||||
void
|
||||
SaveTool::pressed(const CaptureContext& context)
|
||||
void SaveTool::pressed(const CaptureContext& context)
|
||||
{
|
||||
if (context.savePath.isEmpty()) {
|
||||
emit requestAction(REQ_HIDE_GUI);
|
||||
bool ok =
|
||||
ScreenshotSaver().saveToFilesystemGUI(context.selectedScreenshotArea());
|
||||
bool ok = ScreenshotSaver().saveToFilesystemGUI(
|
||||
context.selectedScreenshotArea());
|
||||
if (ok) {
|
||||
emit requestAction(REQ_CAPTURE_DONE_OK);
|
||||
}
|
||||
|
||||
@@ -28,44 +28,37 @@ SelectionTool::SelectionTool(QObject* parent)
|
||||
m_supportsDiagonalAdj = true;
|
||||
}
|
||||
|
||||
bool
|
||||
SelectionTool::closeOnButtonPressed() const
|
||||
bool SelectionTool::closeOnButtonPressed() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QIcon
|
||||
SelectionTool::icon(const QColor& background, bool inEditor) const
|
||||
QIcon SelectionTool::icon(const QColor& background, bool inEditor) const
|
||||
{
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "square-outline.svg");
|
||||
}
|
||||
QString
|
||||
SelectionTool::name() const
|
||||
QString SelectionTool::name() const
|
||||
{
|
||||
return tr("Rectangular Selection");
|
||||
}
|
||||
|
||||
ToolType
|
||||
SelectionTool::nameID() const
|
||||
ToolType SelectionTool::nameID() const
|
||||
{
|
||||
return ToolType::SELECTION;
|
||||
}
|
||||
|
||||
QString
|
||||
SelectionTool::description() const
|
||||
QString SelectionTool::description() const
|
||||
{
|
||||
return tr("Set Selection as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
SelectionTool::copy(QObject* parent)
|
||||
CaptureTool* SelectionTool::copy(QObject* parent)
|
||||
{
|
||||
return new SelectionTool(parent);
|
||||
}
|
||||
|
||||
void
|
||||
SelectionTool::process(QPainter& painter,
|
||||
void SelectionTool::process(QPainter& painter,
|
||||
const QPixmap& pixmap,
|
||||
bool recordUndo)
|
||||
{
|
||||
@@ -76,16 +69,14 @@ SelectionTool::process(QPainter& painter,
|
||||
painter.drawRect(QRect(m_points.first, m_points.second));
|
||||
}
|
||||
|
||||
void
|
||||
SelectionTool::paintMousePreview(QPainter& painter,
|
||||
void SelectionTool::paintMousePreview(QPainter& painter,
|
||||
const CaptureContext& context)
|
||||
{
|
||||
painter.setPen(QPen(context.color, PADDING_VALUE + context.thickness));
|
||||
painter.drawLine(context.mousePos, context.mousePos);
|
||||
}
|
||||
|
||||
void
|
||||
SelectionTool::drawStart(const CaptureContext& context)
|
||||
void SelectionTool::drawStart(const CaptureContext& context)
|
||||
{
|
||||
m_color = context.color;
|
||||
m_thickness = context.thickness + PADDING_VALUE;
|
||||
@@ -93,8 +84,7 @@ SelectionTool::drawStart(const CaptureContext& context)
|
||||
m_points.second = context.mousePos;
|
||||
}
|
||||
|
||||
void
|
||||
SelectionTool::pressed(const CaptureContext& context)
|
||||
void SelectionTool::pressed(const CaptureContext& context)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
|
||||
@@ -22,44 +22,37 @@ SizeIndicatorTool::SizeIndicatorTool(QObject* parent)
|
||||
: AbstractActionTool(parent)
|
||||
{}
|
||||
|
||||
bool
|
||||
SizeIndicatorTool::closeOnButtonPressed() const
|
||||
bool SizeIndicatorTool::closeOnButtonPressed() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QIcon
|
||||
SizeIndicatorTool::icon(const QColor& background, bool inEditor) const
|
||||
QIcon SizeIndicatorTool::icon(const QColor& background, bool inEditor) const
|
||||
{
|
||||
return inEditor ? QIcon()
|
||||
: QIcon(iconPath(background) + "size_indicator.svg");
|
||||
}
|
||||
QString
|
||||
SizeIndicatorTool::name() const
|
||||
QString SizeIndicatorTool::name() const
|
||||
{
|
||||
return tr("Selection Size Indicator");
|
||||
}
|
||||
|
||||
ToolType
|
||||
SizeIndicatorTool::nameID() const
|
||||
ToolType SizeIndicatorTool::nameID() const
|
||||
{
|
||||
return ToolType::SIZEINDICATOR;
|
||||
}
|
||||
|
||||
QString
|
||||
SizeIndicatorTool::description() const
|
||||
QString SizeIndicatorTool::description() const
|
||||
{
|
||||
return tr("Show the dimensions of the selection (X Y)");
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
SizeIndicatorTool::copy(QObject* parent)
|
||||
CaptureTool* SizeIndicatorTool::copy(QObject* parent)
|
||||
{
|
||||
return new SizeIndicatorTool(parent);
|
||||
}
|
||||
|
||||
void
|
||||
SizeIndicatorTool::pressed(const CaptureContext& context)
|
||||
void SizeIndicatorTool::pressed(const CaptureContext& context)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
|
||||
@@ -71,8 +71,8 @@ TextConfig::TextConfig(QWidget* parent)
|
||||
&TextConfig::weightButtonPressed);
|
||||
m_weightButton->setToolTip(tr("Bold"));
|
||||
|
||||
m_italicButton =
|
||||
new QPushButton(QIcon(iconPrefix + "format_italic.svg"), QLatin1String(""));
|
||||
m_italicButton = new QPushButton(QIcon(iconPrefix + "format_italic.svg"),
|
||||
QLatin1String(""));
|
||||
m_italicButton->setCheckable(true);
|
||||
connect(m_italicButton,
|
||||
&QPushButton::clicked,
|
||||
@@ -89,32 +89,27 @@ TextConfig::TextConfig(QWidget* parent)
|
||||
m_layout->addLayout(modifiersLayout);
|
||||
}
|
||||
|
||||
void
|
||||
TextConfig::setUnderline(const bool u)
|
||||
void TextConfig::setUnderline(const bool u)
|
||||
{
|
||||
m_underlineButton->setChecked(u);
|
||||
}
|
||||
|
||||
void
|
||||
TextConfig::setStrikeOut(const bool s)
|
||||
void TextConfig::setStrikeOut(const bool s)
|
||||
{
|
||||
m_strikeOutButton->setChecked(s);
|
||||
}
|
||||
|
||||
void
|
||||
TextConfig::setWeight(const int w)
|
||||
void TextConfig::setWeight(const int w)
|
||||
{
|
||||
m_weightButton->setChecked(static_cast<QFont::Weight>(w) == QFont::Bold);
|
||||
}
|
||||
|
||||
void
|
||||
TextConfig::setItalic(const bool i)
|
||||
void TextConfig::setItalic(const bool i)
|
||||
{
|
||||
m_italicButton->setChecked(i);
|
||||
}
|
||||
|
||||
void
|
||||
TextConfig::weightButtonPressed(const bool w)
|
||||
void TextConfig::weightButtonPressed(const bool w)
|
||||
{
|
||||
if (w) {
|
||||
emit fontWeightChanged(QFont::Bold);
|
||||
|
||||
@@ -26,57 +26,48 @@ TextTool::TextTool(QObject* parent)
|
||||
, m_size(1)
|
||||
{}
|
||||
|
||||
bool
|
||||
TextTool::isValid() const
|
||||
bool TextTool::isValid() const
|
||||
{
|
||||
return !m_text.isEmpty();
|
||||
}
|
||||
|
||||
bool
|
||||
TextTool::closeOnButtonPressed() const
|
||||
bool TextTool::closeOnButtonPressed() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
TextTool::isSelectable() const
|
||||
bool TextTool::isSelectable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TextTool::showMousePreview() const
|
||||
bool TextTool::showMousePreview() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QIcon
|
||||
TextTool::icon(const QColor& background, bool inEditor) const
|
||||
QIcon TextTool::icon(const QColor& background, bool inEditor) const
|
||||
{
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "text.svg");
|
||||
}
|
||||
|
||||
QString
|
||||
TextTool::name() const
|
||||
QString TextTool::name() const
|
||||
{
|
||||
return tr("Text");
|
||||
}
|
||||
|
||||
ToolType
|
||||
TextTool::nameID() const
|
||||
ToolType TextTool::nameID() const
|
||||
{
|
||||
return ToolType::TEXT;
|
||||
}
|
||||
|
||||
QString
|
||||
TextTool::description() const
|
||||
QString TextTool::description() const
|
||||
{
|
||||
return tr("Add text to your capture");
|
||||
}
|
||||
|
||||
QWidget*
|
||||
TextTool::widget()
|
||||
QWidget* TextTool::widget()
|
||||
{
|
||||
TextWidget* w = new TextWidget();
|
||||
w->setTextColor(m_color);
|
||||
@@ -87,14 +78,15 @@ TextTool::widget()
|
||||
return w;
|
||||
}
|
||||
|
||||
QWidget*
|
||||
TextTool::configurationWidget()
|
||||
QWidget* TextTool::configurationWidget()
|
||||
{
|
||||
m_confW = new TextConfig();
|
||||
connect(
|
||||
m_confW, &TextConfig::fontFamilyChanged, this, &TextTool::updateFamily);
|
||||
connect(
|
||||
m_confW, &TextConfig::fontItalicChanged, this, &TextTool::updateFontItalic);
|
||||
connect(m_confW,
|
||||
&TextConfig::fontItalicChanged,
|
||||
this,
|
||||
&TextTool::updateFontItalic);
|
||||
connect(m_confW,
|
||||
&TextConfig::fontStrikeOutChanged,
|
||||
this,
|
||||
@@ -103,8 +95,10 @@ TextTool::configurationWidget()
|
||||
&TextConfig::fontUnderlineChanged,
|
||||
this,
|
||||
&TextTool::updateFontUnderline);
|
||||
connect(
|
||||
m_confW, &TextConfig::fontWeightChanged, this, &TextTool::updateFontWeight);
|
||||
connect(m_confW,
|
||||
&TextConfig::fontWeightChanged,
|
||||
this,
|
||||
&TextTool::updateFontWeight);
|
||||
m_confW->setItalic(m_font.italic());
|
||||
m_confW->setUnderline(m_font.underline());
|
||||
m_confW->setStrikeOut(m_font.strikeOut());
|
||||
@@ -112,11 +106,11 @@ TextTool::configurationWidget()
|
||||
return m_confW;
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
TextTool::copy(QObject* parent)
|
||||
CaptureTool* TextTool::copy(QObject* parent)
|
||||
{
|
||||
TextTool* tt = new TextTool(parent);
|
||||
connect(m_confW, &TextConfig::fontFamilyChanged, tt, &TextTool::updateFamily);
|
||||
connect(
|
||||
m_confW, &TextConfig::fontFamilyChanged, tt, &TextTool::updateFamily);
|
||||
connect(
|
||||
m_confW, &TextConfig::fontItalicChanged, tt, &TextTool::updateFontItalic);
|
||||
connect(m_confW,
|
||||
@@ -133,15 +127,15 @@ TextTool::copy(QObject* parent)
|
||||
return tt;
|
||||
}
|
||||
|
||||
void
|
||||
TextTool::undo(QPixmap& pixmap)
|
||||
void TextTool::undo(QPixmap& pixmap)
|
||||
{
|
||||
QPainter p(&pixmap);
|
||||
p.drawPixmap(m_backupArea.topLeft(), m_pixmapBackup);
|
||||
}
|
||||
|
||||
void
|
||||
TextTool::process(QPainter& painter, const QPixmap& pixmap, bool recordUndo)
|
||||
void TextTool::process(QPainter& painter,
|
||||
const QPixmap& pixmap,
|
||||
bool recordUndo)
|
||||
{
|
||||
if (m_text.isEmpty()) {
|
||||
return;
|
||||
@@ -158,41 +152,36 @@ TextTool::process(QPainter& painter, const QPixmap& pixmap, bool recordUndo)
|
||||
painter.drawText(m_backupArea + QMargins(-5, -5, 5, 5), m_text);
|
||||
}
|
||||
|
||||
void
|
||||
TextTool::paintMousePreview(QPainter& painter, const CaptureContext& context)
|
||||
void TextTool::paintMousePreview(QPainter& painter,
|
||||
const CaptureContext& context)
|
||||
{
|
||||
Q_UNUSED(painter);
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
|
||||
void
|
||||
TextTool::drawEnd(const QPoint& p)
|
||||
void TextTool::drawEnd(const QPoint& p)
|
||||
{
|
||||
m_backupArea.moveTo(p);
|
||||
}
|
||||
|
||||
void
|
||||
TextTool::drawMove(const QPoint& p)
|
||||
void TextTool::drawMove(const QPoint& p)
|
||||
{
|
||||
m_widget->move(p);
|
||||
}
|
||||
|
||||
void
|
||||
TextTool::drawStart(const CaptureContext& context)
|
||||
void TextTool::drawStart(const CaptureContext& context)
|
||||
{
|
||||
m_color = context.color;
|
||||
m_size = context.thickness;
|
||||
emit requestAction(REQ_ADD_CHILD_WIDGET);
|
||||
}
|
||||
|
||||
void
|
||||
TextTool::pressed(const CaptureContext& context)
|
||||
void TextTool::pressed(const CaptureContext& context)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
|
||||
void
|
||||
TextTool::colorChanged(const QColor& c)
|
||||
void TextTool::colorChanged(const QColor& c)
|
||||
{
|
||||
m_color = c;
|
||||
if (m_widget) {
|
||||
@@ -200,8 +189,7 @@ TextTool::colorChanged(const QColor& c)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TextTool::thicknessChanged(const int th)
|
||||
void TextTool::thicknessChanged(const int th)
|
||||
{
|
||||
m_size = th;
|
||||
m_font.setPointSize(m_size + BASE_POINT_SIZE);
|
||||
@@ -210,14 +198,12 @@ TextTool::thicknessChanged(const int th)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TextTool::updateText(const QString& s)
|
||||
void TextTool::updateText(const QString& s)
|
||||
{
|
||||
m_text = s;
|
||||
}
|
||||
|
||||
void
|
||||
TextTool::setFont(const QFont& f)
|
||||
void TextTool::setFont(const QFont& f)
|
||||
{
|
||||
m_font = f;
|
||||
if (m_widget) {
|
||||
@@ -225,8 +211,7 @@ TextTool::setFont(const QFont& f)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TextTool::updateFamily(const QString& s)
|
||||
void TextTool::updateFamily(const QString& s)
|
||||
{
|
||||
m_font.setFamily(s);
|
||||
if (m_widget) {
|
||||
@@ -234,8 +219,7 @@ TextTool::updateFamily(const QString& s)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TextTool::updateFontUnderline(const bool underlined)
|
||||
void TextTool::updateFontUnderline(const bool underlined)
|
||||
{
|
||||
m_font.setUnderline(underlined);
|
||||
if (m_widget) {
|
||||
@@ -243,8 +227,7 @@ TextTool::updateFontUnderline(const bool underlined)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TextTool::updateFontStrikeOut(const bool s)
|
||||
void TextTool::updateFontStrikeOut(const bool s)
|
||||
{
|
||||
m_font.setStrikeOut(s);
|
||||
if (m_widget) {
|
||||
@@ -252,8 +235,7 @@ TextTool::updateFontStrikeOut(const bool s)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TextTool::updateFontWeight(const QFont::Weight w)
|
||||
void TextTool::updateFontWeight(const QFont::Weight w)
|
||||
{
|
||||
m_font.setWeight(w);
|
||||
if (m_widget) {
|
||||
@@ -261,8 +243,7 @@ TextTool::updateFontWeight(const QFont::Weight w)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TextTool::updateFontItalic(const bool italic)
|
||||
void TextTool::updateFontItalic(const bool italic)
|
||||
{
|
||||
m_font.setItalic(italic);
|
||||
if (m_widget) {
|
||||
|
||||
@@ -28,8 +28,7 @@ TextWidget::TextWidget(QWidget* parent)
|
||||
setContextMenuPolicy(Qt::NoContextMenu);
|
||||
}
|
||||
|
||||
void
|
||||
TextWidget::showEvent(QShowEvent* e)
|
||||
void TextWidget::showEvent(QShowEvent* e)
|
||||
{
|
||||
QFont font;
|
||||
QFontMetrics fm(font);
|
||||
@@ -41,45 +40,39 @@ TextWidget::showEvent(QShowEvent* e)
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void
|
||||
TextWidget::resizeEvent(QResizeEvent* e)
|
||||
void TextWidget::resizeEvent(QResizeEvent* e)
|
||||
{
|
||||
m_minSize.setHeight(qMin(m_baseSize.height(), height()));
|
||||
m_minSize.setWidth(qMin(m_baseSize.width(), width()));
|
||||
QTextEdit::resizeEvent(e);
|
||||
}
|
||||
|
||||
void
|
||||
TextWidget::setFont(const QFont& f)
|
||||
void TextWidget::setFont(const QFont& f)
|
||||
{
|
||||
QTextEdit::setFont(f);
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void
|
||||
TextWidget::updateFont(const QFont& f)
|
||||
void TextWidget::updateFont(const QFont& f)
|
||||
{
|
||||
setFont(f);
|
||||
}
|
||||
|
||||
void
|
||||
TextWidget::setFontPointSize(qreal s)
|
||||
void TextWidget::setFontPointSize(qreal s)
|
||||
{
|
||||
QFont f = font();
|
||||
f.setPointSize(s);
|
||||
setFont(f);
|
||||
}
|
||||
|
||||
void
|
||||
TextWidget::setTextColor(const QColor& c)
|
||||
void TextWidget::setTextColor(const QColor& c)
|
||||
{
|
||||
QString s(
|
||||
QStringLiteral("TextWidget { background: transparent; color: %1; }"));
|
||||
setStyleSheet(s.arg(c.name()));
|
||||
}
|
||||
|
||||
void
|
||||
TextWidget::adjustSize()
|
||||
void TextWidget::adjustSize()
|
||||
{
|
||||
QString&& text = this->toPlainText();
|
||||
|
||||
@@ -97,8 +90,7 @@ TextWidget::adjustSize()
|
||||
this->setFixedSize(pixelsWide, pixelsHigh);
|
||||
}
|
||||
|
||||
void
|
||||
TextWidget::emitTextUpdated()
|
||||
void TextWidget::emitTextUpdated()
|
||||
{
|
||||
emit textUpdated(this->toPlainText());
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ ToolFactory::ToolFactory(QObject* parent)
|
||||
: QObject(parent)
|
||||
{}
|
||||
|
||||
CaptureTool*
|
||||
ToolFactory::CreateTool(CaptureToolButton::ButtonType t, QObject* parent)
|
||||
CaptureTool* ToolFactory::CreateTool(CaptureToolButton::ButtonType t,
|
||||
QObject* parent)
|
||||
{
|
||||
CaptureTool* tool;
|
||||
switch (t) {
|
||||
|
||||
@@ -22,44 +22,37 @@ UndoTool::UndoTool(QObject* parent)
|
||||
: AbstractActionTool(parent)
|
||||
{}
|
||||
|
||||
bool
|
||||
UndoTool::closeOnButtonPressed() const
|
||||
bool UndoTool::closeOnButtonPressed() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QIcon
|
||||
UndoTool::icon(const QColor& background, bool inEditor) const
|
||||
QIcon UndoTool::icon(const QColor& background, bool inEditor) const
|
||||
{
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "undo-variant.svg");
|
||||
}
|
||||
QString
|
||||
UndoTool::name() const
|
||||
QString UndoTool::name() const
|
||||
{
|
||||
return tr("Undo");
|
||||
}
|
||||
|
||||
ToolType
|
||||
UndoTool::nameID() const
|
||||
ToolType UndoTool::nameID() const
|
||||
{
|
||||
return ToolType::UNDO;
|
||||
}
|
||||
|
||||
QString
|
||||
UndoTool::description() const
|
||||
QString UndoTool::description() const
|
||||
{
|
||||
return tr("Undo the last modification");
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
UndoTool::copy(QObject* parent)
|
||||
CaptureTool* UndoTool::copy(QObject* parent)
|
||||
{
|
||||
return new UndoTool(parent);
|
||||
}
|
||||
|
||||
void
|
||||
UndoTool::pressed(const CaptureContext& context)
|
||||
void UndoTool::pressed(const CaptureContext& context)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
emit requestAction(REQ_UNDO_MODIFICATION);
|
||||
|
||||
@@ -17,14 +17,12 @@
|
||||
|
||||
#include "colorutils.h"
|
||||
|
||||
inline qreal
|
||||
getColorLuma(const QColor& c)
|
||||
inline qreal getColorLuma(const QColor& c)
|
||||
{
|
||||
return 0.30 * c.redF() + 0.59 * c.greenF() + 0.11 * c.blueF();
|
||||
}
|
||||
|
||||
bool
|
||||
ColorUtils::colorIsDark(const QColor& c)
|
||||
bool ColorUtils::colorIsDark(const QColor& c)
|
||||
{
|
||||
bool isWhite = false;
|
||||
if (getColorLuma(c) <= 0.60) {
|
||||
@@ -33,8 +31,7 @@ ColorUtils::colorIsDark(const QColor& c)
|
||||
return isWhite;
|
||||
}
|
||||
|
||||
QColor
|
||||
ColorUtils::contrastColor(const QColor& c)
|
||||
QColor ColorUtils::contrastColor(const QColor& c)
|
||||
{
|
||||
int change = colorIsDark(c) ? 30 : -45;
|
||||
|
||||
|
||||
@@ -21,10 +21,8 @@
|
||||
|
||||
namespace ColorUtils { // namespace
|
||||
|
||||
bool
|
||||
colorIsDark(const QColor& c);
|
||||
bool colorIsDark(const QColor& c);
|
||||
|
||||
QColor
|
||||
contrastColor(const QColor& c);
|
||||
QColor contrastColor(const QColor& c);
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -26,8 +26,7 @@ ConfigHandler::ConfigHandler()
|
||||
m_settings.setDefaultFormat(QSettings::IniFormat);
|
||||
}
|
||||
|
||||
QVector<CaptureToolButton::ButtonType>
|
||||
ConfigHandler::getButtons()
|
||||
QVector<CaptureToolButton::ButtonType> ConfigHandler::getButtons()
|
||||
{
|
||||
QVector<CaptureToolButton::ButtonType> buttons;
|
||||
if (m_settings.contains(QStringLiteral("buttons"))) {
|
||||
@@ -43,11 +42,13 @@ ConfigHandler::getButtons()
|
||||
buttons = fromIntToButton(buttonsInt);
|
||||
} else {
|
||||
// Default tools
|
||||
buttons << CaptureToolButton::TYPE_PENCIL << CaptureToolButton::TYPE_DRAWER
|
||||
buttons << CaptureToolButton::TYPE_PENCIL
|
||||
<< CaptureToolButton::TYPE_DRAWER
|
||||
<< CaptureToolButton::TYPE_ARROW
|
||||
<< CaptureToolButton::TYPE_SELECTION
|
||||
<< CaptureToolButton::TYPE_RECTANGLE
|
||||
<< CaptureToolButton::TYPE_CIRCLE << CaptureToolButton::TYPE_MARKER
|
||||
<< CaptureToolButton::TYPE_CIRCLE
|
||||
<< CaptureToolButton::TYPE_MARKER
|
||||
<< CaptureToolButton::TYPE_PIXELATE
|
||||
<< CaptureToolButton::TYPE_SELECTIONINDICATOR
|
||||
<< CaptureToolButton::TYPE_MOVESELECTION
|
||||
@@ -55,8 +56,8 @@ ConfigHandler::getButtons()
|
||||
<< CaptureToolButton::TYPE_COPY << CaptureToolButton::TYPE_SAVE
|
||||
<< CaptureToolButton::TYPE_EXIT
|
||||
<< CaptureToolButton::TYPE_IMAGEUPLOADER
|
||||
<< CaptureToolButton::TYPE_OPEN_APP << CaptureToolButton::TYPE_PIN
|
||||
<< CaptureToolButton::TYPE_TEXT
|
||||
<< CaptureToolButton::TYPE_OPEN_APP
|
||||
<< CaptureToolButton::TYPE_PIN << CaptureToolButton::TYPE_TEXT
|
||||
<< CaptureToolButton::TYPE_CIRCLECOUNT;
|
||||
}
|
||||
|
||||
@@ -68,8 +69,8 @@ ConfigHandler::getButtons()
|
||||
return buttons;
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setButtons(const QVector<CaptureToolButton::ButtonType>& buttons)
|
||||
void ConfigHandler::setButtons(
|
||||
const QVector<CaptureToolButton::ButtonType>& buttons)
|
||||
{
|
||||
QVector<int> l = fromButtonToInt(buttons);
|
||||
normalizeButtons(l);
|
||||
@@ -78,8 +79,7 @@ ConfigHandler::setButtons(const QVector<CaptureToolButton::ButtonType>& buttons)
|
||||
QVariant::fromValue(l.toList()));
|
||||
}
|
||||
|
||||
QVector<QColor>
|
||||
ConfigHandler::getUserColors()
|
||||
QVector<QColor> ConfigHandler::getUserColors()
|
||||
{
|
||||
QVector<QColor> colors;
|
||||
const QVector<QColor>& defaultColors = {
|
||||
@@ -105,8 +105,7 @@ ConfigHandler::getUserColors()
|
||||
return colors;
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setUserColors(const QVector<QColor>& l)
|
||||
void ConfigHandler::setUserColors(const QVector<QColor>& l)
|
||||
{
|
||||
QStringList hexColors;
|
||||
|
||||
@@ -118,20 +117,17 @@ ConfigHandler::setUserColors(const QVector<QColor>& l)
|
||||
QVariant::fromValue(hexColors));
|
||||
}
|
||||
|
||||
QString
|
||||
ConfigHandler::savePathValue()
|
||||
QString ConfigHandler::savePathValue()
|
||||
{
|
||||
return m_settings.value(QStringLiteral("savePath")).toString();
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setSavePath(const QString& savePath)
|
||||
void ConfigHandler::setSavePath(const QString& savePath)
|
||||
{
|
||||
m_settings.setValue(QStringLiteral("savePath"), savePath);
|
||||
}
|
||||
|
||||
QColor
|
||||
ConfigHandler::uiMainColorValue()
|
||||
QColor ConfigHandler::uiMainColorValue()
|
||||
{
|
||||
QColor res = QColor(116, 0, 150);
|
||||
|
||||
@@ -145,14 +141,12 @@ ConfigHandler::uiMainColorValue()
|
||||
return res;
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setUIMainColor(const QColor& c)
|
||||
void ConfigHandler::setUIMainColor(const QColor& c)
|
||||
{
|
||||
m_settings.setValue(QStringLiteral("uiColor"), c.name());
|
||||
}
|
||||
|
||||
QColor
|
||||
ConfigHandler::uiContrastColorValue()
|
||||
QColor ConfigHandler::uiContrastColorValue()
|
||||
{
|
||||
QColor res = QColor(86, 0, 120);
|
||||
|
||||
@@ -168,14 +162,12 @@ ConfigHandler::uiContrastColorValue()
|
||||
return res;
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setUIContrastColor(const QColor& c)
|
||||
void ConfigHandler::setUIContrastColor(const QColor& c)
|
||||
{
|
||||
m_settings.setValue(QStringLiteral("contrastUiColor"), c.name());
|
||||
}
|
||||
|
||||
QColor
|
||||
ConfigHandler::drawColorValue()
|
||||
QColor ConfigHandler::drawColorValue()
|
||||
{
|
||||
QColor res(Qt::red);
|
||||
|
||||
@@ -190,14 +182,12 @@ ConfigHandler::drawColorValue()
|
||||
return res;
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setDrawColor(const QColor& c)
|
||||
void ConfigHandler::setDrawColor(const QColor& c)
|
||||
{
|
||||
m_settings.setValue(QStringLiteral("drawColor"), c.name());
|
||||
}
|
||||
|
||||
bool
|
||||
ConfigHandler::showHelpValue()
|
||||
bool ConfigHandler::showHelpValue()
|
||||
{
|
||||
bool res = true;
|
||||
if (m_settings.contains(QStringLiteral("showHelp"))) {
|
||||
@@ -206,56 +196,50 @@ ConfigHandler::showHelpValue()
|
||||
return res;
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setShowHelp(const bool showHelp)
|
||||
void ConfigHandler::setShowHelp(const bool showHelp)
|
||||
{
|
||||
m_settings.setValue(QStringLiteral("showHelp"), showHelp);
|
||||
}
|
||||
|
||||
bool
|
||||
ConfigHandler::showSidePanelButtonValue()
|
||||
bool ConfigHandler::showSidePanelButtonValue()
|
||||
{
|
||||
return m_settings.value(QStringLiteral("showSidePanelButton"), true).toBool();
|
||||
return m_settings.value(QStringLiteral("showSidePanelButton"), true)
|
||||
.toBool();
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setShowSidePanelButton(const bool showSidePanelButton)
|
||||
void ConfigHandler::setShowSidePanelButton(const bool showSidePanelButton)
|
||||
{
|
||||
m_settings.setValue(QStringLiteral("showSidePanelButton"),
|
||||
showSidePanelButton);
|
||||
}
|
||||
|
||||
bool
|
||||
ConfigHandler::desktopNotificationValue()
|
||||
bool ConfigHandler::desktopNotificationValue()
|
||||
{
|
||||
bool res = true;
|
||||
if (m_settings.contains(QStringLiteral("showDesktopNotification"))) {
|
||||
res = m_settings.value(QStringLiteral("showDesktopNotification")).toBool();
|
||||
res =
|
||||
m_settings.value(QStringLiteral("showDesktopNotification")).toBool();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setDesktopNotification(const bool showDesktopNotification)
|
||||
void ConfigHandler::setDesktopNotification(const bool showDesktopNotification)
|
||||
{
|
||||
m_settings.setValue(QStringLiteral("showDesktopNotification"),
|
||||
showDesktopNotification);
|
||||
}
|
||||
|
||||
QString
|
||||
ConfigHandler::filenamePatternValue()
|
||||
QString ConfigHandler::filenamePatternValue()
|
||||
{
|
||||
return m_settings.value(QStringLiteral("filenamePattern")).toString();
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setFilenamePattern(const QString& pattern)
|
||||
void ConfigHandler::setFilenamePattern(const QString& pattern)
|
||||
{
|
||||
return m_settings.setValue(QStringLiteral("filenamePattern"), pattern);
|
||||
}
|
||||
|
||||
bool
|
||||
ConfigHandler::disabledTrayIconValue()
|
||||
bool ConfigHandler::disabledTrayIconValue()
|
||||
{
|
||||
bool res = false;
|
||||
if (m_settings.contains(QStringLiteral("disabledTrayIcon"))) {
|
||||
@@ -264,14 +248,12 @@ ConfigHandler::disabledTrayIconValue()
|
||||
return res;
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setDisabledTrayIcon(const bool disabledTrayIcon)
|
||||
void ConfigHandler::setDisabledTrayIcon(const bool disabledTrayIcon)
|
||||
{
|
||||
m_settings.setValue(QStringLiteral("disabledTrayIcon"), disabledTrayIcon);
|
||||
}
|
||||
|
||||
int
|
||||
ConfigHandler::drawThicknessValue()
|
||||
int ConfigHandler::drawThicknessValue()
|
||||
{
|
||||
int res = 0;
|
||||
if (m_settings.contains(QStringLiteral("drawThickness"))) {
|
||||
@@ -280,26 +262,22 @@ ConfigHandler::drawThicknessValue()
|
||||
return res;
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setdrawThickness(const int thickness)
|
||||
void ConfigHandler::setdrawThickness(const int thickness)
|
||||
{
|
||||
m_settings.setValue(QStringLiteral("drawThickness"), thickness);
|
||||
}
|
||||
|
||||
bool
|
||||
ConfigHandler::keepOpenAppLauncherValue()
|
||||
bool ConfigHandler::keepOpenAppLauncherValue()
|
||||
{
|
||||
return m_settings.value(QStringLiteral("keepOpenAppLauncher")).toBool();
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setKeepOpenAppLauncher(const bool keepOpen)
|
||||
void ConfigHandler::setKeepOpenAppLauncher(const bool keepOpen)
|
||||
{
|
||||
m_settings.setValue(QStringLiteral("keepOpenAppLauncher"), keepOpen);
|
||||
}
|
||||
|
||||
bool
|
||||
ConfigHandler::startupLaunchValue()
|
||||
bool ConfigHandler::startupLaunchValue()
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
@@ -314,8 +292,7 @@ ConfigHandler::startupLaunchValue()
|
||||
return res;
|
||||
}
|
||||
|
||||
bool
|
||||
ConfigHandler::verifyLaunchFile()
|
||||
bool ConfigHandler::verifyLaunchFile()
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
@@ -332,8 +309,7 @@ ConfigHandler::verifyLaunchFile()
|
||||
return res;
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setStartupLaunch(const bool start)
|
||||
void ConfigHandler::setStartupLaunch(const bool start)
|
||||
{
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
|
||||
QString path = QDir::homePath() + "/.config/autostart/";
|
||||
@@ -368,8 +344,7 @@ ConfigHandler::setStartupLaunch(const bool start)
|
||||
m_settings.setValue(QStringLiteral("startupLaunch"), start);
|
||||
}
|
||||
|
||||
int
|
||||
ConfigHandler::contrastOpacityValue()
|
||||
int ConfigHandler::contrastOpacityValue()
|
||||
{
|
||||
int opacity = 190;
|
||||
if (m_settings.contains(QStringLiteral("contrastOpacity"))) {
|
||||
@@ -379,67 +354,56 @@ ConfigHandler::contrastOpacityValue()
|
||||
return opacity;
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setContrastOpacity(const int transparency)
|
||||
void ConfigHandler::setContrastOpacity(const int transparency)
|
||||
{
|
||||
m_settings.setValue(QStringLiteral("contrastOpacity"), transparency);
|
||||
}
|
||||
|
||||
bool
|
||||
ConfigHandler::closeAfterScreenshotValue()
|
||||
bool ConfigHandler::closeAfterScreenshotValue()
|
||||
{
|
||||
return m_settings.value(QStringLiteral("closeAfterScreenshot")).toBool();
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setCloseAfterScreenshot(const bool close)
|
||||
void ConfigHandler::setCloseAfterScreenshot(const bool close)
|
||||
{
|
||||
m_settings.setValue(QStringLiteral("closeAfterScreenshot"), close);
|
||||
}
|
||||
|
||||
bool
|
||||
ConfigHandler::copyAndCloseAfterUploadEnabled()
|
||||
bool ConfigHandler::copyAndCloseAfterUploadEnabled()
|
||||
{
|
||||
return m_settings.value(QStringLiteral("copyAndCloseAfterUpload")).toBool();
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setCopyAndCloseAfterUploadEnabled(const bool value)
|
||||
void ConfigHandler::setCopyAndCloseAfterUploadEnabled(const bool value)
|
||||
{
|
||||
m_settings.setValue(QStringLiteral("copyAndCloseAfterUpload"), value);
|
||||
}
|
||||
bool
|
||||
ConfigHandler::saveAfterCopyValue()
|
||||
bool ConfigHandler::saveAfterCopyValue()
|
||||
{
|
||||
return m_settings.value(QStringLiteral("saveAfterCopy")).toBool();
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setSaveAfterCopy(const bool save)
|
||||
void ConfigHandler::setSaveAfterCopy(const bool save)
|
||||
{
|
||||
m_settings.setValue(QStringLiteral("saveAfterCopy"), save);
|
||||
}
|
||||
|
||||
QString
|
||||
ConfigHandler::saveAfterCopyPathValue()
|
||||
QString ConfigHandler::saveAfterCopyPathValue()
|
||||
{
|
||||
return m_settings.value(QStringLiteral("saveAfterCopyPath")).toString();
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setSaveAfterCopyPath(const QString& path)
|
||||
void ConfigHandler::setSaveAfterCopyPath(const QString& path)
|
||||
{
|
||||
m_settings.setValue(QStringLiteral("saveAfterCopyPath"), path);
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setDefaults()
|
||||
void ConfigHandler::setDefaults()
|
||||
{
|
||||
m_settings.clear();
|
||||
}
|
||||
|
||||
void
|
||||
ConfigHandler::setAllTheButtons()
|
||||
void ConfigHandler::setAllTheButtons()
|
||||
{
|
||||
QVector<int> buttons;
|
||||
auto listTypes = CaptureToolButton::getIterableButtonTypes();
|
||||
@@ -451,14 +415,12 @@ ConfigHandler::setAllTheButtons()
|
||||
QVariant::fromValue(buttons.toList()));
|
||||
}
|
||||
|
||||
QString
|
||||
ConfigHandler::configFilePath() const
|
||||
QString ConfigHandler::configFilePath() const
|
||||
{
|
||||
return m_settings.fileName();
|
||||
}
|
||||
|
||||
bool
|
||||
ConfigHandler::normalizeButtons(QVector<int>& buttons)
|
||||
bool ConfigHandler::normalizeButtons(QVector<int>& buttons)
|
||||
{
|
||||
auto listTypes = CaptureToolButton::getIterableButtonTypes();
|
||||
QVector<int> listTypesInt;
|
||||
@@ -475,8 +437,8 @@ ConfigHandler::normalizeButtons(QVector<int>& buttons)
|
||||
return hasChanged;
|
||||
}
|
||||
|
||||
QVector<CaptureToolButton::ButtonType>
|
||||
ConfigHandler::fromIntToButton(const QVector<int>& l)
|
||||
QVector<CaptureToolButton::ButtonType> ConfigHandler::fromIntToButton(
|
||||
const QVector<int>& l)
|
||||
{
|
||||
QVector<CaptureToolButton::ButtonType> buttons;
|
||||
for (auto const i : l)
|
||||
@@ -484,8 +446,8 @@ ConfigHandler::fromIntToButton(const QVector<int>& l)
|
||||
return buttons;
|
||||
}
|
||||
|
||||
QVector<int>
|
||||
ConfigHandler::fromButtonToInt(const QVector<CaptureToolButton::ButtonType>& l)
|
||||
QVector<int> ConfigHandler::fromButtonToInt(
|
||||
const QVector<CaptureToolButton::ButtonType>& l)
|
||||
{
|
||||
QVector<int> buttons;
|
||||
for (auto const i : l)
|
||||
|
||||
@@ -93,6 +93,8 @@ private:
|
||||
|
||||
bool normalizeButtons(QVector<int>&);
|
||||
|
||||
QVector<CaptureToolButton::ButtonType> fromIntToButton(const QVector<int>& l);
|
||||
QVector<int> fromButtonToInt(const QVector<CaptureToolButton::ButtonType>& l);
|
||||
QVector<CaptureToolButton::ButtonType> fromIntToButton(
|
||||
const QVector<int>& l);
|
||||
QVector<int> fromButtonToInt(
|
||||
const QVector<CaptureToolButton::ButtonType>& l);
|
||||
};
|
||||
|
||||
@@ -25,8 +25,7 @@ DBusUtils::DBusUtils(QObject* parent)
|
||||
: QObject(parent)
|
||||
{}
|
||||
|
||||
void
|
||||
DBusUtils::connectPrintCapture(QDBusConnection& session, uint id)
|
||||
void DBusUtils::connectPrintCapture(QDBusConnection& session, uint id)
|
||||
{
|
||||
m_id = id;
|
||||
// captureTaken
|
||||
@@ -45,8 +44,7 @@ DBusUtils::connectPrintCapture(QDBusConnection& session, uint id)
|
||||
SLOT(captureFailed(uint)));
|
||||
}
|
||||
|
||||
void
|
||||
DBusUtils::checkDBusConnection(const QDBusConnection& connection)
|
||||
void DBusUtils::checkDBusConnection(const QDBusConnection& connection)
|
||||
{
|
||||
if (!connection.isConnected()) {
|
||||
SystemNotification().sendMessage(tr("Unable to connect via DBus"));
|
||||
@@ -54,8 +52,7 @@ DBusUtils::checkDBusConnection(const QDBusConnection& connection)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DBusUtils::captureTaken(uint id, QByteArray rawImage)
|
||||
void DBusUtils::captureTaken(uint id, QByteArray rawImage)
|
||||
{
|
||||
if (m_id == id) {
|
||||
QFile file;
|
||||
@@ -66,8 +63,7 @@ DBusUtils::captureTaken(uint id, QByteArray rawImage)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DBusUtils::captureFailed(uint id)
|
||||
void DBusUtils::captureFailed(uint id)
|
||||
{
|
||||
if (m_id == id) {
|
||||
QTextStream(stdout) << "screenshot aborted\n";
|
||||
|
||||
@@ -30,11 +30,12 @@ DesktopFileParser::DesktopFileParser()
|
||||
m_localeDescription = QStringLiteral("Comment[%1]").arg(locale);
|
||||
m_localeNameShort = QStringLiteral("Name[%1]").arg(localeShort);
|
||||
m_localeDescriptionShort = QStringLiteral("Comment[%1]").arg(localeShort);
|
||||
m_defaultIcon = QIcon::fromTheme(QStringLiteral("application-x-executable"));
|
||||
m_defaultIcon =
|
||||
QIcon::fromTheme(QStringLiteral("application-x-executable"));
|
||||
}
|
||||
|
||||
DesktopAppData
|
||||
DesktopFileParser::parseDesktopFile(const QString& fileName, bool& ok) const
|
||||
DesktopAppData DesktopFileParser::parseDesktopFile(const QString& fileName,
|
||||
bool& ok) const
|
||||
{
|
||||
DesktopAppData res;
|
||||
ok = true;
|
||||
@@ -58,11 +59,14 @@ DesktopFileParser::parseDesktopFile(const QString& fileName, bool& ok) const
|
||||
line.mid(line.indexOf(QLatin1String("=")) + 1).trimmed(),
|
||||
m_defaultIcon);
|
||||
} else if (!nameLocaleSet && line.startsWith(QLatin1String("Name"))) {
|
||||
if (line.startsWith(m_localeName) || line.startsWith(m_localeNameShort)) {
|
||||
res.name = line.mid(line.indexOf(QLatin1String("=")) + 1).trimmed();
|
||||
if (line.startsWith(m_localeName) ||
|
||||
line.startsWith(m_localeNameShort)) {
|
||||
res.name =
|
||||
line.mid(line.indexOf(QLatin1String("=")) + 1).trimmed();
|
||||
nameLocaleSet = true;
|
||||
} else if (line.startsWith(QLatin1String("Name="))) {
|
||||
res.name = line.mid(line.indexOf(QLatin1String("=")) + 1).trimmed();
|
||||
res.name =
|
||||
line.mid(line.indexOf(QLatin1String("=")) + 1).trimmed();
|
||||
}
|
||||
} else if (!descriptionLocaleSet &&
|
||||
line.startsWith(QLatin1String("Comment"))) {
|
||||
@@ -77,7 +81,8 @@ DesktopFileParser::parseDesktopFile(const QString& fileName, bool& ok) const
|
||||
}
|
||||
} else if (line.startsWith(QLatin1String("Exec"))) {
|
||||
if (line.contains(QLatin1String("%"))) {
|
||||
res.exec = line.mid(line.indexOf(QLatin1String("=")) + 1).trimmed();
|
||||
res.exec =
|
||||
line.mid(line.indexOf(QLatin1String("=")) + 1).trimmed();
|
||||
} else {
|
||||
ok = false;
|
||||
break;
|
||||
@@ -107,8 +112,7 @@ DesktopFileParser::parseDesktopFile(const QString& fileName, bool& ok) const
|
||||
return res;
|
||||
}
|
||||
|
||||
int
|
||||
DesktopFileParser::processDirectory(const QDir& dir)
|
||||
int DesktopFileParser::processDirectory(const QDir& dir)
|
||||
{
|
||||
QStringList entries = dir.entryList(QDir::NoDotAndDotDot | QDir::Files);
|
||||
bool ok;
|
||||
@@ -122,8 +126,8 @@ DesktopFileParser::processDirectory(const QDir& dir)
|
||||
return m_appList.length() - length;
|
||||
}
|
||||
|
||||
QVector<DesktopAppData>
|
||||
DesktopFileParser::getAppsByCategory(const QString& category)
|
||||
QVector<DesktopAppData> DesktopFileParser::getAppsByCategory(
|
||||
const QString& category)
|
||||
{
|
||||
QVector<DesktopAppData> res;
|
||||
for (const DesktopAppData& app : m_appList) {
|
||||
@@ -134,8 +138,8 @@ DesktopFileParser::getAppsByCategory(const QString& category)
|
||||
return res;
|
||||
}
|
||||
|
||||
QMap<QString, QVector<DesktopAppData>>
|
||||
DesktopFileParser::getAppsByCategory(const QStringList& categories)
|
||||
QMap<QString, QVector<DesktopAppData>> DesktopFileParser::getAppsByCategory(
|
||||
const QStringList& categories)
|
||||
{
|
||||
QMap<QString, QVector<DesktopAppData>> res;
|
||||
for (const DesktopAppData& app : m_appList) {
|
||||
|
||||
@@ -30,16 +30,14 @@ DesktopInfo::DesktopInfo()
|
||||
DESKTOP_SESSION = e.value(QStringLiteral("DESKTOP_SESSION"));
|
||||
}
|
||||
|
||||
bool
|
||||
DesktopInfo::waylandDectected()
|
||||
bool DesktopInfo::waylandDectected()
|
||||
{
|
||||
return XDG_SESSION_TYPE == QLatin1String("wayland") ||
|
||||
WAYLAND_DISPLAY.contains(QLatin1String("wayland"),
|
||||
Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
DesktopInfo::WM
|
||||
DesktopInfo::windowManager()
|
||||
DesktopInfo::WM DesktopInfo::windowManager()
|
||||
{
|
||||
DesktopInfo::WM res = DesktopInfo::OTHER;
|
||||
if (XDG_CURRENT_DESKTOP.contains(QLatin1String("GNOME"),
|
||||
|
||||
@@ -28,14 +28,12 @@ FileNameHandler::FileNameHandler(QObject* parent)
|
||||
std::locale::global(std::locale(""));
|
||||
}
|
||||
|
||||
QString
|
||||
FileNameHandler::parsedPattern()
|
||||
QString FileNameHandler::parsedPattern()
|
||||
{
|
||||
return parseFilename(ConfigHandler().filenamePatternValue());
|
||||
}
|
||||
|
||||
QString
|
||||
FileNameHandler::parseFilename(const QString& name)
|
||||
QString FileNameHandler::parseFilename(const QString& name)
|
||||
{
|
||||
QString res = name;
|
||||
if (name.isEmpty()) {
|
||||
@@ -55,8 +53,7 @@ FileNameHandler::parseFilename(const QString& name)
|
||||
return res;
|
||||
}
|
||||
|
||||
QString
|
||||
FileNameHandler::generateAbsolutePath(const QString& path)
|
||||
QString FileNameHandler::generateAbsolutePath(const QString& path)
|
||||
{
|
||||
QString directory = path;
|
||||
QString filename = parsedPattern();
|
||||
@@ -64,14 +61,12 @@ FileNameHandler::generateAbsolutePath(const QString& path)
|
||||
return directory + filename;
|
||||
}
|
||||
// path a images si no existe, add numeration
|
||||
void
|
||||
FileNameHandler::setPattern(const QString& pattern)
|
||||
void FileNameHandler::setPattern(const QString& pattern)
|
||||
{
|
||||
ConfigHandler().setFilenamePattern(pattern);
|
||||
}
|
||||
|
||||
QString
|
||||
FileNameHandler::absoluteSavePath(QString& directory, QString& filename)
|
||||
QString FileNameHandler::absoluteSavePath(QString& directory, QString& filename)
|
||||
{
|
||||
ConfigHandler config;
|
||||
directory = config.savePathValue();
|
||||
@@ -85,28 +80,24 @@ FileNameHandler::absoluteSavePath(QString& directory, QString& filename)
|
||||
return directory + filename;
|
||||
}
|
||||
|
||||
QString
|
||||
FileNameHandler::absoluteSavePath()
|
||||
QString FileNameHandler::absoluteSavePath()
|
||||
{
|
||||
QString dir, file;
|
||||
return absoluteSavePath(dir, file);
|
||||
}
|
||||
|
||||
QString
|
||||
FileNameHandler::charArrToQString(const char* c)
|
||||
QString FileNameHandler::charArrToQString(const char* c)
|
||||
{
|
||||
return QString::fromLocal8Bit(c, MAX_CHARACTERS);
|
||||
}
|
||||
|
||||
char*
|
||||
FileNameHandler::QStringTocharArr(const QString& s)
|
||||
char* FileNameHandler::QStringTocharArr(const QString& s)
|
||||
{
|
||||
QByteArray ba = s.toLocal8Bit();
|
||||
return const_cast<char*>(strdup(ba.constData()));
|
||||
}
|
||||
|
||||
void
|
||||
FileNameHandler::fixPath(QString& directory, QString& filename)
|
||||
void FileNameHandler::fixPath(QString& directory, QString& filename)
|
||||
{
|
||||
// add '/' at the end of the directory
|
||||
if (!directory.endsWith(QLatin1String("/"))) {
|
||||
@@ -119,7 +110,8 @@ FileNameHandler::fixPath(QString& directory, QString& filename)
|
||||
filename += QLatin1String("_");
|
||||
int i = 1;
|
||||
while (true) {
|
||||
checkFile.setFile(directory + filename + QString::number(i) + ".png");
|
||||
checkFile.setFile(directory + filename + QString::number(i) +
|
||||
".png");
|
||||
if (!checkFile.exists()) {
|
||||
filename += QString::number(i);
|
||||
break;
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
#include <QApplication>
|
||||
#include <QFontMetrics>
|
||||
|
||||
int
|
||||
GlobalValues::buttonBaseSize()
|
||||
int GlobalValues::buttonBaseSize()
|
||||
{
|
||||
return QApplication::fontMetrics().lineSpacing() * 2.2;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
namespace GlobalValues {
|
||||
|
||||
int
|
||||
buttonBaseSize();
|
||||
int buttonBaseSize();
|
||||
|
||||
}
|
||||
|
||||
@@ -20,22 +20,20 @@
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
|
||||
const QString
|
||||
PathInfo::whiteIconPath()
|
||||
const QString PathInfo::whiteIconPath()
|
||||
{
|
||||
return QStringLiteral(":/img/material/white/");
|
||||
}
|
||||
|
||||
const QString
|
||||
PathInfo::blackIconPath()
|
||||
const QString PathInfo::blackIconPath()
|
||||
{
|
||||
return QStringLiteral(":/img/material/black/");
|
||||
}
|
||||
|
||||
QStringList
|
||||
PathInfo::translationsPaths()
|
||||
QStringList PathInfo::translationsPaths()
|
||||
{
|
||||
QString binaryPath = QFileInfo(qApp->applicationDirPath()).absoluteFilePath();
|
||||
QString binaryPath =
|
||||
QFileInfo(qApp->applicationDirPath()).absoluteFilePath();
|
||||
QString trPath = QDir::toNativeSeparators(binaryPath + "/translations");
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
|
||||
return QStringList()
|
||||
|
||||
@@ -21,13 +21,10 @@
|
||||
|
||||
namespace PathInfo { // namespace
|
||||
|
||||
const QString
|
||||
whiteIconPath();
|
||||
const QString whiteIconPath();
|
||||
|
||||
const QString
|
||||
blackIconPath();
|
||||
const QString blackIconPath();
|
||||
|
||||
QStringList
|
||||
translationsPaths();
|
||||
QStringList translationsPaths();
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -34,8 +34,7 @@ ScreenGrabber::ScreenGrabber(QObject* parent)
|
||||
: QObject(parent)
|
||||
{}
|
||||
|
||||
QPixmap
|
||||
ScreenGrabber::grabEntireDesktop(bool& ok)
|
||||
QPixmap ScreenGrabber::grabEntireDesktop(bool& ok)
|
||||
{
|
||||
ok = true;
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
|
||||
@@ -46,13 +45,14 @@ ScreenGrabber::grabEntireDesktop(bool& ok)
|
||||
case DesktopInfo::GNOME: {
|
||||
// https://github.com/GNOME/gnome-shell/blob/695bfb96160033be55cfb5ac41c121998f98c328/data/org.gnome.Shell.Screenshot.xml
|
||||
QString path =
|
||||
FileNameHandler().generateAbsolutePath(QDir::tempPath()) + ".png";
|
||||
FileNameHandler().generateAbsolutePath(QDir::tempPath()) +
|
||||
".png";
|
||||
QDBusInterface gnomeInterface(
|
||||
QStringLiteral("org.gnome.Shell"),
|
||||
QStringLiteral("/org/gnome/Shell/Screenshot"),
|
||||
QStringLiteral("org.gnome.Shell.Screenshot"));
|
||||
QDBusReply<bool> reply =
|
||||
gnomeInterface.call(QStringLiteral("Screenshot"), false, false, path);
|
||||
QDBusReply<bool> reply = gnomeInterface.call(
|
||||
QStringLiteral("Screenshot"), false, false, path);
|
||||
if (reply.value()) {
|
||||
res = QPixmap(path);
|
||||
QFile dbusResult(path);
|
||||
@@ -64,7 +64,8 @@ ScreenGrabber::grabEntireDesktop(bool& ok)
|
||||
}
|
||||
case DesktopInfo::KDE: {
|
||||
// https://github.com/KDE/spectacle/blob/517a7baf46a4ca0a45f32fd3f2b1b7210b180134/src/PlatformBackends/KWinWaylandImageGrabber.cpp#L145
|
||||
QDBusInterface kwinInterface(QStringLiteral("org.kde.KWin"),
|
||||
QDBusInterface kwinInterface(
|
||||
QStringLiteral("org.kde.KWin"),
|
||||
QStringLiteral("/Screenshot"),
|
||||
QStringLiteral("org.kde.kwin.Screenshot"));
|
||||
QDBusReply<QString> reply =
|
||||
@@ -92,8 +93,8 @@ ScreenGrabber::grabEntireDesktop(bool& ok)
|
||||
geometry = geometry.united(screen->geometry());
|
||||
}
|
||||
|
||||
QPixmap p(
|
||||
QApplication::primaryScreen()->grabWindow(QApplication::desktop()->winId(),
|
||||
QPixmap p(QApplication::primaryScreen()->grabWindow(
|
||||
QApplication::desktop()->winId(),
|
||||
geometry.x(),
|
||||
geometry.y(),
|
||||
geometry.width(),
|
||||
@@ -104,8 +105,7 @@ ScreenGrabber::grabEntireDesktop(bool& ok)
|
||||
return p;
|
||||
}
|
||||
|
||||
QPixmap
|
||||
ScreenGrabber::grabScreen(int screenNumber, bool& ok)
|
||||
QPixmap ScreenGrabber::grabScreen(int screenNumber, bool& ok)
|
||||
{
|
||||
QPixmap p;
|
||||
bool isVirtual = QApplication::desktop()->isVirtualDesktop();
|
||||
@@ -122,7 +122,8 @@ ScreenGrabber::grabScreen(int screenNumber, bool& ok)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
QRect geometry = QApplication::desktop()->screenGeometry(screenNumber);
|
||||
QRect geometry =
|
||||
QApplication::desktop()->screenGeometry(screenNumber);
|
||||
geometry.moveTo(geometry.topLeft() - topLeft);
|
||||
p = p.copy(geometry);
|
||||
}
|
||||
|
||||
@@ -29,8 +29,7 @@ ScreenshotSaver::ScreenshotSaver() {}
|
||||
|
||||
// TODO: If data is saved to the clipboard before the notification is sent via
|
||||
// dbus, the application freezes.
|
||||
void
|
||||
ScreenshotSaver::saveToClipboard(const QPixmap& capture)
|
||||
void ScreenshotSaver::saveToClipboard(const QPixmap& capture)
|
||||
{
|
||||
|
||||
// If we are able to properly save the file, save the file and copy to
|
||||
@@ -44,13 +43,13 @@ ScreenshotSaver::saveToClipboard(const QPixmap& capture)
|
||||
}
|
||||
// Otherwise only save to clipboard
|
||||
else {
|
||||
SystemNotification().sendMessage(QObject::tr("Capture saved to clipboard"));
|
||||
SystemNotification().sendMessage(
|
||||
QObject::tr("Capture saved to clipboard"));
|
||||
QApplication::clipboard()->setPixmap(capture);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ScreenshotSaver::saveToFilesystem(const QPixmap& capture,
|
||||
bool ScreenshotSaver::saveToFilesystem(const QPixmap& capture,
|
||||
const QString& path,
|
||||
const QString& messagePrefix)
|
||||
{
|
||||
@@ -65,8 +64,8 @@ ScreenshotSaver::saveToFilesystem(const QPixmap& capture,
|
||||
saveMessage =
|
||||
messagePrefix + QObject::tr("Capture saved as ") + completePath;
|
||||
} else {
|
||||
saveMessage =
|
||||
messagePrefix + QObject::tr("Error trying to save as ") + completePath;
|
||||
saveMessage = messagePrefix + QObject::tr("Error trying to save as ") +
|
||||
completePath;
|
||||
notificationPath = "";
|
||||
}
|
||||
|
||||
@@ -74,8 +73,7 @@ ScreenshotSaver::saveToFilesystem(const QPixmap& capture,
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
ScreenshotSaver::saveToFilesystemGUI(const QPixmap& capture)
|
||||
bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap& capture)
|
||||
{
|
||||
bool ok = false;
|
||||
|
||||
|
||||
@@ -30,14 +30,13 @@ SystemNotification::SystemNotification(QObject* parent)
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
SystemNotification::sendMessage(const QString& text, const QString& savePath)
|
||||
void SystemNotification::sendMessage(const QString& text,
|
||||
const QString& savePath)
|
||||
{
|
||||
sendMessage(text, tr("Flameshot Info"), savePath);
|
||||
}
|
||||
|
||||
void
|
||||
SystemNotification::sendMessage(const QString& text,
|
||||
void SystemNotification::sendMessage(const QString& text,
|
||||
const QString& title,
|
||||
const QString& savePath,
|
||||
const int timeout)
|
||||
|
||||
@@ -2,6 +2,4 @@
|
||||
|
||||
WaylandUtils::WaylandUtils() {}
|
||||
|
||||
bool
|
||||
WaylandUtils::waylandDetected()
|
||||
{}
|
||||
bool WaylandUtils::waylandDetected() {}
|
||||
|
||||
@@ -38,15 +38,13 @@ ButtonHandler::ButtonHandler(QObject* parent)
|
||||
init();
|
||||
}
|
||||
|
||||
void
|
||||
ButtonHandler::hide()
|
||||
void ButtonHandler::hide()
|
||||
{
|
||||
for (CaptureToolButton* b : m_vectorButtons)
|
||||
b->hide();
|
||||
}
|
||||
|
||||
void
|
||||
ButtonHandler::show()
|
||||
void ButtonHandler::show()
|
||||
{
|
||||
if (m_vectorButtons.isEmpty() || m_vectorButtons.first()->isVisible()) {
|
||||
return;
|
||||
@@ -55,8 +53,7 @@ ButtonHandler::show()
|
||||
b->animatedShow();
|
||||
}
|
||||
|
||||
bool
|
||||
ButtonHandler::isVisible() const
|
||||
bool ButtonHandler::isVisible() const
|
||||
{
|
||||
bool ret = true;
|
||||
for (const CaptureToolButton* b : m_vectorButtons) {
|
||||
@@ -68,14 +65,12 @@ ButtonHandler::isVisible() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
ButtonHandler::buttonsAreInside() const
|
||||
bool ButtonHandler::buttonsAreInside() const
|
||||
{
|
||||
return m_buttonsAreInside;
|
||||
}
|
||||
|
||||
size_t
|
||||
ButtonHandler::size() const
|
||||
size_t ButtonHandler::size() const
|
||||
{
|
||||
return m_vectorButtons.size();
|
||||
}
|
||||
@@ -84,8 +79,7 @@ ButtonHandler::size() const
|
||||
// selection area. Ignores the sides blocked by the end of the screen.
|
||||
// When the selection is too small it works on a virtual selection with
|
||||
// the original in the center.
|
||||
void
|
||||
ButtonHandler::updatePosition(const QRect& selection)
|
||||
void ButtonHandler::updatePosition(const QRect& selection)
|
||||
{
|
||||
resetRegionTrack();
|
||||
const int vecLength = m_vectorButtons.size();
|
||||
@@ -131,13 +125,14 @@ ButtonHandler::updatePosition(const QRect& selection)
|
||||
int addCounter = buttonsPerRow + elemCornersBotton;
|
||||
// Don't add more than we have
|
||||
addCounter = qBound(0, addCounter, vecLength - elemIndicator);
|
||||
QPoint center =
|
||||
QPoint(m_selection.center().x(), m_selection.bottom() + m_separator);
|
||||
QPoint center = QPoint(m_selection.center().x(),
|
||||
m_selection.bottom() + m_separator);
|
||||
if (addCounter > buttonsPerRow) {
|
||||
adjustHorizontalCenter(center);
|
||||
}
|
||||
// ElemIndicator, elemsAtCorners
|
||||
QVector<QPoint> positions = horizontalPoints(center, addCounter, true);
|
||||
QVector<QPoint> positions =
|
||||
horizontalPoints(center, addCounter, true);
|
||||
moveButtonsToPoints(positions, elemIndicator);
|
||||
}
|
||||
// Add buttons at the right side of the seletion
|
||||
@@ -145,9 +140,10 @@ ButtonHandler::updatePosition(const QRect& selection)
|
||||
int addCounter = buttonsPerCol;
|
||||
addCounter = qBound(0, addCounter, vecLength - elemIndicator);
|
||||
|
||||
QPoint center =
|
||||
QPoint(m_selection.right() + m_separator, m_selection.center().y());
|
||||
QVector<QPoint> positions = verticalPoints(center, addCounter, false);
|
||||
QPoint center = QPoint(m_selection.right() + m_separator,
|
||||
m_selection.center().y());
|
||||
QVector<QPoint> positions =
|
||||
verticalPoints(center, addCounter, false);
|
||||
moveButtonsToPoints(positions, elemIndicator);
|
||||
}
|
||||
// Add buttons at the top of the seletion
|
||||
@@ -159,7 +155,8 @@ ButtonHandler::updatePosition(const QRect& selection)
|
||||
if (addCounter == 1 + buttonsPerRow) {
|
||||
adjustHorizontalCenter(center);
|
||||
}
|
||||
QVector<QPoint> positions = horizontalPoints(center, addCounter, false);
|
||||
QVector<QPoint> positions =
|
||||
horizontalPoints(center, addCounter, false);
|
||||
moveButtonsToPoints(positions, elemIndicator);
|
||||
}
|
||||
// Add buttons at the left side of the seletion
|
||||
@@ -169,7 +166,8 @@ ButtonHandler::updatePosition(const QRect& selection)
|
||||
|
||||
QPoint center = QPoint(m_selection.left() - m_buttonExtendedSize,
|
||||
m_selection.center().y());
|
||||
QVector<QPoint> positions = verticalPoints(center, addCounter, true);
|
||||
QVector<QPoint> positions =
|
||||
verticalPoints(center, addCounter, true);
|
||||
moveButtonsToPoints(positions, elemIndicator);
|
||||
}
|
||||
// If there are elements for the next cycle, increase the size of the
|
||||
@@ -184,8 +182,7 @@ ButtonHandler::updatePosition(const QRect& selection)
|
||||
// horizontalPoints is an auxiliary method for the button position computation.
|
||||
// starts from a known center and keeps adding elements horizontally
|
||||
// and returns the computed positions.
|
||||
QVector<QPoint>
|
||||
ButtonHandler::horizontalPoints(const QPoint& center,
|
||||
QVector<QPoint> ButtonHandler::horizontalPoints(const QPoint& center,
|
||||
const int elements,
|
||||
const bool leftToRight) const
|
||||
{
|
||||
@@ -195,7 +192,8 @@ ButtonHandler::horizontalPoints(const QPoint& center,
|
||||
if (elements % 2 == 0) {
|
||||
shift = m_buttonExtendedSize * (elements / 2) - (m_separator / 2);
|
||||
} else {
|
||||
shift = m_buttonExtendedSize * ((elements - 1) / 2) + m_buttonBaseSize / 2;
|
||||
shift =
|
||||
m_buttonExtendedSize * ((elements - 1) / 2) + m_buttonBaseSize / 2;
|
||||
}
|
||||
if (!leftToRight) {
|
||||
shift -= m_buttonBaseSize;
|
||||
@@ -213,8 +211,7 @@ ButtonHandler::horizontalPoints(const QPoint& center,
|
||||
// verticalPoints is an auxiliary method for the button position computation.
|
||||
// starts from a known center and keeps adding elements vertically
|
||||
// and returns the computed positions.
|
||||
QVector<QPoint>
|
||||
ButtonHandler::verticalPoints(const QPoint& center,
|
||||
QVector<QPoint> ButtonHandler::verticalPoints(const QPoint& center,
|
||||
const int elements,
|
||||
const bool upToDown) const
|
||||
{
|
||||
@@ -224,7 +221,8 @@ ButtonHandler::verticalPoints(const QPoint& center,
|
||||
if (elements % 2 == 0) {
|
||||
shift = m_buttonExtendedSize * (elements / 2) - (m_separator / 2);
|
||||
} else {
|
||||
shift = m_buttonExtendedSize * ((elements - 1) / 2) + m_buttonBaseSize / 2;
|
||||
shift =
|
||||
m_buttonExtendedSize * ((elements - 1) / 2) + m_buttonBaseSize / 2;
|
||||
}
|
||||
if (!upToDown) {
|
||||
shift -= m_buttonBaseSize;
|
||||
@@ -239,8 +237,7 @@ ButtonHandler::verticalPoints(const QPoint& center,
|
||||
return res;
|
||||
}
|
||||
|
||||
QRect
|
||||
ButtonHandler::intersectWithAreas(const QRect& rect)
|
||||
QRect ButtonHandler::intersectWithAreas(const QRect& rect)
|
||||
{
|
||||
QRect res;
|
||||
for (const QRect& r : m_screenRegions) {
|
||||
@@ -252,20 +249,17 @@ ButtonHandler::intersectWithAreas(const QRect& rect)
|
||||
return res;
|
||||
}
|
||||
|
||||
void
|
||||
ButtonHandler::init()
|
||||
void ButtonHandler::init()
|
||||
{
|
||||
m_separator = GlobalValues::buttonBaseSize() / 4;
|
||||
}
|
||||
|
||||
void
|
||||
ButtonHandler::resetRegionTrack()
|
||||
void ButtonHandler::resetRegionTrack()
|
||||
{
|
||||
m_buttonsAreInside = false;
|
||||
}
|
||||
|
||||
void
|
||||
ButtonHandler::updateBlockedSides()
|
||||
void ButtonHandler::updateBlockedSides()
|
||||
{
|
||||
const int EXTENSION = m_separator * 2 + m_buttonBaseSize;
|
||||
// Right
|
||||
@@ -292,19 +286,18 @@ ButtonHandler::updateBlockedSides()
|
||||
m_oneHorizontalBlocked =
|
||||
(!m_blockedRight && m_blockedLeft) || (m_blockedRight && !m_blockedLeft);
|
||||
m_horizontalyBlocked = (m_blockedRight && m_blockedLeft);
|
||||
m_allSidesBlocked = (m_blockedBotton && m_horizontalyBlocked && m_blockedTop);
|
||||
m_allSidesBlocked =
|
||||
(m_blockedBotton && m_horizontalyBlocked && m_blockedTop);
|
||||
}
|
||||
|
||||
void
|
||||
ButtonHandler::expandSelection()
|
||||
void ButtonHandler::expandSelection()
|
||||
{
|
||||
int& s = m_buttonExtendedSize;
|
||||
m_selection = m_selection + QMargins(s, s, s, s);
|
||||
m_selection = intersectWithAreas(m_selection);
|
||||
}
|
||||
|
||||
void
|
||||
ButtonHandler::positionButtonsInside(int index)
|
||||
void ButtonHandler::positionButtonsInside(int index)
|
||||
{
|
||||
// Position the buttons in the botton-center of the main but inside of the
|
||||
// selection.
|
||||
@@ -328,11 +321,11 @@ ButtonHandler::positionButtonsInside(int index)
|
||||
m_buttonsAreInside = true;
|
||||
}
|
||||
|
||||
void
|
||||
ButtonHandler::ensureSelectionMinimunSize()
|
||||
void ButtonHandler::ensureSelectionMinimunSize()
|
||||
{
|
||||
// Detect if a side is smaller than a button in order to prevent collision
|
||||
// and redimension the base area the the base size of a single button per side
|
||||
// and redimension the base area the the base size of a single button per
|
||||
// side
|
||||
if (m_selection.width() < m_buttonBaseSize) {
|
||||
if (!m_blockedLeft) {
|
||||
m_selection.setX(m_selection.x() -
|
||||
@@ -349,8 +342,8 @@ ButtonHandler::ensureSelectionMinimunSize()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ButtonHandler::moveButtonsToPoints(const QVector<QPoint>& points, int& index)
|
||||
void ButtonHandler::moveButtonsToPoints(const QVector<QPoint>& points,
|
||||
int& index)
|
||||
{
|
||||
for (const QPoint& p : points) {
|
||||
auto button = m_vectorButtons[index];
|
||||
@@ -359,8 +352,7 @@ ButtonHandler::moveButtonsToPoints(const QVector<QPoint>& points, int& index)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ButtonHandler::adjustHorizontalCenter(QPoint& center)
|
||||
void ButtonHandler::adjustHorizontalCenter(QPoint& center)
|
||||
{
|
||||
if (m_blockedLeft) {
|
||||
center.setX(center.x() + m_buttonExtendedSize / 2);
|
||||
@@ -370,8 +362,7 @@ ButtonHandler::adjustHorizontalCenter(QPoint& center)
|
||||
}
|
||||
|
||||
// setButtons redefines the buttons of the button handler
|
||||
void
|
||||
ButtonHandler::setButtons(const QVector<CaptureToolButton*> v)
|
||||
void ButtonHandler::setButtons(const QVector<CaptureToolButton*> v)
|
||||
{
|
||||
if (v.isEmpty())
|
||||
return;
|
||||
@@ -383,8 +374,7 @@ ButtonHandler::setButtons(const QVector<CaptureToolButton*> v)
|
||||
m_buttonExtendedSize = m_buttonBaseSize + m_separator;
|
||||
}
|
||||
|
||||
bool
|
||||
ButtonHandler::contains(const QPoint& p) const
|
||||
bool ButtonHandler::contains(const QPoint& p) const
|
||||
{
|
||||
QPoint first(m_vectorButtons.first()->pos());
|
||||
QPoint last(m_vectorButtons.last()->pos());
|
||||
@@ -397,8 +387,7 @@ ButtonHandler::contains(const QPoint& p) const
|
||||
return r.contains(p);
|
||||
}
|
||||
|
||||
void
|
||||
ButtonHandler::updateScreenRegions(const QVector<QRect>& rects)
|
||||
void ButtonHandler::updateScreenRegions(const QVector<QRect>& rects)
|
||||
{
|
||||
m_screenRegions = QRegion();
|
||||
for (const QRect& rect : rects) {
|
||||
@@ -406,8 +395,7 @@ ButtonHandler::updateScreenRegions(const QVector<QRect>& rects)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ButtonHandler::updateScreenRegions(const QRect& rect)
|
||||
void ButtonHandler::updateScreenRegions(const QRect& rect)
|
||||
{
|
||||
m_screenRegions = QRegion(rect);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,8 @@ class ButtonHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ButtonHandler(const QVector<CaptureToolButton*>&, QObject* parent = nullptr);
|
||||
ButtonHandler(const QVector<CaptureToolButton*>&,
|
||||
QObject* parent = nullptr);
|
||||
explicit ButtonHandler(QObject* parent = nullptr);
|
||||
|
||||
void hideSectionUnderMouse(const QPoint& p);
|
||||
|
||||
@@ -41,8 +41,7 @@ CaptureButton::CaptureButton(const QIcon& icon,
|
||||
init();
|
||||
}
|
||||
|
||||
void
|
||||
CaptureButton::init()
|
||||
void CaptureButton::init()
|
||||
{
|
||||
setCursor(Qt::ArrowCursor);
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
@@ -55,14 +54,12 @@ CaptureButton::init()
|
||||
setGraphicsEffect(dsEffect);
|
||||
}
|
||||
|
||||
QString
|
||||
CaptureButton::globalStyleSheet()
|
||||
QString CaptureButton::globalStyleSheet()
|
||||
{
|
||||
return CaptureButton(nullptr).styleSheet();
|
||||
}
|
||||
|
||||
QString
|
||||
CaptureButton::styleSheet() const
|
||||
QString CaptureButton::styleSheet() const
|
||||
{
|
||||
QString baseSheet = "CaptureButton { border: none;"
|
||||
"padding: 3px 8px;"
|
||||
@@ -83,8 +80,7 @@ CaptureButton::styleSheet() const
|
||||
.arg(color.name());
|
||||
}
|
||||
|
||||
void
|
||||
CaptureButton::setColor(const QColor& c)
|
||||
void CaptureButton::setColor(const QColor& c)
|
||||
{
|
||||
m_mainColor = c;
|
||||
setStyleSheet(styleSheet());
|
||||
|
||||
@@ -44,8 +44,7 @@ CaptureToolButton::CaptureToolButton(const ButtonType t, QWidget* parent)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CaptureToolButton::initButton()
|
||||
void CaptureToolButton::initButton()
|
||||
{
|
||||
m_tool = ToolFactory().CreateTool(m_buttonType, this);
|
||||
|
||||
@@ -66,8 +65,7 @@ CaptureToolButton::initButton()
|
||||
QSize(GlobalValues::buttonBaseSize(), GlobalValues::buttonBaseSize()));
|
||||
}
|
||||
|
||||
void
|
||||
CaptureToolButton::updateIcon()
|
||||
void CaptureToolButton::updateIcon()
|
||||
{
|
||||
setIcon(icon());
|
||||
setIconSize(size() * 0.6);
|
||||
@@ -80,14 +78,12 @@ CaptureToolButton::getIterableButtonTypes()
|
||||
}
|
||||
|
||||
// get icon returns the icon for the type of button
|
||||
QIcon
|
||||
CaptureToolButton::icon() const
|
||||
QIcon CaptureToolButton::icon() const
|
||||
{
|
||||
return m_tool->icon(m_mainColor, true);
|
||||
}
|
||||
|
||||
void
|
||||
CaptureToolButton::mousePressEvent(QMouseEvent* e)
|
||||
void CaptureToolButton::mousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
if (e->button() == Qt::LeftButton) {
|
||||
emit pressedButton(this);
|
||||
@@ -95,24 +91,22 @@ CaptureToolButton::mousePressEvent(QMouseEvent* e)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CaptureToolButton::animatedShow()
|
||||
void CaptureToolButton::animatedShow()
|
||||
{
|
||||
if (!isVisible()) {
|
||||
show();
|
||||
m_emergeAnimation->start();
|
||||
connect(m_emergeAnimation, &QPropertyAnimation::finished, this, []() {});
|
||||
connect(
|
||||
m_emergeAnimation, &QPropertyAnimation::finished, this, []() {});
|
||||
}
|
||||
}
|
||||
|
||||
CaptureTool*
|
||||
CaptureToolButton::tool() const
|
||||
CaptureTool* CaptureToolButton::tool() const
|
||||
{
|
||||
return m_tool;
|
||||
}
|
||||
|
||||
void
|
||||
CaptureToolButton::setColor(const QColor& c)
|
||||
void CaptureToolButton::setColor(const QColor& c)
|
||||
{
|
||||
CaptureButton::setColor(c);
|
||||
updateIcon();
|
||||
@@ -143,8 +137,7 @@ static std::map<CaptureToolButton::ButtonType, int> buttonTypeOrder{
|
||||
{ CaptureToolButton::TYPE_PIN, 19 },
|
||||
};
|
||||
|
||||
int
|
||||
CaptureToolButton::getPriorityByButton(CaptureToolButton::ButtonType b)
|
||||
int CaptureToolButton::getPriorityByButton(CaptureToolButton::ButtonType b)
|
||||
{
|
||||
auto it = buttonTypeOrder.find(b);
|
||||
return it == buttonTypeOrder.cend() ? (int)buttonTypeOrder.size()
|
||||
|
||||
@@ -107,7 +107,8 @@ CaptureWidget::CaptureWidget(const uint id,
|
||||
|
||||
for (QScreen* const screen : QGuiApplication::screens()) {
|
||||
QPoint topLeftScreen = screen->geometry().topLeft();
|
||||
if (topLeft.x() > topLeftScreen.x() || topLeft.y() > topLeftScreen.y()) {
|
||||
if (topLeft.x() > topLeftScreen.x() ||
|
||||
topLeft.y() > topLeftScreen.y()) {
|
||||
topLeft = topLeftScreen;
|
||||
}
|
||||
}
|
||||
@@ -169,8 +170,7 @@ CaptureWidget::~CaptureWidget()
|
||||
|
||||
// redefineButtons retrieves the buttons configured to be shown with the
|
||||
// selection in the capture
|
||||
void
|
||||
CaptureWidget::updateButtons()
|
||||
void CaptureWidget::updateButtons()
|
||||
{
|
||||
m_uiColor = m_config.uiMainColorValue();
|
||||
m_contrastUiColor = m_config.uiContrastColorValue();
|
||||
@@ -197,8 +197,7 @@ CaptureWidget::updateButtons()
|
||||
m_buttonHandler->setButtons(vectorButtons);
|
||||
}
|
||||
|
||||
QPixmap
|
||||
CaptureWidget::pixmap()
|
||||
QPixmap CaptureWidget::pixmap()
|
||||
{
|
||||
QPixmap p;
|
||||
if (m_toolWidget && m_activeTool) {
|
||||
@@ -211,8 +210,7 @@ CaptureWidget::pixmap()
|
||||
return m_context.selectedScreenshotArea();
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::deleteToolwidgetOrClose()
|
||||
void CaptureWidget::deleteToolwidgetOrClose()
|
||||
{
|
||||
if (m_toolWidget) {
|
||||
m_toolWidget->deleteLater();
|
||||
@@ -222,8 +220,7 @@ CaptureWidget::deleteToolwidgetOrClose()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::paintEvent(QPaintEvent*)
|
||||
void CaptureWidget::paintEvent(QPaintEvent*)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.drawPixmap(0, 0, m_context.screenshot);
|
||||
@@ -264,7 +261,8 @@ CaptureWidget::paintEvent(QPaintEvent*)
|
||||
"\nPress Space to open the side panel.");
|
||||
|
||||
// We draw the white contrasting background for the text, using the
|
||||
// same text and options to get the boundingRect that the text will have.
|
||||
// same text and options to get the boundingRect that the text will
|
||||
// have.
|
||||
QRectF bRect = painter.boundingRect(helpRect, Qt::AlignCenter, helpTxt);
|
||||
|
||||
// These four calls provide padding for the rect
|
||||
@@ -297,8 +295,7 @@ CaptureWidget::paintEvent(QPaintEvent*)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::mousePressEvent(QMouseEvent* e)
|
||||
void CaptureWidget::mousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
if (e->button() == Qt::RightButton) {
|
||||
m_rightClick = true;
|
||||
@@ -356,8 +353,7 @@ CaptureWidget::mousePressEvent(QMouseEvent* e)
|
||||
updateCursor();
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::mouseMoveEvent(QMouseEvent* e)
|
||||
void CaptureWidget::mouseMoveEvent(QMouseEvent* e)
|
||||
{
|
||||
m_context.mousePos = e->pos();
|
||||
|
||||
@@ -373,7 +369,8 @@ CaptureWidget::mouseMoveEvent(QMouseEvent* e)
|
||||
} else if (m_mouseOverHandle == SelectionWidget::NO_SIDE) {
|
||||
// Moving the whole selection
|
||||
QRect initialRect = m_selection->savedGeometry().normalized();
|
||||
QPoint newTopLeft = initialRect.topLeft() + (e->pos() - m_dragStartPoint);
|
||||
QPoint newTopLeft =
|
||||
initialRect.topLeft() + (e->pos() - m_dragStartPoint);
|
||||
QRect finalRect(newTopLeft, initialRect.size());
|
||||
|
||||
if (finalRect.left() < rect().left()) {
|
||||
@@ -386,7 +383,8 @@ CaptureWidget::mouseMoveEvent(QMouseEvent* e)
|
||||
} else if (finalRect.bottom() > rect().bottom()) {
|
||||
finalRect.setBottom(rect().bottom());
|
||||
}
|
||||
m_selection->setGeometry(finalRect.normalized().intersected(rect()));
|
||||
m_selection->setGeometry(
|
||||
finalRect.normalized().intersected(rect()));
|
||||
update();
|
||||
} else {
|
||||
// Dragging a handle
|
||||
@@ -442,9 +440,11 @@ CaptureWidget::mouseMoveEvent(QMouseEvent* e)
|
||||
m_activeTool->drawMove(e->pos());
|
||||
}
|
||||
update();
|
||||
// Hides the buttons under the mouse. If the mouse leaves, it shows them.
|
||||
// Hides the buttons under the mouse. If the mouse leaves, it shows
|
||||
// them.
|
||||
if (m_buttonHandler->buttonsAreInside()) {
|
||||
const bool containsMouse = m_buttonHandler->contains(m_context.mousePos);
|
||||
const bool containsMouse =
|
||||
m_buttonHandler->contains(m_context.mousePos);
|
||||
if (containsMouse) {
|
||||
m_buttonHandler->hide();
|
||||
} else {
|
||||
@@ -462,8 +462,7 @@ CaptureWidget::mouseMoveEvent(QMouseEvent* e)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::mouseReleaseEvent(QMouseEvent* e)
|
||||
void CaptureWidget::mouseReleaseEvent(QMouseEvent* e)
|
||||
{
|
||||
if (e->button() == Qt::RightButton) {
|
||||
m_colorPicker->hide();
|
||||
@@ -509,8 +508,7 @@ CaptureWidget::mouseReleaseEvent(QMouseEvent* e)
|
||||
updateCursor();
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::keyPressEvent(QKeyEvent* e)
|
||||
void CaptureWidget::keyPressEvent(QKeyEvent* e)
|
||||
{
|
||||
if (!m_selection->isVisible()) {
|
||||
return;
|
||||
@@ -545,16 +543,14 @@ CaptureWidget::keyPressEvent(QKeyEvent* e)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::keyReleaseEvent(QKeyEvent* e)
|
||||
void CaptureWidget::keyReleaseEvent(QKeyEvent* e)
|
||||
{
|
||||
if (e->key() == Qt::Key_Control) {
|
||||
m_adjustmentButtonPressed = false;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::wheelEvent(QWheelEvent* e)
|
||||
void CaptureWidget::wheelEvent(QWheelEvent* e)
|
||||
{
|
||||
m_context.thickness += e->angleDelta().y() / 120;
|
||||
m_context.thickness = qBound(0, m_context.thickness, 100);
|
||||
@@ -571,8 +567,7 @@ CaptureWidget::wheelEvent(QWheelEvent* e)
|
||||
emit thicknessChanged(m_context.thickness);
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::resizeEvent(QResizeEvent* e)
|
||||
void CaptureWidget::resizeEvent(QResizeEvent* e)
|
||||
{
|
||||
QWidget::resizeEvent(e);
|
||||
m_context.widgetDimensions = rect();
|
||||
@@ -583,15 +578,13 @@ CaptureWidget::resizeEvent(QResizeEvent* e)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::moveEvent(QMoveEvent* e)
|
||||
void CaptureWidget::moveEvent(QMoveEvent* e)
|
||||
{
|
||||
QWidget::moveEvent(e);
|
||||
m_context.widgetOffset = mapToGlobal(QPoint(0, 0));
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::initContext(const QString& savePath, bool fullscreen)
|
||||
void CaptureWidget::initContext(const QString& savePath, bool fullscreen)
|
||||
{
|
||||
m_context.widgetDimensions = rect();
|
||||
m_context.color = m_config.drawColorValue();
|
||||
@@ -602,8 +595,7 @@ CaptureWidget::initContext(const QString& savePath, bool fullscreen)
|
||||
m_context.fullscreen = fullscreen;
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::initPanel()
|
||||
void CaptureWidget::initPanel()
|
||||
{
|
||||
QRect panelRect = rect();
|
||||
if (m_context.fullscreen) {
|
||||
@@ -660,8 +652,7 @@ CaptureWidget::initPanel()
|
||||
m_panel->pushWidget(new QUndoView(&m_undoStack, this));
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::initSelection()
|
||||
void CaptureWidget::initSelection()
|
||||
{
|
||||
m_selection = new SelectionWidget(m_uiColor, this);
|
||||
connect(m_selection, &SelectionWidget::animationEnded, this, [this]() {
|
||||
@@ -671,8 +662,7 @@ CaptureWidget::initSelection()
|
||||
m_selection->setGeometry(QRect());
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::setState(CaptureToolButton* b)
|
||||
void CaptureWidget::setState(CaptureToolButton* b)
|
||||
{
|
||||
if (!b) {
|
||||
return;
|
||||
@@ -709,8 +699,7 @@ CaptureWidget::setState(CaptureToolButton* b)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::processTool(CaptureTool* t)
|
||||
void CaptureWidget::processTool(CaptureTool* t)
|
||||
{
|
||||
auto backup = m_activeTool;
|
||||
// The tool is active during the pressed().
|
||||
@@ -719,8 +708,7 @@ CaptureWidget::processTool(CaptureTool* t)
|
||||
m_activeTool = backup;
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::handleButtonSignal(CaptureTool::Request r)
|
||||
void CaptureWidget::handleButtonSignal(CaptureTool::Request r)
|
||||
{
|
||||
switch (r) {
|
||||
case CaptureTool::REQ_CLEAR_MODIFICATIONS:
|
||||
@@ -794,7 +782,8 @@ CaptureWidget::handleButtonSignal(CaptureTool::Request r)
|
||||
break;
|
||||
} else {
|
||||
QWidget* w = m_activeTool->widget();
|
||||
connect(this, &CaptureWidget::destroyed, w, &QWidget::deleteLater);
|
||||
connect(
|
||||
this, &CaptureWidget::destroyed, w, &QWidget::deleteLater);
|
||||
w->show();
|
||||
}
|
||||
break;
|
||||
@@ -812,40 +801,36 @@ CaptureWidget::handleButtonSignal(CaptureTool::Request r)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::setDrawColor(const QColor& c)
|
||||
void CaptureWidget::setDrawColor(const QColor& c)
|
||||
{
|
||||
m_context.color = c;
|
||||
ConfigHandler().setDrawColor(m_context.color);
|
||||
emit colorChanged(c);
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::incrementCircleCount()
|
||||
void CaptureWidget::incrementCircleCount()
|
||||
{
|
||||
m_context.circleCount++;
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::decrementCircleCount()
|
||||
void CaptureWidget::decrementCircleCount()
|
||||
{
|
||||
m_context.circleCount--;
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::setDrawThickness(const int& t)
|
||||
void CaptureWidget::setDrawThickness(const int& t)
|
||||
{
|
||||
m_context.thickness = qBound(0, t, 100);
|
||||
ConfigHandler().setdrawThickness(m_context.thickness);
|
||||
emit thicknessChanged(m_context.thickness);
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::leftResize()
|
||||
void CaptureWidget::leftResize()
|
||||
{
|
||||
if (m_selection->isVisible() &&
|
||||
m_selection->geometry().right() > m_selection->geometry().left()) {
|
||||
m_selection->setGeometry(m_selection->geometry() + QMargins(0, 0, -1, 0));
|
||||
m_selection->setGeometry(m_selection->geometry() +
|
||||
QMargins(0, 0, -1, 0));
|
||||
QRect newGeometry = m_selection->geometry().intersected(rect());
|
||||
m_context.selection = extendedRect(&newGeometry);
|
||||
m_buttonHandler->updatePosition(m_selection->geometry());
|
||||
@@ -854,12 +839,12 @@ CaptureWidget::leftResize()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::rightResize()
|
||||
void CaptureWidget::rightResize()
|
||||
{
|
||||
if (m_selection->isVisible() &&
|
||||
m_selection->geometry().right() < rect().right()) {
|
||||
m_selection->setGeometry(m_selection->geometry() + QMargins(0, 0, 1, 0));
|
||||
m_selection->setGeometry(m_selection->geometry() +
|
||||
QMargins(0, 0, 1, 0));
|
||||
QRect newGeometry = m_selection->geometry().intersected(rect());
|
||||
m_context.selection = extendedRect(&newGeometry);
|
||||
m_buttonHandler->updatePosition(m_selection->geometry());
|
||||
@@ -868,12 +853,12 @@ CaptureWidget::rightResize()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::upResize()
|
||||
void CaptureWidget::upResize()
|
||||
{
|
||||
if (m_selection->isVisible() &&
|
||||
m_selection->geometry().bottom() > m_selection->geometry().top()) {
|
||||
m_selection->setGeometry(m_selection->geometry() + QMargins(0, 0, 0, -1));
|
||||
m_selection->setGeometry(m_selection->geometry() +
|
||||
QMargins(0, 0, 0, -1));
|
||||
QRect newGeometry = m_selection->geometry().intersected(rect());
|
||||
m_context.selection = extendedRect(&newGeometry);
|
||||
m_buttonHandler->updatePosition(m_selection->geometry());
|
||||
@@ -882,12 +867,12 @@ CaptureWidget::upResize()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::downResize()
|
||||
void CaptureWidget::downResize()
|
||||
{
|
||||
if (m_selection->isVisible() &&
|
||||
m_selection->geometry().bottom() < rect().bottom()) {
|
||||
m_selection->setGeometry(m_selection->geometry() + QMargins(0, 0, 0, 1));
|
||||
m_selection->setGeometry(m_selection->geometry() +
|
||||
QMargins(0, 0, 0, 1));
|
||||
QRect newGeometry = m_selection->geometry().intersected(rect());
|
||||
m_context.selection = extendedRect(&newGeometry);
|
||||
m_buttonHandler->updatePosition(m_selection->geometry());
|
||||
@@ -896,8 +881,7 @@ CaptureWidget::downResize()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::initShortcuts()
|
||||
void CaptureWidget::initShortcuts()
|
||||
{
|
||||
new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this, SLOT(close()));
|
||||
new QShortcut(
|
||||
@@ -920,18 +904,17 @@ CaptureWidget::initShortcuts()
|
||||
new QShortcut(Qt::Key_Enter, this, SLOT(copyScreenshot()));
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::updateSizeIndicator()
|
||||
void CaptureWidget::updateSizeIndicator()
|
||||
{
|
||||
if (m_sizeIndButton) {
|
||||
const QRect& selection = extendedSelection();
|
||||
m_sizeIndButton->setText(
|
||||
QStringLiteral("%1\n%2").arg(selection.width()).arg(selection.height()));
|
||||
m_sizeIndButton->setText(QStringLiteral("%1\n%2")
|
||||
.arg(selection.width())
|
||||
.arg(selection.height()));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::updateCursor()
|
||||
void CaptureWidget::updateCursor()
|
||||
{
|
||||
if (m_rightClick) {
|
||||
setCursor(Qt::ArrowCursor);
|
||||
@@ -972,8 +955,7 @@ CaptureWidget::updateCursor()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::pushToolToStack()
|
||||
void CaptureWidget::pushToolToStack()
|
||||
{
|
||||
auto mod = new ModificationCommand(&m_context.screenshot, m_activeTool);
|
||||
disconnect(this,
|
||||
@@ -991,43 +973,37 @@ CaptureWidget::pushToolToStack()
|
||||
m_activeTool = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::makeChild(QWidget* w)
|
||||
void CaptureWidget::makeChild(QWidget* w)
|
||||
{
|
||||
w->setParent(this);
|
||||
w->installEventFilter(m_eventFilter);
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::togglePanel()
|
||||
void CaptureWidget::togglePanel()
|
||||
{
|
||||
m_panel->toggle();
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::childEnter()
|
||||
void CaptureWidget::childEnter()
|
||||
{
|
||||
m_previewEnabled = false;
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::childLeave()
|
||||
void CaptureWidget::childLeave()
|
||||
{
|
||||
m_previewEnabled = true;
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::copyScreenshot()
|
||||
void CaptureWidget::copyScreenshot()
|
||||
{
|
||||
m_captureDone = true;
|
||||
ScreenshotSaver().saveToClipboard(pixmap());
|
||||
close();
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::saveScreenshot()
|
||||
void CaptureWidget::saveScreenshot()
|
||||
{
|
||||
m_captureDone = true;
|
||||
hide();
|
||||
@@ -1039,20 +1015,17 @@ CaptureWidget::saveScreenshot()
|
||||
close();
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::undo()
|
||||
void CaptureWidget::undo()
|
||||
{
|
||||
m_undoStack.undo();
|
||||
}
|
||||
|
||||
void
|
||||
CaptureWidget::redo()
|
||||
void CaptureWidget::redo()
|
||||
{
|
||||
m_undoStack.redo();
|
||||
}
|
||||
|
||||
QRect
|
||||
CaptureWidget::extendedSelection() const
|
||||
QRect CaptureWidget::extendedSelection() const
|
||||
{
|
||||
if (!m_selection->isVisible())
|
||||
return QRect();
|
||||
@@ -1060,8 +1033,7 @@ CaptureWidget::extendedSelection() const
|
||||
return extendedRect(&r);
|
||||
}
|
||||
|
||||
QRect
|
||||
CaptureWidget::extendedRect(QRect* r) const
|
||||
QRect CaptureWidget::extendedRect(QRect* r) const
|
||||
{
|
||||
auto devicePixelRatio = m_context.screenshot.devicePixelRatio();
|
||||
return QRect(r->left() * devicePixelRatio,
|
||||
|
||||
@@ -46,35 +46,31 @@ ColorPicker::ColorPicker(QWidget* parent)
|
||||
QPoint(radius * 2, radius));
|
||||
|
||||
for (int i = 0; i < m_colorList.size(); ++i) {
|
||||
m_colorAreaList.append(
|
||||
QRect(baseLine.x2(), baseLine.y2(), m_colorAreaSize, m_colorAreaSize));
|
||||
m_colorAreaList.append(QRect(
|
||||
baseLine.x2(), baseLine.y2(), m_colorAreaSize, m_colorAreaSize));
|
||||
baseLine.setAngle(degreeAcum);
|
||||
degreeAcum += degree;
|
||||
}
|
||||
}
|
||||
|
||||
QColor
|
||||
ColorPicker::drawColor()
|
||||
QColor ColorPicker::drawColor()
|
||||
{
|
||||
return m_drawColor;
|
||||
}
|
||||
|
||||
void
|
||||
ColorPicker::show()
|
||||
void ColorPicker::show()
|
||||
{
|
||||
grabMouse();
|
||||
QWidget::show();
|
||||
}
|
||||
|
||||
void
|
||||
ColorPicker::hide()
|
||||
void ColorPicker::hide()
|
||||
{
|
||||
releaseMouse();
|
||||
QWidget::hide();
|
||||
}
|
||||
|
||||
void
|
||||
ColorPicker::paintEvent(QPaintEvent*)
|
||||
void ColorPicker::paintEvent(QPaintEvent*)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
@@ -101,8 +97,7 @@ ColorPicker::paintEvent(QPaintEvent*)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ColorPicker::mouseMoveEvent(QMouseEvent* e)
|
||||
void ColorPicker::mouseMoveEvent(QMouseEvent* e)
|
||||
{
|
||||
for (int i = 0; i < m_colorList.size(); ++i) {
|
||||
if (m_colorAreaList.at(i).contains(e->pos())) {
|
||||
@@ -114,8 +109,7 @@ ColorPicker::mouseMoveEvent(QMouseEvent* e)
|
||||
}
|
||||
}
|
||||
|
||||
QVector<QRect>
|
||||
ColorPicker::handleMask() const
|
||||
QVector<QRect> ColorPicker::handleMask() const
|
||||
{
|
||||
QVector<QRect> areas;
|
||||
for (const QRect& rect : m_colorAreaList) {
|
||||
|
||||
@@ -30,8 +30,7 @@ HoverEventFilter::HoverEventFilter(QObject* parent)
|
||||
: QObject(parent)
|
||||
{}
|
||||
|
||||
bool
|
||||
HoverEventFilter::eventFilter(QObject* watched, QEvent* event)
|
||||
bool HoverEventFilter::eventFilter(QObject* watched, QEvent* event)
|
||||
{
|
||||
QEvent::Type t = event->type();
|
||||
switch (t) {
|
||||
|
||||
@@ -25,14 +25,12 @@ ModificationCommand::ModificationCommand(QPixmap* p, CaptureTool* t)
|
||||
setText(t->name());
|
||||
}
|
||||
|
||||
void
|
||||
ModificationCommand::undo()
|
||||
void ModificationCommand::undo()
|
||||
{
|
||||
m_tool->undo(*m_pixmap);
|
||||
}
|
||||
|
||||
void
|
||||
ModificationCommand::redo()
|
||||
void ModificationCommand::redo()
|
||||
{
|
||||
QPainter p(m_pixmap);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
@@ -40,14 +40,12 @@ NotifierBox::NotifierBox(QWidget* parent)
|
||||
setFixedSize(QSize(size, size));
|
||||
}
|
||||
|
||||
void
|
||||
NotifierBox::enterEvent(QEvent*)
|
||||
void NotifierBox::enterEvent(QEvent*)
|
||||
{
|
||||
hide();
|
||||
}
|
||||
|
||||
void
|
||||
NotifierBox::paintEvent(QPaintEvent*)
|
||||
void NotifierBox::paintEvent(QPaintEvent*)
|
||||
{
|
||||
QPainter painter(this);
|
||||
// draw Elipse
|
||||
@@ -60,8 +58,7 @@ NotifierBox::paintEvent(QPaintEvent*)
|
||||
painter.drawText(rect(), Qt::AlignCenter, m_message);
|
||||
}
|
||||
|
||||
void
|
||||
NotifierBox::showMessage(const QString& msg)
|
||||
void NotifierBox::showMessage(const QString& msg)
|
||||
{
|
||||
m_message = msg;
|
||||
update();
|
||||
@@ -69,8 +66,7 @@ NotifierBox::showMessage(const QString& msg)
|
||||
m_timer->start();
|
||||
}
|
||||
|
||||
void
|
||||
NotifierBox::showColor(const QColor& color)
|
||||
void NotifierBox::showColor(const QColor& color)
|
||||
{
|
||||
Q_UNUSED(color);
|
||||
m_message = QLatin1String("");
|
||||
|
||||
@@ -45,8 +45,8 @@ SelectionWidget::SelectionWidget(const QColor& c, QWidget* parent)
|
||||
m_handleOffset = QPoint(-handleSide / 2, -handleSide / 2);
|
||||
}
|
||||
|
||||
SelectionWidget::SideType
|
||||
SelectionWidget::getMouseSide(const QPoint& point) const
|
||||
SelectionWidget::SideType SelectionWidget::getMouseSide(
|
||||
const QPoint& point) const
|
||||
{
|
||||
if (m_TLArea.contains(point)) {
|
||||
return TOPLEFT_SIDE;
|
||||
@@ -69,8 +69,7 @@ SelectionWidget::getMouseSide(const QPoint& point) const
|
||||
}
|
||||
}
|
||||
|
||||
QVector<QRect>
|
||||
SelectionWidget::handlerAreas()
|
||||
QVector<QRect> SelectionWidget::handlerAreas()
|
||||
{
|
||||
QVector<QRect> areas;
|
||||
areas << m_TLHandle << m_TRHandle << m_BLHandle << m_BRHandle << m_LHandle
|
||||
@@ -78,8 +77,7 @@ SelectionWidget::handlerAreas()
|
||||
return areas;
|
||||
}
|
||||
|
||||
void
|
||||
SelectionWidget::setGeometryAnimated(const QRect& r)
|
||||
void SelectionWidget::setGeometryAnimated(const QRect& r)
|
||||
{
|
||||
if (isVisible()) {
|
||||
m_animation->setStartValue(geometry());
|
||||
@@ -88,46 +86,39 @@ SelectionWidget::setGeometryAnimated(const QRect& r)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SelectionWidget::saveGeometry()
|
||||
void SelectionWidget::saveGeometry()
|
||||
{
|
||||
m_geometryBackup = geometry();
|
||||
}
|
||||
|
||||
QRect
|
||||
SelectionWidget::savedGeometry()
|
||||
QRect SelectionWidget::savedGeometry()
|
||||
{
|
||||
return m_geometryBackup;
|
||||
}
|
||||
|
||||
void
|
||||
SelectionWidget::paintEvent(QPaintEvent*)
|
||||
void SelectionWidget::paintEvent(QPaintEvent*)
|
||||
{
|
||||
QPainter p(this);
|
||||
p.setPen(m_color);
|
||||
p.drawRect(rect() + QMargins(0, 0, -1, -1));
|
||||
}
|
||||
|
||||
void
|
||||
SelectionWidget::resizeEvent(QResizeEvent*)
|
||||
void SelectionWidget::resizeEvent(QResizeEvent*)
|
||||
{
|
||||
updateAreas();
|
||||
}
|
||||
|
||||
void
|
||||
SelectionWidget::moveEvent(QMoveEvent*)
|
||||
void SelectionWidget::moveEvent(QMoveEvent*)
|
||||
{
|
||||
updateAreas();
|
||||
}
|
||||
|
||||
void
|
||||
SelectionWidget::updateColor(const QColor& c)
|
||||
void SelectionWidget::updateColor(const QColor& c)
|
||||
{
|
||||
m_color = c;
|
||||
}
|
||||
|
||||
void
|
||||
SelectionWidget::updateAreas()
|
||||
void SelectionWidget::updateAreas()
|
||||
{
|
||||
QRect r = rect();
|
||||
m_TLArea.moveTo(m_areaOffset + pos());
|
||||
|
||||
@@ -118,8 +118,7 @@ CaptureLauncher::CaptureLauncher(QWidget* parent)
|
||||
|
||||
// HACK:
|
||||
// https://github.com/KDE/spectacle/blob/fa1e780b8bf3df3ac36c410b9ece4ace041f401b/src/Gui/KSMainWindow.cpp#L70
|
||||
void
|
||||
CaptureLauncher::startCapture()
|
||||
void CaptureLauncher::startCapture()
|
||||
{
|
||||
hide();
|
||||
auto mode = static_cast<CaptureRequest::CaptureMode>(
|
||||
@@ -129,8 +128,7 @@ CaptureLauncher::startCapture()
|
||||
Controller::getInstance()->requestCapture(req);
|
||||
}
|
||||
|
||||
void
|
||||
CaptureLauncher::startDrag()
|
||||
void CaptureLauncher::startDrag()
|
||||
{
|
||||
QDrag* dragHandler = new QDrag(this);
|
||||
QMimeData* mimeData = new QMimeData;
|
||||
@@ -142,8 +140,7 @@ CaptureLauncher::startDrag()
|
||||
dragHandler->exec();
|
||||
}
|
||||
|
||||
void
|
||||
CaptureLauncher::captureTaken(uint id, QPixmap p)
|
||||
void CaptureLauncher::captureTaken(uint id, QPixmap p)
|
||||
{
|
||||
if (id == m_id) {
|
||||
m_id = 0;
|
||||
@@ -159,8 +156,7 @@ CaptureLauncher::captureTaken(uint id, QPixmap p)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CaptureLauncher::captureFailed(uint id)
|
||||
void CaptureLauncher::captureFailed(uint id)
|
||||
{
|
||||
if (id == m_id) {
|
||||
m_id = 0;
|
||||
|
||||
@@ -22,14 +22,12 @@ DraggableWidgetMaker::DraggableWidgetMaker(QObject* parent)
|
||||
: QObject(parent)
|
||||
{}
|
||||
|
||||
void
|
||||
DraggableWidgetMaker::makeDraggable(QWidget* widget)
|
||||
void DraggableWidgetMaker::makeDraggable(QWidget* widget)
|
||||
{
|
||||
widget->installEventFilter(this);
|
||||
}
|
||||
|
||||
bool
|
||||
DraggableWidgetMaker::eventFilter(QObject* obj, QEvent* event)
|
||||
bool DraggableWidgetMaker::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
auto widget = static_cast<QWidget*>(obj);
|
||||
|
||||
|
||||
@@ -36,8 +36,7 @@ ImageLabel::ImageLabel(QWidget* parent)
|
||||
setMinimumSize(size());
|
||||
}
|
||||
|
||||
void
|
||||
ImageLabel::setScreenshot(const QPixmap& pixmap)
|
||||
void ImageLabel::setScreenshot(const QPixmap& pixmap)
|
||||
{
|
||||
m_pixmap = pixmap;
|
||||
const QString tooltip =
|
||||
@@ -46,8 +45,7 @@ ImageLabel::setScreenshot(const QPixmap& pixmap)
|
||||
setScaledPixmap();
|
||||
}
|
||||
|
||||
void
|
||||
ImageLabel::setScaledPixmap()
|
||||
void ImageLabel::setScaledPixmap()
|
||||
{
|
||||
const qreal scale = qApp->devicePixelRatio();
|
||||
QPixmap scaledPixmap = m_pixmap.scaled(
|
||||
@@ -58,8 +56,7 @@ ImageLabel::setScaledPixmap()
|
||||
|
||||
// drag handlers
|
||||
|
||||
void
|
||||
ImageLabel::mousePressEvent(QMouseEvent* event)
|
||||
void ImageLabel::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
m_dragStartPosition = event->pos();
|
||||
@@ -67,16 +64,14 @@ ImageLabel::mousePressEvent(QMouseEvent* event)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ImageLabel::mouseReleaseEvent(QMouseEvent* event)
|
||||
void ImageLabel::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
setCursor(Qt::OpenHandCursor);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ImageLabel::mouseMoveEvent(QMouseEvent* event)
|
||||
void ImageLabel::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
if (!(event->buttons() & Qt::LeftButton)) {
|
||||
return;
|
||||
@@ -90,8 +85,7 @@ ImageLabel::mouseMoveEvent(QMouseEvent* event)
|
||||
}
|
||||
|
||||
// resize handler
|
||||
void
|
||||
ImageLabel::resizeEvent(QResizeEvent* event)
|
||||
void ImageLabel::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
setScaledPixmap();
|
||||
|
||||
@@ -70,13 +70,13 @@ QVector<const char*> InfoWindow::m_description = {
|
||||
QT_TR_NOOP("Copy to clipboard"),
|
||||
QT_TR_NOOP("Save selection as a file"),
|
||||
QT_TR_NOOP("Undo the last modification"),
|
||||
QT_TR_NOOP("Toggle visibility of sidebar with options of the selected tool"),
|
||||
QT_TR_NOOP(
|
||||
"Toggle visibility of sidebar with options of the selected tool"),
|
||||
QT_TR_NOOP("Show color picker"),
|
||||
QT_TR_NOOP("Change the tool's thickness")
|
||||
};
|
||||
|
||||
void
|
||||
InfoWindow::initInfoTable()
|
||||
void InfoWindow::initInfoTable()
|
||||
{
|
||||
QTableWidget* table = new QTableWidget(this);
|
||||
table->setToolTip(tr("Available shortcuts in the screen capture mode."));
|
||||
@@ -119,8 +119,7 @@ InfoWindow::initInfoTable()
|
||||
m_layout->addStretch();
|
||||
}
|
||||
|
||||
void
|
||||
InfoWindow::initLabels()
|
||||
void InfoWindow::initLabels()
|
||||
{
|
||||
m_layout->addStretch();
|
||||
QLabel* licenseTitleLabel = new QLabel(tr("<u><b>License</b></u>"), this);
|
||||
@@ -142,14 +141,14 @@ InfoWindow::initLabels()
|
||||
m_layout->addWidget(versionLabel);
|
||||
m_layout->addStretch();
|
||||
m_layout->addSpacing(10);
|
||||
QLabel* shortcutsTitleLabel = new QLabel(tr("<u><b>Shortcuts</b></u>"), this);
|
||||
QLabel* shortcutsTitleLabel =
|
||||
new QLabel(tr("<u><b>Shortcuts</b></u>"), this);
|
||||
shortcutsTitleLabel->setAlignment(Qt::AlignHCenter);
|
||||
;
|
||||
m_layout->addWidget(shortcutsTitleLabel);
|
||||
}
|
||||
|
||||
void
|
||||
InfoWindow::keyPressEvent(QKeyEvent* e)
|
||||
void InfoWindow::keyPressEvent(QKeyEvent* e)
|
||||
{
|
||||
if (e->key() == Qt::Key_Escape) {
|
||||
close();
|
||||
|
||||
@@ -39,40 +39,34 @@ LoadSpinner::LoadSpinner(QWidget* parent)
|
||||
m_timer->setInterval(30);
|
||||
}
|
||||
|
||||
void
|
||||
LoadSpinner::setColor(const QColor& c)
|
||||
void LoadSpinner::setColor(const QColor& c)
|
||||
{
|
||||
m_color = c;
|
||||
}
|
||||
|
||||
void
|
||||
LoadSpinner::setWidth(int w)
|
||||
void LoadSpinner::setWidth(int w)
|
||||
{
|
||||
setFixedSize(w, w);
|
||||
updateFrame();
|
||||
}
|
||||
|
||||
void
|
||||
LoadSpinner::setHeight(int h)
|
||||
void LoadSpinner::setHeight(int h)
|
||||
{
|
||||
setFixedSize(h, h);
|
||||
updateFrame();
|
||||
}
|
||||
|
||||
void
|
||||
LoadSpinner::start()
|
||||
void LoadSpinner::start()
|
||||
{
|
||||
m_timer->start();
|
||||
}
|
||||
|
||||
void
|
||||
LoadSpinner::stop()
|
||||
void LoadSpinner::stop()
|
||||
{
|
||||
m_timer->stop();
|
||||
}
|
||||
|
||||
void
|
||||
LoadSpinner::paintEvent(QPaintEvent*)
|
||||
void LoadSpinner::paintEvent(QPaintEvent*)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
@@ -86,8 +80,7 @@ LoadSpinner::paintEvent(QPaintEvent*)
|
||||
painter.drawArc(m_frame, (m_startAngle * 16), (m_span * 16));
|
||||
}
|
||||
|
||||
void
|
||||
LoadSpinner::rotate()
|
||||
void LoadSpinner::rotate()
|
||||
{
|
||||
const int advance = 3;
|
||||
const int grow = 8;
|
||||
@@ -107,8 +100,8 @@ LoadSpinner::rotate()
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
LoadSpinner::updateFrame()
|
||||
void LoadSpinner::updateFrame()
|
||||
{
|
||||
m_frame = QRect(OFFSET, OFFSET, width() - OFFSET * 2, height() - OFFSET * 2);
|
||||
m_frame =
|
||||
QRect(OFFSET, OFFSET, width() - OFFSET * 2, height() - OFFSET * 2);
|
||||
}
|
||||
|
||||
@@ -54,16 +54,14 @@ NotificationWidget::NotificationWidget(QWidget* parent)
|
||||
setFixedHeight(40);
|
||||
}
|
||||
|
||||
void
|
||||
NotificationWidget::showMessage(const QString& msg)
|
||||
void NotificationWidget::showMessage(const QString& msg)
|
||||
{
|
||||
m_label->setText(msg);
|
||||
m_label->show();
|
||||
animatedShow();
|
||||
}
|
||||
|
||||
void
|
||||
NotificationWidget::animatedShow()
|
||||
void NotificationWidget::animatedShow()
|
||||
{
|
||||
m_showAnimation->setStartValue(QRect(0, 0, width(), 0));
|
||||
m_showAnimation->setEndValue(QRect(0, 0, width(), height()));
|
||||
@@ -71,8 +69,7 @@ NotificationWidget::animatedShow()
|
||||
m_timer->start();
|
||||
}
|
||||
|
||||
void
|
||||
NotificationWidget::animatedHide()
|
||||
void NotificationWidget::animatedHide()
|
||||
{
|
||||
m_hideAnimation->setStartValue(QRect(0, 0, width(), height()));
|
||||
m_hideAnimation->setEndValue(QRect(0, 0, width(), 0));
|
||||
|
||||
@@ -37,8 +37,7 @@ OrientablePushButton::OrientablePushButton(const QIcon& icon,
|
||||
: CaptureButton(icon, text, parent)
|
||||
{}
|
||||
|
||||
QSize
|
||||
OrientablePushButton::sizeHint() const
|
||||
QSize OrientablePushButton::sizeHint() const
|
||||
{
|
||||
QSize sh = QPushButton::sizeHint();
|
||||
|
||||
@@ -49,8 +48,7 @@ OrientablePushButton::sizeHint() const
|
||||
return sh;
|
||||
}
|
||||
|
||||
void
|
||||
OrientablePushButton::paintEvent(QPaintEvent* event)
|
||||
void OrientablePushButton::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
@@ -73,14 +71,12 @@ OrientablePushButton::paintEvent(QPaintEvent* event)
|
||||
painter.drawControl(QStyle::CE_PushButton, option);
|
||||
}
|
||||
|
||||
OrientablePushButton::Orientation
|
||||
OrientablePushButton::orientation() const
|
||||
OrientablePushButton::Orientation OrientablePushButton::orientation() const
|
||||
{
|
||||
return m_orientation;
|
||||
}
|
||||
|
||||
void
|
||||
OrientablePushButton::setOrientation(
|
||||
void OrientablePushButton::setOrientation(
|
||||
const OrientablePushButton::Orientation& orientation)
|
||||
{
|
||||
m_orientation = orientation;
|
||||
|
||||
@@ -41,7 +41,8 @@ public:
|
||||
case QEvent::MouseMove:
|
||||
return m_pw->handleMouseMove(static_cast<QMouseEvent*>(event));
|
||||
case QEvent::MouseButtonPress:
|
||||
return m_pw->handleMouseButtonPressed(static_cast<QMouseEvent*>(event));
|
||||
return m_pw->handleMouseButtonPressed(
|
||||
static_cast<QMouseEvent*>(event));
|
||||
case QEvent::KeyPress:
|
||||
return m_pw->handleKeyPress(static_cast<QKeyEvent*>(event));
|
||||
default:
|
||||
@@ -107,8 +108,7 @@ SidePanelWidget::SidePanelWidget(QPixmap* p, QWidget* parent)
|
||||
m_layout->addWidget(m_colorWheel);
|
||||
}
|
||||
|
||||
void
|
||||
SidePanelWidget::updateColor(const QColor& c)
|
||||
void SidePanelWidget::updateColor(const QColor& c)
|
||||
{
|
||||
m_color = c;
|
||||
m_colorLabel->setStyleSheet(
|
||||
@@ -116,29 +116,25 @@ SidePanelWidget::updateColor(const QColor& c)
|
||||
m_colorWheel->setColor(m_color);
|
||||
}
|
||||
|
||||
void
|
||||
SidePanelWidget::updateThickness(const int& t)
|
||||
void SidePanelWidget::updateThickness(const int& t)
|
||||
{
|
||||
m_thickness = qBound(0, t, 100);
|
||||
m_thicknessSlider->setValue(m_thickness);
|
||||
}
|
||||
|
||||
void
|
||||
SidePanelWidget::updateColorNoWheel(const QColor& c)
|
||||
void SidePanelWidget::updateColorNoWheel(const QColor& c)
|
||||
{
|
||||
m_color = c;
|
||||
m_colorLabel->setStyleSheet(
|
||||
QStringLiteral("QLabel { background-color : %1; }").arg(c.name()));
|
||||
}
|
||||
|
||||
void
|
||||
SidePanelWidget::updateCurrentThickness()
|
||||
void SidePanelWidget::updateCurrentThickness()
|
||||
{
|
||||
emit thicknessChanged(m_thicknessSlider->value());
|
||||
}
|
||||
|
||||
void
|
||||
SidePanelWidget::colorGrabberActivated()
|
||||
void SidePanelWidget::colorGrabberActivated()
|
||||
{
|
||||
grabKeyboard();
|
||||
grabMouse(Qt::CrossCursor);
|
||||
@@ -151,8 +147,7 @@ SidePanelWidget::colorGrabberActivated()
|
||||
updateGrabButton(true);
|
||||
}
|
||||
|
||||
void
|
||||
SidePanelWidget::releaseColorGrab()
|
||||
void SidePanelWidget::releaseColorGrab()
|
||||
{
|
||||
setMouseTracking(false);
|
||||
removeEventFilter(m_eventFilter);
|
||||
@@ -162,8 +157,7 @@ SidePanelWidget::releaseColorGrab()
|
||||
updateGrabButton(false);
|
||||
}
|
||||
|
||||
QColor
|
||||
SidePanelWidget::grabPixmapColor(const QPoint& p)
|
||||
QColor SidePanelWidget::grabPixmapColor(const QPoint& p)
|
||||
{
|
||||
QColor c;
|
||||
if (m_pixmap) {
|
||||
@@ -173,8 +167,7 @@ SidePanelWidget::grabPixmapColor(const QPoint& p)
|
||||
return c;
|
||||
}
|
||||
|
||||
bool
|
||||
SidePanelWidget::handleKeyPress(QKeyEvent* e)
|
||||
bool SidePanelWidget::handleKeyPress(QKeyEvent* e)
|
||||
{
|
||||
if (e->key() == Qt::Key_Space) {
|
||||
emit togglePanel();
|
||||
@@ -189,8 +182,7 @@ SidePanelWidget::handleKeyPress(QKeyEvent* e)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
SidePanelWidget::handleMouseButtonPressed(QMouseEvent* e)
|
||||
bool SidePanelWidget::handleMouseButtonPressed(QMouseEvent* e)
|
||||
{
|
||||
if (m_colorGrabButton->geometry().contains(e->pos()) ||
|
||||
e->button() == Qt::RightButton) {
|
||||
@@ -203,15 +195,13 @@ SidePanelWidget::handleMouseButtonPressed(QMouseEvent* e)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
SidePanelWidget::handleMouseMove(QMouseEvent* e)
|
||||
bool SidePanelWidget::handleMouseMove(QMouseEvent* e)
|
||||
{
|
||||
updateColorNoWheel(grabPixmapColor(e->globalPos()));
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
SidePanelWidget::updateGrabButton(const bool activated)
|
||||
void SidePanelWidget::updateGrabButton(const bool activated)
|
||||
{
|
||||
if (activated) {
|
||||
m_colorGrabButton->setText(tr("Press ESC to cancel"));
|
||||
|
||||
@@ -44,41 +44,37 @@ UtilityPanel::UtilityPanel(QWidget* parent)
|
||||
&QWidget::hide);
|
||||
}
|
||||
|
||||
QWidget*
|
||||
UtilityPanel::toolWidget() const
|
||||
QWidget* UtilityPanel::toolWidget() const
|
||||
{
|
||||
return m_toolWidget;
|
||||
}
|
||||
|
||||
void
|
||||
UtilityPanel::addToolWidget(QWidget* w)
|
||||
void UtilityPanel::addToolWidget(QWidget* w)
|
||||
{
|
||||
if (m_toolWidget) {
|
||||
m_toolWidget->deleteLater();
|
||||
}
|
||||
if (w) {
|
||||
m_toolWidget = w;
|
||||
m_toolWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred);
|
||||
m_toolWidget->setSizePolicy(QSizePolicy::Ignored,
|
||||
QSizePolicy::Preferred);
|
||||
m_upLayout->addWidget(w);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
UtilityPanel::clearToolWidget()
|
||||
void UtilityPanel::clearToolWidget()
|
||||
{
|
||||
if (m_toolWidget) {
|
||||
m_toolWidget->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
UtilityPanel::pushWidget(QWidget* w)
|
||||
void UtilityPanel::pushWidget(QWidget* w)
|
||||
{
|
||||
m_layout->insertWidget(m_layout->count() - 1, w);
|
||||
}
|
||||
|
||||
void
|
||||
UtilityPanel::toggle()
|
||||
void UtilityPanel::toggle()
|
||||
{
|
||||
if (m_internalPanel->isHidden()) {
|
||||
setAttribute(Qt::WA_TransparentForMouseEvents, false);
|
||||
@@ -94,8 +90,7 @@ UtilityPanel::toggle()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
UtilityPanel::initInternalPanel()
|
||||
void UtilityPanel::initInternalPanel()
|
||||
{
|
||||
m_internalPanel = new QScrollArea(this);
|
||||
m_internalPanel->setAttribute(Qt::WA_NoMousePropagation);
|
||||
|
||||
Reference in New Issue
Block a user