| 1 | #include <mainwindow/mainwindow.h> |
|---|
| 2 | #include "ui_mainwindow.h" |
|---|
| 3 | |
|---|
| 4 | #include <call/calls.h> |
|---|
| 5 | #include <chat/chatwindow.h> |
|---|
| 6 | #include <contacts/contacts.h> |
|---|
| 7 | #include <contacts/contactwidget.h> |
|---|
| 8 | #include <callbar/callbar.h> |
|---|
| 9 | #include <statusbar/statusbar.h> |
|---|
| 10 | #include <profilebar/profilebar.h> |
|---|
| 11 | #include <wizard/wizard.h> |
|---|
| 12 | |
|---|
| 13 | MainWindow * MainWindow::_self = 0; |
|---|
| 14 | |
|---|
| 15 | MainWindow::MainWindow(QWidget *parent) : |
|---|
| 16 | QMainWindow(parent), |
|---|
| 17 | ui(new Ui::MainWindow) |
|---|
| 18 | { |
|---|
| 19 | ui->setupUi(this); |
|---|
| 20 | QWidget * widget = new QWidget; |
|---|
| 21 | |
|---|
| 22 | QVBoxLayout * lay = new QVBoxLayout; |
|---|
| 23 | lay->setMargin(0); |
|---|
| 24 | lay->setSpacing(0); |
|---|
| 25 | widget->setLayout(lay); |
|---|
| 26 | #if defined(OS_MACOSX) |
|---|
| 27 | setUnifiedTitleAndToolBarOnMac(true); |
|---|
| 28 | _toolBar = new QToolBar; |
|---|
| 29 | _toolBar->addWidget(ProfileBar::self()); |
|---|
| 30 | addToolBar(_toolBar); |
|---|
| 31 | #else |
|---|
| 32 | QHBoxLayout * hLayout = new QHBoxLayout; |
|---|
| 33 | hLayout->addWidget(ProfileBar::self()); |
|---|
| 34 | hLayout->addStretch(); |
|---|
| 35 | lay->addLayout(hLayout); |
|---|
| 36 | #endif |
|---|
| 37 | |
|---|
| 38 | lay->addWidget(Contacts::self()); |
|---|
| 39 | lay->addWidget(CallBar::self()); |
|---|
| 40 | setCentralWidget(widget); |
|---|
| 41 | setStatusBar(StatusBar::self()); |
|---|
| 42 | |
|---|
| 43 | ChatWindow::self(); |
|---|
| 44 | Calls::self(); |
|---|
| 45 | |
|---|
| 46 | connect(CallBar::self(),SIGNAL(textChangedSignal(const QString &)),Contacts::self(),SLOT(setFilterSlot(const QString &))); |
|---|
| 47 | connect(ui->actionWizard,SIGNAL(triggered()),Wizard::self(),SLOT(show())); |
|---|
| 48 | connect(ui->actionAdd,SIGNAL(triggered()),this,SLOT(actionAddContactClickedSlot())); |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | MainWindow::~MainWindow() |
|---|
| 52 | { |
|---|
| 53 | delete ChatWindow::self(); |
|---|
| 54 | delete Calls::self(); |
|---|
| 55 | delete ui; |
|---|
| 56 | delete StatusBar::self(); |
|---|
| 57 | delete ProfileBar::self(); |
|---|
| 58 | delete Contacts::self(); |
|---|
| 59 | delete CallBar::self(); |
|---|
| 60 | #if defined(OS_MACOSX) |
|---|
| 61 | delete _toolBar; |
|---|
| 62 | #endif |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | void MainWindow::actionWizardClickedSlot() |
|---|
| 66 | { |
|---|
| 67 | Wizard::self()->show(); |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | void MainWindow::actionAddContactClickedSlot() |
|---|
| 71 | { |
|---|
| 72 | ContactWidget contactWidget; |
|---|
| 73 | contactWidget.exec(); |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | MainWindow * MainWindow::self() |
|---|
| 77 | { |
|---|
| 78 | if(!_self) |
|---|
| 79 | _self = new MainWindow; |
|---|
| 80 | |
|---|
| 81 | return _self; |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | void MainWindow::changeEvent(QEvent *e) |
|---|
| 85 | { |
|---|
| 86 | QMainWindow::changeEvent(e); |
|---|
| 87 | switch (e->type()) { |
|---|
| 88 | case QEvent::LanguageChange: |
|---|
| 89 | ui->retranslateUi(this); |
|---|
| 90 | break; |
|---|
| 91 | default: |
|---|
| 92 | break; |
|---|
| 93 | } |
|---|
| 94 | } |
|---|