1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-13 10:32:11 +01:00

Various changes in add new tab button and list all tabs menu

This commit is contained in:
nowrep 2011-03-26 13:34:08 +01:00
parent 0102bd8ca3
commit 91bd95dc59
13 changed files with 91 additions and 18 deletions

Binary file not shown.

View File

@ -69,5 +69,6 @@
<file>icons/preferences/applications-graphics.png</file> <file>icons/preferences/applications-graphics.png</file>
<file>icons/preferences/document-properties.png</file> <file>icons/preferences/document-properties.png</file>
<file>icons/preferences/stock_keyring.png</file> <file>icons/preferences/stock_keyring.png</file>
<file>icons/other/list-add.png</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

View File

@ -233,7 +233,13 @@ QString DownloadManager::getFileName(QNetworkReply* reply)
if (!endName.isEmpty()) if (!endName.isEmpty())
endName="."+endName; endName="."+endName;
return baseName+endName; QString name = baseName+endName;
if (name.startsWith("\""))
name = name.mid(1);
if (name.endsWith("\";"))
name.remove("\";");
return name;
} }
bool DownloadManager::canClose() bool DownloadManager::canClose()

View File

@ -33,7 +33,6 @@ TabBar::TabBar(QupZilla* mainClass, QWidget* parent) :
loadSettings(); loadSettings();
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &))); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &)));
} }
void TabBar::loadSettings() void TabBar::loadSettings()
@ -56,14 +55,14 @@ void TabBar::contextMenuRequested(const QPoint &position)
TabWidget* tabWidget = qobject_cast<TabWidget*>(parentWidget()); TabWidget* tabWidget = qobject_cast<TabWidget*>(parentWidget());
if (!tabWidget) if (!tabWidget)
return; return;
WebTab* webTab = qobject_cast<WebTab*>(tabWidget->widget(m_clickedTab));
if (!webTab)
return;
QMenu menu; QMenu menu;
menu.addAction(QIcon(":/icons/menu/popup.png"),tr("New tab"), p_QupZilla, SLOT(addTab())); menu.addAction(QIcon(":/icons/menu/popup.png"),tr("New tab"), p_QupZilla, SLOT(addTab()));
menu.addSeparator(); menu.addSeparator();
if (index!=-1) { if (index!=-1) {
WebTab* webTab = qobject_cast<WebTab*>(tabWidget->widget(m_clickedTab));
if (!webTab)
return;
menu.addAction( menu.addAction(
#ifdef Q_WS_X11 #ifdef Q_WS_X11
style()->standardIcon(QStyle::SP_ArrowBack) style()->standardIcon(QStyle::SP_ArrowBack)
@ -134,7 +133,11 @@ QSize TabBar::tabSizeHint(int index) const
if (tabWidget) { if (tabWidget) {
WebTab* webTab = qobject_cast<WebTab*>(tabWidget->widget(index)); WebTab* webTab = qobject_cast<WebTab*>(tabWidget->widget(index));
if (webTab && webTab->isPinned()) if (webTab && webTab->isPinned())
#ifdef Q_WS_WIN
size.setWidth(38);
#else
size.setWidth(31); size.setWidth(31);
#endif
} }
return size; return size;
} }

View File

@ -38,6 +38,7 @@ public:
QSize getTabSizeHint(int index) { return QTabBar::tabSizeHint(index); } QSize getTabSizeHint(int index) { return QTabBar::tabSizeHint(index); }
void loadSettings(); void loadSettings();
QSize getTabSizeHint(int index) const { return QTabBar::tabSizeHint(index); }
signals: signals:
void reloadTab(int index); void reloadTab(int index);

View File

@ -23,6 +23,68 @@
#include "locationbar.h" #include "locationbar.h"
#include "mainapplication.h" #include "mainapplication.h"
#include "webtab.h" #include "webtab.h"
#include "clickablelabel.h"
class NewTabButton : public QToolButton
{
public:
explicit NewTabButton(QWidget* parent ) : QToolButton(parent)
{
}
QSize sizeHint() const
{
QSize siz = QToolButton::sizeHint();
siz.setWidth(25);
return siz;
}
private:
void paintEvent(QPaintEvent*)
{
QPainter p(this);
QStyleOptionTabV3 opt;
opt.init(this);
style()->drawControl(QStyle::CE_TabBarTab, &opt, &p, this);
QPixmap pix(":/icons/other/list-add.png");
QRect r = this->rect();
r.setHeight(r.height()+3);
r.setWidth(r.width()-1);
style()->drawItemPixmap(&p, r, Qt::AlignCenter, pix);
}
};
class TabListButton : public QToolButton
{
public:
explicit TabListButton(QWidget* parent ) : QToolButton(parent)
{
}
QSize sizeHint() const
{
QSize siz = QToolButton::sizeHint();
siz.setWidth(20);
return siz;
}
private:
void paintEvent(QPaintEvent*)
{
QPainter p(this);
QStyleOptionToolButton opt;
opt.init(this);
if (isDown())
opt.state |= QStyle::State_On;
if (opt.state & QStyle::State_MouseOver)
opt.activeSubControls = QStyle::SC_ToolButton;
if (!isChecked() && !isDown())
opt.state |= QStyle::State_Raised;
opt.state |= QStyle::State_AutoRaise;
style()->drawComplexControl(QStyle::CC_ToolButton, &opt, &p, this);
}
};
TabWidget::TabWidget(QupZilla* mainClass, QWidget* parent) : TabWidget::TabWidget(QupZilla* mainClass, QWidget* parent) :
QTabWidget(parent) QTabWidget(parent)
@ -35,7 +97,7 @@ TabWidget::TabWidget(QupZilla* mainClass, QWidget* parent) :
m_tabBar = new TabBar(p_QupZilla); m_tabBar = new TabBar(p_QupZilla);
setTabBar(m_tabBar); setTabBar(m_tabBar);
setObjectName("tabWidget"); setObjectName("tabWidget");
setStyleSheet(" QTabBar::tab{max-width:250px;}"); setStyleSheet("QTabBar::tab{ max-width:250px; }");
loadSettings(); loadSettings();
@ -51,20 +113,16 @@ TabWidget::TabWidget(QupZilla* mainClass, QWidget* parent) :
connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int))); connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int)));
connect(m_tabBar, SIGNAL(closeAllButCurrent(int)), this, SLOT(closeAllButCurrent(int))); connect(m_tabBar, SIGNAL(closeAllButCurrent(int)), this, SLOT(closeAllButCurrent(int)));
m_buttonListTabs = new QToolButton(this); m_buttonListTabs = new TabListButton(this);
m_menuTabs = new QMenu(); m_menuTabs = new QMenu();
m_buttonListTabs->setMenu(m_menuTabs); m_buttonListTabs->setMenu(m_menuTabs);
m_buttonListTabs->setToolButtonStyle(Qt::ToolButtonTextOnly);
m_buttonListTabs->setPopupMode(QToolButton::InstantPopup); m_buttonListTabs->setPopupMode(QToolButton::InstantPopup);
m_buttonListTabs->setAutoRaise(true);
m_buttonListTabs->setToolTip(tr("Show list of opened tabs")); m_buttonListTabs->setToolTip(tr("Show list of opened tabs"));
connect(m_menuTabs, SIGNAL(aboutToShow()), this, SLOT(aboutToShowTabsMenu())); connect(m_menuTabs, SIGNAL(aboutToShow()), this, SLOT(aboutToShowTabsMenu()));
setCornerWidget(m_buttonListTabs); setCornerWidget(m_buttonListTabs);
m_buttonAddTab = new QToolButton(this); m_buttonAddTab = new NewTabButton(this);
m_buttonAddTab->setIcon(QIcon(":/icons/other/plus.png"));
m_buttonAddTab->setToolTip(tr("Add Tab")); m_buttonAddTab->setToolTip(tr("Add Tab"));
m_buttonAddTab->setAutoRaise(true);
connect(m_buttonAddTab, SIGNAL(clicked()), p_QupZilla, SLOT(addTab())); connect(m_buttonAddTab, SIGNAL(clicked()), p_QupZilla, SLOT(addTab()));
setCornerWidget(m_buttonAddTab, Qt::TopLeftCorner); setCornerWidget(m_buttonAddTab, Qt::TopLeftCorner);
} }

View File

@ -24,11 +24,14 @@
#include <QTabBar> #include <QTabBar>
#include <QDateTime> #include <QDateTime>
#include <QToolButton> #include <QToolButton>
#include <QStylePainter>
class QupZilla; class QupZilla;
class WebView; class WebView;
class TabBar; class TabBar;
class WebTab; class WebTab;
class TabListButton;
class NewTabButton;
class TabWidget : public QTabWidget class TabWidget : public QTabWidget
{ {
@ -83,8 +86,8 @@ private:
TabBar* m_tabBar; TabBar* m_tabBar;
QMenu* m_menuTabs; QMenu* m_menuTabs;
QToolButton* m_buttonAddTab; NewTabButton* m_buttonAddTab;
QToolButton* m_buttonListTabs; TabListButton* m_buttonListTabs;
}; };
#endif // TABWIDGET_H #endif // TABWIDGET_H

View File

@ -179,7 +179,7 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte
errString.replace("%FAVICON%", buffer.buffer().toBase64()); errString.replace("%FAVICON%", buffer.buffer().toBase64());
errString.replace("%HEADING%", errorString); errString.replace("%HEADING%", errorString);
errString.replace("%HEADING2%", tr("QupZilla can't load page at %1.").arg(loadedUrl)); errString.replace("%HEADING2%", tr("QupZilla can't load page from %1.").arg(QUrl(loadedUrl).host()));
errString.replace("%LI-1%", tr("Check the address for typing errors such as <b>ww.</b>example.com instead of <b>www.</b>example.com")); errString.replace("%LI-1%", tr("Check the address for typing errors such as <b>ww.</b>example.com instead of <b>www.</b>example.com"));
errString.replace("%LI-2%", tr("If you are unable to load any pages, check your computer's network connection.")); errString.replace("%LI-2%", tr("If you are unable to load any pages, check your computer's network connection."));
errString.replace("%LI-3%", tr("If your computer or network is protected by a firewall or proxy, make sure that QupZilla is permitted to access the Web.")); errString.replace("%LI-3%", tr("If your computer or network is protected by a firewall or proxy, make sure that QupZilla is permitted to access the Web."));

View File

@ -143,7 +143,8 @@ QLabel* WebView::animationLoading(int index, bool addMovie)
QLabel* loadingAnimation = qobject_cast<QLabel*>(tabWidget()->getTabBar()->tabButton(index, QTabBar::LeftSide)); QLabel* loadingAnimation = qobject_cast<QLabel*>(tabWidget()->getTabBar()->tabButton(index, QTabBar::LeftSide));
if (!loadingAnimation) { if (!loadingAnimation) {
loadingAnimation = new QLabel(this); loadingAnimation = new QLabel();
loadingAnimation->setStyleSheet("QLabel { margin: 0px; padding: 0px; }");
} }
if (addMovie && !loadingAnimation->movie()) { if (addMovie && !loadingAnimation->movie()) {
QMovie* movie = new QMovie(":icons/other/progress.gif", QByteArray(), loadingAnimation); QMovie* movie = new QMovie(":icons/other/progress.gif", QByteArray(), loadingAnimation);

View File

@ -2634,12 +2634,12 @@ Prosím přidejte si nějaký kliknutím na RSS ikonku v navigačním řádku.</
<message> <message>
<location filename="../src/webview/tabbar.cpp" line="126"/> <location filename="../src/webview/tabbar.cpp" line="126"/>
<source>Unpin Tab</source> <source>Unpin Tab</source>
<translation>Zrušit připíchnutí</translation> <translation>Odepnout panel</translation>
</message> </message>
<message> <message>
<location filename="../src/webview/tabbar.cpp" line="126"/> <location filename="../src/webview/tabbar.cpp" line="126"/>
<source>Pin Tab</source> <source>Pin Tab</source>
<translation>Připíchnout panel</translation> <translation>Připnout panel</translation>
</message> </message>
<message> <message>
<location filename="../src/webview/tabbar.cpp" line="128"/> <location filename="../src/webview/tabbar.cpp" line="128"/>