-
Notifications
You must be signed in to change notification settings - Fork 0
/
printerpage.cpp
69 lines (54 loc) · 1.79 KB
/
printerpage.cpp
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
#include "printerpage.h"
#include <kapp.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qdir.h>
#include <qpushbutton.h>
#include <kiconloader.h>
#include <kfm.h>
PrinterPage::PrinterPage(QWidget *parent, const char *name)
: QWidget(parent,name)
{
KIconLoader *iconLoader = kapp->getIconLoader();
QGridLayout *grid = new QGridLayout(this, 4,3, 8);
QPixmap pixmap(kapp->kde_datadir()+"/kdewizard/html/wizard_small.gif");
QLabel *l = new QLabel(this);
l->setPixmap(pixmap);
l->setFixedSize(pixmap.size());
grid->addMultiCellWidget(l, 0,1 ,1,2, AlignRight);
l = new QLabel(i18n("You will propably have a printer, don't you? "
"Then why not create a little icon for the printer that "
"allows you to drag & drop files to the printer, and to "
"invoke the printer queue utility!"), this);
l->setAlignment(WordBreak);
l->setBackgroundColor(white);
grid->addMultiCellWidget(l, 0,0, 0,1);
grid->setRowStretch(0,1);
l = new QLabel(i18n("Printer icon"), this);
l->setMinimumSize(l->sizeHint());
l->setAlignment(AlignTop);
l->setBackgroundColor(white);
grid->addWidget(l, 2,1);
QButton *button = new QPushButton(this);
button->setPixmap(iconLoader->loadIcon("printer.xpm"));
button->setFixedSize(button->sizeHint());
grid->addWidget(button, 2,0);
connect(button, SIGNAL(clicked()), this, SLOT(togglePrinter()));
grid->setRowStretch(3,1);
setBackgroundColor(white);
}
void PrinterPage::togglePrinter()
{
QString destname = QDir::homeDirPath()+"/Desktop/Printer.kdelnk";
QFile dest(destname);
if (dest.exists())
dest.remove();
else {
QString srcname = kapp->kde_datadir()+"/kdewizard/printer.kdelnk";
QString command = "cp "+srcname+" "+destname;
system(command.data());
}
KFM kfm;
kfm.refreshDesktop();
}
#include "printerpage.moc"