1 /* SPDX-License-Identifier: GPL-3.0-or-later
2 * SPDX-FileCopyrightText: 2024-2025 Soren Stoutner <soren@stoutner.com>
4 * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
6 * This program is free software: you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License as published by the Free Software
8 * Foundation, either version 3 of the License, or (at your option) any later
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <https://www.gnu.org/licenses/>.
20 // Application headers.
21 #include "RequestDetailDialog.h"
22 #include "GlobalVariables.h"
23 #include "ui_RequestDetailDialog.h"
25 // KDE Frameworks headers.
26 #include <KActionCollection>
27 #include <KColorScheme>
29 // Qt toolkit headers.
32 // Construct the class.
33 RequestDetailDialog::RequestDetailDialog(QWidget *parentWidgetPointer, QTableWidget *tableWidgetPointer, const int initialRow) :
34 QDialog(parentWidgetPointer), currentRow(initialRow), tableWidgetPointer(tableWidgetPointer)
36 // Set the window modality.
37 setWindowModality(Qt::WindowModality::ApplicationModal);
39 // Instantiate the request detail dialog UI.
40 Ui::RequestDetailDialog requestDetailDialogUi;
43 requestDetailDialogUi.setupUi(this);
45 // Get handles for the views.
46 dispositionLineEditPointer = requestDetailDialogUi.dispositionLineEdit;
47 webPageUrlLineEditPointer = requestDetailDialogUi.webPageUrlLineEdit;
48 requestUrlLineEditPointer = requestDetailDialogUi.requestUrlLineEdit;
49 requestUrlWithSeparatorsLineEditPointer = requestDetailDialogUi.requestUrlWithSeparatorsLineEdit;
50 truncatedRequestUrlLineEditPointer = requestDetailDialogUi.truncatedRequestUrlLineEdit;
51 truncatedRequestUrlWithSeparatorsLineEditPointer = requestDetailDialogUi.truncatedRequestUrlWithSeparatorsLineEdit;
52 requestMethodLineEditPointer = requestDetailDialogUi.requestMethodLineEdit;
53 navigationTypeLineEditPointer = requestDetailDialogUi.navigationTypeLineEdit;
54 thirdPartyRequestLineEditPointer = requestDetailDialogUi.thirdPartyRequestLineEdit;
55 resourceTypeLineEditPointer = requestDetailDialogUi.resourceTypeLineEdit;
56 filterListEntryWidget = requestDetailDialogUi.filterListEntryWidget;
57 filterListLineEditPointer = requestDetailDialogUi.filterListLineEdit;
58 sublistLineEditPointer = requestDetailDialogUi.sublistListLineEdit;
59 appliedEntryListLineEditPointer = requestDetailDialogUi.appliedEntryListLineEdit;
60 domainLineEditPointer = requestDetailDialogUi.domainLineEdit;
61 thirdPartyFilterLineEditPointer = requestDetailDialogUi.thirdPartyFilterLineEdit;
62 initialMatchLineEditPointer = requestDetailDialogUi.initialMatchLineEdit;
63 finalMatchLineEditPointer = requestDetailDialogUi.finalMatchLineEdit;
64 domainListLineEditPointer = requestDetailDialogUi.domainListLineEdit;
65 hasRequestOptionsCheckBoxPointer = requestDetailDialogUi.hasRequestOptionsCheckBox;
66 fontLineEditPointer = requestDetailDialogUi.fontLineEdit;
67 imageLineEditPointer = requestDetailDialogUi.imageLineEdit;
68 mainFrameLineEditPointer = requestDetailDialogUi.mainFrameLineEdit;
69 mediaLineEditPointer = requestDetailDialogUi.mediaLineEdit;
70 objectLineEditPointer = requestDetailDialogUi.objectLineEdit;
71 otherLineEditPointer = requestDetailDialogUi.otherLineEdit;
72 pingLineEditPointer = requestDetailDialogUi.pingLineEdit;
73 scriptLineEditPointer = requestDetailDialogUi.scriptLineEdit;
74 styleSheetLineEditPointer = requestDetailDialogUi.styleSheetLineEdit;
75 subFrameLineEditPointer = requestDetailDialogUi.subFrameLineEdit;
76 webSocketLineEditPointer = requestDetailDialogUi.webSocketLineEdit;
77 xmlHttpRequestLineEditPointer = requestDetailDialogUi.xmlHttpRequestLineEdit;
78 appliedFilterOptionsLineEditPointer = requestDetailDialogUi.appliedFilterOptionsLineEdit;
79 originalFilterOptionsLineEditPointer = requestDetailDialogUi.originalFilterOptionsLineEdit;
80 originalEntryLineEditPointer = requestDetailDialogUi.originalEntryLineEdit;
81 previousButtonPointer = requestDetailDialogUi.previousButton;
82 nextButtonPointer = requestDetailDialogUi.nextButton;
83 QDialogButtonBox *dialogButtonBoxPointer = requestDetailDialogUi.dialogButtonBox;
84 QPushButton *closeButtonPointer = dialogButtonBoxPointer->button(QDialogButtonBox::StandardButton::Close);
86 // Disable changing the checkbox checked status.
87 hasRequestOptionsCheckBoxPointer->setAttribute(Qt::WA_TransparentForMouseEvents);
89 // Make the close button the default.
90 closeButtonPointer->setDefault(true);
92 // Get the disposition line edit palettes.
93 normalBackgroundPalette = dispositionLineEditPointer->palette();
94 negativeBackgroundPalette = normalBackgroundPalette;
95 positiveBackgroundPalette = normalBackgroundPalette;
97 // Modify the palettes.
98 KColorScheme::adjustBackground(negativeBackgroundPalette, KColorScheme::NegativeBackground);
99 KColorScheme::adjustBackground(positiveBackgroundPalette, KColorScheme::PositiveBackground);
101 // Connect the buttons.
102 connect(previousButtonPointer, SIGNAL(clicked()), this, SLOT(previous()));
103 connect(nextButtonPointer, SIGNAL(clicked()), this, SLOT(next()));
104 connect(dialogButtonBoxPointer, SIGNAL(rejected()), this, SLOT(close()));
106 // Create the keyboard shortcuts.
107 QShortcut *previousShortcutPointer = new QShortcut(Qt::Key_Left, this);
108 QShortcut *nextShortcutPointer = new QShortcut(Qt::Key_Right, this);
110 // Connect the keyboard shortcuts to the buttons.
111 connect(previousShortcutPointer, SIGNAL(activated()), previousButtonPointer, SLOT(click()));
112 connect(nextShortcutPointer, SIGNAL(activated()), nextButtonPointer, SLOT(click()));
114 // Populate the dialog.
115 populateDialog(currentRow);
118 void RequestDetailDialog::populateDialog(const int row)
120 // Set the window title.
121 setWindowTitle(i18nc("The request detail dialog window title", "Request %1 Detail", row + 1));
123 // Select the row in the table widget (this displays the correct row highlighted in the background of the dialog).
124 tableWidgetPointer->selectRow(row);
126 // Get the first table widget item in the row.
127 QTableWidgetItem *rowFirstTableWidgetItemPointer = tableWidgetPointer->item(row, 0);
129 // Get the data variant.
130 QVariant dataVariant = rowFirstTableWidgetItemPointer->data(Qt::UserRole);
132 // Get the request struct byte array from the data variant.
133 QByteArray requestStructByteArray = dataVariant.toByteArray();
135 // Determine if previous should be enabled.
136 bool previousEnabled = (row > 0);
138 // Determine if next should be enabled.
139 bool nextEnabled = (row < (tableWidgetPointer->rowCount() - 1));
141 // Create a request struct data stream reader.
142 QDataStream requestStructDataStreamReader(requestStructByteArray);
144 // Create a new request struct.
145 RequestStruct *requestStructPointer = new RequestStruct();
147 // Populate the new request struct. The order needs to match how the data stream is populated in RequestsDialog.cpp.
148 requestStructDataStreamReader >> requestStructPointer->dispositionInt;
149 requestStructDataStreamReader >> requestStructPointer->entryStruct.originalEntry;
150 requestStructDataStreamReader >> requestStructPointer->entryStruct.originalFilterOptions;
151 requestStructDataStreamReader >> requestStructPointer->entryStruct.appliedEntryList;
152 requestStructDataStreamReader >> requestStructPointer->entryStruct.appliedFilterOptionsList;
153 requestStructDataStreamReader >> requestStructPointer->entryStruct.domainList;
154 requestStructDataStreamReader >> requestStructPointer->entryStruct.finalMatch;
155 requestStructDataStreamReader >> requestStructPointer->entryStruct.hasRequestOptions;
156 requestStructDataStreamReader >> requestStructPointer->entryStruct.initialMatch;
157 requestStructDataStreamReader >> requestStructPointer->entryStruct.domain;
158 requestStructDataStreamReader >> requestStructPointer->entryStruct.font;
159 requestStructDataStreamReader >> requestStructPointer->entryStruct.image;
160 requestStructDataStreamReader >> requestStructPointer->entryStruct.mainFrame;
161 requestStructDataStreamReader >> requestStructPointer->entryStruct.media;
162 requestStructDataStreamReader >> requestStructPointer->entryStruct.object;
163 requestStructDataStreamReader >> requestStructPointer->entryStruct.other;
164 requestStructDataStreamReader >> requestStructPointer->entryStruct.ping;
165 requestStructDataStreamReader >> requestStructPointer->entryStruct.script;
166 requestStructDataStreamReader >> requestStructPointer->entryStruct.styleSheet;
167 requestStructDataStreamReader >> requestStructPointer->entryStruct.subFrame;
168 requestStructDataStreamReader >> requestStructPointer->entryStruct.thirdParty;
169 requestStructDataStreamReader >> requestStructPointer->entryStruct.webSocket;
170 requestStructDataStreamReader >> requestStructPointer->entryStruct.xmlHttpRequest;
171 requestStructDataStreamReader >> requestStructPointer->filterListTitle;
172 requestStructDataStreamReader >> requestStructPointer->isThirdPartyRequest;
173 requestStructDataStreamReader >> requestStructPointer->matchedUrlType;
174 requestStructDataStreamReader >> requestStructPointer->navigationTypeInt;
175 requestStructDataStreamReader >> requestStructPointer->requestMethodString;
176 requestStructDataStreamReader >> requestStructPointer->resourceTypeInt;
177 requestStructDataStreamReader >> requestStructPointer->sublistInt;
178 requestStructDataStreamReader >> requestStructPointer->truncatedUrlString;
179 requestStructDataStreamReader >> requestStructPointer->truncatedUrlStringWithSeparators;
180 requestStructDataStreamReader >> requestStructPointer->urlString;
181 requestStructDataStreamReader >> requestStructPointer->urlStringWithSeparators;
182 requestStructDataStreamReader >> requestStructPointer->webPageUrlString;
184 // Make a local copy of the has request options boolean.
185 bool hasRequestOptions = requestStructPointer->entryStruct.hasRequestOptions;
187 // Populate the views.
188 dispositionLineEditPointer->setText(globalFilterListHelperPointer->getDispositionString(requestStructPointer->dispositionInt));
189 webPageUrlLineEditPointer->setText(requestStructPointer->webPageUrlString);
190 requestUrlLineEditPointer->setText(requestStructPointer->urlString);
191 requestUrlWithSeparatorsLineEditPointer->setText(requestStructPointer->urlStringWithSeparators);
192 truncatedRequestUrlLineEditPointer->setText(requestStructPointer->truncatedUrlString);
193 truncatedRequestUrlWithSeparatorsLineEditPointer->setText(requestStructPointer->truncatedUrlStringWithSeparators);
194 requestMethodLineEditPointer->setText(requestStructPointer->requestMethodString);
195 thirdPartyRequestLineEditPointer->setText(requestStructPointer->isThirdPartyRequest ? i18n("Yes") : QLatin1String());
196 navigationTypeLineEditPointer->setText(globalFilterListHelperPointer->getNavigationTypeString(requestStructPointer->navigationTypeInt));
197 resourceTypeLineEditPointer->setText(globalFilterListHelperPointer->getResourceTypeString(requestStructPointer->resourceTypeInt));
198 filterListLineEditPointer->setText(requestStructPointer->filterListTitle);
199 sublistLineEditPointer->setText(globalFilterListHelperPointer->getSublistName(requestStructPointer->sublistInt));
200 appliedEntryListLineEditPointer->setText(requestStructPointer->entryStruct.appliedEntryList.join(QLatin1String(" * ")));
201 domainLineEditPointer->setText(globalFilterListHelperPointer->getRequestOptionDispositionString(requestStructPointer->entryStruct.domain));
202 thirdPartyFilterLineEditPointer->setText(globalFilterListHelperPointer->getRequestOptionDispositionString(requestStructPointer->entryStruct.thirdParty));
203 initialMatchLineEditPointer->setText(requestStructPointer->entryStruct.initialMatch ? i18n("Yes") : QLatin1String());
204 finalMatchLineEditPointer->setText(requestStructPointer->entryStruct.finalMatch ? i18n("Yes") : QLatin1String());
205 domainListLineEditPointer->setText(requestStructPointer->entryStruct.domainList.join(QLatin1String(" | ")));
206 hasRequestOptionsCheckBoxPointer->setChecked(hasRequestOptions);
207 fontLineEditPointer->setText(globalFilterListHelperPointer->getRequestOptionDispositionString(requestStructPointer->entryStruct.font));
208 imageLineEditPointer->setText(globalFilterListHelperPointer->getRequestOptionDispositionString(requestStructPointer->entryStruct.image));
209 mainFrameLineEditPointer->setText(globalFilterListHelperPointer->getRequestOptionDispositionString(requestStructPointer->entryStruct.mainFrame));
210 mediaLineEditPointer->setText(globalFilterListHelperPointer->getRequestOptionDispositionString(requestStructPointer->entryStruct.media));
211 objectLineEditPointer->setText(globalFilterListHelperPointer->getRequestOptionDispositionString(requestStructPointer->entryStruct.object));
212 otherLineEditPointer->setText(globalFilterListHelperPointer->getRequestOptionDispositionString(requestStructPointer->entryStruct.other));
213 pingLineEditPointer->setText(globalFilterListHelperPointer->getRequestOptionDispositionString(requestStructPointer->entryStruct.ping));
214 scriptLineEditPointer->setText(globalFilterListHelperPointer->getRequestOptionDispositionString(requestStructPointer->entryStruct.script));
215 styleSheetLineEditPointer->setText(globalFilterListHelperPointer->getRequestOptionDispositionString(requestStructPointer->entryStruct.styleSheet));
216 subFrameLineEditPointer->setText(globalFilterListHelperPointer->getRequestOptionDispositionString(requestStructPointer->entryStruct.subFrame));
217 webSocketLineEditPointer->setText(globalFilterListHelperPointer->getRequestOptionDispositionString(requestStructPointer->entryStruct.webSocket));
218 xmlHttpRequestLineEditPointer->setText(globalFilterListHelperPointer->getRequestOptionDispositionString(requestStructPointer->entryStruct.xmlHttpRequest));
219 appliedFilterOptionsLineEditPointer->setText(requestStructPointer->entryStruct.appliedFilterOptionsList.join(QLatin1String(" , ")));
220 originalFilterOptionsLineEditPointer->setText(requestStructPointer->entryStruct.originalFilterOptions);
221 originalEntryLineEditPointer->setText(requestStructPointer->entryStruct.originalEntry);
223 // Determine if this is an allow list, which have a sublist int of of 0-2.
224 isAllowList = (requestStructPointer->sublistInt <= 2);
226 // Set the third-party request background palette.
227 if (requestStructPointer->isThirdPartyRequest)
228 thirdPartyRequestLineEditPointer->setPalette(negativeBackgroundPalette);
230 thirdPartyRequestLineEditPointer->setPalette(normalBackgroundPalette);
232 // Set the initial and final background palettes.
233 setInitialOrFinalBackgroundPalette(initialMatchLineEditPointer);
234 setInitialOrFinalBackgroundPalette(finalMatchLineEditPointer);
236 // Set the request option background palettes.
237 setFilterOptionBackgroundPalette(domainLineEditPointer);
238 setFilterOptionBackgroundPalette(thirdPartyFilterLineEditPointer);
239 setFilterOptionBackgroundPalette(fontLineEditPointer);
240 setFilterOptionBackgroundPalette(imageLineEditPointer);
241 setFilterOptionBackgroundPalette(mainFrameLineEditPointer);
242 setFilterOptionBackgroundPalette(mediaLineEditPointer);
243 setFilterOptionBackgroundPalette(objectLineEditPointer);
244 setFilterOptionBackgroundPalette(otherLineEditPointer);
245 setFilterOptionBackgroundPalette(pingLineEditPointer);
246 setFilterOptionBackgroundPalette(scriptLineEditPointer);
247 setFilterOptionBackgroundPalette(styleSheetLineEditPointer);
248 setFilterOptionBackgroundPalette(subFrameLineEditPointer);
249 setFilterOptionBackgroundPalette(webSocketLineEditPointer);
250 setFilterOptionBackgroundPalette(xmlHttpRequestLineEditPointer);
252 // Set the request option status.
253 fontLineEditPointer->setEnabled(hasRequestOptions);
254 imageLineEditPointer->setEnabled(hasRequestOptions);
255 mainFrameLineEditPointer->setEnabled(hasRequestOptions);
256 mediaLineEditPointer->setEnabled(hasRequestOptions);
257 objectLineEditPointer->setEnabled(hasRequestOptions);
258 otherLineEditPointer->setEnabled(hasRequestOptions);
259 pingLineEditPointer->setEnabled(hasRequestOptions);
260 scriptLineEditPointer->setEnabled(hasRequestOptions);
261 styleSheetLineEditPointer->setEnabled(hasRequestOptions);
262 subFrameLineEditPointer->setEnabled(hasRequestOptions);
263 webSocketLineEditPointer->setEnabled(hasRequestOptions);
264 xmlHttpRequestLineEditPointer->setEnabled(hasRequestOptions);
266 // Set the domain list line edit to have the same palette as the domain line edit.
267 domainListLineEditPointer->setPalette(domainLineEditPointer->palette());
269 // Set the button status.
270 previousButtonPointer->setEnabled(previousEnabled);
271 nextButtonPointer->setEnabled(nextEnabled);
273 // Set the sublist background palette.
274 switch (requestStructPointer->sublistInt)
276 case FilterListHelper::MAIN_ALLOWLIST:
277 case FilterListHelper::INITIAL_DOMAIN_ALLOWLIST:
278 case FilterListHelper::REGULAR_EXPRESSION_ALLOWLIST:
279 sublistLineEditPointer->setPalette(positiveBackgroundPalette);
282 case FilterListHelper::MAIN_BLOCKLIST:
283 case FilterListHelper::INITIAL_DOMAIN_BLOCKLIST:
284 case FilterListHelper::REGULAR_EXPRESSION_BLOCKLIST:
285 sublistLineEditPointer->setPalette(negativeBackgroundPalette);
289 // Set the applied entry background palette to be the same as the sublist.
290 appliedEntryListLineEditPointer->setPalette(sublistLineEditPointer->palette());
292 // Set the resource type background palette.
293 if (hasRequestOptions) // There are request options.
295 switch (requestStructPointer->resourceTypeInt)
298 case QWebEngineUrlRequestInfo::ResourceTypeFontResource:
300 resourceTypeLineEditPointer->setPalette(fontLineEditPointer->palette());
305 case QWebEngineUrlRequestInfo::ResourceTypeImage:
307 resourceTypeLineEditPointer->setPalette(imageLineEditPointer->palette());
312 case QWebEngineUrlRequestInfo::ResourceTypeMainFrame:
313 case QWebEngineUrlRequestInfo::ResourceTypeNavigationPreloadMainFrame:
315 resourceTypeLineEditPointer->setPalette(mainFrameLineEditPointer->palette());
320 case QWebEngineUrlRequestInfo::ResourceTypeMedia:
322 resourceTypeLineEditPointer->setPalette(mediaLineEditPointer->palette());
327 case QWebEngineUrlRequestInfo::ResourceTypeObject:
329 resourceTypeLineEditPointer->setPalette(objectLineEditPointer->palette());
334 case QWebEngineUrlRequestInfo::ResourceTypeSubResource:
335 case QWebEngineUrlRequestInfo::ResourceTypeWorker:
336 case QWebEngineUrlRequestInfo::ResourceTypeSharedWorker:
337 case QWebEngineUrlRequestInfo::ResourceTypePrefetch:
338 case QWebEngineUrlRequestInfo::ResourceTypeFavicon:
339 case QWebEngineUrlRequestInfo::ResourceTypeServiceWorker:
340 case QWebEngineUrlRequestInfo::ResourceTypeCspReport:
341 case QWebEngineUrlRequestInfo::ResourceTypePluginResource:
342 case QWebEngineUrlRequestInfo::ResourceTypeJson:
343 case QWebEngineUrlRequestInfo::ResourceTypeUnknown:
345 resourceTypeLineEditPointer->setPalette(otherLineEditPointer->palette());
350 case QWebEngineUrlRequestInfo::ResourceTypePing:
352 resourceTypeLineEditPointer->setPalette(pingLineEditPointer->palette());
357 case QWebEngineUrlRequestInfo::ResourceTypeScript:
359 resourceTypeLineEditPointer->setPalette(scriptLineEditPointer->palette());
364 case QWebEngineUrlRequestInfo::ResourceTypeStylesheet:
366 resourceTypeLineEditPointer->setPalette(styleSheetLineEditPointer->palette());
371 case QWebEngineUrlRequestInfo::ResourceTypeSubFrame:
372 case QWebEngineUrlRequestInfo::ResourceTypeNavigationPreloadSubFrame:
374 resourceTypeLineEditPointer->setPalette(subFrameLineEditPointer->palette());
379 case QWebEngineUrlRequestInfo::ResourceTypeWebSocket:
381 resourceTypeLineEditPointer->setPalette(webSocketLineEditPointer->palette());
386 case QWebEngineUrlRequestInfo::ResourceTypeXhr:
388 resourceTypeLineEditPointer->setPalette(xmlHttpRequestLineEditPointer->palette());
393 else // There are no request options.
395 // Reset the resource type background palette.
396 resourceTypeLineEditPointer->setPalette(normalBackgroundPalette);
399 // Modify the interface based on the disposition.
400 switch (requestStructPointer->dispositionInt)
402 case FilterListHelper::DEFAULT:
404 // Reset the disposition line edit background.
405 dispositionLineEditPointer->setPalette(normalBackgroundPalette);
407 // Reset the request URL palettes.
408 requestUrlLineEditPointer->setPalette(normalBackgroundPalette);
409 requestUrlWithSeparatorsLineEditPointer->setPalette(normalBackgroundPalette);
410 truncatedRequestUrlLineEditPointer->setPalette(normalBackgroundPalette);
411 truncatedRequestUrlWithSeparatorsLineEditPointer->setPalette(normalBackgroundPalette);
413 // Hide the filter list entry views.
414 filterListEntryWidget->hide();
419 case FilterListHelper::ALLOWED:
421 // Colorize the disposition line edit background.
422 dispositionLineEditPointer->setPalette(positiveBackgroundPalette);
424 // Colorize the request URLs.
425 setRequestUrlBackgroundPalettes(requestStructPointer->matchedUrlType);
427 // Show the filter list entry views.
428 filterListEntryWidget->show();
433 case FilterListHelper::BLOCKED:
435 // Colorize the disposition line edit background.
436 dispositionLineEditPointer->setPalette(negativeBackgroundPalette);
438 // Colorize the request URLs.
439 setRequestUrlBackgroundPalettes(requestStructPointer->matchedUrlType);
441 // Show the filter list entry views.
442 filterListEntryWidget->show();
449 void RequestDetailDialog::previous()
451 // Update the current row.
454 // Populate the dialog.
455 populateDialog(currentRow);
458 void RequestDetailDialog::next()
460 // Update the current row.
463 // Populate the dialog.
464 populateDialog(currentRow);
467 void RequestDetailDialog::setFilterOptionBackgroundPalette(QLineEdit *lineEditPointer)
469 // Set the background palette according to the text.
470 if (lineEditPointer->text() == globalFilterListHelperPointer->getRequestOptionDispositionString(FilterOptionDisposition::Null)) // Not text is displayed.
472 // Set the normal background palette.
473 lineEditPointer->setPalette(normalBackgroundPalette);
475 else if (lineEditPointer->text() == globalFilterListHelperPointer->getRequestOptionDispositionString(FilterOptionDisposition::Apply)) // `Apply` is displayed.
477 // Set the background palette according to the sublist type.
479 lineEditPointer->setPalette(positiveBackgroundPalette);
481 lineEditPointer->setPalette(negativeBackgroundPalette);
483 else // `Override` is displayed.
485 // Set the background palette according to the sublist type.
487 lineEditPointer->setPalette(negativeBackgroundPalette);
489 lineEditPointer->setPalette(positiveBackgroundPalette);
493 void RequestDetailDialog::setInitialOrFinalBackgroundPalette(QLineEdit *lineEditPointer)
495 // Set the background palette according to the text.
496 if (lineEditPointer->text() == i18n("Yes")) // `Yes` is displayed.
498 // Set the background palette according to the sublist type.
500 lineEditPointer->setPalette(positiveBackgroundPalette);
502 lineEditPointer->setPalette(negativeBackgroundPalette);
504 else // No text is displayed.
506 // Set the normal background palette.
507 lineEditPointer->setPalette(normalBackgroundPalette);
511 void RequestDetailDialog::setRequestUrlBackgroundPalettes(RequestUrlType matchedUrlType)
513 // Colorize the request URL strings according to the matched URL.
514 switch (matchedUrlType)
516 case RequestUrlType::Url: // URL.
518 // Set the request URL palette to match the disposition line edit.
519 requestUrlLineEditPointer->setPalette(dispositionLineEditPointer->palette());
521 // Reset the other palettes.
522 requestUrlWithSeparatorsLineEditPointer->setPalette(normalBackgroundPalette);
523 truncatedRequestUrlLineEditPointer->setPalette(normalBackgroundPalette);
524 truncatedRequestUrlWithSeparatorsLineEditPointer->setPalette(normalBackgroundPalette);
529 case RequestUrlType::UrlWithSeparators: // URL with separators.
531 // Set the request URL with separators palette to match the disposition line edit.
532 requestUrlWithSeparatorsLineEditPointer->setPalette(dispositionLineEditPointer->palette());
534 // Reset the other palettes.
535 requestUrlLineEditPointer->setPalette(normalBackgroundPalette);
536 truncatedRequestUrlLineEditPointer->setPalette(normalBackgroundPalette);
537 truncatedRequestUrlWithSeparatorsLineEditPointer->setPalette(normalBackgroundPalette);
542 case RequestUrlType::TruncatedUrl: // Truncated URL.
544 // Set the truncated request URL palette to match the disposition line edit.
545 truncatedRequestUrlLineEditPointer->setPalette(dispositionLineEditPointer->palette());
547 // Reset the other palettes.
548 requestUrlLineEditPointer->setPalette(normalBackgroundPalette);
549 requestUrlWithSeparatorsLineEditPointer->setPalette(normalBackgroundPalette);
550 truncatedRequestUrlWithSeparatorsLineEditPointer->setPalette(normalBackgroundPalette);
555 case RequestUrlType::TruncatedUrlWithSeparators: // Truncated URL with separators.
557 // Set the truncated request URL with separators palette to match the disposition line edit.
558 truncatedRequestUrlWithSeparatorsLineEditPointer->setPalette(dispositionLineEditPointer->palette());
560 // Reset the other palettes.
561 requestUrlLineEditPointer->setPalette(normalBackgroundPalette);
562 requestUrlWithSeparatorsLineEditPointer->setPalette(normalBackgroundPalette);
563 truncatedRequestUrlLineEditPointer->setPalette(normalBackgroundPalette);