Compare commits

...

2 commits

Author SHA1 Message Date
a3c38ed291 flameshot 0x0.st upload patch 2024-09-17 16:58:49 +02:00
79bad31c5d fix hardcoded usernames 2024-09-17 15:45:36 +02:00
6 changed files with 123 additions and 11 deletions

View file

@ -0,0 +1,107 @@
diff --git a/src/core/flameshot.cpp b/src/core/flameshot.cpp
index c7eadcad..a0e27094 100644
--- a/src/core/flameshot.cpp
+++ b/src/core/flameshot.cpp
@@ -393,14 +393,14 @@ void Flameshot::exportCapture(const QPixmap& capture,
if (tasks & CR::UPLOAD) {
if (!ConfigHandler().uploadWithoutConfirmation()) {
- auto* dialog = new ImgUploadDialog();
- if (dialog->exec() == QDialog::Rejected) {
- return;
- }
+ // auto* dialog = new ImgUploadDialog();
+ // if (dialog->exec() == QDialog::Rejected) {
+ // return;
+ // }
}
ImgUploaderBase* widget = ImgUploaderManager().uploader(capture);
- widget->show();
+ // widget->show();
widget->activateWindow();
// NOTE: lambda can't capture 'this' because it might be destroyed later
CR::ExportTask tasks = tasks;
@@ -411,7 +411,8 @@ void Flameshot::exportCapture(const QPixmap& capture,
FlameshotDaemon::copyToClipboard(
url.toString(), tr("URL copied to clipboard."));
}
- widget->showPostUploadDialog();
+ // widget->showPostUploadDialog();
+ widget->close();
}
});
}
diff --git a/src/tools/imgupload/storages/imgur/imguruploader.cpp b/src/tools/imgupload/storages/imgur/imguruploader.cpp
index d6748b5a..ae80c659 100644
--- a/src/tools/imgupload/storages/imgur/imguruploader.cpp
+++ b/src/tools/imgupload/storages/imgur/imguruploader.cpp
@@ -16,6 +16,8 @@
#include <QNetworkRequest>
#include <QShortcut>
#include <QUrlQuery>
+#include <QHttpPart>
+#include <QHttpMultiPart>
ImgurUploader::ImgurUploader(const QPixmap& capture, QWidget* parent)
: ImgUploaderBase(capture, parent)
@@ -32,25 +34,8 @@ void ImgurUploader::handleReply(QNetworkReply* reply)
spinner()->deleteLater();
m_currentImageName.clear();
if (reply->error() == QNetworkReply::NoError) {
- QJsonDocument response = QJsonDocument::fromJson(reply->readAll());
- QJsonObject json = response.object();
- QJsonObject data = json[QStringLiteral("data")].toObject();
- setImageURL(data[QStringLiteral("link")].toString());
-
- auto deleteToken = data[QStringLiteral("deletehash")].toString();
-
- // save history
- m_currentImageName = imageURL().toString();
- int lastSlash = m_currentImageName.lastIndexOf("/");
- if (lastSlash >= 0) {
- m_currentImageName = m_currentImageName.mid(lastSlash + 1);
- }
-
- // save image to history
- History history;
- m_currentImageName =
- history.packFileName("imgur", deleteToken, m_currentImageName);
- history.save(pixmap(), m_currentImageName);
+ QString img_url = QString(reply->readAll().toStdString().c_str()).trimmed();
+ setImageURL(img_url);
emit uploadOk(imageURL());
} else {
@@ -65,22 +50,18 @@ void ImgurUploader::upload()
QBuffer buffer(&byteArray);
pixmap().save(&buffer, "PNG");
- QUrlQuery urlQuery;
- urlQuery.addQueryItem(QStringLiteral("title"), QStringLiteral(""));
- QString description = FileNameHandler().parsedPattern();
- urlQuery.addQueryItem(QStringLiteral("description"), description);
+ QHttpPart fileDataPart;
+ fileDataPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"file\"; filename=\"image.png\""));
+ fileDataPart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/octet-stream"));
+ fileDataPart.setBody(byteArray);
+
+ QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
+ multiPart->append(fileDataPart);
- QUrl url(QStringLiteral("https://api.imgur.com/3/image"));
- url.setQuery(urlQuery);
+ QUrl url(QStringLiteral("https://0x0.st/"));
QNetworkRequest request(url);
- request.setHeader(QNetworkRequest::ContentTypeHeader,
- "application/application/x-www-form-urlencoded");
- request.setRawHeader("Authorization",
- QStringLiteral("Client-ID %1")
- .arg(ConfigHandler().uploadClientSecret())
- .toUtf8());
- m_NetworkAM->post(request, byteArray);
+ m_NetworkAM->post(request, multiPart);
}
void ImgurUploader::deleteImage(const QString& fileName,

View file

@ -1,13 +1,14 @@
{ lib, pkgs, config, ... }: let { lib, pkgs, config, ... }: let
inherit (lib) mkIf mkEnableOption; inherit (lib) mkIf mkEnableOption;
cfg = config.chuj.stuff.alacritty; cfg = config.chuj.stuff.alacritty;
user = config.chuj.system.user;
in { in {
options.chuj.stuff.alacritty = { options.chuj.stuff.alacritty = {
enable = mkEnableOption "alacritty"; enable = mkEnableOption "alacritty";
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
home-manager.users.krizej.programs.alacritty = { home-manager.users.${user}.programs.alacritty = {
package = pkgs.alacritty-sixel; package = pkgs.alacritty-sixel;
enable = true; enable = true;
settings = { settings = {

View file

@ -8,7 +8,7 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
home-manager.users.krizej.programs.firefox = { home-manager.users.${user}.programs.firefox = {
enable = true; enable = true;
policies = { policies = {
DisableTelemetry = true; DisableTelemetry = true;
@ -52,7 +52,7 @@ in {
}; };
}; };
}; };
profiles.krizej = { profiles.${user} = {
id = 0; id = 0;
isDefault = true; isDefault = true;
search = { search = {

View file

@ -1,12 +1,14 @@
{ lib, pkgs, config, ...}: let { lib, pkgs, config, ...}: let
inherit (lib) mkIf mkEnableOption mkOption; inherit (lib) mkIf mkEnableOption mkOption;
cfg = config.chuj.stuff.flameshot; cfg = config.chuj.stuff.flameshot;
user = config.chuj.system.user;
in { in {
options.chuj.stuff.flameshot = { options.chuj.stuff.flameshot = {
enable = mkEnableOption "flameshot"; enable = mkEnableOption "flameshot";
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
home-manager.users.krizej.services.flameshot = { home-manager.users.${user} = {
services.flameshot = {
enable = true; enable = true;
settings = { settings = {
General = { General = {
@ -16,4 +18,5 @@ in {
}; };
}; };
}; };
};
} }

View file

@ -4,7 +4,8 @@
sddm-i3-theme = callPackage ./sddm-i3-theme.nix {}; sddm-i3-theme = callPackage ./sddm-i3-theme.nix {};
ericw-tools-latest = callPackage ./ericw-tools-latest.nix {}; ericw-tools-latest = callPackage ./ericw-tools-latest.nix {};
alacritty-sixel = callPackage ./alacritty-sixel.nix {}; alacritty-sixel = callPackage ./alacritty-sixel.nix {};
i3status = prevPkgs.i3status.overrideAttrs (_: { patches = [ ../files/i3status.patch ]; }); i3status = prevPkgs.i3status.overrideAttrs (_: { patches = [ ../files/i3status-format-fix.patch ]; });
flameshot = prevPkgs.flameshot.overrideAttrs (_: { patches = [ ../files/flameshot-0x0-upload.patch ]; });
schildichat-web = callPackage ./schildi/schildichat-web.nix {}; schildichat-web = callPackage ./schildi/schildichat-web.nix {};
schildichat-desktop = callPackage ./schildi/schildichat-desktop.nix {}; schildichat-desktop = callPackage ./schildi/schildichat-desktop.nix {};
vkquake_ = prevPkgs.vkquake.overrideAttrs (prev: { vkquake_ = prevPkgs.vkquake.overrideAttrs (prev: {