More Preferences Dialog Stub work

This commit is contained in:
Mark Watkins 2011-08-03 13:09:57 +10:00
parent 31ffec35dd
commit 8ca96d752f
3 changed files with 227 additions and 91 deletions

View File

@ -1,14 +1,74 @@
#include <QLabel>
#include <QColorDialog>
#include "preferencesdialog.h"
#include "ui_preferencesdialog.h"
#include "SleepLib/machine_common.h"
PreferencesDialog::PreferencesDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::PreferencesDialog)
{
ui->setupUi(this);
ui->eventTable->setColumnWidth(0,40);
ui->eventTable->setColumnWidth(1,50);
int row=0;
QTableWidgetItem *item;
QHash<ChannelID, Channel>::iterator ci;
for (ci=channel.begin();ci!=channel.end();ci++) {
if ((ci.value().channeltype()==CT_Event) || (ci.value().channeltype()==CT_Graph)) {
ui->eventTable->insertRow(row);
item=new QTableWidgetItem(ci.value().details());
ui->eventTable->setItem(row,2,item);
QCheckBox *c=new QCheckBox(ui->eventTable);
QLabel *pb=new QLabel(ui->eventTable);
pb->setText("foo");
ui->eventTable->setCellWidget(row,0,c);
ui->eventTable->setCellWidget(row,1,pb);
QColor a(random() % 255, random() %255, random()%255, 255);
QPalette p(a,a,a,a,a,a,a);
pb->setPalette(p);
pb->setAutoFillBackground(true);
pb->setBackgroundRole(QPalette::Background);
row++;
}
}
}
void PreferencesDialog::on_eventColor_selected(QString col)
{
}
PreferencesDialog::~PreferencesDialog()
{
delete ui;
}
void PreferencesDialog::on_combineSlider_sliderMoved(int position)
{
ui->combineLCD->display(position);
}
void PreferencesDialog::on_IgnoreSlider_sliderMoved(int position)
{
if (position>0) {
ui->IgnoreLCD->display(position);
} else ui->IgnoreLCD->display(tr("OFF"));
}
void PreferencesDialog::on_eventTable_doubleClicked(const QModelIndex &index)
{
int row=index.row();
int col=index.column();
if (col==1) {
QWidget *w=ui->eventTable->cellWidget(row,col);
QColorDialog a;
QColor color=w->palette().background().color();
a.setCurrentColor(color);
if (a.exec()==QColorDialog::Accepted) {
QColor c=a.currentColor();
QPalette p(c,c,c,c,c,c,c);
w->setPalette(p);
qDebug() << "Color accepted" << col;
}
}
}

View File

@ -2,7 +2,7 @@
#define PREFERENCESDIALOG_H
#include <QDialog>
#include <QModelIndex>
namespace Ui {
class PreferencesDialog;
}
@ -15,6 +15,14 @@ public:
explicit PreferencesDialog(QWidget *parent = 0);
~PreferencesDialog();
private slots:
void on_combineSlider_sliderMoved(int position);
void on_IgnoreSlider_sliderMoved(int position);
void on_eventColor_selected(QString);
void on_eventTable_doubleClicked(const QModelIndex &index);
private:
Ui::PreferencesDialog *ui;
};

View File

@ -29,13 +29,13 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>&amp;Sessions</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@ -51,9 +51,7 @@
<item>
<widget class="QTimeEdit" name="timeEdit">
<property name="toolTip">
<string>Sessions before this time will go to the previous calendar day.
You must restart SleepyHead to see these changes,
unless you haven't imported any data yet.</string>
<string>Sessions starting before this time will go to the previous calendar day.</string>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::UpDownArrows</enum>
@ -97,7 +95,7 @@ It will be faster changing to days you've already been to if you leave it on. </
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label">
<property name="text">
@ -109,62 +107,74 @@ It will be faster changing to days you've already been to if you leave it on. </
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QSlider" name="horizontalSlider">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Sessions shorter than this value will be kept together on the same day.
You must restart SleepyHead to see these changes,
unless you haven't imported any data yet.</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>240</number>
</property>
<property name="singleStep">
<number>15</number>
</property>
<property name="pageStep">
<number>60</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
<property name="invertedControls">
<bool>false</bool>
</property>
<property name="tickPosition">
<enum>QSlider::TicksAbove</enum>
</property>
<property name="tickInterval">
<number>15</number>
</property>
</widget>
</item>
<item>
<widget class="QLCDNumber" name="lcdNumber_2">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
</widget>
</item>
</layout>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Minutes</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QSlider" name="combineSlider">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Multiple sessions closer together than this value will be kept on the same day.
</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>240</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="pageStep">
<number>60</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
<property name="invertedControls">
<bool>false</bool>
</property>
<property name="tickPosition">
<enum>QSlider::TicksAbove</enum>
</property>
<property name="tickInterval">
<number>30</number>
</property>
</widget>
</item>
<item>
<widget class="QLCDNumber" name="combineLCD">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
@ -176,38 +186,52 @@ unless you haven't imported any data yet.</string>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QSlider" name="horizontalSlider_2">
<property name="toolTip">
<string>Sessions shorter than this will not be imported.
Changing this value only affects future imports.</string>
</property>
<property name="maximum">
<number>60</number>
</property>
<property name="pageStep">
<number>5</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksAbove</enum>
</property>
<property name="tickInterval">
<number>5</number>
</property>
</widget>
</item>
<item>
<widget class="QLCDNumber" name="lcdNumber">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
</widget>
</item>
</layout>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Minutes</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QSlider" name="IgnoreSlider">
<property name="toolTip">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Sessions shorter in duration than this will not be displayed&lt;span style=&quot; font-style:italic;&quot;&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-style:italic;&quot;&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="maximum">
<number>60</number>
</property>
<property name="pageStep">
<number>5</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksAbove</enum>
</property>
<property name="tickInterval">
<number>5</number>
</property>
</widget>
</item>
<item>
<widget class="QLCDNumber" name="IgnoreLCD">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
</widget>
</item>
</layout>
</item>
@ -226,6 +250,50 @@ Changing this value only affects future imports.</string>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>&amp;Events</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QTableWidget" name="eventTable">
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="rowCount">
<number>0</number>
</property>
<property name="columnCount">
<number>3</number>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string>Show</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
</property>
</column>
<column>
<property name="text">
<string>Colour</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
</property>
</column>
<column>
<property name="text">
<string>Event</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>