1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-24 04:36:34 +01:00

Possiblity to move up/down in search engines manager and other...

- F6 shortcut for focusing locationbar
- no more empty title in history back/next menus
- showing only active norification preview in preferences
This commit is contained in:
nowrep 2011-12-16 19:07:36 +01:00
parent bed30cb483
commit 2cfd9808ec
14 changed files with 173 additions and 59 deletions

View File

@ -11,6 +11,7 @@ Comment[sk]=Rýchly a bezpečný webový prehliadač
Comment[de]=Ein schneller und sicherer Web Browser
Comment[nl]=Een snelle en veilige webbrowser
Comment[it]=Un browser web veloce e sicuro
Comment[pl]=Szybka i bezpieczna przeglądarka internetowa
GenericName=Web Browser
GenericName[es]=Navegador Web
GenericName[cs]=Webový prohlížeč
@ -18,6 +19,7 @@ GenericName[sk]=Webový prehliadač
GenericName[de]=Web Browser
GenericName[nl]=Webbrowser
GenericName[it]=Browser Web
GenericName[pl]=Przeglądarka Internetowa
Exec=qupzilla %u
MimeType=text/html;application/xhtml+xml;
Terminal=false

View File

@ -19,7 +19,7 @@ bool TestPlugin::testPlugin()
QTranslator* TestPlugin::getTranslator(QString locale)
{
QTranslator* translator = new QTranslator();
translator->load(":/"+locale);
translator->load(":/" + locale);
return translator;
}
@ -27,7 +27,7 @@ void TestPlugin::showSettings()
{
QWidget* widget = new QWidget();
new QLabel("Example Plugin v0.0.1", widget);
widget->resize(200,200);
widget->resize(200, 200);
widget->setAttribute(Qt::WA_DeleteOnClose);
widget->setWindowModality(Qt::WindowModal); //As the preferences window is modal too
widget->setWindowTitle("Example Plugin Settings");
@ -35,26 +35,29 @@ void TestPlugin::showSettings()
widget->show();
}
void TestPlugin::populateWebViewMenu(QMenu *menu, QWebView *view, QWebHitTestResult r)
void TestPlugin::populateWebViewMenu(QMenu* menu, QWebView* view, QWebHitTestResult r)
{
Q_UNUSED(view)
QString title;
if (!r.imageUrl().isEmpty())
if (!r.imageUrl().isEmpty()) {
title += " on image";
if (!r.linkUrl().isEmpty())
}
if (!r.linkUrl().isEmpty()) {
title += " on link";
}
QWebElement element = r.element();
if (!element.isNull() && (element.tagName().toLower() == "input" || element.tagName().toLower() == "textarea"))
title += " on input";
if (!element.isNull() && (element.tagName().toLower() == "input" || element.tagName().toLower() == "textarea")) {
title += " on input";
}
menu->addAction(tr("My first plugin action") + title, this, SLOT(actionSlot()));
}
void TestPlugin::populateHelpMenu(QMenu *menu)
void TestPlugin::populateHelpMenu(QMenu* menu)
{
menu->addAction(tr("My first plugin action"), this, SLOT(actionSlot()));
}
void TestPlugin::populateToolsMenu(QMenu *menu)
void TestPlugin::populateToolsMenu(QMenu* menu)
{
menu->addAction(tr("My first plugin action"), this, SLOT(actionSlot()));
}

View File

@ -34,9 +34,9 @@ public:
bool hasSettings() { return true; }
void showSettings();
void populateWebViewMenu(QMenu *menu, QWebView *view, QWebHitTestResult r);
void populateHelpMenu(QMenu *menu);
void populateToolsMenu(QMenu *menu);
void populateWebViewMenu(QMenu* menu, QWebView* view, QWebHitTestResult r);
void populateHelpMenu(QMenu* menu);
void populateToolsMenu(QMenu* menu);
private slots:
void actionSlot();

View File

@ -171,12 +171,12 @@ MainApplication::MainApplication(const QList<CommandLineOptions::ActionPair> &cm
connect(saver, SIGNAL(saveApp()), this, SLOT(saveStateSlot()));
if (settings2.value("Web-Browser-Settings/CheckUpdates",
#ifdef Q_WS_WIN
#ifdef Q_WS_WIN
true
#else
#else
false
#endif
).toBool()) {
#endif
).toBool()) {
m_updater = new Updater(qupzilla);
}

View File

@ -1167,6 +1167,12 @@ void QupZilla::openFile()
}
}
void QupZilla::openLocation()
{
locationBar()->setFocus();
locationBar()->selectAll();
}
void QupZilla::showNavigationWithFullscreen()
{
bool state;
@ -1307,6 +1313,7 @@ void QupZilla::keyPressEvent(QKeyEvent* event)
searchOnPage();
event->accept();
break;
case Qt::Key_F6:
case Qt::Key_OpenUrl:
openLocation();
event->accept();

View File

@ -177,7 +177,7 @@ private slots:
void bookmarkAllTabs();
void newWindow() { mApp->makeNewWindow(false); }
void openLocation() { locationBar()->setFocus(); locationBar()->selectAll(); }
void openLocation();
void openFile();
void savePage();
void sendLink() { QDesktopServices::openUrl(QUrl("mailto:?body=" + weView()->url().toString())); }

View File

@ -24,6 +24,25 @@
#include "webhistorywrapper.h"
#include "enhancedmenu.h"
QString titleForUrl(QString title, const QUrl &url)
{
if (title.isEmpty()) {
title = url.path();
}
if (title.isEmpty()) {
title = url.host();
}
if (title.isEmpty()) {
return NavigationBar::tr("No Named Page");
}
if (title.length() > 40) {
title.truncate(40);
title += "..";
}
return title;
}
NavigationBar::NavigationBar(QupZilla* mainClass, QWidget* parent)
: QWidget(parent)
, p_QupZilla(mainClass)
@ -158,11 +177,7 @@ void NavigationBar::aboutToShowHistoryBackMenu()
for (int i = curindex - 1; i >= 0; i--) {
QWebHistoryItem item = history->itemAt(i);
if (item.isValid() && lastUrl != item.url()) {
QString title = item.title();
if (title.length() > 40) {
title.truncate(40);
title += "..";
}
QString title = titleForUrl(item.title(), item.url());
Action* act = new Action(_iconForUrl(item.url()), title);
act->setData(i);
@ -198,11 +213,7 @@ void NavigationBar::aboutToShowHistoryNextMenu()
for (int i = curindex + 1; i < history->count(); i++) {
QWebHistoryItem item = history->itemAt(i);
if (item.isValid() && lastUrl != item.url()) {
QString title = item.title();
if (title.length() > 40) {
title.truncate(40);
title += "..";
}
QString title = titleForUrl(item.title(), item.url());
Action* act = new Action(_iconForUrl(item.url()), title);
act->setData(i);

View File

@ -34,6 +34,9 @@ SearchEnginesDialog::SearchEnginesDialog(QWidget* parent)
connect(ui->remove, SIGNAL(clicked()), this, SLOT(removeEngine()));
connect(ui->edit, SIGNAL(clicked()), this, SLOT(editEngine()));
connect(ui->defaults, SIGNAL(clicked()), this, SLOT(defaults()));
connect(ui->moveUp, SIGNAL(clicked()), this, SLOT(moveUp()));
connect(ui->moveDown, SIGNAL(clicked()), this, SLOT(moveDown()));
connect(ui->treeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(editEngine()));
reloadEngines();
@ -124,6 +127,34 @@ void SearchEnginesDialog::defaults()
reloadEngines();
}
void SearchEnginesDialog::moveUp()
{
QTreeWidgetItem* currentItem = ui->treeWidget->currentItem();
int index = ui->treeWidget->indexOfTopLevelItem(currentItem);
if (!currentItem || index == 0) {
return;
}
ui->treeWidget->takeTopLevelItem(index);
ui->treeWidget->insertTopLevelItem(index - 1, currentItem);
ui->treeWidget->setCurrentItem(currentItem);
}
void SearchEnginesDialog::moveDown()
{
QTreeWidgetItem* currentItem = ui->treeWidget->currentItem();
int index = ui->treeWidget->indexOfTopLevelItem(currentItem);
if (!currentItem || !ui->treeWidget->itemBelow(currentItem)) {
return;
}
ui->treeWidget->takeTopLevelItem(index);
ui->treeWidget->insertTopLevelItem(index + 1, currentItem);
ui->treeWidget->setCurrentItem(currentItem);
}
void SearchEnginesDialog::reloadEngines()
{
ui->treeWidget->clear();

View File

@ -42,6 +42,9 @@ private slots:
void removeEngine();
void editEngine();
void moveUp();
void moveDown();
void defaults();
private:

View File

@ -51,24 +51,21 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="defaults">
<widget class="QPushButton" name="moveUp">
<property name="text">
<string>Defaults</string>
<string>Up</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="moveDown">
<property name="text">
<string>Down</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QTreeWidget" name="treeWidget">
<attribute name="headerDefaultSectionSize">
@ -86,6 +83,46 @@
</column>
</widget>
</item>
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="defaults">
<property name="text">
<string>Defaults</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>

View File

@ -57,9 +57,9 @@ void AboutDialog::showAbout()
m_aboutHtml.append("<div style='margin:10px;'>");
m_aboutHtml.append(tr("<p><b>Application version %1</b><br/>").arg(QupZilla::VERSION
#ifdef GIT_REVISION
+ " (" + GIT_REVISION + ")"
+ " (" + GIT_REVISION + ")"
#endif
));
));
m_aboutHtml.append(tr("<b>WebKit version %1</b></p>").arg(QupZilla::WEBKITVERSION));
m_aboutHtml.append(tr("<p>&copy; %1 %2<br/>All rights reserved.<br/>").arg(QupZilla::COPYRIGHT, QupZilla::AUTHOR));
m_aboutHtml.append(tr("<small>Build time: %1 </small></p>").arg(QupZilla::BUILDTIME));

View File

@ -117,12 +117,12 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
settings.endGroup();
ui->afterLaunch->setCurrentIndex(afterLaunch);
ui->checkUpdates->setChecked(settings.value("Web-Browser-Settings/CheckUpdates",
#ifdef Q_WS_WIN
true
#else
false
#endif
).toBool());
#ifdef Q_WS_WIN
true
#else
false
#endif
).toBool());
ui->newTabFrame->setVisible(false);
if (m_newTabUrl.isEmpty()) {
@ -313,6 +313,9 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
ui->useOSDNotifications->setChecked(true);
}
connect(ui->useNativeSystemNotifications, SIGNAL(toggled(bool)), this, SLOT(setNotificationPreviewVisible(bool)));
connect(ui->useOSDNotifications, SIGNAL(toggled(bool)), this, SLOT(setNotificationPreviewVisible(bool)));
ui->doNotUseNotifications->setChecked(!settings.value("Enabled", true).toBool());
m_notifPosition = settings.value("Position", QPoint(10, 10)).toPoint();
settings.endGroup();
@ -389,21 +392,36 @@ void Preferences::showStackedPage(QListWidgetItem* item)
ui->caption->setText("<b>" + item->text() + "</b>");
ui->stackedWidget->setCurrentIndex(item->whatsThis().toInt());
if (ui->stackedWidget->currentIndex() == 8) {
m_notification = new DesktopNotification(true);
m_notification.data()->setPixmap(QPixmap(":icons/preferences/stock_dialog-question.png"));
m_notification.data()->setHeading(tr("OSD Notification"));
m_notification.data()->setText(tr("Drag it on the screen to place it where you want."));
m_notification.data()->move(m_notifPosition);
m_notification.data()->show();
setNotificationPreviewVisible(ui->stackedWidget->currentIndex() == 8);
}
mApp->desktopNotifications()->nativeNotificationPreview();
}
else if (m_notification.data()) {
void Preferences::setNotificationPreviewVisible(bool state)
{
if (!state && m_notification.data()) {
m_notifPosition = m_notification.data()->pos();
delete m_notification.data();
}
if (state) {
if (ui->useOSDNotifications->isChecked()) {
if (m_notification.data()) {
m_notifPosition = m_notification.data()->pos();
delete m_notification.data();
}
m_notification = new DesktopNotification(true);
m_notification.data()->setPixmap(QPixmap(":icons/preferences/stock_dialog-question.png"));
m_notification.data()->setHeading(tr("OSD Notification"));
m_notification.data()->setText(tr("Drag it on the screen to place it where you want."));
m_notification.data()->move(m_notifPosition);
m_notification.data()->show();
}
else if (ui->useNativeSystemNotifications->isChecked()) {
mApp->desktopNotifications()->nativeNotificationPreview();
}
}
}
void Preferences::allowCacheChanged(bool state)
{
ui->cacheFrame->setEnabled(state);

View File

@ -71,6 +71,8 @@ private slots:
void deleteProfile();
void startProfileIndexChanged(QString index);
void setNotificationPreviewVisible(bool state);
private:
Ui::Preferences* ui;
QupZilla* p_QupZilla;

View File

@ -885,10 +885,10 @@ QString WebView::title() const
{
QString title = QWebView::title();
if (title.isEmpty()) {
title = url().host();
title = url().path();
}
if (title.isEmpty()) {
title = url().path();
title = url().host();
}
if (title.isEmpty()) {
return tr("No Named Page");