Browse Source

Some improvemnts on the color picked & crop editor

tags/v5.0.0
ArsenArsen 5 years ago
parent
commit
f425d47bcd
  1. 2
      colorpicker/colorpickerscene.cpp
  2. 6
      cropeditor/cropeditor.cpp
  3. 2
      cropeditor/cropview.cpp
  4. 41
      mainwindow.cpp
  5. 2
      mainwindow.hpp
  6. 2
      recording/recordingcontroller.cpp
  7. 2
      recording/recordingcontroller.hpp

2
colorpicker/colorpickerscene.cpp

@ -11,7 +11,7 @@ ColorPickerScene::ColorPickerScene(QPixmap *pixmap, QWidget *parentWidget)
setFrameShape(QFrame::NoFrame); // Time taken to solve: A george99g and 38 minutes.
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing);
setCursor(QCursor(Qt::CrossCursor));
setMouseTracking(true);

6
cropeditor/cropeditor.cpp

@ -18,15 +18,15 @@ CropEditor::CropEditor(QPixmap *image, QObject *parent) : QObject(parent) {
pixmapItem->setScale(1 / ratio);
scene->addItem(pixmapItem);
scene->setSceneRect(image->rect());
view->showFullScreen();
QTimer::singleShot(0, [&] { view->showFullScreen(); });
view->show();
view->resize(pixmapItem->pixmap().width(), pixmapItem->pixmap().height());
connect(scene, &CropScene::closedWithRect, this, &CropEditor::crop);
}
CropEditor::~CropEditor() {
delete scene;
delete view;
}
void CropEditor::crop(QRect rect) {

2
cropeditor/cropview.cpp

@ -4,7 +4,7 @@ CropView::CropView(QGraphicsScene *scene) : QGraphicsView(scene) {
setFrameShape(QFrame::NoFrame); // Time taken to solve: A george99g and 38 minutes.
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing);
setCursor(QCursor(Qt::CrossCursor));
}

41
mainwindow.cpp

@ -33,6 +33,22 @@ void addHotkeyItem(QString text, QString name, std::function<void()> func, QStri
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) {
instance = 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 *area = new QAction("Take area shot", 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->addSeparator();
menu->addActions({ fullscreen, area });
menu->addSeparator();
menu->addActions({ rec, recoff });
connect(quit, &QAction::triggered, this, &MainWindow::quit);
connect(shtoggle, &QAction::triggered, this, &MainWindow::toggleVisible);
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(area, &QAction::triggered, this, [] { screenshotter::areaDelayed(); });
connect(rec, &QAction::triggered, this, &MainWindow::rec);
connect(recoff, &QAction::triggered, [this] { controller->end(); });
tray->setContextMenu(menu);
ui->uploaderList->setSelectionBehavior(QAbstractItemView::SelectRows);
@ -88,25 +110,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
ui->hotkeys->setSelectionMode(QListWidget::SingleSelection);
addHotkeyItem("Fullscreen image", "fullscreen", [] { screenshotter::fullscreen(); });
addHotkeyItem("Area image", "area", [] { //
screenshotter::area(); //
});
addHotkeyItem("Area image", "area", [] { screenshotter::area(); });
addHotkeyItem("Color picker", "picker", [] { ColorPickerScene::showPicker(); });
addHotkeyItem("Stop Recording", "recordingstop", [&] { controller->end(); });
addHotkeyItem("Start Recording", "recordingstart", [&] {
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);
});
addHotkeyItem("Start Recording", "recordingstart", [&] { this->rec(); });
ui->quickMode->setChecked(settings::settings().value("quickMode", false).toBool());
ui->hideToTray->setChecked(settings::settings().value("hideOnClose", true).toBool());

2
mainwindow.hpp

@ -53,6 +53,8 @@ public:
private:
static MainWindow *instance;
RecordingController *controller = new RecordingController;
private slots:
void rec();
protected:
void closeEvent(QCloseEvent *event);

2
recording/recordingcontroller.cpp

@ -25,10 +25,12 @@ bool RecordingController::start(RecordingContext *context) {
_context = context;
ScreenAreaSelector *sel = new ScreenAreaSelector;
connect(sel, &ScreenAreaSelector::selectedArea, this, &RecordingController::startWithArea);
connect(this, &RecordingController::ended, sel, &ScreenAreaSelector::deleteLater);
return true;
}
bool RecordingController::end() {
emit ended();
if (!isRunning()) return false;
area = QRect();
if (preview) {

2
recording/recordingcontroller.hpp

@ -52,6 +52,8 @@ private:
RecordingPreview *preview = nullptr;
unsigned int frame = 0;
unsigned int time = 0;
signals:
void ended();
};
#endif // RECORDINGCONTROLLER_HPP

Loading…
Cancel
Save