Skip to content

Commit 2e8a081

Browse files
committed
Check file types when started from Explorer's context menu
1 parent 535d0e0 commit 2e8a081

File tree

18 files changed

+72
-70
lines changed

18 files changed

+72
-70
lines changed

Data/Scripts/ImageSearch/yandex.nut

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function SearchByImage(FileName, options) {
99

1010
nm.setUrl("https://yandex.ru/images/search?rpt=imageview");
1111
nm.addQueryHeader("Origin", "https://yandex.ru");
12-
nm.addQueryParamFile("upfile", FileName, ExtractFileName(FileName), "");
12+
nm.addQueryParamFile("upfile", FileName, ExtractFileName(FileName), GetFileMimeType(FileName));
1313
nm.addQueryParam("original_width", imageInfo.Width);
1414
nm.addQueryParam("original_height", imageInfo.Height);
1515
nm.addQueryParam("prg", "1");

Source/Core/OutputGenerator/AbstractOutputGenerator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class AbstractOutputGenerator
7171
bool loadTemplate(const std::string& templateFileName);
7272
std::string generate(const std::vector<UploadObject>& items, bool withTemplate = true);
7373
protected:
74-
CodeType codeType_;
74+
CodeType codeType_ = ctTableOfThumbnails;
7575
bool preferDirectLinks_ = true, shortenUrl_ = false, groupByFile_ = false;
7676
int itemsPerLine_ = 4;
7777
std::optional<std::string> templateHead_, templateFoot_;

Source/Core/Upload/Filters/UrlShorteningFilter.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ bool UrlShorteningFilter::PostUpload(UploadTask* task)
3838
shorteningTask->setParentUrlType(UrlShorteningTask::DirectUrl);
3939
task->setShorteningStarted(true);
4040
fileTask->addChildTask(shorteningTask);
41-
res = true;
4241
}
4342
else if (!downloadUrl.empty()) {
4443
std::shared_ptr<UrlShorteningTask> shorteningTask = std::make_shared<UrlShorteningTask>(downloadUrl, task);
@@ -47,7 +46,6 @@ bool UrlShorteningFilter::PostUpload(UploadTask* task)
4746
shorteningTask->setParentUrlType(UrlShorteningTask::DownloadUrl);
4847
task->setShorteningStarted(true);
4948
fileTask->addChildTask(shorteningTask);
50-
res = true;
5149
}
5250
return res;
5351
}

Source/Core/WinServerIconCache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ NativeIcon WinServerIconCache::getIconForServer(const std::string& name) {
6565
NativeIcon WinServerIconCache::getBigIconForServer(const std::string& name) {
6666
CString iconFileName = IuCoreUtils::Utf8ToWstring(getIconNameForServer(name, true)).c_str();
6767

68-
if (!iconFileName) {
68+
if (iconFileName.IsEmpty()) {
6969
return {};
7070
}
7171
const int w = GetSystemMetrics(SM_CXICON);

Source/Gui/Dialogs/AddFtpServerDialog.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -228,24 +228,21 @@ LRESULT CAddFtpServerDialog::OnClickedTestConnection(WORD wNotifyCode, WORD wID,
228228

229229
void CAddFtpServerDialog::addServer(bool test) {
230230
CString serverName = GuiTools::GetDlgItemText(m_hWnd, IDC_SERVEREDIT);
231-
serverName.TrimLeft(L" ");
232-
serverName.TrimRight(L" ");
231+
serverName.Trim(_T(" "));
233232

234233
if (serverName.IsEmpty()) {
235234
MessageBox(TR("Server's name cannot be empty"), TR("Error"), MB_ICONERROR);
236235
return;
237236
}
238237
CString connectionName = GuiTools::GetDlgItemText(m_hWnd, IDC_CONNECTIONNAMEEDIT);
239-
connectionName.TrimLeft(L" ");
240-
connectionName.TrimRight(L" ");
238+
connectionName.Trim(_T(" "));
241239
if (connectionName.IsEmpty()) {
242240
LocalizedMessageBox(TR("Connection name cannot be empty"), TR("Error"), MB_ICONERROR);
243241
return;
244242
}
245243

246244
CString downloadUrl = GuiTools::GetDlgItemText(m_hWnd, IDC_DOWNLOADURLEDIT);
247-
downloadUrl.TrimLeft(L" ");
248-
downloadUrl.TrimRight(L" ");
245+
downloadUrl.Trim(_T(" "));
249246
if (downloadUrl.IsEmpty()) {
250247
LocalizedMessageBox(TR("Download URL cannot be empty."), TR("Error"), MB_ICONERROR);
251248
return;
@@ -312,7 +309,6 @@ void CAddFtpServerDialog::addServer(bool test) {
312309
} else {
313310
EndDialog(IDOK);
314311
}
315-
316312
}
317313
catch (const std::exception& ex) {
318314
CString errorMessage = TR("Could not add server.");
@@ -329,7 +325,6 @@ void CAddFtpServerDialog::enableControls(bool enable) {
329325
GuiTools::EnableDialogItem(m_hWnd, IDC_TESTCONNECTIONBTN, enable);
330326
}
331327

332-
333328
LRESULT CAddFtpServerDialog::OnCtlColorMsgDlg(HDC hdc, HWND hwndChild) {
334329
if (hwndChild == GetDlgItem(IDC_CONNECTIONSTATUSLABEL)) {
335330
if (testSuccess_) {
@@ -341,4 +336,4 @@ LRESULT CAddFtpServerDialog::OnCtlColorMsgDlg(HDC hdc, HWND hwndChild) {
341336
return reinterpret_cast<LRESULT>(backgroundBrush_.m_hBrush);
342337
}
343338
return 0;
344-
}
339+
}

Source/Gui/Dialogs/FloatingWindow.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,9 @@ void CFloatingWindow::ShowImageUploadedMessage(UploadTask* task, const CString&
939939
if (generatorId == gidXmlTemplate) {
940940
int templateIndex = settings->CodeType - 4;
941941
auto xmlTemplateGenerator = dynamic_cast<XmlTemplateGenerator*>(generator.get());
942-
xmlTemplateGenerator->setTemplateIndex(templateIndex);
942+
if (xmlTemplateGenerator) {
943+
xmlTemplateGenerator->setTemplateIndex(templateIndex);
944+
}
943945
}
944946

945947
code = U2W(generator->generate(objects, settings->UseTxtTemplate));

Source/Gui/Dialogs/FolderAddDlg.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "WizardDlg.h"
88
#include "MainDlg.h"
99
#include "Func/IuCommonFunctions.h"
10+
#include "Core/Settings/WtlGuiSettings.h"
1011

1112
CFolderAdd::CFolderAdd(CWizardDlg *WizardDlg):
1213
count(0),
@@ -84,6 +85,7 @@ int CFolderAdd::ProcessDir(CString currentDir, bool bRecursive /* = true */)
8485

8586
DWORD CFolderAdd::Run()
8687
{
88+
auto* settings = ServiceLocator::instance()->settings<WtlGuiSettings>();
8789
EnableWindow(m_pWizardDlg->m_hWnd, false);
8890
ServiceLocator::instance()->taskRunner()->runInGuiThread([&] {
8991
m_pWizardDlg->beginAddFiles();
@@ -118,8 +120,12 @@ DWORD CFolderAdd::Run()
118120
GuiTools::LocalizedMessageBox(m_pWizardDlg->m_hWnd, m_bImagesOnly ? TR("No pictures were found.") : TR("No files were found."), APPNAME, MB_ICONINFORMATION);
119121
else {
120122
if (m_pWizardDlg->getQuickUploadMarker()) {
123+
if (settings->CheckFileTypesBeforeUpload && !m_pWizardDlg->checkFileFormats(m_pWizardDlg->getSessionImageServer(), m_pWizardDlg->getSessionFileServer())) {
124+
m_pWizardDlg->ShowPage(CWizardDlg::wpUploadSettingsPage);
125+
} else {
126+
m_pWizardDlg->ShowPage(CWizardDlg::wpUploadPage);
127+
}
121128

122-
m_pWizardDlg->ShowPage(CWizardDlg::wpUploadPage);
123129
} else {
124130
m_pWizardDlg->ShowPage(CWizardDlg::wpMainPage);
125131
//m_pWizardDlg->getPage<CMainDlg>(CWizardDlg::wpMainPage)->ThumbsView.LoadThumbnails();

Source/Gui/Dialogs/HistoryWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ LRESULT CHistoryWindow::OnEditFileOnServer(WORD wNotifyCode, WORD wID, HWND hWnd
367367
TreeItem* item = m_treeView.selectedItem();
368368
if (!item) return 0;
369369
HistoryItem* historyItem = CHistoryTreeControl::getItemData(item);
370-
if (historyItem) {
370+
if (!historyItem) {
371371
return 0;
372372
}
373373
WinUtils::ShellOpenFileOrUrl(U2W(historyItem->editUrl), m_hWnd);

Source/Gui/Dialogs/MainDlg.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ limitations under the License.
3535

3636
class WinServerIconCache;
3737

38-
39-
4038
class CMainDlg : public CDialogImpl<CMainDlg>,public CThreadImpl<CMainDlg>,public CWizardPage,
4139
public CMessageFilter
4240
{
@@ -53,8 +51,6 @@ class CMainDlg : public CDialogImpl<CMainDlg>,public CThreadImpl<CMainDlg>,publi
5351
MENUITEM_DELETE,
5452
MENUITEM_PROPERTIES,
5553
MENUITEM_OPENWITH
56-
57-
5854
};
5955
enum { kStatusTimer = 1 };
6056
explicit CMainDlg(WinServerIconCache* iconCache);

Source/Gui/Dialogs/ResultsPanel.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ CResultsPanel::CResultsPanel(CWizardDlg *dlg, std::vector<ImageUploader::Core::O
5050
openedFromHistory_ = openedFromHistory;
5151
rectNeeded = {};
5252
rectNeeded.left = -1;
53-
CString TemplateLoadError;
5453
shortenUrl_ = false;
5554
outputChanged_ = false;
5655
m_Page = OG::clBBCode;
@@ -236,10 +235,9 @@ std::string CResultsPanel::GenerateOutput()
236235
if (p < 1) {
237236
p = 4;
238237
}
239-
bool UseTemplate = settings->UseTxtTemplate;
238+
bool useTemplate = settings->UseTxtTemplate;
240239
bool preferDirectLinks = settings->UseDirectLinks;
241240
groupByFileName_ = settings->GroupByFilename;
242-
settings->UseTxtTemplate = UseTemplate;
243241

244242
OG::GeneratorID generatorId = OG::gidBBCode;
245243
OG::CodeLang lang = OG::clBBCode;
@@ -262,10 +260,12 @@ std::string CResultsPanel::GenerateOutput()
262260
if (generatorId == OG::gidXmlTemplate) {
263261
int templateIndex = Index - 4;
264262
auto xmlTemplateGenerator = dynamic_cast<OG::XmlTemplateGenerator*>(generator);
265-
xmlTemplateGenerator->setTemplateIndex(templateIndex);
263+
if (xmlTemplateGenerator) {
264+
xmlTemplateGenerator->setTemplateIndex(templateIndex);
265+
}
266266
}
267267

268-
return generator->generate(UrlList, UseTemplate);
268+
return generator->generate(UrlList, useTemplate);
269269
}
270270

271271
void CResultsPanel::UpdateOutput(bool immediately)

0 commit comments

Comments
 (0)