* First build on Linux

* Added EditDeviceDialog
* Added SystrayIcon
This commit is contained in:
Micke Prag 2008-12-15 23:00:07 +00:00
parent c3d04c6b69
commit ab2d72683f
18 changed files with 185 additions and 22 deletions

View file

@ -4,8 +4,12 @@
TARGET = TelldusCenter
TEMPLATE = app
SOURCES += main.cpp \
mainwindow.cpp
HEADERS += mainwindow.h
mainwindow.cpp \
tellduscenterapplication.cpp
HEADERS += mainwindow.h \
tellduscenterapplication.h
FORMS +=
RESOURCES += resource.qrc
LIBS += -lTelldusGui -L../TelldusGui
macx:LIBS += -lTelldusGui \
-L../TelldusGui
!macx:LIBS += -ltelldus-gui

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -1,12 +1,14 @@
#include <QtGui/QApplication>
#include "tellduscenterapplication.h"
#include "mainwindow.h"
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE( resource );
QApplication a(argc, argv);
TelldusCenterApplication application(argc, argv);
MainWindow *w = new MainWindow();
w->show();
return a.exec();
return application.exec();
}

View file

@ -5,9 +5,10 @@
#include <QStackedWidget>
#include <QStatusBar>
#include <QToolBar>
#include <QMessageBox>
#include "../TelldusGui/TelldusGui_global.h"
#include "../TelldusGui/telldusgui.h"
MainWindow::MainWindow(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
@ -40,13 +41,18 @@ void MainWindow::setupMenu()
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
helpMenu->addSeparator();
helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));
helpMenu->addAction(tr("About &TelldusCenter"), this, SLOT(slotAboutApplication()));
helpMenu->addAction(tr("About &Telldus Center"), this, SLOT(slotAboutApplication()));
}
void MainWindow::setupToolBar()
{
setUnifiedTitleAndToolBarOnMac(true);
m_pagesBar = addToolBar(tr("Pages"));
#if defined(Q_WS_MAC)
m_pagesBar->setIconSize(QSize(18, 18));
#else
m_pagesBar->setIconSize(QSize(32, 32));
#endif
QActionGroup *ag = new QActionGroup(this);
@ -56,3 +62,10 @@ void MainWindow::setupToolBar()
ag->addAction(actionDevices);
m_pagesBar->addActions( ag->actions() );
}
void MainWindow::slotAboutApplication() {
QMessageBox::about(this, tr("About Telldus Center"),
tr("<h2>Telldus Center 0.1</h2>"
"<p>Copyright &copy; 2008 Telldus Technologies AB<p>"
"<p>Telldus Center is a configuration utility for Telldus TellStick&reg;</p>"));
}

View file

@ -13,6 +13,9 @@ public:
MainWindow(QWidget *parent = 0, Qt::WFlags flags = 0);
~MainWindow();
private slots:
void slotAboutApplication();
private:
void setupMenu();
void setupToolBar();

View file

@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/" >
<file>images/devices-bw.png</file>
<file>images/devices.png</file>
</qresource>
</RCC>

View file

@ -0,0 +1,22 @@
#include "tellduscenterapplication.h"
TelldusCenterApplication::TelldusCenterApplication(int &argc, char **argv)
:QApplication(argc, argv),
systrayIcon(this)
{
#if defined(Q_WS_MAC)
systrayIcon.setIcon(QIcon(":/images/devices-bw.png"));
#else
systrayIcon.setIcon(QIcon(":/images/devices.png"));
#endif
systrayIcon.show();
//setQuitOnLastWindowClosed( false );
}
TelldusCenterApplication::~TelldusCenterApplication() {
}
TelldusCenterApplication *TelldusCenterApplication::instance() {
return (static_cast<TelldusCenterApplication *>(QCoreApplication::instance()));
}

View file

@ -0,0 +1,20 @@
#ifndef TELLDUSCENTERAPPLICATION_H
#define TELLDUSCENTERAPPLICATION_H
#include <QApplication>
#include <QSystemTrayIcon>
class TelldusCenterApplication : public QApplication
{
Q_OBJECT
public:
TelldusCenterApplication(int &argc, char **argv);
virtual ~TelldusCenterApplication();
static TelldusCenterApplication *instance();
private:
QSystemTrayIcon systrayIcon;
};
#endif // TELLDUSCENTERAPPLICATION_H

View file

@ -1,24 +1,28 @@
# -------------------------------------------------
# Project created by QtCreator 2008-12-11T15:48:29
# -------------------------------------------------
TARGET = TelldusGui
TEMPLATE = lib
DEFINES += TELLDUSGUI_LIBRARY
SOURCES += telldusgui.cpp \
devicewidget.cpp \
devicemodel.cpp \
devicesetting/devicesetting.cpp \
device.cpp
devicemodel.cpp \ # devicesetting/devicesetting.cpp \
device.cpp \
editdevicedialog.cpp
HEADERS += telldusgui.h \
TelldusGui_global.h \
devicewidget.h \
devicemodel.h \
devicesetting/devicesetting.h \
device.h
devicemodel.h \ # devicesetting/devicesetting.h \
device.h \
editdevicedialog.h
FORMS +=
macx {
LIBS += -framework \
telldus-core
ICON = images/telldussetup.icns
TARGET = TelldusGui
}
RESOURCES += resource.qrc
!macx {
LIBS += -l \
telldus-core
TARGET = telldus-gui
}
RESOURCES += telldusgui.qrc

View file

@ -54,14 +54,17 @@ bool DeviceModel::removeRows ( int row, int count, const QModelIndex & parent )
return true;
}
const Device &DeviceModel::newDevice() const {
Device *DeviceModel::newDevice() const {
Device *device = Device::newDevice();
connect(device, SIGNAL(deviceAdded(int)), this, SLOT(deviceAdded(int)));
return *device;
return device;
}
void DeviceModel::deviceAdded( int id ) {
qDebug("Yes");
int deviceCount = tdGetNumberOfDevices();
beginInsertRows( QModelIndex(), deviceCount - 1, deviceCount );
qDebug() << "Ny enhet: " << id;
endInsertRows();
}
int DeviceModel::deviceId( const QModelIndex &index ) const {

View file

@ -19,7 +19,7 @@ public:
virtual bool removeRows ( int row, int count, const QModelIndex & parent = QModelIndex() );
const Device &newDevice() const;
Device *newDevice() const;
private slots:
void deviceAdded( int id );

View file

@ -6,6 +6,8 @@
#include <QHBoxLayout>
#include <QMessageBox>
#include "editdevicedialog.h"
DeviceWidget::DeviceWidget(QWidget *parent) :
QWidget(parent),
deviceView(this),
@ -22,6 +24,7 @@ DeviceWidget::DeviceWidget(QWidget *parent) :
buttonLayout->setSpacing(0);
addToolButton.setIcon( QIcon( ":/images/list-add.png" ) );
connect(&addToolButton, SIGNAL(clicked()), this, SLOT(addDevice()));
buttonLayout->addWidget( &addToolButton );
removeToolButton.setIcon( QIcon( ":/images/list-remove.png" ) );
@ -49,6 +52,19 @@ void DeviceWidget::changeEvent(QEvent *e)
}
}
void DeviceWidget::addDevice() {
Device *device = model.newDevice();
EditDeviceDialog *dialog = new EditDeviceDialog( );
if (dialog->exec() == QDialog::Accepted) {
//device->save();
} else {
delete device;
}
delete dialog;
}
void DeviceWidget::deleteDevice() {
QMessageBox msgBox;
msgBox.setText( tr("Are you sure you want to remove the selected device?") );

View file

@ -19,6 +19,7 @@ protected:
private slots:
void listActivated(const QModelIndex &);
void addDevice();
void deleteDevice();
private:

View file

@ -0,0 +1,58 @@
#include "editdevicedialog.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QStackedLayout>
#include <QFormLayout>
#include <QTreeView>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
#include <QDialogButtonBox>
EditDeviceDialog::EditDeviceDialog(QWidget *parent, Qt::WFlags flags)
:QDialog(parent, flags)
{
QVBoxLayout *layout = new QVBoxLayout(this);
QHBoxLayout *deviceLayout = new QHBoxLayout(this);
QTreeView *deviceView = new QTreeView(this);
deviceLayout->addWidget(deviceView);
QGroupBox *deviceGroupBox = new QGroupBox(this);
deviceGroupBox->setTitle( tr("Device") );
deviceGroupBox->setLayout(deviceLayout);
layout->addWidget(deviceGroupBox);
QVBoxLayout *addressLayout = new QVBoxLayout(this);
QFormLayout *nameLayout = new QFormLayout(this);
QLabel *nameLabel = new QLabel(this);
nameLabel->setText( tr("&Name:") );
QLineEdit *nameLineEdit = new QLineEdit( this );
nameLabel->setBuddy(nameLineEdit);
nameLayout->addRow(nameLabel, nameLineEdit);
addressLayout->addLayout( nameLayout );
QStackedLayout *settingsLayout = new QStackedLayout(this);
QLabel *noDeviceLabel = new QLabel( tr("Choose a device above"), this );
noDeviceLabel->setAlignment( Qt::AlignCenter );
settingsLayout->addWidget( noDeviceLabel );
addressLayout->addLayout(settingsLayout);
QGroupBox *settingsGroupBox = new QGroupBox(this);
settingsGroupBox->setTitle( tr("Addresscode") );
settingsGroupBox->setLayout( addressLayout );
layout->addWidget( settingsGroupBox );
QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
buttonBox->setStandardButtons( QDialogButtonBox::Save | QDialogButtonBox::Cancel );
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
layout->addWidget(buttonBox);
}
EditDeviceDialog::~EditDeviceDialog() {
}

View file

@ -0,0 +1,16 @@
#ifndef EDITDEVICEDIALOG_H
#define EDITDEVICEDIALOG_H
#include <QDialog>
class EditDeviceDialog : public QDialog
{
public:
EditDeviceDialog(QWidget *parent = 0, Qt::WFlags flags = 0);
virtual ~EditDeviceDialog();
private:
};
#endif // EDITDEVICEDIALOG_H

View file

@ -1,4 +1,4 @@
#include "TelldusGui_global.h"
#include "telldusgui.h"
#include "devicewidget.h"