diff --git a/.travis.yml b/.travis.yml index 99c5071..d921d82 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,5 +7,4 @@ before_install: script: - cd build - qmake .. - - make -j4 - + - make -j$(($(nproc) + 1)) diff --git a/AppVeyor/appveyor.yml b/AppVeyor/appveyor.yml index 5c6c092..fa1939d 100644 --- a/AppVeyor/appveyor.yml +++ b/AppVeyor/appveyor.yml @@ -19,7 +19,7 @@ build_script: - xcopy ffmpeg-3.3.2-win64-dev\* %QTDIR% /e /i /Y - xcopy QtAV-depends-windows-x86+x64\* %QTDIR% /e /i /Y - qmake CONFIG+=nopkg ../KShare.pro - - mingw32-make.exe -j8 + - mingw32-make.exe -j%NUMBER_OF_PROCESSORS% - copy release\KShare.exe ..\KShare.exe - cd .. - bash AppVeyor\make_installer.sh diff --git a/KShare.pro b/KShare.pro index 1892928..c92c8fc 100644 --- a/KShare.pro +++ b/KShare.pro @@ -135,19 +135,19 @@ nopkg { } mac { - ICON = icons/icon.icns + ICON = $$PWD/icons/icon.icns SOURCES += $$PWD/platformspecifics/mac/macbackend.cpp HEADERS += $$PWD/platformspecifics/mac/macbackend.hpp LIBS += -framework Carbon warning(Mac is on TODO); } else:win32 { - RC_FILE = icon.rc + RC_FILE = $$PWD/icon.rc SOURCES += $$PWD/platformspecifics/u32/u32backend.cpp HEADERS += $$PWD/platformspecifics/u32/u32backend.hpp LIBS += -luser32 -lkernel32 -lpthread QT += winextras } else:unix { - RC_FILE = icon.rc + RC_FILE = $$PWD/icon.rc SOURCES += $$PWD/platformspecifics/x11/x11backend.cpp HEADERS += $$PWD/platformspecifics/x11/x11backend.hpp QT += x11extras diff --git a/README.md b/README.md index 7931c7f..84e0371 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ A [ShareX](https://getsharex.com/) inspired cross platform utility written with |Linux|Windows|OS X| |:---:|:-----:|:--:| -|[![Build Status](https://nativeci.arsenarsen.com/job/KShare/badge/icon)](https://nativeci.arsenarsen.com/job/KShare)| [![Build status](https://ci.appveyor.com/api/projects/status/7wa4f0bl6u62lo6v?svg=true)](https://ci.appveyor.com/project/ArsenArsen/kshare)| Soon | +|[![Build Status](https://nativeci.arsenarsen.com/job/KShare/badge/icon)](https://nativeci.arsenarsen.com/job/KShare)| [![Build status](https://ci.appveyor.com/api/projects/status/7wa4f0bl6u62lo6v?svg=true)](https://ci.appveyor.com/project/ArsenArsen/kshare)| [![Build Status](https://travis-ci.org/ArsenArsen/KShare.svg?branch=master)](https://travis-ci.org/ArsenArsen/KShare) | ## Screenshot Made with KShare itself, of course :) ![](http://i.imgur.com/ffWvCun.png) diff --git a/cropeditor/cropeditor.cpp b/cropeditor/cropeditor.cpp index bac293d..a0e5e5c 100644 --- a/cropeditor/cropeditor.cpp +++ b/cropeditor/cropeditor.cpp @@ -23,6 +23,8 @@ CropEditor::CropEditor(QPixmap image, QObject *parent) : QObject(parent) { view->move(p.x() + settings::settings().value("cropx", 0).toInt(), p.y() + settings::settings().value("cropy", 0).toInt()); view->setWindowTitle("KShare Crop Editor"); view->show(); + view->raise(); + view->activateWindow(); connect(scene, &CropScene::closedWithRect, this, &CropEditor::crop); } diff --git a/cropeditor/cropscene.cpp b/cropeditor/cropscene.cpp index 3c1702e..6f5d3de 100644 --- a/cropeditor/cropscene.cpp +++ b/cropeditor/cropscene.cpp @@ -92,6 +92,10 @@ CropScene::CropScene(QObject *parent, QPixmap pixmap) initMagnifierGrid(); updateMag(); + addItem(hint); + hint->setPos(5, 5); + hint->setZValue(2); + hint->setVisible(settings::settings().value("crophint", true).toBool()); connect(menu.addAction("Set Font"), &QAction::triggered, this, &CropScene::fontAsk); QPolygonF poly; @@ -169,6 +173,7 @@ void CropScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) { QCursor::setPos(views()[0]->mapToGlobal(cursorPos.toPoint())); } else cursorPos = e->scenePos(); + hint->setVisible(!hint->sceneBoundingRect().contains(cursorPos)); cursorItem->setPos(cursorPos); updateMag(); @@ -283,6 +288,11 @@ void CropScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *e) { void CropScene::keyReleaseEvent(QKeyEvent *event) { if (((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && !drawingSelection) || event->key() == Qt::Key_Escape) done(event->key() != Qt::Key_Escape); + else if (event->key() == Qt::Key_F1) { + bool enabled = !settings::settings().value("crophint", true).toBool(); + hint->setVisible(enabled); + settings::settings().setValue("crophint", enabled); + } } void CropScene::updateMag() { @@ -338,6 +348,7 @@ void CropScene::initMagnifierGrid() { void CropScene::done(bool notEsc) { if (notEsc && rect) { + hint->setVisible(false); rect->setPen(QPen(Qt::NoPen)); magnifier->setVisible(false); cursorItem->setVisible(false); diff --git a/cropeditor/cropscene.hpp b/cropeditor/cropscene.hpp index d2dcfd4..67b1323 100644 --- a/cropeditor/cropscene.hpp +++ b/cropeditor/cropscene.hpp @@ -9,6 +9,7 @@ #include #include #include +#include class CropScene; #include @@ -79,6 +80,19 @@ private: QList gridRectsX; QList gridRectsY; QGraphicsPolygonItem *cursorItem = nullptr; + QGraphicsPixmapItem *hint = new QGraphicsPixmapItem(screenshotutil::renderText( // + "Press F1 to toggle this hint\n" + "\tHold Shift to slow the cursor down\n" + "\tCtrl+Drag a drawing to move it around\n" + "\tAlt+Click a drawing to remove it\n" + "\tPress Return/Enter to finish\n" + "\tPress ESC to cancel\n" + "\tRight-click to get a drawing menu\n" + "\tNOTE: You must select 'Reset pen selection' before closing the editor\n" + "\tIf you do not it will not close.", + 5, + QColor(0, 0, 0, 125), + Qt::white)); }; #endif // CROPSCENE_HPP diff --git a/cropeditor/drawing/bluritem.hpp b/cropeditor/drawing/bluritem.hpp index bfff86f..2882a5a 100644 --- a/cropeditor/drawing/bluritem.hpp +++ b/cropeditor/drawing/bluritem.hpp @@ -7,7 +7,7 @@ class BlurItem : public DrawItem { public: - QString name() { + QString name() override { return "Blur"; } ~BlurItem() { diff --git a/cropeditor/drawing/ellipseitem.hpp b/cropeditor/drawing/ellipseitem.hpp index 0169d74..46c8678 100644 --- a/cropeditor/drawing/ellipseitem.hpp +++ b/cropeditor/drawing/ellipseitem.hpp @@ -7,7 +7,7 @@ class EllipseItem : public DrawItem { public: EllipseItem() { } - QString name() { + QString name() override { return "Blur"; } ~EllipseItem() { diff --git a/main.cpp b/main.cpp index a16c765..a1ed9af 100644 --- a/main.cpp +++ b/main.cpp @@ -89,7 +89,7 @@ int main(int argc, char *argv[]) { Worker::init(); a.connect(&a, &QApplication::aboutToQuit, Worker::end); a.connect(&a, &QApplication::aboutToQuit, [] { stillAlive = false; }); - + screenshotutil::renderText("DICKS").save("/home/arsen/test.png"); if (!parser.isSet(h)) w.show(); return a.exec(); } diff --git a/recording/encoders/encodersettingsdialog.ui b/recording/encoders/encodersettingsdialog.ui index 0ba32c2..7c945c0 100644 --- a/recording/encoders/encodersettingsdialog.ui +++ b/recording/encoders/encodersettingsdialog.ui @@ -13,7 +13,7 @@ Dialog - + @@ -62,7 +62,7 @@ - 0 + 2 @@ -162,7 +162,7 @@ VP9 - + @@ -176,7 +176,7 @@ GIF - + diff --git a/recording/recordingformats.cpp b/recording/recordingformats.cpp index dfb5d37..c19d9c6 100644 --- a/recording/recordingformats.cpp +++ b/recording/recordingformats.cpp @@ -22,19 +22,10 @@ RecordingFormats::RecordingFormats(formats::Recording f) { validator = [](QSize) { return false; }; return; } - tmpDir = QDir(tmp); - QString name - = QString("KShareTemp-") + QString::number(PlatformBackend::inst().pid()) + "-" + QTime::currentTime().toString(); - tmpDir.mkdir(name); - tmpDir.cd(name); iFormat = QImage::Format_RGB888; - path = tmpDir.absoluteFilePath("res." + formats::recordingFormatName(f).toLower()); + path = tmpDir.filePath("res." + formats::recordingFormatName(f).toLower()); finalizer = [&] { delete enc; - if (interrupt || !frameAdded) { - tmpDir.removeRecursively(); - return QString(); - } return QFile(path).size() > 0 ? path : QString(); }; validator = [&](QSize s) { @@ -69,10 +60,7 @@ RecordingFormats::RecordingFormats(formats::Recording f) { interrupt = true; } }; - postUploadTask = [&] { - tmpDir.removeRecursively(); - QScopedPointer th(this); - }; + postUploadTask = [&] { QScopedPointer th(this); }; anotherFormat = formats::recordingFormatName(f); } diff --git a/recording/recordingformats.hpp b/recording/recordingformats.hpp index ad5825d..09fb505 100644 --- a/recording/recordingformats.hpp +++ b/recording/recordingformats.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -27,7 +28,7 @@ private: std::function postUploadTask; std::vector frames; QImage::Format iFormat; - QDir tmpDir; + QTemporaryDir tmpDir; QString path; Encoder *enc = NULL; bool interrupt = false; diff --git a/screenareaselector/screenareaselector.cpp b/screenareaselector/screenareaselector.cpp index 4a731b5..3d44ae5 100644 --- a/screenareaselector/screenareaselector.cpp +++ b/screenareaselector/screenareaselector.cpp @@ -35,7 +35,7 @@ ScreenAreaSelector::~ScreenAreaSelector() { void ScreenAreaSelector::keyPressEvent(QKeyEvent *event) { event->accept(); if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) { - QRect r = QRect(pos(), rect().size()); + QRect r = QRect(mapToGlobal(pos()), rect().size()); emit selectedArea(r); close(); } else if (event->key() == Qt::Key_Escape) diff --git a/screenshotutil.cpp b/screenshotutil.cpp index 0cc7c1d..ffe2044 100644 --- a/screenshotutil.cpp +++ b/screenshotutil.cpp @@ -75,5 +75,27 @@ QPoint screenshotutil::smallestScreenCoordinate() { return smallestCoordinate; } -QPixmap screenshotutil::renderText(QString toRender, QColor background, QFont font) { +QPixmap screenshotutil::renderText(QString toRender, int padding, QColor background, QColor pen, QFont font) { + QFontMetrics metric(font); + QStringList lines = toRender.replace("\r", "").split('\n'); + QSize resultingSize(0, padding * 2); + int lineSpace = metric.leading(); + for (QString line : lines) { + QRect br = metric.boundingRect(line); + resultingSize.rheight() += lineSpace + br.height(); + resultingSize.rwidth() = qMax(br.width(), resultingSize.width()); + } + resultingSize.rwidth() += padding * 2; + QPixmap renderred(resultingSize); + renderred.fill(background); + QPainter painter(&renderred); + painter.setPen(pen); + int y = padding; + for (QString line : lines) { + QRect br = metric.boundingRect(line); + painter.drawText(padding, y, br.width(), br.height(), 0, line); + y += lineSpace + br.height(); + } + painter.end(); + return renderred; } diff --git a/screenshotutil.hpp b/screenshotutil.hpp index 83267db..91a7965 100644 --- a/screenshotutil.hpp +++ b/screenshotutil.hpp @@ -10,7 +10,7 @@ QPixmap fullscreenArea(bool cursor = true, qreal x = 0, qreal y = 0, qreal w = - QPixmap window(WId wid, QScreen *w = QApplication::primaryScreen()); void toClipboard(QString value); QPoint smallestScreenCoordinate(); -QPixmap renderText(QString toRender, QColor background = Qt::transparent, QFont font = QFont()); +QPixmap renderText(QString toRender, int padding = 5, QColor background = Qt::transparent, QColor pen = Qt::white, QFont font = QFont()); } #endif // SCREENSHOTUTIL_HPP