1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
|
/*
* gpgwin.cpp
*
* Copyright 2008 gpg4usb-team <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include "gpgwin.h"
#include "fileencryptiondialog.h"
#include "settingsdialog.h"
GpgWin::GpgWin()
{
mCtx = new GpgME::Context();
keyMgmt = NULL; // initialized on first key-management-window open
/* get path were app was started */
QString appPath = qApp->applicationDirPath();
iconPath = appPath + "/icons/";
edit = new QPlainTextEdit();
setCentralWidget(edit);
// setAcceptDrops(true);
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
/* the list of Keys available*/
mKeyList = new KeyList(mCtx, iconPath);
/* List of binary Attachments */
mAttachments = new Attachments(iconPath);
createActions();
createMenus();
createToolBars();
createStatusBar();
createDockWindows();
setCurrentFile("");
mKeyList->addMenuAction(appendSelectedKeysAct);
restoreSettings();
// open filename if provided as first command line parameter
QStringList args = qApp->arguments();
if(args.size() > 1) {
if(!args[1].startsWith("-")) {
if(QFile::exists(args[1]))
loadFile(args[1]);
}
}
}
void GpgWin::restoreSettings()
{
QSettings settings;
// state sets pos & size of dock-widgets
this->restoreState(settings.value("window/windowState").toByteArray());
// Restore window size & location
Qt::CheckState windowSave = static_cast<Qt::CheckState>(settings.value("window/windowSave", Qt::Unchecked).toUInt());
if (windowSave == Qt::Checked) {
QPoint pos = settings.value("window/pos", QPoint(100, 100)).toPoint();
QSize size = settings.value("window/size", QSize(800, 450)).toSize();
this->resize(size);
this->move(pos);
} else {
this->resize(QSize(800,450));
this->move(QPoint(100, 100));
}
// Iconsize
QSize iconSize = settings.value("toolbar/iconsize", QSize(32, 32)).toSize();
this->setIconSize(iconSize);
// Iconstyle
Qt::ToolButtonStyle buttonStyle = static_cast<Qt::ToolButtonStyle>(settings.value("toolbar/iconstyle", Qt::ToolButtonTextUnderIcon).toUInt());
this->setToolButtonStyle(buttonStyle);
// Checked Keys
Qt::CheckState keySave = static_cast<Qt::CheckState>(settings.value("keys/keySave", Qt::Unchecked).toUInt());
if (keySave == Qt::Checked) {
QStringList keyIds = settings.value("keys/keyList").toStringList();
mKeyList->setChecked(&keyIds);
}
}
void GpgWin::createActions()
{
/** Main Menu
*/
openAct = new QAction(tr("&Open..."), this);
openAct->setIcon(QIcon(iconPath + "fileopen.png"));
openAct->setShortcut(tr("Ctrl+O"));
openAct->setToolTip(tr("Open an existing file"));
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
saveAct = new QAction(tr("&Save"), this);
saveAct->setIcon(QIcon(iconPath + "filesave.png"));
saveAct->setShortcut(tr("Ctrl+S"));
saveAct->setToolTip(tr("Save the current File"));
connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
saveAsAct = new QAction(tr("Save &As"), this);
saveAsAct->setIcon(QIcon(iconPath + "filesaveas.png"));
saveAsAct->setToolTip(tr("Save the current File as..."));
connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
printAct = new QAction(tr("&Print"), this);
printAct->setIcon(QIcon(iconPath + "fileprint.png"));
printAct->setShortcut(tr("Ctrl+P"));
printAct->setToolTip(tr("Print Document"));
connect(printAct, SIGNAL(triggered()), this, SLOT(print()));
quitAct = new QAction(tr("&Quit"), this);
quitAct->setShortcut(tr("Ctrl+Q"));
quitAct->setIcon(QIcon(iconPath + "exit.png"));
quitAct->setToolTip(tr("Quit Program"));
connect(quitAct, SIGNAL(triggered()), this, SLOT(close()));
/** Edit Menu
*/
pasteAct = new QAction(tr("&Paste"), this);
pasteAct->setIcon(QIcon(iconPath + "button_paste.png"));
pasteAct->setShortcut(tr("Ctrl+V"));
pasteAct->setToolTip(tr("Paste Text From Clipboard"));
connect(pasteAct, SIGNAL(triggered()), edit, SLOT(paste()));
cutAct = new QAction(tr("Cu&t"), this);
cutAct->setIcon(QIcon(iconPath + "button_cut.png"));
cutAct->setShortcut(tr("Ctrl+X"));
cutAct->setToolTip(tr("Cut the current selection's contents to the "
"clipboard"));
connect(cutAct, SIGNAL(triggered()), edit, SLOT(cut()));
copyAct = new QAction(tr("&Copy"), this);
copyAct->setIcon(QIcon(iconPath + "button_copy.png"));
copyAct->setShortcut(tr("Ctrl+C"));
copyAct->setToolTip(tr("Copy the current selection's contents to the "
"clipboard"));
connect(copyAct, SIGNAL(triggered()), edit, SLOT(copy()));
selectallAct = new QAction(tr("Select &All"), this);
selectallAct->setIcon(QIcon(iconPath + "edit.png"));
selectallAct->setShortcut(tr("Ctrl+A"));
selectallAct->setToolTip(tr("Select the whole text"));
connect(selectallAct, SIGNAL(triggered()), edit, SLOT(selectAll()));
openSettingsAct = new QAction(tr("Se&ttings"), this);
openSettingsAct->setToolTip(tr("Open settings dialog"));
connect(openSettingsAct, SIGNAL(triggered()), this, SLOT(openSettingsDialog()));
/** Crypt Menu
*/
encryptAct = new QAction(tr("&Encrypt"), this);
encryptAct->setIcon(QIcon(iconPath + "encrypted.png"));
encryptAct->setShortcut(tr("Ctrl+E"));
encryptAct->setToolTip(tr("Encrypt Message"));
connect(encryptAct, SIGNAL(triggered()), this, SLOT(encrypt()));
decryptAct = new QAction(tr("&Decrypt"), this);
decryptAct->setIcon(QIcon(iconPath + "decrypted.png"));
decryptAct->setShortcut(tr("Ctrl+D"));
decryptAct->setToolTip(tr("Decrypt Message"));
connect(decryptAct, SIGNAL(triggered()), this, SLOT(decrypt()));
fileEncryptionAct = new QAction(tr("&File Encryption"), this);
fileEncryptionAct->setIcon(QIcon(iconPath + "fileencrytion.png"));
fileEncryptionAct->setToolTip(tr("Encrypt/Decrypt File"));
connect(fileEncryptionAct, SIGNAL(triggered()), this, SLOT(fileEncryption()));
/** Key Menu
*/
importKeyFromFileAct = new QAction(tr("&File"), this);
importKeyFromFileAct->setIcon(QIcon(iconPath + "misc_doc.png"));
importKeyFromFileAct->setToolTip(tr("Import New Key From File"));
connect(importKeyFromFileAct, SIGNAL(triggered()), this, SLOT(importKeyFromFile()));
importKeyFromEditAct = new QAction(tr("&Editor"), this);
importKeyFromEditAct->setIcon(QIcon(iconPath + "txt.png"));
importKeyFromEditAct->setToolTip(tr("Import New Key From Editor"));
connect(importKeyFromEditAct, SIGNAL(triggered()), this, SLOT(importKeyFromEdit()));
importKeyFromClipboardAct = new QAction(tr("&Clipboard"), this);
importKeyFromClipboardAct->setIcon(QIcon(iconPath + "button_paste.png"));
importKeyFromClipboardAct->setToolTip(tr("Import New Key From Clipboard"));
connect(importKeyFromClipboardAct, SIGNAL(triggered()), this, SLOT(importKeyFromClipboard()));
openKeyManagementAct = new QAction(tr("Key Management"), this);
openKeyManagementAct->setIcon(QIcon(iconPath + "keymgmt.png"));
openKeyManagementAct->setToolTip(tr("Open Keymanagement"));
connect(openKeyManagementAct, SIGNAL(triggered()), this, SLOT(openKeyManagement()));
importKeyDialogAct = new QAction(tr("Import Key"), this);
importKeyDialogAct->setIcon(QIcon(iconPath + "key_import.png"));
importKeyDialogAct->setToolTip(tr("Open Import New Key Dialog"));
connect(importKeyDialogAct, SIGNAL(triggered()), this, SLOT(importKeyDialog()));
/** About Menu
*/
aboutAct = new QAction(tr("&About"), this);
aboutAct->setIcon(QIcon(iconPath + "help.png"));
aboutAct->setToolTip(tr("Show the application's About box"));
connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
/** Popup-Menu-Action for KeyList
*/
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()));
}
void GpgWin::createMenus()
{
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(openAct);
fileMenu->addAction(saveAct);
fileMenu->addAction(saveAsAct);
fileMenu->addAction(printAct);
fileMenu->addSeparator();
fileMenu->addAction(quitAct);
editMenu = menuBar()->addMenu(tr("&Edit"));
editMenu->addAction(copyAct);
editMenu->addAction(cutAct);
editMenu->addAction(pasteAct);
editMenu->addAction(selectallAct);
editMenu->addAction(openSettingsAct);
cryptMenu = menuBar()->addMenu(tr("&Crypt"));
cryptMenu->addAction(encryptAct);
cryptMenu->addAction(decryptAct);
cryptMenu->addSeparator();
cryptMenu->addAction(fileEncryptionAct);
keyMenu = menuBar()->addMenu(tr("&Keys"));
importKeyMenu = keyMenu->addMenu(tr("&Import Key From..."));
importKeyMenu->setIcon(QIcon(iconPath + "key_import.png"));
importKeyMenu->addAction(importKeyFromFileAct);
importKeyMenu->addAction(importKeyFromEditAct);
importKeyMenu->addAction(importKeyFromClipboardAct);
keyMenu->addAction(openKeyManagementAct);
viewMenu = menuBar()->addMenu(tr("&View"));
helpMenu = menuBar()->addMenu(tr("&Help"));
helpMenu->addAction(aboutAct);
}
void GpgWin::createToolBars()
{
cryptToolBar = addToolBar(tr("Crypt"));
cryptToolBar->addAction(encryptAct);
cryptToolBar->addAction(decryptAct);
cryptToolBar->addAction(fileEncryptionAct);
viewMenu->addAction(cryptToolBar->toggleViewAction());
keyToolBar = addToolBar(tr("Key"));
keyToolBar->addAction(importKeyDialogAct);
keyToolBar->addAction(openKeyManagementAct);
viewMenu->addAction(keyToolBar->toggleViewAction());
editToolBar = addToolBar(tr("Edit"));
editToolBar->addAction(copyAct);
editToolBar->addAction(pasteAct);
editToolBar->addAction(selectallAct);
viewMenu->addAction(editToolBar->toggleViewAction());
}
void GpgWin::createStatusBar()
{
statusBar()->showMessage(tr("Ready"));
}
void GpgWin::createDockWindows()
{
/** KeyList-Dockwindow
*/
dock = new QDockWidget(tr("Encrypt for:"), this);
dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
addDockWidget(Qt::RightDockWidgetArea, dock);
dock->setWidget(mKeyList);
viewMenu->addAction(dock->toggleViewAction());
/** Attachments-Dockwindow
*/
aDock = new QDockWidget(tr("Attached files:"), this);
aDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea );
addDockWidget(Qt::BottomDockWidgetArea, aDock);
aDock->setWidget(mAttachments);
// hide till attachmendt is decrypted
aDock->hide();
}
void GpgWin::closeEvent(QCloseEvent *event)
{
/** ask to save changes, if text modified
*/
if (maybeSave()) {
event->accept();
} else {
event->ignore();
}
/** Save the settings
*/
QSettings settings;
// window position and size
settings.setValue("window/windowState", saveState());
settings.setValue("window/pos", pos());
settings.setValue("window/size", size());
// keyid-list of private checked keys
Qt::CheckState keySave = static_cast<Qt::CheckState>(settings.value("keys/keySave", Qt::Unchecked).toUInt());
if ( keySave == Qt::Checked ) {
QStringList *keyIds = mKeyList->getPrivateChecked();
if (!keyIds->isEmpty()){
settings.setValue("keys/keyList", *keyIds);
} else {
settings.setValue("keys/keyList","");
}
} else {
settings.remove("keys/keyList");
}
/********************
* Quit programm
* ******************/
QMainWindow::closeEvent(event);
}
void GpgWin::open()
{
if (maybeSave()) {
QString fileName = QFileDialog::getOpenFileName(this);
if (!fileName.isEmpty())
loadFile(fileName);
}
}
bool GpgWin::save()
{
if (curFile.isEmpty()) {
return saveAs();
} else {
return saveFile(curFile);
}
}
bool GpgWin::saveAs()
{
QString fileName = QFileDialog::getSaveFileName(this);
if (fileName.isEmpty())
return false;
return saveFile(fileName);
}
void GpgWin::loadFile(const QString &fileName)
{
QFile file(fileName);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
QMessageBox::warning(this, tr("Application"),
tr("Cannot read file %1:\n%2.")
.arg(fileName)
.arg(file.errorString()));
return;
}
QTextStream in(&file);
QApplication::setOverrideCursor(Qt::WaitCursor);
edit->setPlainText(in.readAll());
QApplication::restoreOverrideCursor();
setCurrentFile(fileName);
statusBar()->showMessage(tr("File loaded"), 2000);
}
void GpgWin::setCurrentFile(const QString &fileName)
{
curFile = fileName;
edit->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 GpgWin::strippedName(const QString &fullFileName)
{
return QFileInfo(fullFileName).fileName();
}
bool GpgWin::maybeSave()
{
if (edit->document()->isModified()) {
QMessageBox::StandardButton ret;
ret = QMessageBox::warning(this, tr("Application"),
tr("The document has been modified.\nDo you want to save your changes?"),
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
if (ret == QMessageBox::Save)
return save();
else if (ret == QMessageBox::Cancel)
return false;
}
return true;
}
bool GpgWin::saveFile(const QString &fileName)
{
QFile file(fileName);
if (!file.open(QFile::WriteOnly | QFile::Text)) {
QMessageBox::warning(this, tr("File"),
tr("Cannot write file %1:\n%2.")
.arg(fileName)
.arg(file.errorString()));
return false;
}
QTextStream out(&file);
QApplication::setOverrideCursor(Qt::WaitCursor);
out << edit->toPlainText();
QApplication::restoreOverrideCursor();
statusBar()->showMessage(tr("Saved '%1'").arg(fileName), 2000);
return true;
}
void GpgWin::print()
{
#ifndef QT_NO_PRINTER
QTextDocument *document = edit->document();
QPrinter printer;
QPrintDialog *dlg = new QPrintDialog(&printer, this);
if (dlg->exec() != QDialog::Accepted)
return;
document->print(&printer);
statusBar()->showMessage(tr("Ready"), 2000);
#endif
}
void GpgWin::about()
{
QMessageBox::about(this, tr("About ") + qApp->applicationName(),
"<center><h2>" + qApp->applicationName() + " "
+ qApp->applicationVersion() + "</h2></center>"
+ tr("<center>This Application allows you to do simple<br>"
"encryption/decryption of your text-message or file.<br>"
"It's licensed under the GPL v2.0<br><br>"
"<b>Developer:</b><br>"
"Bene, Heimer, Juergen, Nils, Ubbo<br><br>"
"<b>Translation:</b><br>"
"Alessandro (pt_br), Alex (fr), Kirill (ru), Viriato (es)<br><br>"
"If you have any questions and/or<br>"
"suggestions, contact us at<br>"
"gpg4usb at cpunk.de</a><br><br>"
"or feel free to meet us in our xmpp-channel:<br>"
"gpg4usb at conference.jabber.ccc.de</center>"));
}
void GpgWin::encrypt()
{
QStringList *uidList = mKeyList->getChecked();
QByteArray *tmp = new QByteArray();
if (mCtx->encrypt(uidList, edit->toPlainText().toUtf8(), tmp)) {
QString *tmp2 = new QString(*tmp);
edit->setPlainText(*tmp2);
}
}
void GpgWin::decrypt()
{
QByteArray *tmp = new QByteArray();
QByteArray text = edit->toPlainText().toAscii();
preventNoDataErr(&text);
mCtx->decrypt(text, tmp);
if (!tmp->isEmpty()) {
// is it mime? TODO: parseMime should be optional by setting
parseMime(tmp);
edit->setPlainText(QString::fromUtf8(*tmp));
}
}
/**
* if this is mime, split text and attachents...
* message contains only text afterwards
*/
void GpgWin::parseMime(QByteArray *message) {
if( ! Mime::isMultipart(message) ) {
qDebug() << "no multipart";
return;
}
qDebug() << "multipart";
QString pText;
bool showmadock = false;
Mime *mime = new Mime(message);
foreach(MimePart tmp, mime->parts()) {
if(tmp.getValue("Content-Type")=="text/plain") {
pText.append(QString(tmp.body));
}
else {
(mAttachments->addMimePart(&tmp));
showmadock=true;
}
}
*message = pText.toAscii();
if(showmadock) aDock->show();
}
/**
* if there is no '\n' before the PGP-Begin-Block, but for example a whitespace,
* GPGME doesn't recognise the Message as encrypted. This function adds '\n'
* before the PGP-Begin-Block, if missing.
*/
void GpgWin::preventNoDataErr(QByteArray *in)
{
int block_start = in->indexOf("-----BEGIN PGP MESSAGE-----");
if (block_start > 0 && in->at(block_start - 1) != '\n') {
in->insert(block_start, '\n');
}
}
void GpgWin::importKeyFromEdit()
{
mCtx->importKey(edit->toPlainText().toAscii());
}
void GpgWin::importKeyFromClipboard()
{
QClipboard *cb = QApplication::clipboard();
mCtx->importKey(cb->text(QClipboard::Clipboard).toAscii());
}
void GpgWin::importKeyFromFile()
{
QFile file;
QByteArray inBuffer;
QString fileName = QFileDialog::getOpenFileName(this, tr("Open Key"), "", tr("Key Files") + " (*.asc *.txt);;"+tr("All Files")+" (*)");
if (! fileName.isNull()) {
file.setFileName(fileName);
if (!file.open(QIODevice::ReadOnly)) {
qDebug() << tr("couldn't open file: ") + fileName;
}
QByteArray inBuffer = file.readAll();
mCtx->importKey(inBuffer);
}
}
void GpgWin::openKeyManagement()
{
if (!keyMgmt) {
keyMgmt = new KeyMgmt(mCtx, iconPath);
// keyMgmt->resize(800, 400);
}
keyMgmt->show();
keyMgmt->raise();
keyMgmt->activateWindow();
}
void GpgWin::importKeyDialog()
{
QDialog *dialog = new QDialog();
dialog->setWindowTitle(tr("Import Key"));
dialog->setModal(true);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
QGroupBox *groupBox = new QGroupBox(tr("Import Key From..."));
QRadioButton *radio1 = new QRadioButton(tr("&File"));
QRadioButton *radio2 = new QRadioButton(tr("&Editor"));
QRadioButton *radio3 = new QRadioButton(tr("&Clipboard"));
radio1->setChecked(true);
QVBoxLayout *vbox1 = new QVBoxLayout();
vbox1->addWidget(radio1);
vbox1->addWidget(radio2);
vbox1->addWidget(radio3);
groupBox->setLayout(vbox1);
QVBoxLayout *vbox2 = new QVBoxLayout();
vbox2->addWidget(groupBox);
vbox2->addWidget(buttonBox);
dialog->setLayout(vbox2);
if (dialog->exec() == QDialog::Accepted) {
if (radio1->isChecked()) importKeyFromFile();
if (radio2->isChecked()) importKeyFromEdit();
if (radio3->isChecked()) importKeyFromClipboard();
}
}
/**
* Append the selected (not checked!) Key(s) To Textedit
*/
void GpgWin::appendSelectedKeys()
{
QByteArray *keyArray = new QByteArray();
mCtx->exportKeys(mKeyList->getSelected(), keyArray);
edit->appendPlainText(*keyArray);
}
void GpgWin::fileEncryption()
{
new FileEncryptionDialog(mCtx, iconPath, this);
}
void GpgWin::openSettingsDialog()
{
QSettings settings;
new SettingsDialog(this);
// restoreSettings();
// Iconsize
QSize iconSize = settings.value("toolbar/iconsize", QSize(32, 32)).toSize();
this->setIconSize(iconSize);
// Iconstyle
Qt::ToolButtonStyle buttonStyle = static_cast<Qt::ToolButtonStyle>(settings.value("toolbar/iconstyle", Qt::ToolButtonTextUnderIcon).toUInt());
this->setToolButtonStyle(buttonStyle);
}
|