Some improvemnts on the color picked & crop editor
This commit is contained in:
parent
7c9266085b
commit
f425d47bcd
@ -11,7 +11,7 @@ ColorPickerScene::ColorPickerScene(QPixmap *pixmap, QWidget *parentWidget)
|
|||||||
setFrameShape(QFrame::NoFrame); // Time taken to solve: A george99g and 38 minutes.
|
setFrameShape(QFrame::NoFrame); // Time taken to solve: A george99g and 38 minutes.
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
|
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
|
||||||
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing);
|
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing);
|
||||||
setCursor(QCursor(Qt::CrossCursor));
|
setCursor(QCursor(Qt::CrossCursor));
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
@ -18,15 +18,15 @@ CropEditor::CropEditor(QPixmap *image, QObject *parent) : QObject(parent) {
|
|||||||
pixmapItem->setScale(1 / ratio);
|
pixmapItem->setScale(1 / ratio);
|
||||||
scene->addItem(pixmapItem);
|
scene->addItem(pixmapItem);
|
||||||
scene->setSceneRect(image->rect());
|
scene->setSceneRect(image->rect());
|
||||||
view->showFullScreen();
|
view->show();
|
||||||
|
view->resize(pixmapItem->pixmap().width(), pixmapItem->pixmap().height());
|
||||||
QTimer::singleShot(0, [&] { view->showFullScreen(); });
|
|
||||||
|
|
||||||
connect(scene, &CropScene::closedWithRect, this, &CropEditor::crop);
|
connect(scene, &CropScene::closedWithRect, this, &CropEditor::crop);
|
||||||
}
|
}
|
||||||
|
|
||||||
CropEditor::~CropEditor() {
|
CropEditor::~CropEditor() {
|
||||||
delete scene;
|
delete scene;
|
||||||
|
delete view;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CropEditor::crop(QRect rect) {
|
void CropEditor::crop(QRect rect) {
|
||||||
|
@ -4,7 +4,7 @@ CropView::CropView(QGraphicsScene *scene) : QGraphicsView(scene) {
|
|||||||
setFrameShape(QFrame::NoFrame); // Time taken to solve: A george99g and 38 minutes.
|
setFrameShape(QFrame::NoFrame); // Time taken to solve: A george99g and 38 minutes.
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
|
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
|
||||||
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing);
|
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing);
|
||||||
setCursor(QCursor(Qt::CrossCursor));
|
setCursor(QCursor(Qt::CrossCursor));
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,22 @@ void addHotkeyItem(QString text, QString name, std::function<void()> func, QStri
|
|||||||
hotkeying::load(name, func, def);
|
hotkeying::load(name, func, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::rec() {
|
||||||
|
if (controller->isRunning()) return;
|
||||||
|
auto f
|
||||||
|
= static_cast<formats::Recording>(settings::settings().value("recording/format", (int)formats::Recording::None).toInt());
|
||||||
|
if (f >= formats::Recording::None) return;
|
||||||
|
RecordingContext *ctx = new RecordingContext;
|
||||||
|
RecordingFormats *format = new RecordingFormats(f);
|
||||||
|
ctx->consumer = format->getConsumer();
|
||||||
|
ctx->finalizer = format->getFinalizer();
|
||||||
|
ctx->validator = format->getValidator();
|
||||||
|
ctx->format = format->getFormat();
|
||||||
|
ctx->postUploadTask = format->getPostUploadTask();
|
||||||
|
ctx->anotherFormat = format->getAnotherFormat();
|
||||||
|
controller->start(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||||
instance = this;
|
instance = this;
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -46,9 +62,13 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
QAction *fullscreen = new QAction("Take fullscreen shot", this);
|
QAction *fullscreen = new QAction("Take fullscreen shot", this);
|
||||||
QAction *area = new QAction("Take area shot", this);
|
QAction *area = new QAction("Take area shot", this);
|
||||||
QAction *picker = new QAction("Show color picker", this);
|
QAction *picker = new QAction("Show color picker", this);
|
||||||
|
QAction *rec = new QAction("Record screen", this);
|
||||||
|
QAction *recoff = new QAction("Stop recording", this);
|
||||||
menu->addActions({ quit, shtoggle, picker });
|
menu->addActions({ quit, shtoggle, picker });
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addActions({ fullscreen, area });
|
menu->addActions({ fullscreen, area });
|
||||||
|
menu->addSeparator();
|
||||||
|
menu->addActions({ rec, recoff });
|
||||||
connect(quit, &QAction::triggered, this, &MainWindow::quit);
|
connect(quit, &QAction::triggered, this, &MainWindow::quit);
|
||||||
connect(shtoggle, &QAction::triggered, this, &MainWindow::toggleVisible);
|
connect(shtoggle, &QAction::triggered, this, &MainWindow::toggleVisible);
|
||||||
connect(picker, &QAction::triggered, [] { ColorPickerScene::showPicker(); });
|
connect(picker, &QAction::triggered, [] { ColorPickerScene::showPicker(); });
|
||||||
@ -58,6 +78,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
});
|
});
|
||||||
connect(fullscreen, &QAction::triggered, this, [] { screenshotter::fullscreenDelayed(); });
|
connect(fullscreen, &QAction::triggered, this, [] { screenshotter::fullscreenDelayed(); });
|
||||||
connect(area, &QAction::triggered, this, [] { screenshotter::areaDelayed(); });
|
connect(area, &QAction::triggered, this, [] { screenshotter::areaDelayed(); });
|
||||||
|
connect(rec, &QAction::triggered, this, &MainWindow::rec);
|
||||||
|
connect(recoff, &QAction::triggered, [this] { controller->end(); });
|
||||||
tray->setContextMenu(menu);
|
tray->setContextMenu(menu);
|
||||||
|
|
||||||
ui->uploaderList->setSelectionBehavior(QAbstractItemView::SelectRows);
|
ui->uploaderList->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
@ -88,25 +110,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
ui->hotkeys->setSelectionMode(QListWidget::SingleSelection);
|
ui->hotkeys->setSelectionMode(QListWidget::SingleSelection);
|
||||||
|
|
||||||
addHotkeyItem("Fullscreen image", "fullscreen", [] { screenshotter::fullscreen(); });
|
addHotkeyItem("Fullscreen image", "fullscreen", [] { screenshotter::fullscreen(); });
|
||||||
addHotkeyItem("Area image", "area", [] { //
|
addHotkeyItem("Area image", "area", [] { screenshotter::area(); });
|
||||||
screenshotter::area(); //
|
|
||||||
});
|
|
||||||
addHotkeyItem("Color picker", "picker", [] { ColorPickerScene::showPicker(); });
|
addHotkeyItem("Color picker", "picker", [] { ColorPickerScene::showPicker(); });
|
||||||
addHotkeyItem("Stop Recording", "recordingstop", [&] { controller->end(); });
|
addHotkeyItem("Stop Recording", "recordingstop", [&] { controller->end(); });
|
||||||
addHotkeyItem("Start Recording", "recordingstart", [&] {
|
addHotkeyItem("Start Recording", "recordingstart", [&] { this->rec(); });
|
||||||
auto f
|
|
||||||
= static_cast<formats::Recording>(settings::settings().value("recording/format", (int)formats::Recording::None).toInt());
|
|
||||||
if (f >= formats::Recording::None) return;
|
|
||||||
RecordingContext *ctx = new RecordingContext;
|
|
||||||
RecordingFormats *format = new RecordingFormats(f);
|
|
||||||
ctx->consumer = format->getConsumer();
|
|
||||||
ctx->finalizer = format->getFinalizer();
|
|
||||||
ctx->validator = format->getValidator();
|
|
||||||
ctx->format = format->getFormat();
|
|
||||||
ctx->postUploadTask = format->getPostUploadTask();
|
|
||||||
ctx->anotherFormat = format->getAnotherFormat();
|
|
||||||
controller->start(ctx);
|
|
||||||
});
|
|
||||||
|
|
||||||
ui->quickMode->setChecked(settings::settings().value("quickMode", false).toBool());
|
ui->quickMode->setChecked(settings::settings().value("quickMode", false).toBool());
|
||||||
ui->hideToTray->setChecked(settings::settings().value("hideOnClose", true).toBool());
|
ui->hideToTray->setChecked(settings::settings().value("hideOnClose", true).toBool());
|
||||||
|
@ -53,6 +53,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
static MainWindow *instance;
|
static MainWindow *instance;
|
||||||
RecordingController *controller = new RecordingController;
|
RecordingController *controller = new RecordingController;
|
||||||
|
private slots:
|
||||||
|
void rec();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
|
@ -25,10 +25,12 @@ bool RecordingController::start(RecordingContext *context) {
|
|||||||
_context = context;
|
_context = context;
|
||||||
ScreenAreaSelector *sel = new ScreenAreaSelector;
|
ScreenAreaSelector *sel = new ScreenAreaSelector;
|
||||||
connect(sel, &ScreenAreaSelector::selectedArea, this, &RecordingController::startWithArea);
|
connect(sel, &ScreenAreaSelector::selectedArea, this, &RecordingController::startWithArea);
|
||||||
|
connect(this, &RecordingController::ended, sel, &ScreenAreaSelector::deleteLater);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RecordingController::end() {
|
bool RecordingController::end() {
|
||||||
|
emit ended();
|
||||||
if (!isRunning()) return false;
|
if (!isRunning()) return false;
|
||||||
area = QRect();
|
area = QRect();
|
||||||
if (preview) {
|
if (preview) {
|
||||||
|
@ -52,6 +52,8 @@ private:
|
|||||||
RecordingPreview *preview = nullptr;
|
RecordingPreview *preview = nullptr;
|
||||||
unsigned int frame = 0;
|
unsigned int frame = 0;
|
||||||
unsigned int time = 0;
|
unsigned int time = 0;
|
||||||
|
signals:
|
||||||
|
void ended();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RECORDINGCONTROLLER_HPP
|
#endif // RECORDINGCONTROLLER_HPP
|
||||||
|
Loading…
Reference in New Issue
Block a user