Skip to content

Commit

Permalink
NEW:
Browse files Browse the repository at this point in the history
- Saving window state and state of sidebar.
- Custom error pages.

FIXED:
- Crash when entering non-URL string into address bar.
  • Loading branch information
MayaPosch committed Apr 2, 2013
1 parent 4d1acd6 commit b81f78b
Show file tree
Hide file tree
Showing 10 changed files with 744 additions and 5 deletions.
6 changes: 4 additions & 2 deletions WildFox-Mimic.pro
Expand Up @@ -22,7 +22,8 @@ SOURCES += main.cpp\
json.cpp \
bookmarks.cpp \
chrome/chromejsinterface.cpp \
chrome/chromebookmarks.cpp
chrome/chromebookmarks.cpp \
wfwebpage.cpp

HEADERS += mainwindow.h \
wfwebview.h \
Expand All @@ -36,7 +37,8 @@ HEADERS += mainwindow.h \
types.h \
bookmarks.h \
chrome/chromejsinterface.h \
chrome/chromebookmarks.h
chrome/chromebookmarks.h \
wfwebpage.h

FORMS += mainwindow.ui \
optionsdialog.ui \
Expand Down
2 changes: 1 addition & 1 deletion chrome/chromebookmarks.h
Expand Up @@ -18,7 +18,7 @@
#include <QtWebKit>

//class Bookmarks;
#include "bookmarks.h"
#include "../bookmarks.h"


class ChromeBookmarks : public QObject {
Expand Down
16 changes: 16 additions & 0 deletions mainwindow.cpp
Expand Up @@ -140,6 +140,11 @@ MainWindow::MainWindow(QWidget *parent) :
}
}

// Restore application state
restoreGeometry(settings->value("geometry").toByteArray());
restoreState(settings->value("windowState").toByteArray());
bookmarksTree->setVisible(settings->value("bookmarkSidebar", false).toBool());

// pass extension filter data to the network access manager
//nam->setFilters(extFilters);

Expand Down Expand Up @@ -226,6 +231,7 @@ void MainWindow::gotoURL(QString url) {
url.toLower();
qDebug() << "Lower-case URL: " << url;

// TODO: perform more advanced URL validation.
if (url.size() < 1) {
QMessageBox::critical(this, "Error", "No URL provided: " + url);
return;
Expand Down Expand Up @@ -551,3 +557,13 @@ void MainWindow::gotoAddressBar() {
addressBar->setFocus(Qt::ShortcutFocusReason);
addressBar->selectAll();
}


// --- CLOSE EVENT ---
// Reeimplements the close event function of QWidget to save state.
void MainWindow::closeEvent(QCloseEvent* event) {
settings->setValue("geometry", saveGeometry());
settings->setValue("windowState", saveState());
settings->setValue("bookmarkSidebar", bookmarksTree->isVisible());
QMainWindow::closeEvent(event);
}
3 changes: 3 additions & 0 deletions mainwindow.h
Expand Up @@ -78,6 +78,9 @@ public slots:
const QString &textContent);

void gotoAddressBar();

protected:
void closeEvent(QCloseEvent* event);

private:
void setStopButton();
Expand Down
15 changes: 14 additions & 1 deletion mainwindow.ui
Expand Up @@ -148,6 +148,19 @@ height: 25px;
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="searchBar">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Search query</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down Expand Up @@ -231,7 +244,7 @@ height: 25px;
<x>0</x>
<y>0</y>
<width>741</width>
<height>25</height>
<height>18</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
Expand Down
2 changes: 1 addition & 1 deletion tldutil.cpp
Expand Up @@ -70,7 +70,7 @@ bool isEffectiveTLD(const QString &domain) {
// Return it and the first public section preceding it.
QString getPublicDomain(const QString &domain) {
QStringList sections = domain.toLower().split(QLatin1Char('.'), QString::SkipEmptyParts);
if (sections.isEmpty())
if (sections.isEmpty() || sections.size() <= 1)
return QString();

QString tld = "";
Expand Down

0 comments on commit b81f78b

Please sign in to comment.