diff options
author | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2012-09-30 01:50:01 +0000 |
---|---|---|
committer | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2012-09-30 01:50:01 +0000 |
commit | f1a9739feed5de5e04e5127adb116eca13f73cd8 (patch) | |
tree | 4fa0ef7d871715a3e40017eb6c2bcdc80884a992 | |
parent | refactored slots in quitdialog.* and settingsdialog.* (diff) | |
download | gpg4usb-f1a9739feed5de5e04e5127adb116eca13f73cd8.tar.gz gpg4usb-f1a9739feed5de5e04e5127adb116eca13f73cd8.zip |
refactored slots in settingsdialog.* and textedit.*
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@985 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r-- | mainwindow.cpp | 32 | ||||
-rwxr-xr-x | settingsdialog.cpp | 8 | ||||
-rwxr-xr-x | settingsdialog.h | 4 | ||||
-rw-r--r-- | textedit.cpp | 34 | ||||
-rw-r--r-- | textedit.h | 36 |
5 files changed, 57 insertions, 57 deletions
diff --git a/mainwindow.cpp b/mainwindow.cpp index a9d9827..66585ae 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -154,36 +154,36 @@ void MainWindow::createActions() newTabActShortcutList.append(QKeySequence (Qt::CTRL + Qt::Key_T)); newTabAct->setShortcuts(newTabActShortcutList); newTabAct->setToolTip(tr("Open a new file")); - connect(newTabAct, SIGNAL(triggered()), edit, SLOT(newTab())); + connect(newTabAct, SIGNAL(triggered()), edit, SLOT(slotNewTab())); openAct = new QAction(tr("&Open..."), this); openAct->setIcon(QIcon(":fileopen.png")); openAct->setShortcut(QKeySequence::Open); openAct->setToolTip(tr("Open an existing file")); - connect(openAct, SIGNAL(triggered()), edit, SLOT(open())); + connect(openAct, SIGNAL(triggered()), edit, SLOT(slotOpen())); saveAct = new QAction(tr("&Save"), this); saveAct->setIcon(QIcon(":filesave.png")); saveAct->setShortcut(QKeySequence::Save); saveAct->setToolTip(tr("Save the current File")); - connect(saveAct, SIGNAL(triggered()), edit, SLOT(save())); + connect(saveAct, SIGNAL(triggered()), edit, SLOT(slotSave())); saveAsAct = new QAction(tr("Save &As")+"...", this); saveAsAct->setIcon(QIcon(":filesaveas.png")); saveAsAct->setShortcut(QKeySequence::SaveAs); saveAsAct->setToolTip(tr("Save the current File as...")); - connect(saveAsAct, SIGNAL(triggered()), edit, SLOT(saveAs())); + connect(saveAsAct, SIGNAL(triggered()), edit, SLOT(slotSaveAs())); printAct = new QAction(tr("&Print"), this); printAct->setIcon(QIcon(":fileprint.png")); printAct->setShortcut(QKeySequence::Print); printAct->setToolTip(tr("Print Document")); - connect(printAct, SIGNAL(triggered()), edit, SLOT(print())); + connect(printAct, SIGNAL(triggered()), edit, SLOT(slotPrint())); closeTabAct = new QAction(tr("&Close"), this); closeTabAct->setShortcut(QKeySequence::Close); closeTabAct->setToolTip(tr("Close file")); - connect(closeTabAct, SIGNAL(triggered()), edit, SLOT(closeTab())); + connect(closeTabAct, SIGNAL(triggered()), edit, SLOT(slotCloseTab())); quitAct = new QAction(tr("&Quit"), this); quitAct->setShortcut(QKeySequence::Quit); @@ -234,7 +234,7 @@ void MainWindow::createActions() quoteAct = new QAction(tr("&Quote"), this); quoteAct->setIcon(QIcon(":quote.png")); quoteAct->setToolTip(tr("Quote whole text")); - connect(quoteAct, SIGNAL(triggered()), edit, SLOT(quote())); + connect(quoteAct, SIGNAL(triggered()), edit, SLOT(slotQuote())); selectallAct = new QAction(tr("Select &All"), this); selectallAct->setIcon(QIcon(":edit.png")); @@ -390,12 +390,12 @@ void MainWindow::createActions() */ switchTabUpAct = new QAction(this); switchTabUpAct->setShortcut(QKeySequence::NextChild); - connect(switchTabUpAct, SIGNAL(triggered()), edit, SLOT(switchTabUp())); + connect(switchTabUpAct, SIGNAL(triggered()), edit, SLOT(slotSwitchTabUp())); this->addAction(switchTabUpAct); switchTabDownAct = new QAction(this); switchTabDownAct->setShortcut(QKeySequence::PreviousChild); - connect(switchTabDownAct, SIGNAL(triggered()), edit, SLOT(switchTabDown())); + connect(switchTabDownAct, SIGNAL(triggered()), edit, SLOT(slotSwitchTabDown())); this->addAction(switchTabDownAct); cutPgpHeaderAct = new QAction(tr("Remove PGP Header"), this); @@ -696,7 +696,7 @@ void MainWindow::slotOpenHelp() { void MainWindow::slotOpenHelp(const QString page) { - edit->newHelpTab("help", "file:" + qApp->applicationDirPath() + "/help/" + page); + edit->slotNewHelpTab("help", "file:" + qApp->applicationDirPath() + "/help/" + page); } void MainWindow::slotSetStatusBarText(QString text) @@ -947,7 +947,7 @@ void MainWindow::slotEncryptDone(int result) if (result == KGpgTransaction::TS_OK) { const QString lf = QLatin1String("\n"); //setPlainText(enc->encryptedText().join(lf) + lf); - edit->fillTextEditWithText(enc->encryptedText().join(lf) + lf); + edit->slotFillTextEditWithText(enc->encryptedText().join(lf) + lf); } else { /*KMessageBox::sorry(this, i18n("The encryption failed with error code %1", result), i18n("Encryption failed."));*/ @@ -998,7 +998,7 @@ void MainWindow::slotSignDone(int result) return; } - edit->fillTextEditWithText(signt->signedText().join(QLatin1String("\n")) + QLatin1String("\n")); + edit->slotFillTextEditWithText(signt->signedText().join(QLatin1String("\n")) + QLatin1String("\n")); } @@ -1069,7 +1069,7 @@ void MainWindow::slotDecryptDone(int result) if (result == KGpgTransaction::TS_OK) { // FIXME choose codec //setPlainText(decr->decryptedText().join(QLatin1String("\n")) + QLatin1Char('\n')); - edit->fillTextEditWithText(decr->decryptedText().join(QLatin1String("\n")) + QLatin1Char('\n')); + edit->slotFillTextEditWithText(decr->decryptedText().join(QLatin1String("\n")) + QLatin1Char('\n')); } else if (result != KGpgTransaction::TS_USER_ABORTED) { //KMessageBox::detailedSorry(this, i18n("Decryption failed."), decr->getMessages().join( QLatin1String( "\n" ))); qDebug() << "Decryption failed." << decr->getMessages().join( QLatin1String( "\n" )); @@ -1323,7 +1323,7 @@ void MainWindow::slotCleanDoubleLinebreaks() content.replace("\n\n", "\n"); } - edit->fillTextEditWithText(content); + edit->slotFillTextEditWithText(content); } void MainWindow::slotAddPgpHeader() { @@ -1336,7 +1336,7 @@ void MainWindow::slotAddPgpHeader() { content.prepend("\n\n").prepend(GpgConstants::PGP_CRYPT_BEGIN); content.append("\n").append(GpgConstants::PGP_CRYPT_END); - edit->fillTextEditWithText(content); + edit->slotFillTextEditWithText(content); } void MainWindow::slotCutPgpHeader() { @@ -1361,5 +1361,5 @@ void MainWindow::slotCutPgpHeader() { end = content.indexOf(GpgConstants::PGP_CRYPT_END); content.remove(end, QString(GpgConstants::PGP_CRYPT_END).size()); - edit->fillTextEditWithText(content.trimmed()); + edit->slotFillTextEditWithText(content.trimmed()); } diff --git a/settingsdialog.cpp b/settingsdialog.cpp index 6929ee2..72e0cce 100755 --- a/settingsdialog.cpp +++ b/settingsdialog.cpp @@ -538,9 +538,9 @@ GpgPathsTab::GpgPathsTab(QWidget *parent) keydbLabel = new QLabel(accKeydbPath,this); QPushButton *keydbButton = new QPushButton("Change keydb path",this); - connect(keydbButton, SIGNAL(clicked()), this, SLOT(chooseKeydbDir())); + connect(keydbButton, SIGNAL(clicked()), this, SLOT(slotChooseKeydbDir())); QPushButton *keydbDefaultButton = new QPushButton("Set keydb to default path",this); - connect(keydbDefaultButton, SIGNAL(clicked()), this, SLOT(setKeydbPathToDefault())); + connect(keydbDefaultButton, SIGNAL(clicked()), this, SLOT(slotSetKeydbPathToDefault())); keydbBox->setLayout(keydbBoxLayout); keydbBoxLayout->addWidget(new QLabel(tr("Current keydb path: ")),1,1); @@ -568,13 +568,13 @@ QString GpgPathsTab::getRelativePath(const QString dir1,const QString dir2) return s; } -void GpgPathsTab::setKeydbPathToDefault() +void GpgPathsTab::slotSetKeydbPathToDefault() { accKeydbPath = "."; keydbLabel->setText("."); } -QString GpgPathsTab::chooseKeydbDir() +QString GpgPathsTab::slotChooseKeydbDir() { QString dir = QFileDialog::getExistingDirectory(this,tr ("Choose keydb directory"),accKeydbPath,QFileDialog::ShowDirsOnly); diff --git a/settingsdialog.h b/settingsdialog.h index 3626cbb..65d4f31 100755 --- a/settingsdialog.h +++ b/settingsdialog.h @@ -150,8 +150,8 @@ private: void setSettings(); private slots: - QString chooseKeydbDir(); - void setKeydbPathToDefault(); + QString slotChooseKeydbDir(); + void slotSetKeydbPathToDefault(); }; diff --git a/textedit.cpp b/textedit.cpp index 61de5fe..14dde4a 100644 --- a/textedit.cpp +++ b/textedit.cpp @@ -36,13 +36,13 @@ TextEdit::TextEdit() setLayout(layout); connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(removeTab(int))); - newTab(); + slotNewTab(); setAcceptDrops(false); QPushButton *newButton = new QPushButton("new",this); tabWidget->setCornerWidget(newButton,Qt::TopRightCorner); } -void TextEdit::newTab() +void TextEdit::slotNewTab() { QString header = tr("untitled") + QString::number(++countPage)+".txt"; @@ -51,10 +51,10 @@ void TextEdit::newTab() tabWidget->addTab(page, header); tabWidget->setCurrentIndex(tabWidget->count() - 1); page->getTextPage()->setFocus(); - connect(page->getTextPage()->document(), SIGNAL(modificationChanged(bool)), this, SLOT(showModified())); + connect(page->getTextPage()->document(), SIGNAL(modificationChanged(bool)), this, SLOT(slotShowModified())); } -void TextEdit::newHelpTab(QString title, QString path) +void TextEdit::slotNewHelpTab(QString title, QString path) { HelpPage *page = new HelpPage(path); @@ -63,7 +63,7 @@ void TextEdit::newHelpTab(QString title, QString path) } -void TextEdit::open() +void TextEdit::slotOpen() { QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open file"), QDir::currentPath()); @@ -85,7 +85,7 @@ void TextEdit::open() tabWidget->setCurrentIndex(tabWidget->count() - 1); QApplication::restoreOverrideCursor(); page->getTextPage()->setFocus(); - connect(page->getTextPage()->document(), SIGNAL(modificationChanged(bool)), this, SLOT(showModified())); + connect(page->getTextPage()->document(), SIGNAL(modificationChanged(bool)), this, SLOT(slotShowModified())); //enableAction(true) file.close(); } else { @@ -98,7 +98,7 @@ void TextEdit::open() } } -void TextEdit::save() +void TextEdit::slotSave() { if (tabWidget->count() == 0 || curPage() == 0) { return; @@ -109,7 +109,7 @@ void TextEdit::save() if (fileName.isEmpty()) { //QString docname = tabWidget->tabText(tabWidget->currentIndex()); //docname.remove(0,2); - saveAs(); + slotSaveAs(); } else { saveFile(fileName); } @@ -150,7 +150,7 @@ bool TextEdit::saveFile(const QString &fileName) } -bool TextEdit::saveAs() +bool TextEdit::slotSaveAs() { if (tabWidget->count() == 0 || curPage() == 0) { return true; @@ -169,7 +169,7 @@ bool TextEdit::saveAs() return saveFile(fileName); } -void TextEdit::closeTab() +void TextEdit::slotCloseTab() { removeTab(tabWidget->currentIndex()); if (tabWidget->count() != 0) { @@ -239,7 +239,7 @@ bool TextEdit::maybeSaveCurrentTab(bool askToSave) { if (filePath == "") { //QString docname = tabWidget->tabText(tabWidget->currentIndex()); //docname.remove(0,2); - return saveAs(); + return slotSaveAs(); } else { return saveFile(filePath); } @@ -343,7 +343,7 @@ EditorPage* TextEdit::curPage() return curPage; } -void TextEdit::quote() +void TextEdit::slotQuote() { if (tabWidget->count() == 0 || curTextPage() == 0) { return; @@ -365,7 +365,7 @@ void TextEdit::quote() cursor.endEditBlock(); } -void TextEdit::fillTextEditWithText(QString text) { +void TextEdit::slotFillTextEditWithText(QString text) { QTextCursor cursor(curTextPage()->document()); cursor.beginEditBlock(); this->curTextPage()->selectAll(); @@ -398,7 +398,7 @@ QString TextEdit::strippedName(const QString &fullFileName) return QFileInfo(fullFileName).fileName(); } -void TextEdit::print() +void TextEdit::slotPrint() { if (tabWidget->count() == 0) { return; @@ -423,7 +423,7 @@ void TextEdit::print() #endif } -void TextEdit::showModified() { +void TextEdit::slotShowModified() { int index=tabWidget->currentIndex(); QString title= tabWidget->tabText(index); // if doc is modified now, add leading * to title, @@ -435,14 +435,14 @@ void TextEdit::showModified() { } } -void TextEdit::switchTabUp() { +void TextEdit::slotSwitchTabUp() { if (tabWidget->count() > 1) { int newindex=(tabWidget->currentIndex()+1)%(tabWidget->count()); tabWidget->setCurrentIndex(newindex); } } -void TextEdit::switchTabDown() { +void TextEdit::slotSwitchTabDown() { if (tabWidget->count() > 1) { int newindex=(tabWidget->currentIndex()-1+tabWidget->count())%tabWidget->count(); tabWidget->setCurrentIndex(newindex); @@ -92,46 +92,52 @@ public: public slots: /** + * @details Return pointer to the currently activated tabpage. + * + */ + EditorPage *curPage(); + + /** * @details Insert a ">" at the begining of every line of current textedit. */ - void quote(); + void slotQuote(); /** * @details replace the text of currently active textedit with given text. * @param text to fill on. */ - void fillTextEditWithText(QString text); + void slotFillTextEditWithText(QString text); /** * @details Saves the content of the current tab, if it has a filepath * otherwise it calls saveAs for the current tab */ - void save(); + void slotSave(); /** * @details Opens a savefiledialog and calls saveFile with the choosen filename. * * @return Return the return value of the savefile method */ - bool saveAs(); + bool slotSaveAs(); /** * @details Show an OpenFileDoalog and open the file in a new tab. * Shows an error dialog, if the open fails. * Set the focus to the tab of the opened file. */ - void open(); + void slotOpen(); /** * @details Open a print-dialog for the current tab */ - void print(); + void slotPrint(); /** * @details Adds a new tab with the title "untitled"+countpage+".txt" * Sets the focus to the new tab. Increase Tab-Count by one */ - void newTab(); + void slotNewTab(); /** * @details Adds a new tab with the given title and opens given html file. @@ -139,36 +145,30 @@ public slots: * @param title title for the tab * @param path path for html file to show */ - void newHelpTab(QString title, QString path); + void slotNewHelpTab(QString title, QString path); /** * @details put a * in front of current tabs title, if current textedit is modified */ - void showModified(); + void slotShowModified(); /** * @details close the current tab and decrease TabWidget->count by \a 1 * */ - void closeTab(); + void slotCloseTab(); /** * @details Switch to the next tab. * */ - void switchTabUp(); + void slotSwitchTabUp(); /** * @details Switch to the previous tab. * */ - void switchTabDown(); - - /** - * @details Return pointer to the currently activated tabpage. - * - */ - EditorPage *curPage(); + void slotSwitchTabDown(); private: /** |