1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

Fixed building with NONBLOCK_JS_DIALOGS + other small fixes.

This commit is contained in:
nowrep 2012-03-16 23:28:23 +01:00
parent bb8e1ffdb5
commit 471ac7ba1f
8 changed files with 56 additions and 23 deletions

View File

@ -155,8 +155,8 @@ MainApplication::MainApplication(const QList<CommandLineOptions::ActionPair> &cm
m_postLaunchActions.append(PrivateBrowsing);
break;
case Qz::CL_OpenUrl:
startUrl = QUrl::fromEncoded(pair.text.toUtf8());
messages.append("URL:" + startUrl.toString());
startUrl = QUrl(pair.text.toUtf8());
messages.append("URL:" + pair.text);
break;
default:
break;
@ -440,8 +440,8 @@ void MainApplication::receiveAppMessage(QString message)
{
QWidget* actWin = getWindow();
if (message.startsWith("URL:")) {
QString url(message.remove("URL:"));
addNewTab(QUrl::fromUserInput(url));
QUrl url = QUrl::fromEncoded(message.mid(4).toUtf8());
addNewTab(url);
actWin = getWindow();
}
else if (message.startsWith("ACTION:")) {

View File

@ -145,6 +145,8 @@ void DownloadItem::finished()
ui->frame->hide();
m_outputFile.close();
m_reply->deleteLater();
m_item->setSizeHint(sizeHint());
#if QT_VERSION == 0x040700 // Workaround
ui->button->show();

View File

@ -48,6 +48,7 @@ SourceViewer::SourceViewer(QWebFrame* frame, const QString &selectedHtml)
m_statusBar = new QStatusBar(this);
m_statusBar->showMessage(frame->url().toString());
QMenuBar* menuBar = new QMenuBar(this);
m_layout->addWidget(m_sourceEdit);
m_layout->addWidget(m_statusBar);
@ -55,8 +56,6 @@ SourceViewer::SourceViewer(QWebFrame* frame, const QString &selectedHtml)
m_layout->setSpacing(0);
m_layout->setMenuBar(menuBar);
resize(650, 600);
QFont font;
font.setFamily("Tahoma");
font.setFixedPitch(true);
@ -65,6 +64,9 @@ SourceViewer::SourceViewer(QWebFrame* frame, const QString &selectedHtml)
m_sourceEdit->setFont(font);
new HtmlHighlighter(m_sourceEdit->document());
resize(650, 600);
qz_centerWidgetToParent(this, frame->page()->view());
QMenu* menuFile = new QMenu(tr("File"));
menuFile->addAction(QIcon::fromTheme("document-save"), tr("Save as..."), this, SLOT(save()))->setShortcut(QKeySequence("Ctrl+S"));
menuFile->addSeparator();
@ -99,8 +101,6 @@ SourceViewer::SourceViewer(QWebFrame* frame, const QString &selectedHtml)
menuView->actions().at(3)->setChecked(true);
menuBar->addMenu(menuView);
qz_centerWidgetToParent(this, frame->page()->view());
connect(m_sourceEdit, SIGNAL(copyAvailable(bool)), this, SLOT(copyAvailable(bool)));
connect(m_sourceEdit, SIGNAL(redoAvailable(bool)), this, SLOT(redoAvailable(bool)));
connect(m_sourceEdit, SIGNAL(undoAvailable(bool)), this, SLOT(undoAvailable(bool)));
@ -144,9 +144,8 @@ void SourceViewer::loadSource()
if (!m_selectedHtml.isEmpty()) {
m_sourceEdit->find(m_selectedHtml, QTextDocument::FindWholeWords);
}
else {
m_sourceEdit->moveCursor(QTextCursor::Start);
}
m_sourceEdit->setShowingCursor(true);
}
void SourceViewer::save()

View File

@ -62,6 +62,7 @@
PlainEditWithLines::PlainEditWithLines(QWidget* parent)
: QPlainTextEdit(parent)
, m_lineNumberArea(new LineNumberArea(this))
, m_isShowingCursor(false)
, m_countCache(-1, -1)
{
connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
@ -86,6 +87,16 @@ int PlainEditWithLines::lineNumberAreaWidth()
return space;
}
void PlainEditWithLines::setShowingCursor(bool show)
{
m_isShowingCursor = show;
}
bool PlainEditWithLines::isShowingCursor() const
{
return m_isShowingCursor;
}
void PlainEditWithLines::setReadOnly(bool ro)
{
QPlainTextEdit::setReadOnly(ro);
@ -138,17 +149,21 @@ void PlainEditWithLines::resizeEvent(QResizeEvent* e)
void PlainEditWithLines::highlightCurrentLine()
{
QList<QTextEdit::ExtraSelection> extraSelections;
if (!m_isShowingCursor) {
return;
}
const QColor &lineColor = palette().color(QPalette::Highlight).lighter();
QList<QTextEdit::ExtraSelection> selectionsList;
QTextEdit::ExtraSelection selection;
QColor lineColor = palette().color(QPalette::Highlight).lighter();
selection.format.setBackground(lineColor);
selection.format.setProperty(QTextFormat::FullWidthSelection, true);
selection.cursor = textCursor();
selection.cursor.clearSelection();
extraSelections.append(selection);
selectionsList.append(selection);
setExtraSelections(extraSelections);
setExtraSelections(selectionsList);
}
void PlainEditWithLines::lineNumberAreaPaintEvent(QPaintEvent* event)

View File

@ -79,6 +79,9 @@ public:
void lineNumberAreaPaintEvent(QPaintEvent* event);
int lineNumberAreaWidth();
void setShowingCursor(bool show);
bool isShowingCursor() const;
void setReadOnly(bool ro);
public slots:
@ -95,6 +98,7 @@ private slots:
private:
QWidget* m_lineNumberArea;
bool m_isShowingCursor;
QPair<int, int> m_countCache;
};

View File

@ -82,6 +82,7 @@ TabWidget::TabWidget(QupZilla* mainClass, QWidget* parent)
, m_lastTabIndex(0)
, m_lastBackgroundTabIndex(-1)
, m_isClosingToLastTabIndex(false)
, m_isRestoringState(false)
, m_closedTabsManager(new ClosedTabsManager)
, m_locationBars(new QStackedWidget)
{
@ -376,7 +377,7 @@ void TabWidget::closeTab(int index)
void TabWidget::currentTabChanged(int index)
{
if (index < 0) {
if (index < 0 || m_isRestoringState) {
return;
}
@ -516,12 +517,13 @@ int TabWidget::duplicateTab(int index)
WebTab* webTab = weTab(index);
const QUrl &url = webTab->url();
const QString &title = webTab->title();
const QByteArray &history = webTab->historyData();
QNetworkRequest req(url);
req.setRawHeader("Referer", url.toEncoded());
int id = addView(req, tabText(index), Qz::NT_CleanNotSelectedTab);
int id = addView(req, title, Qz::NT_CleanNotSelectedTab);
weTab(id)->setHistoryData(history);
return id;
@ -661,6 +663,8 @@ void TabWidget::restorePinnedTabs()
QList<QByteArray> tabHistory;
stream >> tabHistory;
m_isRestoringState = true;
for (int i = 0; i < pinnedTabs.count(); ++i) {
QUrl url = QUrl::fromEncoded(pinnedTabs.at(i).toUtf8());
@ -686,6 +690,8 @@ void TabWidget::restorePinnedTabs()
m_tabBar->updateCloseButton(addedIndex);
m_tabBar->moveTab(addedIndex, i);
}
m_isRestoringState = false;
}
QByteArray TabWidget::saveState()
@ -728,6 +734,8 @@ bool TabWidget::restoreState(const QByteArray &state)
stream >> tabListCount;
m_isRestoringState = true;
for (int i = 0; i < tabListCount; ++i) {
WebTab::SavedTab tab;
stream >> tab;
@ -738,6 +746,8 @@ bool TabWidget::restoreState(const QByteArray &state)
stream >> currentTab;
m_isRestoringState = false;
setCurrentIndex(currentTab);
currentTabChanged(currentTab);

View File

@ -131,9 +131,9 @@ private:
int m_lastTabIndex;
int m_lastBackgroundTabIndex;
bool m_isClosingToLastTabIndex;
bool m_isRestoringState;
TabBar* m_tabBar;
QMenu* m_menuTabs;
ToolButton* m_buttonListTabs;
AddTabButton* m_buttonAddTab;

View File

@ -22,11 +22,6 @@
#include "downloadmanager.h"
#include "webpluginfactory.h"
#include "mainapplication.h"
#ifdef NONBLOCK_JS_DIALOGS
#include "ui_jsconfirm.h"
#include "ui_jsalert.h"
#include "ui_jsprompt.h"
#endif
#include "checkboxdialog.h"
#include "widget.h"
#include "globalfunctions.h"
@ -37,6 +32,14 @@
#include "networkmanagerproxy.h"
#include "adblockicon.h"
#ifdef NONBLOCK_JS_DIALOGS
#include "ui_jsconfirm.h"
#include "ui_jsalert.h"
#include "ui_jsprompt.h"
#include <QPushButton>
#endif
#include <QDir>
#include <QWebHistory>
#include <QFileSystemWatcher>