Skip to content

Commit

Permalink
Start adding coordinate conversion between view and capture.
Browse files Browse the repository at this point in the history
  • Loading branch information
karliss committed Jun 13, 2021
1 parent 8e636b1 commit 47bf2da
Show file tree
Hide file tree
Showing 7 changed files with 228 additions and 82 deletions.
17 changes: 4 additions & 13 deletions src/core/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ void Controller::startVisualCapture(const uint id,
return;
}

m_captureWindow = new CaptureWidget(id, forcedSavePath);
//m_captureWindow = new CaptureWidget(id, forcedSavePath, ConfigHandler().windowMode());
m_captureWindow = new CaptureWidget(id, forcedSavePath, CaptureConfig::MaximizeWindow);
// m_captureWindow = new CaptureWidget(id, forcedSavePath, false); //
// debug
connect(m_captureWindow,
Expand All @@ -307,18 +308,8 @@ void Controller::startVisualCapture(const uint id,
this,
&Controller::captureTaken);

#ifdef Q_OS_WIN
m_captureWindow->show();
#elif defined(Q_OS_MACOS)
// In "Emulate fullscreen mode"
m_captureWindow->showFullScreen();
m_captureWindow->activateWindow();
m_captureWindow->raise();
#else
//m_captureWindow->showFullScreen();
m_captureWindow->showMaximized();
// m_captureWindow->show(); // For CaptureWidget Debugging under Linux
#endif
m_captureWindow->OpenAndShow();

if (!m_appLatestUrl.isEmpty() &&
ConfigHandler().ignoreUpdateToVersion().compare(
m_appLatestVersion) < 0) {
Expand Down
22 changes: 22 additions & 0 deletions src/utils/confighandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <QFile>
#include <QKeySequence>
#include <QStandardPaths>
#include <QMetaEnum>
#include <algorithm>
#if defined(Q_OS_MACOS)
#include <QProcess>
Expand Down Expand Up @@ -75,6 +76,27 @@ void ConfigHandler::setButtons(
QVariant::fromValue(l.toList()));
}

CaptureConfig::CaptureWindowMode ConfigHandler::windowMode()
{
auto modeEnum = QMetaEnum::fromType<CaptureConfig::CaptureWindowMode>();
auto modeString = m_settings.value("windowMode", "").toString().toUtf8();
bool ok = false;
CaptureConfig::CaptureWindowMode result = static_cast<CaptureConfig::CaptureWindowMode>(modeEnum.keyToValue(modeString.constData(), &ok));
if (ok) {
return result;
}
#if defined(Q_OS_MACOS)
return CaptureConfig::CaptureWindowMode::FullScreenCurrent;
#endif
return CaptureConfig::CaptureWindowMode::FullScreenAll;
}

void ConfigHandler::setWindowMode(CaptureConfig::CaptureWindowMode mode)
{
auto modeEnum = QMetaEnum::fromType<CaptureConfig::CaptureWindowMode>();
m_settings.setValue("windowMode", modeEnum.valueToKey(static_cast<int>(mode)));
}

QVector<QColor> ConfigHandler::getUserColors()
{
QVector<QColor> colors;
Expand Down
4 changes: 4 additions & 0 deletions src/utils/confighandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include "src/widgets/capture/capturetoolbutton.h"
#include "src/widgets/capture/captureconfig.h"
#include <QSettings>
#include <QStringList>
#include <QVariant>
Expand All @@ -17,6 +18,9 @@ class ConfigHandler
QVector<CaptureToolButton::ButtonType> getButtons();
void setButtons(const QVector<CaptureToolButton::ButtonType>&);

CaptureConfig::CaptureWindowMode windowMode();
void setWindowMode(CaptureConfig::CaptureWindowMode);

QVector<QColor> getUserColors();

QString savePath();
Expand Down
1 change: 1 addition & 0 deletions src/widgets/capture/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ target_sources(
PRIVATE buttonhandler.h
capturebutton.h
capturetoolbutton.h
captureconfig.h
capturewidget.h
colorpicker.h
hovereventfilter.h
Expand Down
18 changes: 18 additions & 0 deletions src/widgets/capture/captureconfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: GPL-3.0-or-later


#pragma once

#include <QObject>

namespace CaptureConfig {
Q_NAMESPACE

enum CaptureWindowMode {
FullScreenAll,
FullScreenCurrent,
MaximizeWindow,
DebugNonFullScreen
};
Q_ENUM_NS(CaptureWindowMode)
}
Loading

0 comments on commit 47bf2da

Please sign in to comment.