From 0b5c18f24a5f6e3d62c398210313f596a00cb3c1 Mon Sep 17 00:00:00 2001 From: nils Date: Sun, 2 Jan 2011 23:56:59 +0000 Subject: added shortcuts Ctrl+Tab and Ctrl+Shift+Tab to switch through the tabs git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@424 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- textedit.cpp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'textedit.cpp') diff --git a/textedit.cpp b/textedit.cpp index 0e666e8..16cbd84 100644 --- a/textedit.cpp +++ b/textedit.cpp @@ -79,7 +79,7 @@ void TextEdit::newTab() EditorPage *page = new EditorPage(); tabWidget->addTab(page, header); tabWidget->setCurrentIndex(tabWidget->count() - 1); - + page->getTextPage()->setFocus(); connect(page->getTextPage(), SIGNAL(modificationChanged(bool)), this, SLOT(showModified())); // setCursorPosition(); } @@ -102,13 +102,13 @@ void TextEdit::open() QApplication::setOverrideCursor(Qt::WaitCursor); page->getTextPage()->setPlainText(in.readAll()); page->setFilePath(fileName); - QTextDocument *document = page->getTextPage()->document(); document->setModified(false); tabWidget->addTab(page, strippedName(fileName)); tabWidget->setCurrentIndex(tabWidget->count() - 1); QApplication::restoreOverrideCursor(); + page->getTextPage()->setFocus(); connect(page->getTextPage(), SIGNAL(modificationChanged(bool)), this, SLOT(showModified())); // setCursorPosition(); //enableAction(true) @@ -426,3 +426,30 @@ void TextEdit::showModified() { else tabWidget->setTabText(index, title.remove(0,2)); } + +void TextEdit::switchTabUp() { + if (tabWidget->count() > 1) + { + if (tabWidget->count() == tabWidget->currentIndex()+1){ + tabWidget->setCurrentIndex(0); + } + else + { + tabWidget->setCurrentIndex(tabWidget->currentIndex()+1); + } + } +} + +void TextEdit::switchTabDown() { + if (tabWidget->count() > 1) + { + if (tabWidget->currentIndex()==1) { + tabWidget->setCurrentIndex(tabWidget->count()-1); + } + else + { + tabWidget->setCurrentIndex(tabWidget->currentIndex()-1); + } + } +} + -- cgit v1.2.3