From be80930053e592c04267751052a1907b5c8fa9a8 Mon Sep 17 00:00:00 2001 From: nowrep Date: Fri, 25 Mar 2011 19:16:21 +0100 Subject: [PATCH] Added Pinning Tabs feature --- bin/locale/cs_CZ.qm | Bin 54623 -> 54861 bytes src/app/appui.cpp | 1 + src/app/mainapplication.cpp | 1 + src/downloads/downloadoptionsdialog.cpp | 1 + src/webview/tabbar.cpp | 137 +++++++++++++++- src/webview/tabbar.h | 16 +- src/webview/tabwidget.cpp | 89 +++++++++- src/webview/tabwidget.h | 5 +- src/webview/webtab.cpp | 27 +++ src/webview/webtab.h | 6 + src/webview/webview.h | 2 +- translations/cs_CZ.ts | 209 +++++++++++++----------- translations/sk_SK.ts | 209 +++++++++++++----------- 13 files changed, 496 insertions(+), 207 deletions(-) diff --git a/bin/locale/cs_CZ.qm b/bin/locale/cs_CZ.qm index 48699192975304161b669e4f59ff941ee9b6fea4..cd5c6cecc47203e12ec3d46eeee3dd71ccc01729 100644 GIT binary patch delta 4395 zcmZ9Pd0dTY|HnV)ocliel0<|eHCfA2)-VYPr73BIXp=^g3R#ayDAT56i4rPBk|pt2 zN|MJicBV0mZNxL?v9FI=% zx*vsLWe?OhLs(q^#Q!YOT#+MvIsOJh*+MR4C9xy}!l98szl{>>E?D?5g_y|=7axR}e;R0W7h<^u_+});-P3_(brKtMAvW^4<;4l17`G_`_+kP4ghjyGRQMSW0+ZLmFS?pRcS1may0xhUK}TN!n6)-l@F zb0oT_Ve*W=bUp!7R@4AROA+=gl2$k&a^)pJ@e5`wXAoC8VYa3eFc$}6_69A`YbfT# zF`C^RktCb~X0O4bmuW!pVWiDg1K!rya4a79$4{utqCq}gaNzhD8W4rrm0YmH5?qLU z1Pr~4i)BebT@tR>76AjYaAP?+ZWkW-wc>9ZnZp1Ya?(@g)anh>Z3z1B7qlE8agHdl z;*iWK(T#=aEbG>^7|_?q`hKSXa<0pUR5OmDZZfZq&A@OQ*#uXA;83$HGKvx0m?w*B zqG6kF%c9?MSRzaoxj+A9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pP(@A`lH^bq>(C7=>wXW)csrap|@YMtyb&9zM@r?8}*AEwlI!M^szOU z>Gmc4>HzL%&68SNqV)Ux&I3+^^+geXutaqF(vhw#jV}7*A*Xp(xc-aKeO#ZeKhuk6 z*2U}3{OAoF^3qqO&SaCYcdVvax8H*bugEi?7^1K2~EFw8WCx5umti3cE;e|g|%Hh$}r-?=k-~J38^2PhaspZ9hsYK2wrfNm7p+0 zW-#bgZw$-lxxjkL_>m>%sbNk399}2q82SbC$dO_H`F&p_UCU^o|tbLOsrp zl4AGK`TirNgsIe}wp7}@td!~5cTh?yVub`0NSPIko;XO_eRCuq+#wwZ+sJFf5h>d* zfiDpUrK4TD@?JbdDhqaGe^*PD3Z{8{fYiJ?gctr|>A#0vfJrgZoq81yR>@p9QF?jR zo()ZBwEg`xJMsggbB}TwJkHp!S>!>J8m!aIw$5J0CAX;LV`VaHx*KCpo#R|eFsAs} zGTG;i*|qh}IjwtsADbKxRz%HPyhnGWn3YqAUI&RLso>gZ_#KJzu%cgpAR z@iw_HXMJrMYVzv+lzB5dm?qu1M(=lh-4|WPi^L%$5_47Y-_|L=Gp>LUEuk&D& zpG@1qAGnl4tTCs)3FZr&ySdhbY23cWT%U7-q58-C?ar%!O_ljdxHkuyo%znsIlM@8 zFhBaNjsiboe)3^d4Bsa+?XCIEx7Rtze=@)Qh>@H5BS|39lj;restorePinnedTabs(); //Open tab from command line argument bool addTab = true; QStringList arguments = qApp->arguments(); diff --git a/src/app/mainapplication.cpp b/src/app/mainapplication.cpp index 23b32c548..199c8a2dc 100644 --- a/src/app/mainapplication.cpp +++ b/src/app/mainapplication.cpp @@ -439,6 +439,7 @@ bool MainApplication::saveStateSlot() stream << m_mainWindows.at(i)->saveState(); } file.close(); + getWindow()->tabWidget()->savePinnedTabs(); settings.setValue("restoreSession",true); settings.endGroup(); diff --git a/src/downloads/downloadoptionsdialog.cpp b/src/downloads/downloadoptionsdialog.cpp index 71c67c462..2545b6a16 100644 --- a/src/downloads/downloadoptionsdialog.cpp +++ b/src/downloads/downloadoptionsdialog.cpp @@ -39,6 +39,7 @@ int DownloadOptionsDialog::exec() return 1; else if (ui->radioSave->isChecked()) return 2; + return 2; } DownloadOptionsDialog::~DownloadOptionsDialog() diff --git a/src/webview/tabbar.cpp b/src/webview/tabbar.cpp index bb530eb78..cda705b14 100644 --- a/src/webview/tabbar.cpp +++ b/src/webview/tabbar.cpp @@ -18,6 +18,38 @@ #include "tabbar.h" #include "tabwidget.h" #include "qupzilla.h" +#include "webtab.h" + +class CloseButton : public QToolButton +{ +public: + explicit CloseButton(QWidget* parent ) : QToolButton(parent) { } + +private: + void paintEvent(QPaintEvent *) + { + QPainter p(this); + QStyleOption opt; + opt.init(this); + opt.state |= QStyle::State_AutoRaise; + if (isEnabled() && underMouse() && !isChecked() && !isDown()) + opt.state |= QStyle::State_Raised; + if (isChecked()) + opt.state |= QStyle::State_On; + if (isDown()) + opt.state |= QStyle::State_Sunken; + + if (const QTabBar *tb = qobject_cast(parent())) { + int index = tb->currentIndex(); + QTabBar::ButtonPosition position = (QTabBar::ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, tb); + if (tb->tabButton(index, position) == this) + opt.state |= QStyle::State_Selected; + } + + style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &opt, &p, this); + } +}; + TabBar::TabBar(QupZilla* mainClass, QWidget* parent) : QTabBar(parent) @@ -26,8 +58,8 @@ TabBar::TabBar(QupZilla* mainClass, QWidget* parent) : { setContextMenuPolicy(Qt::CustomContextMenu); setObjectName("tabBar"); - setTabsClosable(true); setElideMode(Qt::ElideRight); + setTabsClosable(true); setDocumentMode(true); loadSettings(); @@ -49,16 +81,19 @@ void TabBar::loadSettings() void TabBar::contextMenuRequested(const QPoint &position) { + int index = tabAt(position); + m_clickedTab = index; + TabWidget* tabWidget = qobject_cast(parentWidget()); if (!tabWidget) return; - int index = tabAt(position); - m_clickedTab = index; + WebTab* webTab = qobject_cast(tabWidget->widget(m_clickedTab)); + if (!webTab) + return; QMenu menu; menu.addAction(QIcon(":/icons/menu/popup.png"),tr("New tab"), p_QupZilla, SLOT(addTab())); menu.addSeparator(); - if (index!=-1) { menu.addAction( #ifdef Q_WS_X11 @@ -88,6 +123,8 @@ void TabBar::contextMenuRequested(const QPoint &position) QIcon(":/icons/faenza/reload.png") #endif ,tr("Reload Tab"), this, SLOT(reloadTab())); + menu.addAction(webTab->isPinned() ? tr("Unpin Tab") : tr("Pin Tab"), this, SLOT(pinTab())); + menu.addSeparator(); menu.addAction(tr("Reload All Tabs"), tabWidget, SLOT(reloadAllTabs())); menu.addAction(tr("Bookmark This Tab"), this, SLOT(bookmarkTab())); menu.addAction(tr("Bookmark All Tabs"), p_QupZilla, SLOT(bookmarkAllTabs())); @@ -121,11 +158,103 @@ void TabBar::contextMenuRequested(const QPoint &position) menu.exec(p); } +QSize TabBar::tabSizeHint(int index) const +{ + QSize size = QTabBar::tabSizeHint(index); + TabWidget* tabWidget = qobject_cast(parentWidget()); + if (tabWidget) { + WebTab* webTab = qobject_cast(tabWidget->widget(index)); + if (webTab && webTab->isPinned()) + size.setWidth(35); + } + return size; +} + +#ifdef Q_WS_X11 +void TabBar::tabInserted(int index) +{ +// CloseButton* closeButton = new CloseButton(this); +// closeButton->setAutoRaise(true); +// closeButton->setMaximumSize(17,17); +// closeButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarMaxButton)); +// connect(closeButton, SIGNAL(clicked()), this, SLOT(closeCurrentTab())); +// setTabButton(index, QTabBar::RightSide, closeButton); + QAbstractButton* button = (QAbstractButton*)tabButton(index, QTabBar::RightSide); + if (!button) + return; + button->setMaximumSize(17,17); +} +#endif + +//void TabBar::showCloseButton(int index) +//{ +// TabWidget* tabWidget = qobject_cast(parentWidget()); +// if (!tabWidget) +// return; + +// WebTab* webTab = qobject_cast(tabWidget->widget(index)); +// if (webTab && webTab->isPinned()) +// return; + +// CloseButton* button = (CloseButton*)tabButton(index, QTabBar::RightSide); +// if (!button) +// return; + +// button->show(); +//} + +//void TabBar::hideCloseButton(int index) +//{ +// CloseButton* button = (CloseButton*)tabButton(index, QTabBar::RightSide); +// if (!button) +// return; +// button->hide(); +//} + +void TabBar::updateCloseButton(int index) +{ + QAbstractButton* button = (QAbstractButton*)tabButton(index, QTabBar::RightSide); + if (!button) + return; + + TabWidget* tabWidget = qobject_cast(parentWidget()); + if (!tabWidget) + return; + + WebTab* webTab = qobject_cast(tabWidget->widget(index)); + if (webTab && webTab->isPinned()) + button->hide(); + else + button->show(); +} + +void TabBar::closeCurrentTab() +{ + int id = currentIndex(); + TabWidget* tabWidget = qobject_cast(parentWidget()); + if (!tabWidget || id < 0) + return; + tabWidget->closeTab(id); +} + void TabBar::bookmarkTab() { p_QupZilla->addBookmark(p_QupZilla->weView(m_clickedTab)->url(), p_QupZilla->weView(m_clickedTab)->title()); } +void TabBar::pinTab() +{ + TabWidget* tabWidget = qobject_cast(parentWidget()); + if (!tabWidget) + return; + + WebTab* webTab = qobject_cast(tabWidget->widget(m_clickedTab)); + if (!webTab) + return; + + webTab->pinTab(m_clickedTab); +} + void TabBar::mouseDoubleClickEvent(QMouseEvent* event) { TabWidget* tabWidget = qobject_cast(parentWidget()); diff --git a/src/webview/tabbar.h b/src/webview/tabbar.h index 7bcedbb13..53273b638 100644 --- a/src/webview/tabbar.h +++ b/src/webview/tabbar.h @@ -32,6 +32,12 @@ class TabBar : public QTabBar Q_OBJECT public: explicit TabBar(QupZilla* mainClass, QWidget* parent = 0); +// void hideCloseButton(int index); +// void showCloseButton(int index); + void updateCloseButton(int index); + + QSize getTabSizeHint(int index) { return QTabBar::tabSizeHint(index); } + void loadSettings(); signals: void reloadTab(int index); @@ -43,9 +49,6 @@ signals: public slots: -public: - void loadSettings(); - private slots: void contextMenuRequested(const QPoint &position); void reloadTab() { emit reloadTab(m_clickedTab); } @@ -55,8 +58,15 @@ private slots: void closeAllButCurrent() { emit closeAllButCurrent(m_clickedTab); } void closeTab() { emit closeTab(m_clickedTab); } void bookmarkTab(); + void pinTab(); + void closeCurrentTab(); + private: void mouseDoubleClickEvent(QMouseEvent* event); + QSize tabSizeHint(int index) const; +#ifdef Q_WS_X11 + void tabInserted(int index); +#endif QupZilla* p_QupZilla; bool m_showCloseButtonWithOneTab; diff --git a/src/webview/tabwidget.cpp b/src/webview/tabwidget.cpp index f0099cde2..7aa3b7e57 100644 --- a/src/webview/tabwidget.cpp +++ b/src/webview/tabwidget.cpp @@ -168,7 +168,12 @@ int TabWidget::addView(QUrl url, QString title, OpenUrlIn openIn, bool selectLin void TabWidget::setTabText(int index, const QString& text) { - QString newtext = text + " "; + QString newtext = text + " "; + + if (WebTab* webTab = qobject_cast(p_QupZilla->tabWidget()->widget(index)) ) { + if (webTab->isPinned()) + newtext = ""; + } QTabWidget::setTabText(index, newtext); } @@ -222,10 +227,10 @@ void TabWidget::tabChanged(int index) if (p_QupZilla->inspectorDock() && p_QupZilla->inspectorDock()->isVisible()) p_QupZilla->showInspector(); - weView()->setFocus(); m_lastTabIndex = index; + m_tabBar->updateCloseButton(index); } void TabWidget::reloadAllTabs() @@ -267,6 +272,79 @@ void TabWidget::restoreClosedTab() m_canRestoreTab = false; } +void TabWidget::savePinnedTabs() +{ + QByteArray data; + QDataStream stream(&data, QIODevice::WriteOnly); + + QStringList tabs; + QList tabsHistory; + for (int i = 0; i < count(); ++i) { + if (WebView* tab = weView(i)) { + WebTab* webTab = qobject_cast(widget(i)); + if (!webTab || !webTab->isPinned()) + continue; + + tabs.append(QString::fromUtf8(tab->url().toEncoded())); + if (tab->history()->count() != 0) { + QByteArray tabHistory; + QDataStream tabHistoryStream(&tabHistory, QIODevice::WriteOnly); + tabHistoryStream << *tab->history(); + tabsHistory.append(tabHistory); + } else { + tabsHistory << QByteArray(); + } + } else { + tabs.append(QString::null); + tabsHistory.append(QByteArray()); + } + } + stream << tabs; + stream << tabsHistory; + QFile file(mApp->getActiveProfil()+"pinnedTabs.dat"); + file.open(QIODevice::WriteOnly); + file.write(data); + file.close(); +} + +void TabWidget::restorePinnedTabs() +{ + QFile file(mApp->getActiveProfil()+"pinnedTabs.dat"); + file.open(QIODevice::ReadOnly); + QByteArray sd = file.readAll(); + file.close(); + + QDataStream stream(&sd, QIODevice::ReadOnly); + if (stream.atEnd()) + return; + + QStringList pinnedTabs; + stream >> pinnedTabs; + QList tabHistory; + stream >> tabHistory; + + for (int i = 0; i < pinnedTabs.count(); ++i) { + QUrl url = QUrl::fromEncoded(pinnedTabs.at(i).toUtf8()); + + QByteArray historyState = tabHistory.value(i); + int addedIndex; + if (!historyState.isEmpty()) { + addedIndex= addView(QUrl()); + QDataStream historyStream(historyState); + historyStream >> *weView(addedIndex)->history(); + weView(addedIndex)->load(url); + } else { + addedIndex = addView(url); + } + WebTab* webTab = (WebTab*)widget(addedIndex); + if (webTab) + webTab->setPinned(true); + + m_tabBar->moveTab(addedIndex, i); + m_tabBar->updateCloseButton(i); + } +} + QByteArray TabWidget::saveState() { QByteArray data; @@ -276,6 +354,10 @@ QByteArray TabWidget::saveState() QList tabsHistory; for (int i = 0; i < count(); ++i) { if (WebView* tab = weView(i)) { + WebTab* webTab = qobject_cast(widget(i)); + if (webTab && webTab->isPinned()) + continue; + tabs.append(QString::fromUtf8(tab->url().toEncoded())); if (tab->history()->count() != 0) { QByteArray tabHistory; @@ -309,14 +391,12 @@ bool TabWidget::restoreState(const QByteArray &state) int currentTab; stream >> currentTab; - setCurrentIndex(currentTab); QList tabHistory; stream >> tabHistory; for (int i = 0; i < openTabs.count(); ++i) { QUrl url = QUrl::fromEncoded(openTabs.at(i).toUtf8()); - //TabWidget::OpenUrlIn tab = QByteArray historyState = tabHistory.value(i); if (!historyState.isEmpty()) { @@ -328,6 +408,7 @@ bool TabWidget::restoreState(const QByteArray &state) addView(url); } } + setCurrentIndex(currentTab); return true; } diff --git a/src/webview/tabwidget.h b/src/webview/tabwidget.h index 70278f852..5e5231ac2 100644 --- a/src/webview/tabwidget.h +++ b/src/webview/tabwidget.h @@ -40,6 +40,9 @@ public: QByteArray saveState(); bool restoreState(const QByteArray &state); + void savePinnedTabs(); + void restorePinnedTabs(); + void setTabText(int index, const QString& text); void loadSettings(); @@ -59,9 +62,9 @@ public slots: void restoreClosedTab(); private slots: - void tabChanged(int index); void aboutToShowTabsMenu(); void actionChangeIndex(); + void tabChanged(int index); private: inline WebView* weView() { WebTab* webTab = qobject_cast(widget(currentIndex())); if (!webTab) return 0; return webTab->view(); } diff --git a/src/webview/webtab.cpp b/src/webview/webtab.cpp index a4b1d00c1..b9d0ba4a6 100644 --- a/src/webview/webtab.cpp +++ b/src/webview/webtab.cpp @@ -18,11 +18,13 @@ #include "webtab.h" #include "qupzilla.h" #include "webview.h" +#include "tabbar.h" WebTab::WebTab(QupZilla* mainClass, QWidget* parent) :QWidget(parent) ,p_QupZilla(mainClass) ,m_view(0) + ,m_pinned(false) { m_layout = new QVBoxLayout(this); setLayout(m_layout); @@ -45,6 +47,31 @@ void WebTab::showNotification(QWidget* notif) notif->show(); } +int WebTab::tabIndex() +{ + return m_view->tabIndex(); +} + +void WebTab::pinTab(int index) +{ + TabWidget* tabWidget = p_QupZilla->tabWidget(); + if (!tabWidget) + return; + + if (m_pinned) { //Unpin tab + m_pinned = false; + tabWidget->setTabText(index, m_view->title()); + tabWidget->getTabBar()->updateCloseButton(index); + } else { // Pin tab + m_pinned = true; + tabWidget->setCurrentIndex(0); // <<-- those 2 lines fixes + tabWidget->getTabBar()->moveTab(index, 0);// | weird bug with bad + tabWidget->setTabText(0, ""); // | tabwidget update if we + tabWidget->setCurrentIndex(0); // <<-- are moving current tab + tabWidget->getTabBar()->updateCloseButton(0); + } +} + WebTab::~WebTab() { delete m_view; diff --git a/src/webview/webtab.h b/src/webview/webtab.h index 8a1dc9a53..730efcc36 100644 --- a/src/webview/webtab.h +++ b/src/webview/webtab.h @@ -31,14 +31,20 @@ public: explicit WebTab(QupZilla* mainClass, QWidget* parent = 0); ~WebTab(); WebView* view() { return m_view; } + bool isPinned() { return m_pinned; } + void pinTab(int index); + void setPinned(bool state) { m_pinned = state; } private slots: void showNotification(QWidget* notif); private: + int tabIndex(); QupZilla* p_QupZilla; QPointer m_view; QVBoxLayout* m_layout; + + bool m_pinned; }; #endif // WEBTAB_H diff --git a/src/webview/webview.h b/src/webview/webview.h index d4f45f958..b4e25d7e0 100644 --- a/src/webview/webview.h +++ b/src/webview/webview.h @@ -59,6 +59,7 @@ public: static QUrl guessUrlFromString(const QString &string); static bool isUrlValid(const QUrl &url); + int tabIndex() const; public slots: void stop(){ if (page()) {emit ipChanged(m_currentIp); page()->triggerAction(QWebPage::Stop); loadFinished(true);} } @@ -106,7 +107,6 @@ private: void contextMenuEvent(QContextMenuEvent* event); void wheelEvent(QWheelEvent* event); TabWidget* tabWidget() const; - int tabIndex() const; bool isCurrent(); void applyZoom(); diff --git a/translations/cs_CZ.ts b/translations/cs_CZ.ts index 6c514059c..a94acb8f0 100644 --- a/translations/cs_CZ.ts +++ b/translations/cs_CZ.ts @@ -599,83 +599,83 @@ p, li { white-space: pre-wrap; } - + Remaining time unavailable Neznámý zbývající čas - + Done - %1 Hotovo - %1 - - + + Cancelled Zrušeno - + few seconds několik sekund - + seconds sekund - + minutes minut - + hours hodin - + Remaining %1 - %2 of %3 (%4) Zbývá %1 - %2 z %3 (%4) - + Cancelled - %1 Zrušeno - %1 - + Open File Otevřít soubor - + Open Folder Otevřít složku - + Cancel downloading Zrušit stahování - + Clear Vyčistit - + Error Chyba - + Not found Soubor neexistuje - + Sorry, the file %1 is not found! @@ -684,12 +684,12 @@ p, li { white-space: pre-wrap; } neexistuje! - + Error: Cannot write to file! Chyba: Nelze zapisovat do souboru! - + Error: Chyba: @@ -707,22 +707,22 @@ neexistuje! % - Správce stahování - + Save file as... Uložit soubor jako... - + Warning Varování - + Are you sure to quit? All uncompleted downloads will be cancelled! Jste si jistý že chcete skončit? Všechna nedokončená stahování budou zrušena! - + NoNameDownload BezNazvu @@ -747,35 +747,40 @@ neexistuje! Otevírám - + which is a: což je: - + from: z: - + You have chosen to open Zvolili jste otevřít - + <b>What should QupZilla do with this file?</b> <b>Co má QupZilla udělat s tímto souborem?</b> - + Open... Otevřít... - + Save File Uložit soubor + + + Opening %1 + Otevírám %1 + HistoryManager @@ -923,12 +928,12 @@ neexistuje! MainApplication - + Last session crashed Poslední relace spadla - + <b>QupZilla crashed :-(</b><br/>Oops, last session of QupZilla ends with its crash. We are very sorry. Would you try to restore saved state? <b>QupZilla spadla :-(</b><br/>Oops, poslední relace QupZilly skončila jejím pádem. Velice se omlouváme. Přejete si obnovit uložený stav? @@ -1593,72 +1598,72 @@ neexistuje! QupZilla - + File Soubor - + Open File Otevřít soubor - + Edit Úpravy - + Tools Nástroje - + Help Nápověda - + View Zobrazení - + Bookmarks Záložky - + History Historie - + Save Page As... Uložit stránku jako... - + Print Tisk - + Quit Konec - + New Tab Nový panel - + Undo Zpět - + Redo Vpřed @@ -1678,111 +1683,111 @@ neexistuje! O Qt - + Close Tab Zavřít panel - + Find Najít - + Cut Vyjmout - + IP Address of current page IP Adresa aktuální stránky - + Copy Kopírovat - + Paste Vložit - + Delete Odstranit - + Select All Vybrat vše - + Navigation Toolbar Navigační lišta - + Status Bar Status bar - - + + Stop Zastavit - - + + Reload Obnovit - + Character Encoding Kódování znaků - + Zoom In Zoom + - + Zoom Out Zoom - - + Reset Původní - + Page Source Zdrojový kód stránky - + Fullscreen Celá obrazovka - + Back Zpět - + Forward Vpřed - + Home Domů @@ -1808,22 +1813,22 @@ neexistuje! Organizovat záložky - + New Window Nové okno - + Close Window Zavřít okno - + Open Location Otevřít adresu - + Send Link... Poslat odkaz... @@ -1883,37 +1888,37 @@ neexistuje! Správce cookies - + Bookmarks Toolbar Panel záložek - + Navigation Navigace - + Main Menu Hlavní menu - + Exit Fullscreen Zrušit celou obrazovku - + Private Browsing Enabled Soukromé prohlížení zapnuto - + Flash Plugin Enabled Flash Plugin zapnut - + Menu Bar Menu @@ -2601,62 +2606,72 @@ Prosím přidejte si nějaký kliknutím na RSS ikonku v navigačním řádku. TabBar - - + + New tab Nový panel - + Back Zpět - + Forward Vpřed - + Stop Tab Zastavit panel - + Reload Tab Obnovit panel - - + + Unpin Tab + Zrušit připíchnutí + + + + Pin Tab + Připíchnout panel + + + + Reload All Tabs Close other tabs Obnovit všechny panely - + Bookmark This Tab Přidat panel do záložek - - + + Bookmark All Tabs Přidat všechny panely do záložek - - + + Restore Closed Tab Obnovit zavřený panel - + Close Other Tabs Zavřít ostatní panely - + Close Zavřít @@ -2680,7 +2695,7 @@ Prosím přidejte si nějaký kliknutím na RSS ikonku v navigačním řádku. - + No Named Page Bezejmenná stránka @@ -2690,7 +2705,7 @@ Prosím přidejte si nějaký kliknutím na RSS ikonku v navigačním řádku.Dohromady máte otevřeno %1 panelů - + New tab Nový panel @@ -2826,7 +2841,7 @@ Prosím přidejte si nějaký kliknutím na RSS ikonku v navigačním řádku.Načítám... - + No Named Page Bezejmenná stránka diff --git a/translations/sk_SK.ts b/translations/sk_SK.ts index 9356dadaa..bec8d71c3 100644 --- a/translations/sk_SK.ts +++ b/translations/sk_SK.ts @@ -602,83 +602,83 @@ p, li { white-space: pre-wrap; } - + Remaining time unavailable Neznámy zostávajúci čas - + Done - %1 Dokončené - %1 - - + + Cancelled Zrušené - + few seconds pár sekúnd - + seconds sekúnd - + minutes minút - + hours hodín - + Remaining %1 - %2 of %3 (%4) Zostáva %1 - %2 z %3 (%4) - + Cancelled - %1 Zrušene - %1 - + Open File Otvoriť súbor - + Open Folder Otvoriť priečinok - + Cancel downloading Zrušiť sťahovanie - + Clear Vyčistiť - + Error Chyba - + Not found Súbor neexistuje - + Sorry, the file %1 is not found! @@ -687,12 +687,12 @@ p, li { white-space: pre-wrap; } neexistuje! - + Error: Cannot write to file! Chyba: Nejde zapisovať do súboru! - + Error: Chyba: @@ -710,22 +710,22 @@ neexistuje! % - Správca sťahovania - + Save file as... Uložiť súbor ako... - + Warning Upozornenie - + Are you sure to quit? All uncompleted downloads will be cancelled! Ste si istý, že chcete skončiť? Všetky nedokončené sťahovania budú zrušene! - + NoNameDownload BezNázvu @@ -750,35 +750,40 @@ neexistuje! Otváram - + which is a: čo je: - + from: z: - + You have chosen to open Zvolili ste si otvoriť - + <b>What should QupZilla do with this file?</b> <b>Čo má QupZilla urobiť s týmto súborom?</b> - + Open... Otvoriť... - + Save File Uložiť súbor + + + Opening %1 + + HistoryManager @@ -925,12 +930,12 @@ neexistuje! MainApplication - + Last session crashed Posledná relácia spadla - + <b>QupZilla crashed :-(</b><br/>Oops, last session of QupZilla ends with its crash. We are very sorry. Would you try to restore saved state? <b>QupZilla spadla :-(</b><br/>Oops, posledná relácia QupZilly skončila chybou. Prepáčte. Chcete obnoviť uložený stav? @@ -1595,72 +1600,72 @@ neexistuje! QupZilla - + File Súbor - + Edit Upraviť - + Tools Nástroje - + Help Pomocník - + Open File Otvoriť súbor - + View Zobraziť - + Bookmarks Záložky - + History História - + Save Page As... Uložiť stránku ako... - + Print Tlačiť - + Quit Koniec - + New Tab Nový panel - + Undo Späť - + Redo Dopredu @@ -1680,111 +1685,111 @@ neexistuje! O Qt - + Close Tab Zavriet panel - + Find Hľadať - + IP Address of current page IP Adresa aktuálnej stránky - + Cut Vystrihnúť - + Copy Kopírovať - + Paste Prilepiť - + Delete Vymazať - + Select All Vybrať všetko - + Navigation Toolbar Navigačná lišta - + Status Bar Status bar - - + + Stop Zastaviť - - + + Reload Obnoviť - + Character Encoding Kódovanie znakov - + Zoom In Priblížiť - + Zoom Out Oddialiť - + Reset Resetovať - + Page Source Zdrojový kód stránky - + Fullscreen Celá obrazovka - + Back Späť - + Forward Dopredu - + Home Domov @@ -1810,22 +1815,22 @@ neexistuje! Organizovať záložky - + New Window Nové okno - + Close Window Zavrieť okno - + Open Location Otvoriť adresu - + Send Link... Poslať odkaz... @@ -1885,37 +1890,37 @@ neexistuje! Správca cookies - + Bookmarks Toolbar Panel záložiek - + Navigation Navigácia - + Main Menu Hlavné menu - + Exit Fullscreen Ukončiť režím Fullscreen - + Private Browsing Enabled Súkromné prehliadanie je zapnuté - + Flash Plugin Enabled Flash Plugin zapnutý - + Menu Bar Menu @@ -2601,62 +2606,72 @@ Prosím pridajte si nejaký kliknutím na RSS ikonku v navigačnom riadku. TabBar - - + + New tab Nový panel - + Back Späť - + Forward Dopredu - + Stop Tab Zastaviť panel - + Reload Tab Obnoviť panel - + + Unpin Tab + + + + + Pin Tab + + + + Bookmark This Tab Založiť tento panel - - + + Bookmark All Tabs Založiť všetky panely - - + + Restore Closed Tab Obnoviť zavretý panel - + Close Other Tabs Zavrieť ostatné panely - - + + Reload All Tabs Restore closed tab Obnoviť všetky panely - + Close Zavrieť @@ -2680,7 +2695,7 @@ Prosím pridajte si nejaký kliknutím na RSS ikonku v navigačnom riadku. - + No Named Page Stránka bez mena @@ -2690,7 +2705,7 @@ Prosím pridajte si nejaký kliknutím na RSS ikonku v navigačnom riadku.Momentálne otvorených %1 panelov - + New tab Nový panel @@ -2826,7 +2841,7 @@ Prosím pridajte si nejaký kliknutím na RSS ikonku v navigačnom riadku.Načítavam... - + No Named Page Stránka bez mena