diff options
-rw-r--r-- | gpgwin.cpp | 19 | ||||
-rw-r--r-- | gpgwin.h | 2 | ||||
-rw-r--r-- | textedit.cpp | 31 | ||||
-rw-r--r-- | textedit.h | 2 |
4 files changed, 50 insertions, 4 deletions
@@ -32,12 +32,12 @@ GpgWin::GpgWin() QString appPath = qApp->applicationDirPath(); iconPath = appPath + "/icons/"; - edit = new TextEdit(); - setCentralWidget(edit); setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); + edit = new TextEdit(); + setCentralWidget(edit); /* the list of Keys available*/ mKeyList = new KeyList(mCtx, iconPath); @@ -61,7 +61,9 @@ GpgWin::GpgWin() // open filename if provided as first command line parameter QStringList args = qApp->arguments(); + qDebug() << args.size(); if (args.size() > 1) { + if (!args[1].startsWith("-")) { if (QFile::exists(args[1])) edit->loadFile(args[1]); @@ -288,6 +290,19 @@ void GpgWin::createActions() appendSelectedKeysAct = new QAction(tr("Append Selected Key(s) To Text"), this); appendSelectedKeysAct->setToolTip(tr("Append The Selected Keys To Text in Editor")); connect(appendSelectedKeysAct, SIGNAL(triggered()), this, SLOT(appendSelectedKeys())); + + + /** Key-Shortcuts for Tab-Switchung-Action + */ + switchTabUpAct = new QAction(this); + switchTabUpAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Tab)); + connect(switchTabUpAct, SIGNAL(triggered()), edit, SLOT(switchTabUp())); + this->addAction(switchTabUpAct); + + switchTabDownAct = new QAction(this); + switchTabDownAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Shift+ Qt::Key_Tab)); + connect(switchTabDownAct, SIGNAL(triggered()), edit, SLOT(switchTabDown())); + this->addAction(switchTabDownAct); } void GpgWin::createMenus() @@ -109,6 +109,8 @@ private: QDialog *genkeyDialog; QAction *newTabAct; + QAction *switchTabUpAct; + QAction *switchTabDownAct; QAction *openAct; QAction *saveAct; QAction *saveAsAct; 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); + } + } +} + @@ -54,6 +54,8 @@ public slots: void newTab(); void showModified(); void closeTab(); + void switchTabUp(); + void switchTabDown(); private: QString strippedName(const QString &fullFileName); |