aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-01-02 16:33:22 +0000
committernils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-01-02 16:33:22 +0000
commit948362b8ee383614e37225d1f1fe0bd66e15b4df (patch)
tree04f9086a4b1130a36cc2cb55f04132b265460264
parentadded star in tabtitle, if document is changed (diff)
downloadgpg4usb-948362b8ee383614e37225d1f1fe0bd66e15b4df.tar.gz
gpg4usb-948362b8ee383614e37225d1f1fe0bd66e15b4df.zip
added shortcuts for tab-handling and made different bugfixes
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@422 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r--gpgwin.cpp19
-rw-r--r--gpgwin.h2
-rw-r--r--keylist.cpp4
-rwxr-xr-xsettingsdialog.cpp4
-rw-r--r--textedit.cpp94
-rw-r--r--textedit.h4
6 files changed, 56 insertions, 71 deletions
diff --git a/gpgwin.cpp b/gpgwin.cpp
index c089bd5..35bd30c 100644
--- a/gpgwin.cpp
+++ b/gpgwin.cpp
@@ -55,7 +55,6 @@ GpgWin::GpgWin()
createToolBars();
createStatusBar();
createDockWindows();
- edit->setCurrentFile("");
mKeyList->addMenuAction(appendSelectedKeysAct);
restoreSettings();
@@ -125,9 +124,9 @@ void GpgWin::createActions()
{
/** Main Menu
*/
- newTabAct = new QAction(tr("&New Tab..."), this);
-// openAct->setShortcut(QKeySequence::Open);
- newTabAct->setToolTip(tr("Open a new tab"));
+ newTabAct = new QAction(tr("&New"), this);
+ newTabAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_T));
+ newTabAct->setToolTip(tr("Open a new file"));
connect(newTabAct, SIGNAL(triggered()), edit, SLOT(newTab()));
openAct = new QAction(tr("&Open..."), this);
@@ -142,7 +141,7 @@ void GpgWin::createActions()
saveAct->setToolTip(tr("Save the current File"));
connect(saveAct, SIGNAL(triggered()), edit, SLOT(save()));
- saveAsAct = new QAction(tr("Save &As"), this);
+ saveAsAct = new QAction(tr("Save &As")+"...", this);
saveAsAct->setIcon(QIcon(iconPath + "filesaveas.png"));
saveAsAct->setShortcut(QKeySequence::SaveAs);
saveAsAct->setToolTip(tr("Save the current File as..."));
@@ -154,6 +153,11 @@ void GpgWin::createActions()
printAct->setToolTip(tr("Print Document"));
connect(printAct, SIGNAL(triggered()), edit, SLOT(print()));
+ closeTabAct = new QAction(tr("&Close"), this);
+ closeTabAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W));
+ closeTabAct->setToolTip(tr("Close file"));
+ connect(closeTabAct, SIGNAL(triggered()), edit, SLOT(closeTab()));
+
quitAct = new QAction(tr("&Quit"), this);
// quitAct->setShortcut(QKeySequence::Quit);
quitAct->setIcon(QIcon(iconPath + "exit.png"));
@@ -194,7 +198,7 @@ void GpgWin::createActions()
quoteAct = new QAction(tr("&Quote"), this);
quoteAct->setIcon(QIcon(iconPath + "quote.png"));
- quoteAct->setToolTip(tr("Insert \">\" in front of every line"));
+ quoteAct->setToolTip(tr("Quote whole text"));
connect(quoteAct, SIGNAL(triggered()), edit, SLOT(quote()));
selectallAct = new QAction(tr("Select &All"), this);
@@ -291,10 +295,13 @@ void GpgWin::createMenus()
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(newTabAct);
fileMenu->addAction(openAct);
+ fileMenu->addSeparator();
fileMenu->addAction(saveAct);
fileMenu->addAction(saveAsAct);
+ fileMenu->addSeparator();
fileMenu->addAction(printAct);
fileMenu->addSeparator();
+ fileMenu->addAction(closeTabAct);
fileMenu->addAction(quitAct);
editMenu = menuBar()->addMenu(tr("&Edit"));
diff --git a/gpgwin.h b/gpgwin.h
index 46e2c04..ed09f8e 100644
--- a/gpgwin.h
+++ b/gpgwin.h
@@ -113,6 +113,7 @@ private:
QAction *saveAct;
QAction *saveAsAct;
QAction *printAct;
+ QAction *closeTabAct;
QAction *quitAct;
QAction *encryptAct;
QAction *decryptAct;
@@ -151,7 +152,6 @@ private:
QLabel *statusBarIcon;
QSettings settings;
- QString curFile;
KeyList *mKeyList;
Attachments *mAttachments;
GpgME::Context *mCtx;
diff --git a/keylist.cpp b/keylist.cpp
index 3b1348d..8f40950 100644
--- a/keylist.cpp
+++ b/keylist.cpp
@@ -171,10 +171,10 @@ void KeyList::dropEvent(QDropEvent* event)
dialog->setWindowTitle(tr("Import Keys"));
QLabel *label;
- label = new QLabel(tr("Import keys from dropped files, if possible?"));
+ label = new QLabel(tr("You've dropped something on the keylist.\n gpg4usb will now try to import key(s).")+"\n");
// "always import keys"-CheckBox
- QCheckBox *checkBox = new QCheckBox(tr("Don't Ask Me Again."));
+ QCheckBox *checkBox = new QCheckBox(tr("Always import without bothering."));
if (settings.value("general/confirmImportKeys").toBool()) checkBox->setCheckState(Qt::Unchecked);
// Buttons for ok and cancel
diff --git a/settingsdialog.cpp b/settingsdialog.cpp
index 8e97928..215aa4f 100755
--- a/settingsdialog.cpp
+++ b/settingsdialog.cpp
@@ -99,9 +99,9 @@ class QGroupBox;
/*****************************************
* Key-Impport-Confirmation Box
*****************************************/
- QGroupBox *importConfirmationBox = new QGroupBox(tr("Confirm key import"));
+ QGroupBox *importConfirmationBox = new QGroupBox(tr("Confirm drag'n'drop key import"));
QHBoxLayout *importConfirmationBoxLayout = new QHBoxLayout();
- importConfirmationCheckBox= new QCheckBox(tr("Ask for confirmation to import, if keyfiles are dropped on the keylist."), this);
+ importConfirmationCheckBox= new QCheckBox(tr("Import files dropped on the keylist without confirmation."), this);
importConfirmationBoxLayout->addWidget(importConfirmationCheckBox);
importConfirmationBox->setLayout(importConfirmationBoxLayout);
diff --git a/textedit.cpp b/textedit.cpp
index 39e0626..b8d4109 100644
--- a/textedit.cpp
+++ b/textedit.cpp
@@ -41,9 +41,8 @@ TextEdit::TextEdit()
setLayout(layout);
connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(removeTab(int)));
-// connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(curSyntaxHiglight()));
newTab();
- setAcceptDrops(true);
+ setAcceptDrops(false);
}
@@ -88,39 +87,39 @@ void TextEdit::newTab()
void TextEdit::open()
{
- QString fileName = QFileDialog::getOpenFileName(this, tr("Open file"),
- QDir::currentPath());
- setCurrentFile(fileName);
- if (!fileName.isEmpty())
- {
- QFile file(fileName);
-
- if (file.open(QIODevice::ReadOnly | QIODevice::Text))
+ QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open file"),
+ QDir::currentPath());
+ foreach (QString fileName,fileNames){
+ if (!fileName.isEmpty())
{
- EditorPage *page = new EditorPage(fileName);
-
- QTextStream in(&file);
- QApplication::setOverrideCursor(Qt::WaitCursor);
- page->getTextPage()->setPlainText(in.readAll());
- page->setFilePath(fileName);
+ QFile file(fileName);
- QTextDocument *document = page->getTextPage()->document();
- document->setModified(false);
-
- tabWidget->addTab(page, strippedName(fileName));
- tabWidget->setCurrentIndex(tabWidget->count() - 1);
- QApplication::restoreOverrideCursor();
- connect(page->getTextPage(), SIGNAL(modificationChanged(bool)), this, SLOT(showModified()));
- // setCursorPosition();
- //enableAction(true)
-
- }
- else
- {
- QMessageBox::warning(this, tr("Application"),
- tr("Cannot read file %1:\n%2.")
- .arg(fileName)
- .arg(file.errorString()));
+ if (file.open(QIODevice::ReadOnly | QIODevice::Text))
+ {
+ EditorPage *page = new EditorPage(fileName);
+
+ QTextStream in(&file);
+ 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();
+ connect(page->getTextPage(), SIGNAL(modificationChanged(bool)), this, SLOT(showModified()));
+ // setCursorPosition();
+ //enableAction(true)
+ }
+ else
+ {
+ QMessageBox::warning(this, tr("Application"),
+ tr("Cannot read file %1:\n%2.")
+ .arg(fileName)
+ .arg(file.errorString()));
+ }
}
}
}
@@ -219,6 +218,10 @@ bool TextEdit::closeFile()
}
+void TextEdit::closeTab()
+{
+ removeTab(tabWidget->currentIndex());
+}
void TextEdit::removeTab(int index)
{
if (tabWidget->count() != 0)
@@ -373,13 +376,6 @@ void TextEdit::quote()
}
-bool TextEdit::isKey(QString key)
-{
- qDebug() << key.contains("-----BEGIN PGP PUBLIC KEY BLOCK-----", Qt::CaseSensitive);
- return true;
-}
-
-
void TextEdit::loadFile(const QString &fileName)
{
QFile file(fileName);
@@ -394,26 +390,10 @@ void TextEdit::loadFile(const QString &fileName)
QApplication::setOverrideCursor(Qt::WaitCursor);
curTextPage()->setPlainText(in.readAll());
QApplication::restoreOverrideCursor();
- curPage()->setFilePath(fileName);
- setCurrentFile(fileName);
+ curPage()->setFilePath(fileName);
// statusBar()->showMessage(tr("File loaded"), 2000);
}
-void TextEdit::setCurrentFile(const QString &fileName)
-{
- curFile = fileName;
- curTextPage()->document()->setModified(false);
- setWindowModified(false);
-
- QString shownName;
- if (curFile.isEmpty())
- shownName = "untitled.txt";
- else
- shownName = strippedName(curFile);
-
- //setWindowTitle(tr("%1[*] - %2").arg(shownName).arg(qApp->applicationName()));
-}
-
QString TextEdit::strippedName(const QString &fullFileName)
{
return QFileInfo(fullFileName).fileName();
diff --git a/textedit.h b/textedit.h
index 5ee9931..5e61721 100644
--- a/textedit.h
+++ b/textedit.h
@@ -41,7 +41,6 @@ class TextEdit : public QWidget
Q_OBJECT
public:
TextEdit();
- void setCurrentFile(const QString &fileName);
void loadFile(const QString &fileName);
bool maybeSave();
QPlainTextEdit* curTextPage();
@@ -54,11 +53,10 @@ public slots:
void print();
void newTab();
void showModified();
+ void closeTab();
private:
- bool isKey(QString key);
QString strippedName(const QString &fullFileName);
- QString curFile;
int countPage;
QTabWidget *tabWidget;
bool maybeSaveFile();