Skip to content

Commit 2247bc0

Browse files
committed
Several changes:
- Added touchMoved event handling to WTableView - WFileDropWidget fallback with file-picker - add method to display file-upload as another widget - Fixed includes in WWidgetItem - ImageUtils: JWt fixes
1 parent 4c11fb2 commit 2247bc0

File tree

18 files changed

+139
-15
lines changed

18 files changed

+139
-15
lines changed

resources/themes/bootstrap/2/wt.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,3 +1028,7 @@ body.Wt-rtl .Wt-treeview .Wt-ctrl.noexpand {
10281028
.Wt-filedropzone-hover * {
10291029
pointer-events: none;
10301030
}
1031+
1032+
.Wt-fileupload-hidden {
1033+
display: none !important;
1034+
}

resources/themes/bootstrap/2/wt.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,3 +1110,7 @@ body.Wt-rtl {
11101110
.Wt-filedropzone-hover * {
11111111
pointer-events: none;
11121112
}
1113+
1114+
.Wt-fileupload-hidden {
1115+
display: none !important;
1116+
}

resources/themes/bootstrap/3/wt.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,3 +1201,7 @@ body.Wt-rtl .Wt-treeview .Wt-ctrl.noexpand {
12011201
.Wt-filedropzone-hover * {
12021202
pointer-events: none;
12031203
}
1204+
1205+
.Wt-fileupload-hidden {
1206+
display: none !important;
1207+
}

resources/themes/bootstrap/3/wt.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,3 +1107,7 @@ body.Wt-rtl {
11071107
.Wt-filedropzone-hover * {
11081108
pointer-events: none;
11091109
}
1110+
1111+
.Wt-fileupload-hidden {
1112+
display: none !important;
1113+
}

resources/themes/default/wt.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,3 +1176,7 @@ table.x-grid3-row-table {
11761176
.Wt-filedropzone-hover * {
11771177
pointer-events: none;
11781178
}
1179+
1180+
.Wt-fileupload-hidden {
1181+
display: none !important;
1182+
}

resources/themes/polished/wt.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,3 +1219,7 @@ table.x-grid3-row-table {
12191219
.Wt-filedropzone-hover * {
12201220
pointer-events: none;
12211221
}
1222+
1223+
.Wt-fileupload-hidden {
1224+
display: none !important;
1225+
}

src/Wt/WAbstractItemView.C

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,12 @@ void WAbstractItemView::handleTouchStart(const std::vector<WModelIndex>& indices
14211421
touchStarted_.emit(indices, event);
14221422
}
14231423

1424+
void WAbstractItemView::handleTouchMove(const std::vector<WModelIndex>& indices,
1425+
const WTouchEvent& event)
1426+
{
1427+
touchMoved_.emit(indices, event);
1428+
}
1429+
14241430
void WAbstractItemView::handleTouchEnd(const std::vector<WModelIndex>& indices,
14251431
const WTouchEvent& event)
14261432
{

src/Wt/WAbstractItemView.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,14 @@ class WT_API WAbstractItemView : public WCompositeWidget
727727
*/
728728
Signal<std::vector<WModelIndex>, WTouchEvent>& touchStarted() { return touchStarted_; }
729729

730+
/*! \brief %Signal emitted when one or more fingers are moved on the screen.
731+
*
732+
* When the event happened over an item, the first argument
733+
* indicates the items that were touched. The indices in the model index
734+
* vector match the indices in the \link WTouchEvent::changedTouches() changedTouches() of the WTouchEvent\endlink.
735+
*/
736+
Signal<std::vector<WModelIndex>, WTouchEvent>& touchMoved() { return touchMoved_; }
737+
730738
/*! \brief %Signal emitted when one or more fingers are removed from the screen.
731739
*
732740
* When the event happened over an item, the first argument
@@ -1038,6 +1046,11 @@ class WT_API WAbstractItemView : public WCompositeWidget
10381046
virtual void handleTouchStart(const std::vector<WModelIndex>& indices,
10391047
const WTouchEvent& event);
10401048

1049+
/*! \brief Handles a touch moved event.
1050+
*/
1051+
virtual void handleTouchMove(const std::vector<WModelIndex>& indices,
1052+
const WTouchEvent& event);
1053+
10411054
/*! \brief Handles a touch ended event.
10421055
*/
10431056
virtual void handleTouchEnd(const std::vector<WModelIndex>& indices,
@@ -1114,6 +1127,7 @@ class WT_API WAbstractItemView : public WCompositeWidget
11141127
Signal<WModelIndex, WMouseEvent> mouseWentUp_;
11151128
Signal<WModelIndex, WTouchEvent> touchStart_;
11161129
Signal<std::vector<WModelIndex>, WTouchEvent> touchStarted_;
1130+
Signal<std::vector<WModelIndex>, WTouchEvent> touchMoved_;
11171131
Signal<std::vector<WModelIndex>, WTouchEvent> touchEnded_;
11181132
Signal<> selectionChanged_;
11191133
Signal<> pageChanged_;

src/Wt/WFileUpload.C

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,22 @@ void WFileUpload::setProgressBar(std::unique_ptr<WProgressBar> bar)
243243
}
244244
}
245245

246+
void WFileUpload::setDisplayWidget(WInteractWidget *widget) {
247+
addStyleClass("Wt-fileupload-hidden");
248+
widget->clicked().connect(displayWidgetClickJS());
249+
}
250+
251+
std::string WFileUpload::displayWidgetClickJS() {
252+
return "function(obj, event) {" +
253+
jsRef() + ".click();" +
254+
" var children = " + jsRef() + ".children;" +
255+
" for (var i=0; i < children.length; i++) {" +
256+
" children[i].click();" +
257+
" }" +
258+
"}";
259+
}
260+
261+
246262
EventSignal<>& WFileUpload::uploaded()
247263
{
248264
return *voidEventSignal(UPLOADED_SIGNAL, true);

src/Wt/WFileUpload.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,17 @@ class WT_API WFileUpload : public WWebWidget
192192
*/
193193
bool canUpload() const { return fileUploadTarget_ != nullptr; }
194194

195+
/*! \brief Use the click signal of another widget to open the file picker.
196+
*
197+
* This hides the default WFileUpload widget and uses the click-signal of the argument to
198+
* open the file picker. The upload logic is still handled by WFileUpload behind the scenes.
199+
* This action cannot be undone.
200+
*
201+
* WFileUpload does not take ownership of the widget, nor does it display it. You must still
202+
* place it in the widget tree yourself.
203+
*/
204+
void setDisplayWidget(WInteractWidget *widget);
205+
195206
/*! \brief %Signal emitted when a new file was uploaded.
196207
*
197208
* This signal is emitted when file upload has been completed. It
@@ -339,6 +350,8 @@ class WT_API WFileUpload : public WWebWidget
339350
void onData(::uint64_t current, ::uint64_t total);
340351
void onDataExceeded(::uint64_t dataExceeded);
341352

353+
std::string displayWidgetClickJS();
354+
342355
virtual void setRequestTooLarge(::int64_t size) override;
343356

344357
protected:

0 commit comments

Comments
 (0)