Fix Qt compilation on Windows. Check the user-supplied range syntax

and provide instant feedback in the Win32 file dialog similar to the Qt
code. Tango-ize some colors. Escape a backslash in QtShark.pro.

svn path=/trunk/; revision=45430
This commit is contained in:
Gerald Combs 2012-10-09 15:34:40 +00:00
parent 9d37b98748
commit b28da10eec
4 changed files with 66 additions and 27 deletions

View File

@ -51,7 +51,7 @@ FONT 8, "MS Shell Dlg"
CONTROL "Marked packets", EWFD_MARKED_BTN, "Button", BS_AUTORADIOBUTTON, 78, 47, 67, 10
CONTROL "First to last marked", EWFD_FIRST_LAST_BTN, "Button", BS_AUTORADIOBUTTON, 78, 59, 75, 10
CONTROL "Range:", EWFD_RANGE_BTN, "Button", BS_AUTORADIOBUTTON, 78, 71, 35, 10
EDITTEXT EWFD_RANGE_EDIT, 117, 70, 105, 12, ES_AUTOHSCROLL
CONTROL "", EWFD_RANGE_EDIT, RICHEDIT_CLASS, ES_AUTOHSCROLL, 117, 70, 105, 12, WS_EX_CLIENTEDGE
CONTROL "Remove Ignored packets", EWFD_REMOVE_IGN_CB, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 78, 83, 100, 10
LTEXT "0", EWFD_ALL_PKTS_CAP, 232, 24, 39, 8, SS_RIGHT

View File

@ -325,7 +325,7 @@ RC_FILE = qtshark.rc
!isEmpty(TRANSLATIONS) {
isEmpty(QMAKE_LRELEASE) {
win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\lrelease.exe
win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\\lrelease.exe
else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
}

View File

@ -158,7 +158,7 @@ check_savability_t CaptureFileDialog::checkSaveAsWithComments(QWidget *
#if defined(Q_WS_WIN)
if (!parent || !cf)
return CANCELLED;
return win32_check_save_as_with_comments(parent->effectiveWinId(), cap_file_, file_type);
return win32_check_save_as_with_comments(parent->effectiveWinId(), cf, file_type);
#else // Q_WS_WIN
QMessageBox msg_dialog;
int response;
@ -402,11 +402,11 @@ check_savability_t CaptureFileDialog::saveAs(QString &file_name, bool must_suppo
return CANCELLED;
}
check_savability_t CaptureFileDialog::exportSelectedPackets(QString &file_name) {
check_savability_t CaptureFileDialog::exportSelectedPackets(QString &file_name, packet_range_t *range) {
GString *fname = g_string_new(file_name.toUtf8().constData());
gboolean wespf_status;
wespf_status = win32_export_specified_packets_file(parentWidget()->effectiveWinId(), fname, &file_type_, &compressed_, &range_);
wespf_status = win32_export_specified_packets_file(parentWidget()->effectiveWinId(), fname, &file_type_, &compressed_, range);
file_name = fname->str;
g_string_free(fname, TRUE);
@ -651,13 +651,14 @@ int CaptureFileDialog::mergeType() {
return 0;
}
#endif // Q_WS_WINDOWS
// Slots
void CaptureFileDialog::rangeValidityChanged(bool is_valid) {
if (save_bt_) save_bt_->setEnabled(is_valid);
}
#endif // Q_WS_WINDOWS
// Slots
/* do a preview run on the currently selected capture file */

View File

@ -1340,10 +1340,10 @@ filter_tb_syntax_check(HWND hwnd, TCHAR *filter_text) {
if (dfp != NULL)
dfilter_free(dfp);
/* Valid (light green) */
SendMessage(hwnd, EM_SETBKGNDCOLOR, 0, 0x00afffaf);
SendMessage(hwnd, EM_SETBKGNDCOLOR, 0, RGB(0xe4, 0xff, 0xc7)); /* tango_chameleon_1 */
} else {
/* Invalid (light red) */
SendMessage(hwnd, EM_SETBKGNDCOLOR, 0, 0x00afafff);
SendMessage(hwnd, EM_SETBKGNDCOLOR, 0, RGB(0xff, 0xcc, 0xcc)); /* tango_scarlet_red_1 */
}
if (strval) g_free(strval);
@ -1826,7 +1826,8 @@ range_update_dynamics(HWND dlg_hwnd, packet_range_t *range) {
TCHAR static_val[STATIC_LABEL_CHARS];
gint selected_num;
guint32 ignored_cnt = 0, displayed_ignored_cnt = 0;
guint32 displayed_cnt;
guint32 displayed_cnt;
gboolean range_valid = TRUE;
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_DISPLAYED_BTN);
if (SendMessage(cur_ctrl, BM_GETCHECK, 0, 0) == BST_CHECKED)
@ -1920,23 +1921,51 @@ range_update_dynamics(HWND dlg_hwnd, packet_range_t *range) {
SetWindowText(cur_ctrl, static_val);
/* RANGE_SELECT_USER */
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_CAP);
EnableWindow(cur_ctrl, !filtered_active);
if (range->remove_ignored) {
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->user_range_cnt - range->ignored_user_range_cnt);
} else {
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->user_range_cnt);
}
SetWindowText(cur_ctrl, static_val);
switch (packet_range_check(range)) {
case CVT_NO_ERROR:
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_EDIT);
SendMessage(cur_ctrl, EM_SETBKGNDCOLOR, (WPARAM) 1, COLOR_WINDOW);
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_DISP);
EnableWindow(cur_ctrl, filtered_active);
if (range->remove_ignored) {
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_user_range_cnt - range->displayed_ignored_user_range_cnt);
} else {
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_user_range_cnt);
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_CAP);
EnableWindow(cur_ctrl, !filtered_active);
if (range->remove_ignored) {
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->user_range_cnt - range->ignored_user_range_cnt);
} else {
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->user_range_cnt);
}
SetWindowText(cur_ctrl, static_val);
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_DISP);
EnableWindow(cur_ctrl, filtered_active);
if (range->remove_ignored) {
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_user_range_cnt - range->displayed_ignored_user_range_cnt);
} else {
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), range->displayed_user_range_cnt);
}
SetWindowText(cur_ctrl, static_val);
break;
case CVT_SYNTAX_ERROR:
if (range->process == range_process_user_range) range_valid = FALSE;
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_EDIT);
SendMessage(cur_ctrl, EM_SETBKGNDCOLOR, 0, RGB(0xff, 0xcc, 0xcc));
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_CAP);
SetWindowText(cur_ctrl, _T("Bad range"));
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_DISP);
SetWindowText(cur_ctrl, _T("-"));
break;
case CVT_NUMBER_TOO_BIG:
if (range->process == range_process_user_range) range_valid = FALSE;
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_EDIT);
SendMessage(cur_ctrl, EM_SETBKGNDCOLOR, 0, RGB(0xff, 0xcc, 0xcc));
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_CAP);
SetWindowText(cur_ctrl, _T("Too large"));
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_DISP);
SetWindowText(cur_ctrl, _T("-"));
break;
default:
g_assert_not_reached();
}
SetWindowText(cur_ctrl, static_val);
/* RANGE_REMOVE_IGNORED_PACKETS */
switch(range->process) {
@ -1976,6 +2005,9 @@ range_update_dynamics(HWND dlg_hwnd, packet_range_t *range) {
EnableWindow(cur_ctrl, displayed_ignored_cnt && filtered_active);
StringCchPrintf(static_val, STATIC_LABEL_CHARS, _T("%u"), displayed_ignored_cnt);
SetWindowText(cur_ctrl, static_val);
cur_ctrl = GetDlgItem(GetParent(dlg_hwnd), IDOK);
EnableWindow(cur_ctrl, range_valid);
}
static void
@ -1989,6 +2021,12 @@ range_handle_wm_initdialog(HWND dlg_hwnd, packet_range_t *range) {
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_CAPTURED_BTN);
SendMessage(cur_ctrl, BM_SETCHECK, TRUE, 0);
/* Retain the filter text, and fill it in. */
if(range->user_range != NULL) {
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_EDIT);
SetWindowText(cur_ctrl, utf_8to16(range_convert_range(range->user_range)));
}
/* dynamic values in the range frame */
range_update_dynamics(dlg_hwnd, range);
@ -2068,7 +2106,7 @@ range_handle_wm_command(HWND dlg_hwnd, HWND ctrl, WPARAM w_param, packet_range_t
cur_ctrl = GetDlgItem(dlg_hwnd, EWFD_RANGE_BTN);
SendMessage(cur_ctrl, BM_CLICK, 0, 0);
break;
case (EN_CHANGE << 16) | EWFD_RANGE_EDIT:
case (EN_UPDATE << 16) | EWFD_RANGE_EDIT:
SendMessage(ctrl, WM_GETTEXT, (WPARAM) RANGE_TEXT_MAX, (LPARAM) range_text);
packet_range_convert_str(range, utf_16to8(range_text));
range_update_dynamics(dlg_hwnd, range);