X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=src%2Fdialogs%2FRequestDetailDialog.cpp;fp=src%2Fdialogs%2FRequestDetailDialog.cpp;h=bdc4b6ae136da38f6f327e5147c2e681c64865a3;hb=a44e607fb5398c80c5de2629017865ae749e8fbf;hp=0000000000000000000000000000000000000000;hpb=c5706a6ff3fbc42418e60b79fbe3f5c19396f7d2;p=PrivacyBrowserPC.git diff --git a/src/dialogs/RequestDetailDialog.cpp b/src/dialogs/RequestDetailDialog.cpp new file mode 100644 index 0000000..bdc4b6a --- /dev/null +++ b/src/dialogs/RequestDetailDialog.cpp @@ -0,0 +1,150 @@ +/* + * Copyright 2024 Soren Stoutner . + * + * This file is part of Privacy Browser PC . + * + * Privacy Browser PC is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Privacy Browser PC is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Privacy Browser PC. If not, see . + */ + +// Application headers. +#include "RequestDetailDialog.h" +#include "GlobalVariables.h" +#include "ui_RequestDetailDialog.h" +#include "structs/RequestStruct.h" + +// Qt toolkit headers. +#include + +// KDE Frameworks headers. +#include +#include + +// Construct the class. +RequestDetailDialog::RequestDetailDialog(QWidget *parentWidgetPointer, QByteArray &requestStructByteArray) : QDialog(parentWidgetPointer) +{ + // Create a request struct data stream reader. + QDataStream requestStructDataStreamReader(requestStructByteArray); + + // Create a new request struct. + RequestStruct *requestStructPointer = new RequestStruct(); + + // Populate the new request struct. + requestStructDataStreamReader >> requestStructPointer->dispositionInt; + requestStructDataStreamReader >> requestStructPointer->entryStruct.appliedEntry; + requestStructDataStreamReader >> requestStructPointer->entryStruct.originalEntry; + requestStructDataStreamReader >> requestStructPointer->filterListTitle; + requestStructDataStreamReader >> requestStructPointer->navigationTypeInt; + requestStructDataStreamReader >> requestStructPointer->requestMethodString; + requestStructDataStreamReader >> requestStructPointer->resourceTypeInt; + requestStructDataStreamReader >> requestStructPointer->sublistInt; + requestStructDataStreamReader >> requestStructPointer->urlString; + + qDebug().noquote().nospace() << "Disposition: " << requestStructPointer->dispositionInt; + qDebug().noquote().nospace() << "Applied Entry: " << requestStructPointer->entryStruct.appliedEntry; + qDebug().noquote().nospace() << "Original Entry: " << requestStructPointer->entryStruct.originalEntry; + qDebug().noquote().nospace() << "Filter List: " << requestStructPointer->filterListTitle; + qDebug().noquote().nospace() << "Request Method: " << requestStructPointer->requestMethodString; + qDebug().noquote().nospace() << "Navigation Type: " << requestStructPointer->navigationTypeInt; + qDebug().noquote().nospace() << "Resource Type: " << requestStructPointer->resourceTypeInt; + qDebug().noquote().nospace() << "Sublist: " << requestStructPointer->sublistInt; + qDebug().noquote().nospace() << "URL: " << requestStructPointer->urlString; + + // Set the window title. + setWindowTitle(i18nc("The request detail dialog window title", "Request Detail")); + + // Set the window modality. + setWindowModality(Qt::WindowModality::ApplicationModal); + + // Instantiate the request detail dialog UI. + Ui::RequestDetailDialog requestDetailDialogUi; + + // Setup the UI. + requestDetailDialogUi.setupUi(this); + + // Get handles for the views. + QLineEdit *dispositionLineEditPointer = requestDetailDialogUi.dispositionLineEdit; + QLineEdit *urlLineEditPointer = requestDetailDialogUi.urlLineEdit; + QLineEdit *requestMethodLineEditPointer = requestDetailDialogUi.requestMethodLineEdit; + QLineEdit *navigationTypeLineEditPointer = requestDetailDialogUi.navigationTypeLineEdit; + QLineEdit *resourceTypeLineEditPointer = requestDetailDialogUi.resourceTypeLineEdit; + QFrame *horizontalLinePointer = requestDetailDialogUi.horizontalLine; + QLabel *filterListLabelPointer = requestDetailDialogUi.filterListLabel; + QLineEdit *filterListLineEditPointer = requestDetailDialogUi.filterListLineEdit; + QLabel *sublistLabelPointer = requestDetailDialogUi.sublistLabel; + QLineEdit *sublistLineEditPointer = requestDetailDialogUi.sublistListLineEdit; + QLabel *appliedEntryLabelPointer = requestDetailDialogUi.appliedEntryLabel; + QLineEdit *appliedEntryLineEditPointer = requestDetailDialogUi.appliedEntryLineEdit; + QLabel *originalEntryLabelPointer = requestDetailDialogUi.originalEntryLabel; + QLineEdit *originalEntryLineEditPointer = requestDetailDialogUi.originalEntryLineEdit; + QDialogButtonBox *dialogButtonBoxPointer = requestDetailDialogUi.dialogButtonBox; + + // Populate the views. + dispositionLineEditPointer->setText(globalFilterListHelperPointer->getDispositionString(requestStructPointer->dispositionInt)); + urlLineEditPointer->setText(requestStructPointer->urlString); + requestMethodLineEditPointer->setText(requestStructPointer->requestMethodString); + navigationTypeLineEditPointer->setText(globalFilterListHelperPointer->getNavigationTypeString(requestStructPointer->navigationTypeInt)); + resourceTypeLineEditPointer->setText(globalFilterListHelperPointer->getResourceTypeString(requestStructPointer->resourceTypeInt)); + filterListLineEditPointer->setText(requestStructPointer->filterListTitle); + sublistLineEditPointer->setText(globalFilterListHelperPointer->getSublistName(requestStructPointer->sublistInt)); + appliedEntryLineEditPointer->setText(requestStructPointer->entryStruct.appliedEntry); + originalEntryLineEditPointer->setText(requestStructPointer->entryStruct.originalEntry); + + // Get the disposition line edit palettes. + QPalette normalBackgroundPalette = dispositionLineEditPointer->palette(); + QPalette negativeBackgroundPalette = normalBackgroundPalette; + QPalette positiveBackgroundPalette = normalBackgroundPalette; + + // Modify the palettes. + KColorScheme::adjustBackground(negativeBackgroundPalette, KColorScheme::NegativeBackground); + KColorScheme::adjustBackground(positiveBackgroundPalette, KColorScheme::PositiveBackground); + + // Modify the interface based on the disposition. + switch (requestStructPointer->dispositionInt) + { + case FilterListHelper::DEFAULT: + { + // Hide the filter list views. + horizontalLinePointer->hide(); + filterListLabelPointer->hide(); + filterListLineEditPointer->hide(); + sublistLabelPointer->hide(); + sublistLineEditPointer->hide(); + appliedEntryLabelPointer->hide(); + appliedEntryLineEditPointer->hide(); + originalEntryLabelPointer->hide(); + originalEntryLineEditPointer->hide(); + + break; + } + + case FilterListHelper::ALLOWED: + { + // Colorize the disposition line edit background. + dispositionLineEditPointer->setPalette(positiveBackgroundPalette); + + break; + } + + case FilterListHelper::BLOCKED: + { + // Colorize the disposition line edit background. + dispositionLineEditPointer->setPalette(negativeBackgroundPalette); + + break; + } + } + + // Connect the buttons. + connect(dialogButtonBoxPointer, SIGNAL(rejected()), this, SLOT(close())); +}