Skip to content

Commit

Permalink
Small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zenden2k committed Jul 2, 2024
1 parent bc2fcba commit 38b8116
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 22 deletions.
3 changes: 0 additions & 3 deletions Source/Gui/Dialogs/ConnectionSettingsPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ LRESULT CConnectionSettingsPage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM l
}
int index = serverTypeCombo_.AddString(item.first);
serverTypeCombo_.SetItemData(index, item.second);

}

// ---- connection settings -----
Expand Down Expand Up @@ -145,7 +144,6 @@ LRESULT CConnectionSettingsPage::OnClickedUseSystemProxy(WORD wNotifyCode, WORD
return 0;
}


bool CConnectionSettingsPage::Apply()
{
WtlGuiSettings& Settings = *ServiceLocator::instance()->settings<WtlGuiSettings>();
Expand Down Expand Up @@ -204,7 +202,6 @@ void CConnectionSettingsPage::proxyRadioChanged() {
}
}


void CConnectionSettingsPage::CheckBounds(int controlId, int minValue, int maxValue, int labelId) const {
int value = GetDlgItemInt(controlId);
if (value < minValue || value > maxValue) {
Expand Down
21 changes: 8 additions & 13 deletions Source/Gui/Dialogs/FloatingWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ CFloatingWindow::CFloatingWindow(CWizardDlg* wizardDlg, UploadManager* uploadMan
m_bStopCapturingWindows = false;
WM_TASKBARCREATED = RegisterWindowMessage(_T("TaskbarCreated"));
m_bIsUploading = false;
lastUploadedItem_ = nullptr;
iconAnimationCounter_ = 0;
animationEnabled_ = false;
m_hTrayIconMenu = nullptr;
Expand Down Expand Up @@ -849,15 +848,9 @@ void CFloatingWindow::showLastUploadedCode() {
using namespace ImageUploader::Core::OutputGenerator;
auto *settings = ServiceLocator::instance()->settings<WtlGuiSettings>();
std::vector<UploadObject> items;
UploadObject newItem;
if (lastUploadedItem_) {
UploadResult* uploadResult = lastUploadedItem_->uploadResult();
newItem.fillFromUploadResult(uploadResult, lastUploadedItem_);

if (newItem.isNull()) {
return;
}
items.push_back(newItem);
if (lastUploadedItem_) {
items.push_back(*lastUploadedItem_);
CResultsWindow resultsWindow_(wizardDlg_, items, false);
resultsWindow_.DoModal(m_hWnd);
}
Expand Down Expand Up @@ -891,7 +884,7 @@ void CFloatingWindow::OnFileFinished(UploadTask* task, bool ok)
url = Utf8ToWstring(!uploadResult->downloadUrlShortened.empty() ? uploadResult->downloadUrlShortened : uploadResult->downloadUrl).c_str();
usedDirectLink = false;
}
lastUploadedItem_ = task;

ShowImageUploadedMessage(task, url);

} else {
Expand All @@ -917,8 +910,9 @@ void CFloatingWindow::ShowImageUploadedMessage(UploadTask* task, const CString&
{
using namespace ImageUploader::Core::OutputGenerator;
auto* settings = ServiceLocator::instance()->settings<WtlGuiSettings>();
UploadObject obj;
obj.fillFromUploadResult(task->uploadResult(), task);
auto obj = std::make_unique<UploadObject>();
obj->fillFromUploadResult(task->uploadResult(), task);

CString code;
if (settings->TrayResult == WtlGuiSettings::trJustURL) {
code = url;
Expand All @@ -927,7 +921,7 @@ void CFloatingWindow::ShowImageUploadedMessage(UploadTask* task, const CString&
//CodeLang lang = clBBCode;
CodeType codeType = static_cast<CodeType>(settings->CodeType);
OutputGeneratorFactory factory;
std::vector<UploadObject> objects { obj };
std::vector<UploadObject> objects { *obj };
auto generator = factory.createOutputGenerator(generatorId, codeType);
generator->setPreferDirectLinks(settings->UseDirectLinks);
generator->setItemsPerLine(settings->ThumbsPerLine);
Expand All @@ -951,6 +945,7 @@ void CFloatingWindow::ShowImageUploadedMessage(UploadTask* task, const CString&
TR("Screenshot was uploaded"), 17000, [this] {showLastUploadedCode(); });
CString statusText = TR("Screenshot was uploaded") + CString(_T("\r\n")) + trimmedUrl;
setStatusText(statusText, kStatusHideTimeout);
lastUploadedItem_ = std::move(obj);
}

void CFloatingWindow::ShowScreenshotCopiedToClipboardMessage() {
Expand Down
11 changes: 7 additions & 4 deletions Source/Gui/Dialogs/FloatingWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
#include "Gui/Components/trayicon.h"
#include "SettingsDlg.h"
#include "Core/Upload/UploadManager.h"
#include "Core/Upload/UrlShorteningTask.h"
#include "Core/Settings/WtlGuiSettings.h"

// FloatingWindow

constexpr int IDM_UPLOADFILES = 20001;
Expand Down Expand Up @@ -78,8 +78,11 @@ constexpr int WM_RELOADSETTINGS = WM_USER + 3;
namespace ImageUploader::Core::OutputGenerator {
class XmlTemplateList;
class XmlTemplateGenerator;
struct UploadObject;
}

class UrlShorteningTask;

class CFloatingWindow :
public CWindowImpl<CFloatingWindow>,
public CTrayIconImpl<CFloatingWindow>
Expand All @@ -96,7 +99,7 @@ class CFloatingWindow :
CIcon activeIcon_;
bool m_bStopCapturingWindows;
bool m_bIsUploading;
UploadTask* lastUploadedItem_;
std::unique_ptr<ImageUploader::Core::OutputGenerator::UploadObject> lastUploadedItem_;
std::shared_ptr<UrlShorteningTask> lastUrlShorteningTask_;
CString imageUrlShortened_;
CString downloadUrlShortened_;
Expand Down Expand Up @@ -239,9 +242,9 @@ class CFloatingWindow :
enum UploadType {
utImage, utUrl, utShorteningImageUrl
};
CWizardDlg* wizardDlg_;
CWizardDlg* wizardDlg_;
std::function<void()> balloonClickFunction_;
std::unique_ptr<ImageUploader::Core::OutputGenerator::XmlTemplateList> templateList_;
std::unique_ptr<ImageUploader::Core::OutputGenerator::XmlTemplateList> templateList_;
protected:
static CString HotkeyToString(CString funcName, CString menuItemText);
};
Expand Down
2 changes: 1 addition & 1 deletion Source/Gui/Dialogs/SettingsDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CSettingsDlg : public CCustomDialogIndirectImpl<CSettingsDlg>
};
CSettingsDlg(SettingsPage Page, UploadEngineManager* uploadEngineManager);
enum { IDD = IDD_SETTINGSDLG };
enum { kStatusLabelTimer = 1, SettingsPageCount = 10 };
enum { kStatusLabelTimer = 1, SettingsPageCount = 11 };

protected:
BEGIN_MSG_MAP(CSettingsDlg)
Expand Down
1 change: 0 additions & 1 deletion Source/Gui/Dialogs/TransferSettingsPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ LRESULT CTransferSettingsPage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lPa
GuiTools::SetCheck(m_hWnd, IDC_EXECUTESCRIPTCHECKBOX, Settings.ExecuteScript);
executeScriptCheckboxChanged();
SetDlgItemText(IDC_SCRIPTFILENAMEEDIT, IuCoreUtils::Utf8ToWstring(Settings.ScriptFileName).c_str());
SetDlgItemInt(IDC_UPLOADSPEEDLIMITEDIT, Settings.MaxUploadSpeed);

useLastCodeTypeRadioButton_.SetCheck(Settings.TrayResult == WtlGuiSettings::trLastCodeType);
justURLRadioButton_.SetCheck(Settings.TrayResult == WtlGuiSettings::trJustURL);
Expand Down

0 comments on commit 38b8116

Please sign in to comment.