]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/commitdiff
Add the URL line edit.
authorSoren Stoutner <soren@stoutner.com>
Fri, 28 Jan 2022 00:04:15 +0000 (17:04 -0700)
committerSoren Stoutner <soren@stoutner.com>
Fri, 28 Jan 2022 00:04:15 +0000 (17:04 -0700)
CMakeLists.txt
src/CMakeLists.txt
src/icons/sc-apps-privacy-browser.svg [new file with mode: 0644]
src/mainview.cpp
src/mainview.h
src/mainview.ui
src/mainwindow.cpp

index b32fd1854b7db33b922b9bcc1fc05a59b9229ff8..87b77b50708d018e16e71d1da91ebbb84962d815 100644 (file)
@@ -52,6 +52,7 @@ find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
 
 # Load the KDE Frameworks components.
 find_package(KF5 ${KDE_FRAMEWORKS_MIN_VERSION} REQUIRED COMPONENTS
+    Completion
     ConfigWidgets
     CoreAddons
     Crash
index 811cb8092acde2825fbfbab3bc09a32ae093dae7..2b5beb12619e52cb0ea1ea4a435e451ec7d96c5f 100644 (file)
@@ -45,6 +45,7 @@ ki18n_wrap_ui(privacy-browser
 # Link the following libraries.
 target_link_libraries(privacy-browser
     KF5::ConfigWidgets
+    KF5::Completion
     KF5::CoreAddons
     KF5::Crash
     KF5::DBusAddons
diff --git a/src/icons/sc-apps-privacy-browser.svg b/src/icons/sc-apps-privacy-browser.svg
new file mode 100644 (file)
index 0000000..428d507
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+
+<!--
+  Copyright © 2016-2017,2021-2022 Soren Stoutner <soren@stoutner.com>.
+
+  This file is derived from `security` and `language`, which are part of the Android Material icon set.  They are released under the Apache License 2.0.  <https://fonts.google.com/icons>
+
+  This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-android>.
+
+  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 <http://www.gnu.org/licenses/>. -->
+
+<svg
+    xmlns="http://www.w3.org/2000/svg"
+    viewBox="0 0 256 256" >
+
+    <!-- Inner Shield. -->
+    <g transform="translate(0,160)" >
+        <path
+            style="fill:#0d47a1"
+            d="m 128,-147.2 -94.254546,41.89091 v 62.836368 c 0,58.123635 40.215273,112.477091 94.254546,125.672721 54.03928,-13.19563 94.25454,-67.549086 94.25454,-125.672721 v -62.836368 z" />
+    </g>
+
+    <!-- Outer Shield. -->
+    <g transform="translate(0,160)" >
+        <path
+            style="fill:#1976d2"
+            d="m 128,-160 -104.727273,46.54546 v 69.818182 C 23.272727,20.945459 67.956363,81.338188 128,95.999999 188.04364,81.338188 232.72727,20.945459 232.72727,-43.636358 v -69.818182 z m 0,127.883641 h 81.45454 C 203.28728,15.825464 171.28727,58.530919 128,71.912739 V -31.999996 H 46.545455 V -98.327268 L 128,-134.51636 Z" />
+    </g>
+
+    <!-- Globe. -->
+    <g transform="translate(0,232)" >
+        <path
+            style="fill:#ffffff"
+            d="m 127.92021,-183.78553 c -44.041614,0 -79.705747,35.74391 -79.705747,79.78553 0,44.041617 35.664133,79.785537 79.705747,79.785537 44.1214,0 79.86533,-35.74392 79.86533,-79.785537 0,-44.04162 -35.74393,-79.78553 -79.86533,-79.78553 z m 55.29138,47.87132 h -23.53674 c -2.55313,-9.9732 -6.22326,-19.54746 -11.0104,-28.40365 14.68055,5.02648 26.88773,15.23903 34.54714,28.40365 z M 128,-167.50929 c 6.6222,9.57427 11.80825,20.18574 15.23903,31.59508 h -30.47807 c 3.43078,-11.40934 8.61684,-22.02081 15.23904,-31.59508 z M 66.245993,-88.042889 C 64.969425,-93.149168 64.171571,-98.494798 64.171571,-104 c 0,-5.5052 0.797855,-10.85083 2.074422,-15.95711 h 26.96751 c -0.63829,5.26585 -1.117,10.5317 -1.117,15.95711 0,5.425417 0.47872,10.691263 1.117,15.957111 z m 6.542412,15.957108 H 96.32514 c 2.553137,9.973191 6.22327,19.547449 11.0104,28.403644 C 92.655006,-48.708619 80.44782,-58.841391 72.788405,-72.085781 Z M 96.32514,-135.91421 H 72.788405 c 7.659415,-13.2444 19.866601,-23.37717 34.547135,-28.40365 -4.78713,8.85619 -8.457263,18.43045 -11.0104,28.40365 z M 128,-40.49071 c -6.6222,-9.574268 -11.80826,-20.185747 -15.23904,-31.595071 h 30.47807 C 139.80825,-60.676457 134.6222,-50.064978 128,-40.49071 Z m 18.66982,-47.552179 h -37.33964 c -0.71801,-5.265848 -1.27656,-10.531694 -1.27656,-15.957111 0,-5.42541 0.55854,-10.77105 1.27656,-15.95711 h 37.33964 c 0.71811,5.18606 1.27656,10.5317 1.27656,15.95711 0,5.425417 -0.55844,10.691263 -1.27656,15.957111 z m 1.99463,44.360752 c 4.78714,-8.856195 8.45727,-18.430453 11.0104,-28.403644 h 23.53674 c -7.65941,13.164605 -19.86659,23.377162 -34.54714,28.403644 z m 14.12204,-44.360752 c 0.63828,-5.265848 1.117,-10.531694 1.117,-15.957111 0,-5.42541 -0.47871,-10.69126 -1.117,-15.95711 h 26.96752 c 1.27656,5.10628 2.07441,10.45191 2.07441,15.95711 0,5.505202 -0.79784,10.850832 -2.07441,15.957111 z" />
+    </g>
+</svg>
index 844f930971428834cd1bd747df6d028a5624b204..a1e018b400734422350bbf1b8cf3c46d5ef88685 100644 (file)
 #include "mainview.h"
 #include "settings.h"
 
+// KDE Framework headers.
+#include <KLineEdit>
+
 // Qt framework headers.
 #include <QWebEngineView>
 
 MainView::MainView(QWidget *parent) : QWidget(parent)
 {
+    // Instantiate the mainview UI.
+    Ui::MainView mainViewUi;
+
     // Setup the UI.
     mainViewUi.setupUi(this);
 
-    // Get a handle for the web engine view.
-    QWebEngineView *webEngineViewPointer = mainViewUi.webEngineView;
+    // Get handles for the views.
+    urlLineEditPointer = mainViewUi.urlLineEdit;
+    webEngineViewPointer = mainViewUi.webEngineView;
+
+    // Update the webengine view from the URL line edit.
+    connect(urlLineEditPointer, SIGNAL(returnKeyPressed(const QString)), this, SLOT(loadUrl(const QString)));
+
+    // Update the URL line edit form the webengine view.
+    connect(webEngineViewPointer, SIGNAL(loadStarted()), this, SLOT(updateUrlLineEdit()));
+    connect(webEngineViewPointer, SIGNAL(loadProgress(int)), this, SLOT(updateUrlLineEdit()));
+    connect(webEngineViewPointer, SIGNAL(loadFinished(bool)), this, SLOT(updateUrlLineEdit()));
 
     // Load a website.
     webEngineViewPointer->setUrl(QUrl(QStringLiteral("https://www.stoutner.com/")));
 }
+
+void MainView::loadUrl(const QString &urlFromUser)
+{
+    // Load the URL, adding standard protocol sections if needed.  TODO.  Replace this with logic that prefers HTTPS.
+    webEngineViewPointer->setUrl(QUrl::fromUserInput(urlFromUser));
+}
+
+void MainView::updateUrlLineEdit()
+{
+    // Update the URL line edit.
+    urlLineEditPointer->setText(webEngineViewPointer->url().toString());
+}
index 8129ecaf57bdf9618ea9ad0ebb03febfe8e8810f..9affb38d933492da108a3f71008aa899af6433dc 100644 (file)
@@ -32,8 +32,14 @@ public:
     // The default contructor.
     explicit MainView(QWidget *parent);
 
+private Q_SLOTS:
+    // Define the private slots.
+    void loadUrl(const QString &urlFromUser);
+    void updateUrlLineEdit();
+
 private:
-    // Declare the private variables.
-    Ui::MainView mainViewUi;
+    // Define the private variables.
+    KLineEdit *urlLineEditPointer;
+    QWebEngineView *webEngineViewPointer;
 };
 #endif
index 41b9b00b2a021f8e9573760937fd4cbe2f001b22..2174544c90558deb59ef747c9b7f7b920bf466f2 100644 (file)
@@ -32,7 +32,8 @@
             </rect>
         </property>
 
-        <layout class="QGridLayout">
+        <layout class="QVBoxLayout">
+            <!-- Set the margins to 0. -->
             <property name="topMargin">
                 <number>0</number>
             </property>
                 <number>0</number>
             </property>
 
-            <item row="0" column="0">
-                <widget class="QWebEngineView" name="webEngineView">
-                </widget>
+            <item>
+                <widget class="KLineEdit" name="urlLineEdit" />
+            </item>
+
+            <item>
+                <widget class="QWebEngineView" name="webEngineView" />
             </item>
         </layout>
     </widget>
-
-    <resources/>
-
-    <connections/>
 </ui>
index 3564a8e7a71d32e638d4a6a0683de73552fa4473..1f7f34643832d83db1d14774441c8f95394c6e27 100644 (file)
@@ -38,17 +38,6 @@ MainWindow::MainWindow() : KXmlGuiWindow()
     // Get a handle for the action collectoin.
     KActionCollection *actionCollectionPointer = this->actionCollection();
 
-    // Create a switch colorsaction pointer.
-    QAction *switchColorsActionPointer;
-
-    // Populate the switch colors action pointer.
-    switchColorsActionPointer = actionCollectionPointer->addAction(QStringLiteral("switch_action"));
-    switchColorsActionPointer->setText(i18nc("@action", "Switch Colors"));
-    switchColorsActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("fill-color")));
-
-    // Connect the signals to the slots.
-    connect(switchColorsActionPointer, &QAction::triggered, mainViewPointer, &MainView::switchColors);
-
     // Add the standard actions.
     KStandardAction::openNew(this, SLOT(fileNew()), actionCollectionPointer);
     KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollectionPointer);