diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-10-23 07:23:48 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-10-23 07:23:48 +0300 |
commit | 5b34ee8697c5da2a8c0b2fc0cec4120e18d5954d (patch) | |
tree | a28e2db5350de56c96ea6b2e1a0ce2ec39b29b9b /src | |
parent | 72320a536f36ea8014e7e31ab918e3e238cb732f (diff) |
UploadWidget: Remember token; Upload button visibility
The token is saved just like the text editor content.
In a single panel layout, the Upload button should only be shown when a detail panel is visible.
The text editor panel shouldn't scroll because the input widget does its own scrolling.
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/uploadwidget.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/ui/uploadwidget.c b/src/ui/uploadwidget.c index 3bd11cfb..90df1958 100644 --- a/src/ui/uploadwidget.c +++ b/src/ui/uploadwidget.c | |||
@@ -126,6 +126,17 @@ static const iArray *makeIdentityItems_UploadWidget_(const iUploadWidget *d) { | |||
126 | return items; | 126 | return items; |
127 | } | 127 | } |
128 | 128 | ||
129 | static void enableUploadButton_UploadWidget_(iUploadWidget *d, iBool enable) { | ||
130 | if (isUsingPanelLayout_Mobile()) { | ||
131 | iWidget *back = findChild_Widget(as_Widget(d), "panel.back"); | ||
132 | setFlags_Widget(child_Widget(back, 0), hidden_WidgetFlag, !enable); | ||
133 | refresh_Widget(back); | ||
134 | } | ||
135 | else { | ||
136 | /* Not on used in the desktop layout. */ | ||
137 | } | ||
138 | } | ||
139 | |||
129 | void init_UploadWidget(iUploadWidget *d) { | 140 | void init_UploadWidget(iUploadWidget *d) { |
130 | iWidget *w = as_Widget(d); | 141 | iWidget *w = as_Widget(d); |
131 | init_Widget(w); | 142 | init_Widget(w); |
@@ -165,7 +176,7 @@ void init_UploadWidget(iUploadWidget *d) { | |||
165 | initPanels_Mobile(w, NULL, (iMenuItem[]){ | 176 | initPanels_Mobile(w, NULL, (iMenuItem[]){ |
166 | { "title id:heading.upload" }, | 177 | { "title id:heading.upload" }, |
167 | { "label id:upload.info" }, | 178 | { "label id:upload.info" }, |
168 | { "panel id:dlg.upload.text icon:0x1f5b9", 0, 0, (const void *) textItems }, | 179 | { "panel id:dlg.upload.text icon:0x1f5b9 noscroll:1", 0, 0, (const void *) textItems }, |
169 | { "panel id:dlg.upload.file icon:0x1f4c1", 0, 0, (const void *) fileItems }, | 180 | { "panel id:dlg.upload.file icon:0x1f4c1", 0, 0, (const void *) fileItems }, |
170 | { "padding" }, | 181 | { "padding" }, |
171 | { "dropdown id:upload.id icon:0x1f464", 0, 0, constData_Array(makeIdentityItems_UploadWidget_(d)) }, | 182 | { "dropdown id:upload.id icon:0x1f464", 0, 0, constData_Array(makeIdentityItems_UploadWidget_(d)) }, |
@@ -179,6 +190,9 @@ void init_UploadWidget(iUploadWidget *d) { | |||
179 | d->mime = findChild_Widget(w, "upload.mime"); | 190 | d->mime = findChild_Widget(w, "upload.mime"); |
180 | d->token = findChild_Widget(w, "upload.token"); | 191 | d->token = findChild_Widget(w, "upload.token"); |
181 | d->counter = findChild_Widget(w, "upload.counter"); | 192 | d->counter = findChild_Widget(w, "upload.counter"); |
193 | if (isPortraitPhone_App()) { | ||
194 | enableUploadButton_UploadWidget_(d, iFalse); | ||
195 | } | ||
182 | } | 196 | } |
183 | else { | 197 | else { |
184 | useSheetStyle_Widget(w); | 198 | useSheetStyle_Widget(w); |
@@ -260,6 +274,7 @@ void init_UploadWidget(iUploadWidget *d) { | |||
260 | setLineLimits_InputWidget(d->input, 7, 20); | 274 | setLineLimits_InputWidget(d->input, 7, 20); |
261 | setHint_InputWidget(d->input, "${hint.upload.text}"); | 275 | setHint_InputWidget(d->input, "${hint.upload.text}"); |
262 | setBackupFileName_InputWidget(d->input, "uploadbackup.txt"); | 276 | setBackupFileName_InputWidget(d->input, "uploadbackup.txt"); |
277 | setBackupFileName_InputWidget(d->token, "uploadtoken.txt"); /* TODO: site-specific config? */ | ||
263 | updateInputMaxHeight_UploadWidget_(d); | 278 | updateInputMaxHeight_UploadWidget_(d); |
264 | } | 279 | } |
265 | 280 | ||
@@ -361,18 +376,30 @@ static void updateFileInfo_UploadWidget_(iUploadWidget *d) { | |||
361 | setTextCStr_InputWidget(d->mime, mediaType_Path(&d->filePath)); | 376 | setTextCStr_InputWidget(d->mime, mediaType_Path(&d->filePath)); |
362 | } | 377 | } |
363 | 378 | ||
379 | static void showOrHideUploadButton_UploadWidget_(iUploadWidget *d) { | ||
380 | if (isUsingPanelLayout_Mobile()) { | ||
381 | enableUploadButton_UploadWidget_( | ||
382 | d, currentPanelIndex_Mobile(as_Widget(d)) != iInvalidPos || !isPortraitPhone_App()); | ||
383 | } | ||
384 | } | ||
385 | |||
364 | static iBool processEvent_UploadWidget_(iUploadWidget *d, const SDL_Event *ev) { | 386 | static iBool processEvent_UploadWidget_(iUploadWidget *d, const SDL_Event *ev) { |
365 | iWidget *w = as_Widget(d); | 387 | iWidget *w = as_Widget(d); |
366 | const char *cmd = command_UserEvent(ev); | 388 | const char *cmd = command_UserEvent(ev); |
367 | if (isResize_UserEvent(ev) || equal_Command(cmd, "keyboard.changed")) { | 389 | if (isResize_UserEvent(ev) || equal_Command(cmd, "keyboard.changed")) { |
368 | updateInputMaxHeight_UploadWidget_(d); | 390 | updateInputMaxHeight_UploadWidget_(d); |
391 | showOrHideUploadButton_UploadWidget_(d); | ||
392 | } | ||
393 | else if (equal_Command(cmd, "panel.changed")) { | ||
394 | showOrHideUploadButton_UploadWidget_(d); | ||
395 | return iFalse; | ||
369 | } | 396 | } |
370 | if (equal_Command(cmd, "upload.cancel")) { | 397 | else if (equal_Command(cmd, "upload.cancel")) { |
371 | setupSheetTransition_Mobile(w, iFalse); | 398 | setupSheetTransition_Mobile(w, iFalse); |
372 | destroy_Widget(w); | 399 | destroy_Widget(w); |
373 | return iTrue; | 400 | return iTrue; |
374 | } | 401 | } |
375 | if (isCommand_Widget(w, ev, "upload.setport")) { | 402 | else if (isCommand_Widget(w, ev, "upload.setport")) { |
376 | if (hasLabel_Command(cmd, "value")) { | 403 | if (hasLabel_Command(cmd, "value")) { |
377 | setValue_SiteSpec(collectNewRange_String(urlRoot_String(&d->originalUrl)), | 404 | setValue_SiteSpec(collectNewRange_String(urlRoot_String(&d->originalUrl)), |
378 | titanPort_SiteSpecKey, arg_Command(cmd)); | 405 | titanPort_SiteSpecKey, arg_Command(cmd)); |