mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Move Image Uploader settings to the new tab
This commit is contained in:
parent
a0551ce41a
commit
097eb7ba79
2 changed files with 95 additions and 90 deletions
|
@ -100,51 +100,6 @@ ExternalToolsPage::ExternalToolsPage()
|
||||||
lineEdit->setPlaceholderText("custom-player-scheme://");
|
lineEdit->setPlaceholderText("custom-player-scheme://");
|
||||||
groupLayout->addRow("Custom stream player URI Scheme:", lineEdit);
|
groupLayout->addRow("Custom stream player URI Scheme:", lineEdit);
|
||||||
}
|
}
|
||||||
layout->addSpacing(16);
|
|
||||||
|
|
||||||
{
|
|
||||||
auto group = layout.emplace<QGroupBox>("Image Uploader");
|
|
||||||
auto groupLayout = group.setLayoutType<QFormLayout>();
|
|
||||||
|
|
||||||
const auto description = new QLabel(
|
|
||||||
"You can set custom host for uploading images, like "
|
|
||||||
"imgur.com or s-ul.eu.<br>Check " +
|
|
||||||
formatRichNamedLink("https://chatterino.com/help/image-uploader",
|
|
||||||
"this guide") +
|
|
||||||
" for help.");
|
|
||||||
description->setWordWrap(true);
|
|
||||||
description->setStyleSheet("color: #bbb");
|
|
||||||
description->setTextFormat(Qt::RichText);
|
|
||||||
description->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
|
||||||
Qt::LinksAccessibleByKeyboard |
|
|
||||||
Qt::LinksAccessibleByMouse);
|
|
||||||
description->setOpenExternalLinks(true);
|
|
||||||
|
|
||||||
groupLayout->setWidget(0, QFormLayout::SpanningRole, description);
|
|
||||||
|
|
||||||
groupLayout->addRow(this->createCheckBox(
|
|
||||||
"Enable image uploader", getSettings()->imageUploaderEnabled));
|
|
||||||
groupLayout->addRow(
|
|
||||||
this->createCheckBox("Ask for confirmation when uploading an image",
|
|
||||||
getSettings()->askOnImageUpload));
|
|
||||||
|
|
||||||
groupLayout->addRow(
|
|
||||||
"Request URL: ",
|
|
||||||
this->createLineEdit(getSettings()->imageUploaderUrl));
|
|
||||||
groupLayout->addRow(
|
|
||||||
"Form field: ",
|
|
||||||
this->createLineEdit(getSettings()->imageUploaderFormField));
|
|
||||||
groupLayout->addRow(
|
|
||||||
"Extra Headers: ",
|
|
||||||
this->createLineEdit(getSettings()->imageUploaderHeaders));
|
|
||||||
groupLayout->addRow(
|
|
||||||
"Image link: ",
|
|
||||||
this->createLineEdit(getSettings()->imageUploaderLink));
|
|
||||||
groupLayout->addRow(
|
|
||||||
"Deletion link: ",
|
|
||||||
this->createLineEdit(getSettings()->imageUploaderDeletionLink));
|
|
||||||
}
|
|
||||||
|
|
||||||
layout->addStretch(1);
|
layout->addStretch(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,15 +3,19 @@
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "singletons/imageuploader/ImageUploader.hpp"
|
#include "singletons/imageuploader/ImageUploader.hpp"
|
||||||
#include "singletons/imageuploader/UploadedImageModel.hpp"
|
#include "singletons/imageuploader/UploadedImageModel.hpp"
|
||||||
|
#include "singletons/Settings.hpp"
|
||||||
|
#include "util/Helpers.hpp"
|
||||||
#include "util/LayoutCreator.hpp"
|
#include "util/LayoutCreator.hpp"
|
||||||
#include "widgets/helper/EditableModelView.hpp"
|
#include "widgets/helper/EditableModelView.hpp"
|
||||||
#include "widgets/listview/ImagePtrItemDelegate.hpp"
|
#include "widgets/listview/ImagePtrItemDelegate.hpp"
|
||||||
|
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
#include <QFormLayout>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
|
#include <QTabWidget>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
@ -20,11 +24,12 @@ ImageUploaderPage::ImageUploaderPage()
|
||||||
: imgDelegate_(new ImagePtrItemDelegate())
|
: imgDelegate_(new ImagePtrItemDelegate())
|
||||||
{
|
{
|
||||||
LayoutCreator<ImageUploaderPage> layoutCreator(this);
|
LayoutCreator<ImageUploaderPage> layoutCreator(this);
|
||||||
auto layout = layoutCreator.emplace<QVBoxLayout>();
|
auto tabs = layoutCreator.emplace<QTabWidget>();
|
||||||
|
|
||||||
|
{
|
||||||
|
auto layout = tabs.appendTab(new QVBoxLayout, "Logs");
|
||||||
|
|
||||||
auto *model = getApp()->imageUploader->createModel(nullptr);
|
auto *model = getApp()->imageUploader->createModel(nullptr);
|
||||||
//EditableModelView *view =
|
|
||||||
// layout.emplace<EditableModelView>(model).getElement();
|
|
||||||
|
|
||||||
auto container = layout.emplace<QVBoxLayout>();
|
auto container = layout.emplace<QVBoxLayout>();
|
||||||
container->setContentsMargins(0, 0, 0, 0);
|
container->setContentsMargins(0, 0, 0, 0);
|
||||||
|
@ -47,13 +52,15 @@ ImageUploaderPage::ImageUploaderPage()
|
||||||
|
|
||||||
view->horizontalHeader()->setSectionResizeMode(
|
view->horizontalHeader()->setSectionResizeMode(
|
||||||
1, QHeaderView::ResizeToContents);
|
1, QHeaderView::ResizeToContents);
|
||||||
model->setHeaderData(1, Qt::Horizontal, "Date uploaded", Qt::DisplayRole);
|
model->setHeaderData(1, Qt::Horizontal, "Date uploaded",
|
||||||
|
Qt::DisplayRole);
|
||||||
|
|
||||||
view->horizontalHeader()->setSectionResizeMode(
|
view->horizontalHeader()->setSectionResizeMode(
|
||||||
2, QHeaderView::ResizeToContents);
|
2, QHeaderView::ResizeToContents);
|
||||||
model->setHeaderData(2, Qt::Horizontal, "Delete link", Qt::DisplayRole);
|
model->setHeaderData(2, Qt::Horizontal, "Delete link", Qt::DisplayRole);
|
||||||
|
|
||||||
view->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Interactive);
|
view->horizontalHeader()->setSectionResizeMode(
|
||||||
|
3, QHeaderView::Interactive);
|
||||||
model->setHeaderData(3, Qt::Horizontal, "Path", Qt::DisplayRole);
|
model->setHeaderData(3, Qt::Horizontal, "Path", Qt::DisplayRole);
|
||||||
|
|
||||||
QObject::connect(forget, &QPushButton::pressed, this, [view, model]() {
|
QObject::connect(forget, &QPushButton::pressed, this, [view, model]() {
|
||||||
|
@ -74,11 +81,54 @@ ImageUploaderPage::ImageUploaderPage()
|
||||||
});
|
});
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
view, &QTableView::doubleClicked, [](const QModelIndex &clicked) {
|
view, &QTableView::doubleClicked, [](const QModelIndex &clicked) {
|
||||||
auto url = clicked.data(UploadedImageModel::DOUBLE_CLICK_LINK_ROLE)
|
auto url =
|
||||||
|
clicked.data(UploadedImageModel::DOUBLE_CLICK_LINK_ROLE)
|
||||||
.toString();
|
.toString();
|
||||||
QDesktopServices::openUrl(QUrl(url));
|
QDesktopServices::openUrl(QUrl(url));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
auto groupLayout = tabs.appendTab(new QFormLayout, "Settings");
|
||||||
|
|
||||||
|
auto *description = new QLabel(
|
||||||
|
"You can set custom host for uploading images, like "
|
||||||
|
"imgur.com or s-ul.eu.<br>Check " +
|
||||||
|
formatRichNamedLink("https://chatterino.com/help/image-uploader",
|
||||||
|
"this guide") +
|
||||||
|
" for help.");
|
||||||
|
description->setWordWrap(true);
|
||||||
|
description->setStyleSheet("color: #bbb");
|
||||||
|
description->setTextFormat(Qt::RichText);
|
||||||
|
description->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
||||||
|
Qt::LinksAccessibleByKeyboard |
|
||||||
|
Qt::LinksAccessibleByMouse);
|
||||||
|
description->setOpenExternalLinks(true);
|
||||||
|
|
||||||
|
groupLayout->setWidget(0, QFormLayout::SpanningRole, description);
|
||||||
|
|
||||||
|
groupLayout->addRow(this->createCheckBox(
|
||||||
|
"Enable image uploader", getSettings()->imageUploaderEnabled));
|
||||||
|
groupLayout->addRow(
|
||||||
|
this->createCheckBox("Ask for confirmation when uploading an image",
|
||||||
|
getSettings()->askOnImageUpload));
|
||||||
|
|
||||||
|
groupLayout->addRow(
|
||||||
|
"Request URL: ",
|
||||||
|
this->createLineEdit(getSettings()->imageUploaderUrl));
|
||||||
|
groupLayout->addRow(
|
||||||
|
"Form field: ",
|
||||||
|
this->createLineEdit(getSettings()->imageUploaderFormField));
|
||||||
|
groupLayout->addRow(
|
||||||
|
"Extra Headers: ",
|
||||||
|
this->createLineEdit(getSettings()->imageUploaderHeaders));
|
||||||
|
groupLayout->addRow(
|
||||||
|
"Image link: ",
|
||||||
|
this->createLineEdit(getSettings()->imageUploaderLink));
|
||||||
|
groupLayout->addRow(
|
||||||
|
"Deletion link: ",
|
||||||
|
this->createLineEdit(getSettings()->imageUploaderDeletionLink));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImageUploaderPage::~ImageUploaderPage()
|
ImageUploaderPage::~ImageUploaderPage()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue