Skip to content
Snippets Groups Projects
Commit 7e32c6c3 authored by jpbl's avatar jpbl
Browse files

Added buttons to the GUI

parent eb802c8f
No related branches found
No related tags found
No related merge requests found
Showing
with 288 additions and 0 deletions
/*
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jerome Oufella (jerome.oufella@savoirfairelinux.com)
*
* Portions (c) Jean-Philippe Barrette-LaPierre
* (jean-philippe.barrette-lapierre@savoirfairelinux.com)
* Portions (c) Valentin Heinitz
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2,
* or (at your option) any later version.
*
* This is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with dpkg; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <QEvent>
#include <QMouseEvent>
#include <QPixmap>
#include "JPushButton.hpp"
JPushButton::JPushButton(const QPixmap &released,
const QPixmap &pressed,
QWidget* parent,
Qt::WFlags flags)
: QLabel(parent, flags)
{
mImages[0] = new QPixmap(released);
mImages[1] = new QPixmap(pressed);
release();
}
JPushButton::~JPushButton()
{
delete mImages[0];
delete mImages[1];
}
void
JPushButton::release()
{
resize(mImages[0]->size());
setPixmap (*mImages[0]);
}
void
JPushButton::press()
{
resize(mImages[1]->size());
setPixmap (*mImages[1]);
}
// Mouse button released
void
JPushButton::mousePressEvent(QMouseEvent *e)
{
switch (e->button()) {
case Qt::LeftButton:
press();
break;
default:
e->ignore();
break;
}
}
// Mouse button released
void
JPushButton::mouseReleaseEvent (QMouseEvent *e) {
switch (e->button()) {
case Qt::LeftButton:
release();
// Emulate the left mouse click
if (this->rect().contains(e->pos())) {
emit clicked();
}
break;
default:
e->ignore();
break;
}
}
void
JPushButton::mouseMoveEvent(QMouseEvent *e)
{
e->accept();
}
/*
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jerome Oufella (jerome.oufella@savoirfairelinux.com)
*
* Portions (c) Jean-Philippe Barrette-LaPierre
* (jean-philippe.barrette-lapierre@savoirfairelinux.com)
* Portions (c) Valentin Heinitz
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2,
* or (at your option) any later version.
*
* This is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with dpkg; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __J_PUSH_BUTTON_H__
#define __J_PUSH_BUTTON_H__
#include <QLabel>
/**
* This class Emulate a PushButton but takes two
* images to display its state.
*/
class JPushButton : public QLabel {
Q_OBJECT
public:
JPushButton(const QPixmap &released,
const QPixmap &pressed,
QWidget *parent,
Qt::WFlags flags = 0);
~JPushButton();
private:
/**
* This function will switch the button
*/
void press();
void release();
private:
QPixmap* mImages[2];
protected:
void mousePressEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
void mouseMoveEvent(QMouseEvent *);
signals:
void clicked(void);
};
#endif // defined(__J_PUSH_BUTTON_H__)
#include "SFLPhoneWindow.hpp"
#include <QLabel>
#include <QPixmap>
#include <iostream>
#include "JPushButton.hpp"
#define NBLINES 6
SFLPhoneWindow::SFLPhoneWindow()
: QMainWindow(NULL, 0)
// Qt::FramelessWindowHint)
{
setAttribute(Qt::WA_DeleteOnClose);
QLabel *l = new QLabel(this);
QPixmap main(":/images/main-img.png");
l->setPixmap(main);
resize(main.size());
l->resize(main.size());
initLineButtons();
}
void
SFLPhoneWindow::initLineButtons()
{
int xpos = 21;
int ypos = 151;
int offset = 31;
for(int i = 0; i < NBLINES; i++) {
JPushButton *line = new JPushButton(QPixmap(QString(":/images/line") +
QString::number(i + 1) +
"off-img.png"),
QPixmap(QString(":/images/line") +
QString::number(i + 1) +
"on-img.png"),
this);
line->move(xpos, ypos);
xpos += offset;
mLines.push_back(line);
}
}
#include <QMainWindow>
#include <list>
class JPushButton;
class SFLPhoneWindow : public QMainWindow
{
public:
SFLPhoneWindow();
void initLineButtons();
private:
std::list< JPushButton * > mLines;
};
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>SFLPhoneWindow</class>
<widget class="QMainWindow" name="SFLPhoneWindow" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>395</width>
<height>219</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle" >
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget" >
<widget class="QPushButton" name="pushButton" >
<property name="geometry" >
<rect>
<x>260</x>
<y>80</y>
<width>91</width>
<height>31</height>
</rect>
</property>
<property name="text" >
<string/>
</property>
</widget>
<widget class="QLabel" name="label" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>395</width>
<height>219</height>
</rect>
</property>
<property name="text" >
<string/>
</property>
<property name="pixmap" >
<pixmap resource="sflphone.qrc" >:/images/images/main.png</pixmap>
</property>
</widget>
</widget>
</widget>
<pixmapfunction></pixmapfunction>
<resources>
<include location="sflphone.qrc" />
</resources>
<connections/>
</ui>
src/gui/official/images/close_off.png

778 B

src/gui/official/images/close_on.png

806 B

src/gui/official/images/conference_off.png

2.3 KiB

src/gui/official/images/conference_on.png

2.32 KiB

src/gui/official/images/directory_off.png

2.02 KiB

src/gui/official/images/directory_on.png

2.05 KiB

src/gui/official/images/dtmf_0_off.png

1.58 KiB

src/gui/official/images/dtmf_0_on.png

1.64 KiB

src/gui/official/images/dtmf_1_off.png

1.39 KiB

src/gui/official/images/dtmf_1_on.png

1.41 KiB

src/gui/official/images/dtmf_2_off.png

2.18 KiB

src/gui/official/images/dtmf_2_on.png

2.22 KiB

src/gui/official/images/dtmf_3_off.png

2.18 KiB

src/gui/official/images/dtmf_3_on.png

2.22 KiB

src/gui/official/images/dtmf_4_off.png

2.04 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment