Miscellaneous small fixes (#1972)

* m_captureWindow->activateWindow(), raise()

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Revert "m_captureWindow->activateWindow(), raise()"

This reverts commit 36320aa38a9584864a5fab32a2ce4872ff5ad072.

* screen --number: indicate 0-indexation

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix color update bug

Also refactored SidePanelWidget sigslots related to color change.

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Stop creating empty flameshot.conf file

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>
This commit is contained in:
Haris Gušić
2021-10-17 17:38:16 +02:00
committed by GitHub
parent f88c98b286
commit b05b028861
5 changed files with 29 additions and 24 deletions

View File

@@ -186,7 +186,7 @@ int main(int argc, char* argv[])
"nothing if raw is specified"));
CommandOption screenNumberOption(
{ "n", "number" },
QObject::tr("Define the screen to capture") + ",\n" +
QObject::tr("Define the screen to capture (starting from 0)") + ",\n" +
QObject::tr("default: screen containing the cursor"),
QObject::tr("Screen number"),
QStringLiteral("-1"));

View File

@@ -163,10 +163,13 @@ static QMap<QString, QSharedPointer<KeySequence>> recognizedShortcuts = {
// CLASS CONFIGHANDLER
ConfigHandler::ConfigHandler(bool skipInitialErrorCheck)
: m_settings(QSettings::IniFormat,
QSettings::UserScope,
qApp->organizationName(),
qApp->applicationName())
{
m_settings.setDefaultFormat(QSettings::IniFormat);
if (m_configWatcher == nullptr && qApp != nullptr) {
if (m_configWatcher == nullptr) {
if (!skipInitialErrorCheck) {
// check for error on initial call
checkAndHandleError();

View File

@@ -184,7 +184,10 @@ CaptureWidget::CaptureWidget(uint id,
connect(m_colorPicker,
&ColorPicker::colorSelected,
this,
&CaptureWidget::setDrawColor);
[this](const QColor& c) {
m_context.mousePos = mapFromGlobal(QCursor::pos());
setDrawColor(c);
});
m_colorPicker->hide();
// Init notification widget
@@ -950,7 +953,7 @@ void CaptureWidget::initPanel()
connect(this,
&CaptureWidget::colorChanged,
m_sidePanel,
&SidePanelWidget::updateColor);
&SidePanelWidget::onColorChanged);
connect(this,
&CaptureWidget::thicknessChanged,
m_sidePanel,
@@ -1150,6 +1153,8 @@ void CaptureWidget::setDrawColor(const QColor& c)
if (m_context.color.isValid()) {
ConfigHandler().setDrawColor(m_context.color);
emit colorChanged(c);
// Update mouse preview
updateTool(activeButtonTool());
// change color for the active tool
auto toolItem = activeToolObject();

View File

@@ -70,7 +70,7 @@ SidePanelWidget::SidePanelWidget(QPixmap* p, QWidget* parent)
if (!QColor::isValidColor(m_colorHex->text())) {
m_colorHex->setText(m_color.name(QColor::HexRgb));
} else {
updateColor(m_colorHex->text());
emit colorChanged(m_colorHex->text());
}
});
// color grab button sigslots
@@ -79,30 +79,20 @@ SidePanelWidget::SidePanelWidget(QPixmap* p, QWidget* parent)
this,
&SidePanelWidget::startColorGrab);
// color wheel sigslots
// re-emit ColorWheel::colorSelected as SidePanelWidget::colorChanged
connect(m_colorWheel,
&color_widgets::ColorWheel::mouseReleaseOnColor,
this,
&SidePanelWidget::colorChanged);
connect(m_colorWheel,
&color_widgets::ColorWheel::colorSelected,
this,
&SidePanelWidget::updateColorNoWheel);
}
void SidePanelWidget::updateColor(const QColor& c)
void SidePanelWidget::onColorChanged(const QColor& c)
{
m_color = c;
updateColorNoWheel(c);
m_colorWheel->setColor(c);
}
void SidePanelWidget::updateColorNoWheel(const QColor& c)
{
m_colorLabel->setStyleSheet(
QStringLiteral("QLabel { background-color : %1; }").arg(c.name()));
m_colorHex->setText(c.name(QColor::HexRgb));
}
void SidePanelWidget::updateThickness(const int& t)
{
m_thickness = qBound(0, t, maxDrawThickness);
@@ -116,7 +106,7 @@ void SidePanelWidget::startColorGrab()
connect(m_colorGrabber,
&ColorGrabWidget::colorUpdated,
this,
&SidePanelWidget::onColorUpdated);
&SidePanelWidget::onTemporaryColorUpdated);
connect(m_colorGrabber,
&ColorGrabWidget::colorGrabbed,
this,
@@ -141,10 +131,10 @@ void SidePanelWidget::onColorGrabAborted()
{
finalizeGrab();
// Restore color that was selected before we started grabbing
updateColor(m_revertColor);
onColorChanged(m_revertColor);
}
void SidePanelWidget::onColorUpdated(const QColor& color)
void SidePanelWidget::onTemporaryColorUpdated(const QColor& color)
{
updateColorNoWheel(color);
}
@@ -154,6 +144,13 @@ void SidePanelWidget::finalizeGrab()
emit togglePanel();
}
void SidePanelWidget::updateColorNoWheel(const QColor& c)
{
m_colorLabel->setStyleSheet(
QStringLiteral("QLabel { background-color : %1; }").arg(c.name()));
m_colorHex->setText(c.name(QColor::HexRgb));
}
bool SidePanelWidget::eventFilter(QObject* obj, QEvent* event)
{
if (event->type() == QEvent::ShortcutOverride) {

View File

@@ -31,18 +31,18 @@ signals:
void togglePanel();
public slots:
void updateColor(const QColor& c);
void updateColorNoWheel(const QColor& c);
void onColorChanged(const QColor& c);
void updateThickness(const int& t);
private slots:
void startColorGrab();
void onColorGrabFinished();
void onColorGrabAborted();
void onColorUpdated(const QColor& color);
void onTemporaryColorUpdated(const QColor& color);
private:
void finalizeGrab();
void updateColorNoWheel(const QColor& c);
bool eventFilter(QObject* obj, QEvent* event) override;
void hideEvent(QHideEvent* event) override;