summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp63
1 files changed, 33 insertions, 30 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 2287370c..dc29d2eb 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -320,7 +320,9 @@ void MainWindow::setupActions()
browserLoading(false); //first init for blank start page
a = new KAction(i18n("Open Location"), this);
- a->setShortcut(Qt::CTRL + Qt::Key_L);
+ KShortcut openLocationShortcut(Qt::CTRL + Qt::Key_L);
+ openLocationShortcut.setAlternate(Qt::Key_F6);
+ a->setShortcut(openLocationShortcut);
actionCollection()->addAction(QL1S("open_location"), a);
connect(a, SIGNAL(triggered(bool)) , this, SLOT(openLocation()));
@@ -398,6 +400,16 @@ void MainWindow::setupActions()
closedTabsMenu->setDelayed(false);
actionCollection()->addAction(QL1S("closed_tab_menu"), closedTabsMenu);
+ // shortcuts for quickly switching to a tab
+ for( int i = 1; i <= 9; i++ ) {
+ a = new KAction(i18n("Switch to Tab %1", i), this);
+ a->setShortcut(KShortcut( QString("Alt+%1").arg(i) ));
+ a->setData( QVariant(i) );
+ actionCollection()->addAction(QL1S(("switch_tab_" + QString::number(i)).toAscii()), a);
+ connect(a, SIGNAL(triggered(bool)), m_view, SLOT(switchToTab()));
+ }
+
+
// ============================== Indexed Tab Actions ====================================
a = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this);
actionCollection()->addAction(QL1S("close_tab"), a);
@@ -597,8 +609,19 @@ void MainWindow::openLocation()
void MainWindow::fileSaveAs()
{
- KUrl srcUrl = currentTab()->url();
-
+ KUrl srcUrl;
+ WebTab *w = currentTab();
+ if (w->page()->isOnRekonqPage())
+ {
+ QWebElement el = w->page()->mainFrame()->documentElement();
+ srcUrl = KUrl( el.findFirst("object").attribute("data") );
+ }
+ else
+ {
+ srcUrl = w->url();
+ }
+ kDebug() << "URL to save: " << srcUrl;
+
QString name = srcUrl.fileName();
if (name.isNull())
{
@@ -634,7 +657,6 @@ void MainWindow::preferences()
void MainWindow::updateActions()
{
bool rekonqPage = currentTab()->page()->isOnRekonqPage();
- kDebug() << "UPDATE ACTIONS: rekonq page = " << rekonqPage;
QAction *historyBackAction = actionByName(KStandardAction::name(KStandardAction::Back));
if( rekonqPage )
@@ -658,7 +680,7 @@ void MainWindow::updateActions()
if (am->menu())
am->menu()->clear();
- foreach (HistoryItem item, mainView()->recentlyClosedTabs())
+ foreach (const HistoryItem &item, mainView()->recentlyClosedTabs())
{
KAction *a = new KAction(Application::icon(item.url), item.title, this);
a->setData(item.url);
@@ -884,7 +906,7 @@ void MainWindow::setZoomFactor(int factor)
void MainWindow::setZoomSliderFactor(qreal factor)
{
- m_zoomSlider->setValue(factor*10);
+ m_zoomSlider->setValue(factor * 10);
}
@@ -942,26 +964,8 @@ void MainWindow::viewPageSource()
if (!currentTab())
return;
- KUrl url(currentTab()->url());
- bool isTempFile = false;
- if (!url.isLocalFile())
- {
- KTemporaryFile sourceFile;
-
- /// TODO: autochoose tempfile suffix
- sourceFile.setSuffix(QString(".html"));
- sourceFile.setAutoRemove(false);
-
- if (sourceFile.open())
- {
- sourceFile.write(currentTab()->page()->mainFrame()->toHtml().toUtf8());
-
- url = KUrl();
- url.setPath(sourceFile.fileName());
- isTempFile = true;
- }
- }
- KRun::runUrl(url, QL1S("text/plain"), this, isTempFile);
+ KUrl url = currentTab()->url();
+ KRun::runUrl(url, QL1S("text/plain"), this, false);
}
@@ -1314,7 +1318,7 @@ void MainWindow::setEncoding(QAction *qa)
{
QString currentCodec = qa->text().toLatin1();
currentCodec = currentCodec.remove('&');
- kDebug() << currentCodec;
+ kDebug() << "Setting codec: " << currentCodec;
currentTab()->page()->settings()->setDefaultTextEncoding(currentCodec);
}
@@ -1331,7 +1335,6 @@ void MainWindow::populateEncodingMenu()
codecs.sort();
QString currentCodec = currentTab()->page()->settings()->defaultTextEncoding();
- kDebug() << "Current Codec: " << currentCodec;
m_encodingMenu->clear();
KMenu *isoMenu = new KMenu( QL1S("ISO"), m_encodingMenu);
@@ -1380,8 +1383,8 @@ bool MainWindow::queryClose()
{
int answer = KMessageBox::questionYesNoCancel(
this,
- i18np("Are you sure you want to close the window?\n" "You have 1 tab open",
- "Are you sure you want to close the window?\n" "You have %1 tabs open" ,
+ i18np("Are you sure you want to close the window?\n" "You have 1 tab open.",
+ "Are you sure you want to close the window?\n" "You have %1 tabs open.",
m_view->count()),
i18n("Are you sure you want to close the window?"),
KStandardGuiItem::quit(),