diff --git a/Ring.pro b/Ring.pro index fd92b74c240c7f98cb4eb58ddedf7cba5be48e1a..e57bf0334dcf3b57c2619fdfa09d349446f56bf7 100644 --- a/Ring.pro +++ b/Ring.pro @@ -14,9 +14,11 @@ TEMPLATE = app CONFIG += c++11 SOURCES += main.cpp\ - mainwindow.cpp + mainwindow.cpp \ + mylistview.cpp -HEADERS += mainwindow.h +HEADERS += mainwindow.h \ + mylistview.h FORMS += mainwindow.ui diff --git a/mainwindow.cpp b/mainwindow.cpp index e67c7791d216b454815ccfe2d655d973a06f80cb..a62a9adafec9efa5a70303d71dd553d70c035330 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -8,6 +8,11 @@ MainWindow::MainWindow(QWidget *parent) : ui(new Ui::MainWindow) { ui->setupUi(this); + ui->contact_list->setModel(CallModel::instance()); + ui->contact_list->setModel(HistoryModel::instance()); + ui->contact_list->setModel(ContactModel::instance()); + //setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint); + //setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint); mainAccount_ = AccountModel::currentAccount(); callModel_ = CallModel::instance(); @@ -21,22 +26,51 @@ MainWindow::MainWindow(QWidget *parent) : MainWindow::~MainWindow() { + if (mainCall_ != nullptr) + mainCall_->performAction(Call::Action::REFUSE); + delete mainAccount_; + delete mainCall_; delete ui; } +void MainWindow::mousePressEvent(QMouseEvent *e) +{ + clickPos_ = e->pos(); +} + +void MainWindow::mouseMoveEvent(QMouseEvent *e) +{ + qDebug() << clickPos_; + move(e->globalPos() - clickPos_); +} + + + //// SLOTS //// -void MainWindow::on_pushButton_clicked() +void MainWindow::on_call_button_clicked() { mainCall_ = CallModel::instance()->dialingCall(); mainCall_->setDialNumber(ui->call_number->text()); mainCall_->performAction(Call::Action::ACCEPT); } +void MainWindow::on_hangup_button_clicked() +{ + if (mainCall_) + mainCall_->performAction(Call::Action::REFUSE); +} + void MainWindow::on_state_changed(Call *call, Call::State previousState) { qDebug() << "on state changed!" << endl; } +void MainWindow::pollEvents() +{ + qDebug() << "Poll Events?"; + AccountModel::currentAccount()->poll_events(); +} + diff --git a/mainwindow.h b/mainwindow.h index 363a954469840c1c6f054cb207df1b189e1c20fc..2da6f54ee0aa897fbf4e1cbc05d63d9f60b13f1f 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -5,6 +5,7 @@ #include <QDebug> #include <QMainWindow> #include <QTimer> +#include <QMouseEvent> #include <memory> @@ -12,6 +13,8 @@ #include <accountmodel.h> #include <call.h> #include <callmodel.h> +#include <contactmodel.h> +#include <historymodel.h> namespace Ui { class MainWindow; @@ -25,24 +28,27 @@ public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); -private slots: - void on_pushButton_clicked(); - void on_state_changed(Call* call, Call::State previousState); +protected: + void mousePressEvent(QMouseEvent *); + void mouseMoveEvent(QMouseEvent *); + +private: + private slots: - void pollEvents() { - qDebug() << "Poll Events?"; - AccountModel::currentAccount()->poll_events(); - } + void on_call_button_clicked(); + void on_state_changed(Call* call, Call::State previousState); + void on_hangup_button_clicked(); + void pollEvents(); private: Ui::MainWindow *ui; - CallModel* callModel_; - Call* mainCall_; + CallModel* callModel_{nullptr}; + Call* mainCall_{nullptr}; Account* mainAccount_; QString savedNumber_; - QTimer pollTimer_; + QPoint clickPos_{QPoint(0,0)}; }; #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index fd160123ca192adce64574174a5d74ce4616f35a..7a5641e3424cc46a732318c9b094c5273c7184e1 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -6,82 +6,170 @@ <rect> <x>0</x> <y>0</y> - <width>326</width> - <height>207</height> + <width>766</width> + <height>597</height> </rect> </property> <property name="windowTitle"> <string>MainWindow</string> </property> <widget class="QWidget" name="centralWidget"> - <layout class="QVBoxLayout" name="verticalLayout"> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <property name="spacing"> + <number>0</number> + </property> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> <item> - <spacer name="verticalSpacer_3"> + <widget class="QSplitter" name="splitter"> <property name="orientation"> - <enum>Qt::Vertical</enum> + <enum>Qt::Horizontal</enum> </property> - <property name="sizeHint" stdset="0"> - <size> - <width>17</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLineEdit" name="call_number"> - <property name="text"> - <string>192.168.49.103</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton"> - <property name="text"> - <string>Call</string> + <property name="handleWidth"> + <number>0</number> </property> + <widget class="QWidget" name=""> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="spacing"> + <number>10</number> + </property> + <property name="leftMargin"> + <number>20</number> + </property> + <property name="topMargin"> + <number>10</number> + </property> + <property name="bottomMargin"> + <number>10</number> + </property> + <item> + <widget class="QLineEdit" name="lineEdit"> + <property name="text"> + <string/> + </property> + <property name="frame"> + <bool>true</bool> + </property> + <property name="placeholderText"> + <string>Search</string> + </property> + <property name="clearButtonEnabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="pushButton"> + <property name="text"> + <string>M</string> + </property> + <property name="autoDefault"> + <bool>false</bool> + </property> + <property name="default"> + <bool>false</bool> + </property> + <property name="flat"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="MyListView" name="contact_list"> + <property name="styleSheet"> + <string notr="true">background-color: rgba(255,255,255, 0.0);</string> + </property> + <property name="frameShape"> + <enum>QFrame::NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Plain</enum> + </property> + <property name="lineWidth"> + <number>0</number> + </property> + <property name="flow"> + <enum>QListView::TopToBottom</enum> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name=""> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QWidget" name="widget" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="styleSheet"> + <string notr="true">background-color: rgb(255,255,255);</string> + </property> + </widget> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLineEdit" name="call_number"> + <property name="text"> + <string>192.168.49.103</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QPushButton" name="call_button"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Call</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="hangup_button"> + <property name="text"> + <string>Hang up</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QPushButton" name="answer_button"> + <property name="text"> + <string>Answer</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> </widget> </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>17</width> - <height>1</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="pushButton_3"> - <property name="text"> - <string>Answer</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_2"> - <property name="text"> - <string>Hang up</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer_2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>17</width> - <height>0</height> - </size> - </property> - </spacer> - </item> </layout> </widget> <widget class="QMenuBar" name="menuBar"> @@ -89,19 +177,26 @@ <rect> <x>0</x> <y>0</y> - <width>326</width> + <width>766</width> <height>22</height> </rect> </property> </widget> </widget> <layoutdefault spacing="6" margin="11"/> + <customwidgets> + <customwidget> + <class>MyListView</class> + <extends>QListView</extends> + <header>mylistview.h</header> + </customwidget> + </customwidgets> <resources/> <connections> <connection> <sender>call_number</sender> <signal>returnPressed()</signal> - <receiver>pushButton</receiver> + <receiver>call_button</receiver> <slot>animateClick()</slot> <hints> <hint type="sourcelabel"> diff --git a/mylistview.cpp b/mylistview.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4442c25bbc78f8dfd0e920d4b2b3aa35c58b2082 --- /dev/null +++ b/mylistview.cpp @@ -0,0 +1,7 @@ +#include "mylistview.h" + +MyListView::MyListView(QWidget *parent) : + QListView(parent) +{ + setAttribute(Qt::WA_MacShowFocusRect, false); +} diff --git a/mylistview.h b/mylistview.h new file mode 100644 index 0000000000000000000000000000000000000000..5cee6b71a19b4b0ecc016a574445cdaab55b6681 --- /dev/null +++ b/mylistview.h @@ -0,0 +1,19 @@ +#ifndef MYLISTVIEW_H +#define MYLISTVIEW_H + +#include <QWidget> +#include <QListView> + +class MyListView : public QListView +{ + Q_OBJECT +public: + explicit MyListView(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // MYLISTVIEW_H