Add usage hints
This commit is contained in:
parent
0dd4a40adc
commit
e090389201
@ -7,5 +7,4 @@ before_install:
|
||||
script:
|
||||
- cd build
|
||||
- qmake ..
|
||||
- make -j4
|
||||
|
||||
- make -j$(($(nproc) + 1))
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <QKeyEvent>
|
||||
#include <QMenu>
|
||||
#include <functional>
|
||||
#include <screenshotutil.hpp>
|
||||
class CropScene;
|
||||
|
||||
#include <cropeditor/drawing/drawitem.hpp>
|
||||
@ -79,6 +80,19 @@ private:
|
||||
QList<QGraphicsRectItem *> gridRectsX;
|
||||
QList<QGraphicsRectItem *> 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
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
class BlurItem : public DrawItem {
|
||||
public:
|
||||
QString name() {
|
||||
QString name() override {
|
||||
return "Blur";
|
||||
}
|
||||
~BlurItem() {
|
||||
|
@ -7,7 +7,7 @@ class EllipseItem : public DrawItem {
|
||||
public:
|
||||
EllipseItem() {
|
||||
}
|
||||
QString name() {
|
||||
QString name() override {
|
||||
return "Blur";
|
||||
}
|
||||
~EllipseItem() {
|
||||
|
2
main.cpp
2
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();
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
@ -62,7 +62,7 @@
|
||||
<item row="4" column="0">
|
||||
<widget class="QTabWidget" name="videoTabs">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="hTab">
|
||||
<property name="layoutDirection">
|
||||
@ -162,7 +162,7 @@
|
||||
<attribute name="title">
|
||||
<string>VP9</string>
|
||||
</attribute>
|
||||
<layout class="QFormLayout" name="verticalLayout">
|
||||
<layout class="QFormLayout" name="verticalLayout1">
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="vp9Lossless">
|
||||
<property name="text">
|
||||
@ -176,7 +176,7 @@
|
||||
<attribute name="title">
|
||||
<string>GIF</string>
|
||||
</attribute>
|
||||
<layout class="QFormLayout" name="verticalLayout">
|
||||
<layout class="QFormLayout" name="verticalLayout2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
|
@ -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<RecordingFormats> th(this);
|
||||
};
|
||||
postUploadTask = [&] { QScopedPointer<RecordingFormats> th(this); };
|
||||
anotherFormat = formats::recordingFormatName(f);
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <QFile>
|
||||
#include <QImage>
|
||||
#include <QString>
|
||||
#include <QTemporaryDir>
|
||||
#include <formats.hpp>
|
||||
#include <functional>
|
||||
|
||||
@ -27,7 +28,7 @@ private:
|
||||
std::function<void()> postUploadTask;
|
||||
std::vector<QImage> frames;
|
||||
QImage::Format iFormat;
|
||||
QDir tmpDir;
|
||||
QTemporaryDir tmpDir;
|
||||
QString path;
|
||||
Encoder *enc = NULL;
|
||||
bool interrupt = false;
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user