Skip to content
Permalink
Browse files

Allow opening direct link to image without opening in browser #248

  • Loading branch information
DamirPorobic committed Feb 13, 2020
1 parent 1847965 commit d88ab4b077985bde9ec1b6536e5da33fae16d6fd
@@ -1,6 +1,7 @@
# Change log

## Release 1.6.1
* Fixed: Allow opening link directly to image without opening in browser. ([#248](https://github.com/ksnip/kImageAnnotator/issues/248))
* Fixed kImageAnnotator: Edit border around text box doesn't disappear when done with editing. ([#71](https://github.com/ksnip/kImageAnnotator/issues/71))
* Fixed kImageAnnotator: Edit border not shown under Windows when NoFillNoBorder selected for Text Tool. ([#72](https://github.com/ksnip/kImageAnnotator/issues/72))
* Fixed kImageAnnotator: When adding text with background under Windows a filled rect is show in top left corner. ([#73](https://github.com/ksnip/kImageAnnotator/issues/73))
@@ -621,17 +621,17 @@ void KsnipConfig::setImgurForceAnonymous(bool enabled)
saveValue(KsnipConfigOptions::imgurForceAnonymousString(), enabled);
}

bool KsnipConfig::imgurOpenLinkDirectlyToImage() const
bool KsnipConfig::imgurLinkDirectlyToImage() const
{
return loadValue(KsnipConfigOptions::imgurOpenLinkDirectlyToImageString(), false).toBool();
return loadValue(KsnipConfigOptions::imgurLinkDirectlyToImageString(), false).toBool();
}

void KsnipConfig::setImgurOpenLinkDirectlyToImage(bool enabled)
void KsnipConfig::setImgurLinkDirectlyToImage(bool enabled)
{
if (imgurOpenLinkDirectlyToImage() == enabled) {
if (imgurLinkDirectlyToImage() == enabled) {
return;
}
saveValue(KsnipConfigOptions::imgurOpenLinkDirectlyToImageString(), enabled);
saveValue(KsnipConfigOptions::imgurLinkDirectlyToImageString(), enabled);
}

bool KsnipConfig::imgurAlwaysCopyToClipboard() const
@@ -164,8 +164,8 @@ class KsnipConfig : public QObject
bool imgurForceAnonymous() const;
void setImgurForceAnonymous(bool enabled);

bool imgurOpenLinkDirectlyToImage() const;
void setImgurOpenLinkDirectlyToImage(bool enabled);
bool imgurLinkDirectlyToImage() const;
void setImgurLinkDirectlyToImage(bool enabled);

bool imgurAlwaysCopyToClipboard() const;
void setImgurAlwaysCopyToClipboard(bool enabled);
@@ -204,7 +204,7 @@ QString KsnipConfigOptions::imgurForceAnonymousString()
return imgurSectionString() + QStringLiteral("ForceAnonymous");
}

QString KsnipConfigOptions::imgurOpenLinkDirectlyToImageString()
QString KsnipConfigOptions::imgurLinkDirectlyToImageString()
{
return imgurSectionString() + QStringLiteral("OpenLinkDirectlyToImage");
}
@@ -62,7 +62,7 @@ class KsnipConfigOptions
static QString imgurAccessTokenString();
static QString imgurRefreshTokenString();
static QString imgurForceAnonymousString();
static QString imgurOpenLinkDirectlyToImageString();
static QString imgurLinkDirectlyToImageString();
static QString imgurOpenLinkInBrowserString();
static QString imgurAlwaysCopyToClipboardString();
static QString imgurConfirmBeforeUploadString();
@@ -30,11 +30,8 @@ HandleUploadResponseOperation::HandleUploadResponseOperation(const QString &resp
bool HandleUploadResponseOperation::execute()
{
auto url = formatUrl(mResponse);

openInBrowser(url);

copyToClipboard(url);

notifyAboutUpload(url);

return true;
@@ -55,7 +52,7 @@ void HandleUploadResponseOperation::openInBrowser(const QUrl &url) const

QUrl HandleUploadResponseOperation::formatUrl(QString &response) const
{
if (!mConfig->imgurOpenLinkDirectlyToImage()) {
if (!mConfig->imgurLinkDirectlyToImage()) {
response = response.remove(QStringLiteral(".png"));
}
return response;
@@ -50,7 +50,7 @@ ImgurUploaderSettings::~ImgurUploaderSettings()
void ImgurUploaderSettings::saveSettings()
{
mConfig->setImgurForceAnonymous(mImgurForceAnonymousCheckbox->isChecked());
mConfig->setImgurOpenLinkDirectlyToImage(mImgurDirectLinkToImageCheckbox->isChecked());
mConfig->setImgurLinkDirectlyToImage(mImgurDirectLinkToImageCheckbox->isChecked());
mConfig->setImgurAlwaysCopyToClipboard(mImgurAlwaysCopyToClipboardCheckBox->isChecked());
mConfig->setImgurConfirmBeforeUpload(mImgurConfirmBeforeUploadCheckbox->isChecked());
mConfig->setImgurOpenLinkInBrowser(mImgurOpenLinkInBrowserCheckbox->isChecked());
@@ -78,12 +78,10 @@ void ImgurUploaderSettings::initGui()

mImgurForceAnonymousCheckbox->setText(tr("Force anonymous upload"));
mImgurOpenLinkInBrowserCheckbox->setText(tr("After uploading open Imgur link in default browser"));
mImgurDirectLinkToImageCheckbox->setText(tr("Open link directly to image"));
mImgurDirectLinkToImageCheckbox->setText(tr("Link directly to image"));
mImgurAlwaysCopyToClipboardCheckBox->setText(tr("Always copy Imgur link to clipboard"));
mImgurConfirmBeforeUploadCheckbox->setText(tr("Ask for confirmation before uploading"));

connect(mImgurOpenLinkInBrowserCheckbox, &QCheckBox::stateChanged, this, &ImgurUploaderSettings::openLinkInBrowserChanged);

mImgurClientIdLineEdit->setPlaceholderText(tr("Client ID"));
connect(mImgurClientIdLineEdit, &QLineEdit::textChanged, this, &ImgurUploaderSettings::imgurClientEntered);

@@ -111,7 +109,7 @@ void ImgurUploaderSettings::initGui()
mLayout->setColumnMinimumWidth(0, 10);
mLayout->addWidget(mImgurForceAnonymousCheckbox, 0, 0, 1, 3);
mLayout->addWidget(mImgurOpenLinkInBrowserCheckbox, 1, 0, 1, 3);
mLayout->addWidget(mImgurDirectLinkToImageCheckbox, 2, 1, 1, 3);
mLayout->addWidget(mImgurDirectLinkToImageCheckbox, 2, 0, 1, 3);
mLayout->addWidget(mImgurAlwaysCopyToClipboardCheckBox, 3, 0, 1, 3);
mLayout->addWidget(mImgurConfirmBeforeUploadCheckbox, 4, 0, 1, 3);
mLayout->setRowMinimumHeight(5, 15);
@@ -131,12 +129,10 @@ void ImgurUploaderSettings::loadConfig()
{
mImgurForceAnonymousCheckbox->setChecked(mConfig->imgurForceAnonymous());
mImgurOpenLinkInBrowserCheckbox->setChecked(mConfig->imgurOpenLinkInBrowser());
mImgurDirectLinkToImageCheckbox->setChecked(mConfig->imgurOpenLinkDirectlyToImage());
mImgurDirectLinkToImageCheckbox->setChecked(mConfig->imgurLinkDirectlyToImage());
mImgurAlwaysCopyToClipboardCheckBox->setChecked(mConfig->imgurAlwaysCopyToClipboard());
mImgurConfirmBeforeUploadCheckbox->setChecked(mConfig->imgurConfirmBeforeUpload());

openLinkInBrowserChanged();

mImgurUsernameLabel->setText(tr("Username") + ": " + mConfig->imgurUsername());
if(!mConfig->imgurClientId().isEmpty()) {
mImgurClientIdLineEdit->setPlaceholderText(mConfig->imgurClientId());
@@ -184,12 +180,10 @@ void ImgurUploaderSettings::imgurClientEntered(const QString&)
* We have received a new token from imgur.com, now we save it to config for
* later use and inform the user about it.
*/
void ImgurUploaderSettings::imgurTokenUpdated(const QString& accessToken,
const QString& refreshTocken,
const QString& username)
void ImgurUploaderSettings::imgurTokenUpdated(const QString& accessToken, const QString& refreshToken, const QString& username)
{
mConfig->setImgurAccessToken(accessToken.toUtf8());
mConfig->setImgurRefreshToken(refreshTocken.toUtf8());
mConfig->setImgurRefreshToken(refreshToken.toUtf8());
mConfig->setImgurUsername(username);

mImgurUsernameLabel->setText(tr("Username:") + username);
@@ -212,7 +206,3 @@ void ImgurUploaderSettings::showImgurHistoryDialog()
dialog.exec();
}

void ImgurUploaderSettings::openLinkInBrowserChanged()
{
mImgurDirectLinkToImageCheckbox->setEnabled(mImgurOpenLinkInBrowserCheckbox->isChecked());
}
@@ -65,10 +65,9 @@ private slots:
void requestImgurPin();
void getImgurToken();
void imgurClientEntered(const QString &text);
void imgurTokenUpdated(const QString &accessToken, const QString &refreshTocken, const QString &username);
void imgurTokenUpdated(const QString &accessToken, const QString &refreshToken, const QString &username);
void imgurTokenError(const QString &message);
void showImgurHistoryDialog();
void openLinkInBrowserChanged();
};

#endif //KSNIP_IMGURUPLOADERSETTINGS_H

0 comments on commit d88ab4b

Please sign in to comment.
You can’t perform that action at this time.