]> Shamusworld >> Repos - architektonas/blob - src/forms/exitdialog.cpp
Initial import
[architektonas] / src / forms / exitdialog.cpp
1 // exitdialog.cpp
2 //
3 // Originally part of QCad Community Edition by Andrew Mustun
4 // Extensively rewritten and refactored by James L. Hammons
5 // (C) 2010 Underground Software
6 //
7 // JLH = James L. Hammons <jlhamm@acm.org>
8 //
9 // Who  When        What
10 // ---  ----------  -----------------------------------------------------------
11 // JLH  05/12/2010  Created this file. :-)
12 //
13
14 #include "exitdialog.h"
15
16 #include <QMessageBox>
17
18 ExitDialog::ExitDialog(QWidget * parent/*= NULL*/, Qt::WindowFlags flags/*= 0*/):
19         QDialog(parent, flags)
20 {
21         ui.setupUi(this);
22
23 #if 0
24         //set dlg icon
25         QMessageBox mb("", "", QMessageBox::Warning, QMessageBox::Ok, Qt::NoButton, Qt::NoButton);
26         l_icon->setPixmap(*mb.iconPixmap());
27 #else
28 #warning "Needs porting to Qt4... !!! FIX !!!"
29 #endif
30 // Icons are now put on the form
31 //      bLeave->setIconSet(qPixmapFromMimeSource("fileclose.png"));
32 //      ui.bLeave->setIcon(QIcon(":/images/fileclose.png"));
33         makeLetterAccel(ui.bLeave);
34 //      bSave->setIconSet(qPixmapFromMimeSource("filesave2.png"));
35 //      ui.bSave->setIcon(QIcon(":/images/filesave2.png"));
36         makeLetterAccel(ui.bSave);
37 //      bSaveAs->setIconSet(qPixmapFromMimeSource("filesaveas.png"));
38 //      ui.bSaveAs->setIcon(QIcon(":/images/filesaveas.png"));
39         makeLetterAccel(ui.bSaveAs);
40         makeLetterAccel(ui.bCancel);
41 }
42
43 ExitDialog::~ExitDialog()
44 {
45 }
46
47 void ExitDialog::setText(const QString & text)
48 {
49         ui.lQuestion->setText(text);
50 #if 0
51         resize(lQuestion->sizeHint().width() + 32,
52                 lQuestion->sizeHint().height() + layButtons->sizeHint().height() + 32);
53 #else
54 #warning "Needs porting to Qt4... !!! FIX !!!"
55 #endif
56 }
57
58 void ExitDialog::setTitle(const QString & text)
59 {
60         setWindowTitle(text);
61 }
62
63 void ExitDialog::setForce(bool force)
64 {
65         ui.bCancel->setDisabled(force);
66 }
67
68 void ExitDialog::slotSaveAs()
69 {
70         done(3);
71 }
72
73 void ExitDialog::slotSave()
74 {
75         done(2);
76 }
77
78 //sets additional accel, eg. Key_A for ALT+Key_A
79 void ExitDialog::makeLetterAccel(QPushButton * btn)
80 {
81 #if 0
82         if (btn->accel().count() < 1)
83                 return;
84
85         Q3Accel * a = new Q3Accel(btn);
86         a->connectItem(a->insertItem(btn->accel() & ~(Qt::MODIFIER_MASK | Qt::UNICODE_ACCEL)),
87                 btn, SLOT(animateClick()));
88 #else
89 #warning "Needs porting to Qt4... !!! FIX !!!"
90 #endif
91 }