Scale identity combobox and send/cancel buttons according to screen DPI.
[kdepim.git] / ktimetracker / edittaskdialog.cpp
bloba53f0490c3798fd02bc1ae539e02c781b4a869ab
1 #include "edittaskdialog.h"
2 #include "ui_edittaskdialog.h"
3 #include "historydialog.h"
4 #include <KMessageBox>
5 #include "ktimetrackerutility.h"
6 #include <QCheckBox>
8 QVector<QCheckBox*> desktopcheckboxes;
10 EditTaskDialog::EditTaskDialog(TaskView *parent, const QString &caption, DesktopList* desktopList)
11 : QDialog( parent ),
12 m_ui(new Ui::EditTaskDialog)
14 setWindowTitle(caption);
15 m_parent=parent;
16 m_ui->setupUi(this);
18 { // Set the desktop checkboxes
19 QCheckBox* desktopcheckbox;
20 desktopcheckboxes.clear();
21 int lines=5;
22 for (int i=0; i<desktopcount(); ++i)
24 desktopcheckbox = new QCheckBox(m_ui->autotrackinggroupbox);
25 desktopcheckbox->setObjectName(QString::fromUtf8("desktop_").append(i));
26 desktopcheckbox->setText(KWindowSystem::desktopName( i + 1 ));
27 m_ui->gridLayout_2->addWidget(desktopcheckbox, i % lines, i / lines + 1);
28 desktopcheckboxes.push_back(desktopcheckbox);
30 if ( desktopList && ( desktopList->size() > 0 ) )
32 DesktopList::iterator it = desktopList->begin();
33 while ( it != desktopList->end() )
35 desktopcheckboxes[*it]->setChecked( true );
36 ++it;
38 m_ui->autotrackinggroupbox->setChecked(true);
40 else
41 for ( int i = 0; i < desktopcheckboxes.count(); i++ )
42 desktopcheckboxes[i]->setEnabled(false);
46 EditTaskDialog::~EditTaskDialog()
48 delete m_ui;
51 void EditTaskDialog::changeEvent(QEvent *e)
53 QDialog::changeEvent(e);
54 switch (e->type())
56 case QEvent::LanguageChange:
57 m_ui->retranslateUi(this);
58 break;
59 default:
60 break;
64 QString EditTaskDialog::taskName()
66 return m_ui->tasknamelineedit->text();
69 QString EditTaskDialog::timeChange()
71 return m_ui->letimechange->text();
74 void EditTaskDialog::setTask( const QString &name )
76 m_ui->tasknamelineedit->setText( name );
79 void EditTaskDialog::status(DesktopList *desktopList) const
81 if ( desktopList )
83 desktopList->clear();
84 for ( int i = 0; i < desktopcheckboxes.count(); i++ )
86 if ( desktopcheckboxes[i]->isEnabled() && desktopcheckboxes[i]->isChecked() ) desktopList->append( i );
91 void EditTaskDialog::on_edittimespushbutton_clicked()
93 historydialog* historydialog1=new historydialog(m_parent);
94 lower();
95 historydialog1->exec();
98 void EditTaskDialog::on_autotrackinggroupbox_clicked()
100 for ( int i = 0; i < desktopcheckboxes.count(); i++ )
101 desktopcheckboxes[i]->setEnabled(m_ui->autotrackinggroupbox->isChecked());