Skip to content

Commit

Permalink
blink1control: more ifttt fixes, even more work on preferences window
Browse files Browse the repository at this point in the history
  • Loading branch information
todbot committed Aug 26, 2014
1 parent 985fd45 commit b16181f
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 33 deletions.
Binary file added qt/blink1control/images/gear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 26 additions & 10 deletions qt/blink1control/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <QClipboard>


#include "patternsReadOnly.h"

enum {
Expand All @@ -34,7 +35,7 @@ MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
fromPattern=false;
mk2=false;
mk2=true;
blinkStatus="";
iftttKey="";
blink1Id="none";
Expand Down Expand Up @@ -697,6 +698,7 @@ void MainWindow::loadSettings()
QJsonArray qarr = doc.array();

qint64 nowSecs = QDateTime::currentDateTime().toMSecsSinceEpoch()/1000;
lastIftttDate = nowSecs;

for( int i=0; i< qarr.size(); i++ ) {
Blink1Pattern* bp = new Blink1Pattern();
Expand Down Expand Up @@ -728,19 +730,19 @@ void MainWindow::loadSettings()
inputs.insert( bi->name(), bi );
// find most recent ifttt time
if( bi->type() == "ifttt" ) {
//qDebug() << "iftttTime: "<<bi->date();
if( bi->date() > nowSecs || bi->date() == 0 ) { // if bad stored date, fix it
qDebug() << "input name:"<<bi->name() <<" iftttTime: "<<bi->date() << " nowSecs: "<<nowSecs;
if( bi->date() > nowSecs || bi->date() < 1 ) { // if bad stored date, fix it
bi->setDate( nowSecs );
}
if( bi->date() > lastIftttDate )
lastIftttDate = bi->date();
//if( bi->date() > lastIftttDate )
// lastIftttDate = bi->date();
}
}
}
if( lastIftttDate > nowSecs ) {
qDebug() << "lastIftttDate: bad date in input";
lastIftttDate = nowSecs;
}
//if( lastIftttDate > nowSecs ) {
// qDebug() << "lastIftttDate: bad date in input: "<< lastIftttDate;
// lastIftttDate = nowSecs;
//}

QString sButtStr = settings.value("bigbuttons2","").toString();
if( sButtStr.length() ) {
Expand Down Expand Up @@ -882,6 +884,7 @@ void MainWindow::createActions()
#endif
minimizeAction = new QAction(tr("Start minimized"), this);
connect(minimizeAction,SIGNAL(triggered()),this,SLOT(changeMinimizeOption()));
//connect(minimizeAction,SIGNAL(triggered()),this,SLOT(updatePreferences()));
minimizeAction->setCheckable(true);
minimizeAction->setChecked(startmin);
restoreAction = new QAction(tr("&Restore"), this);
Expand All @@ -893,10 +896,12 @@ void MainWindow::createActions()
autorunAction->setCheckable(true);
autorunAction->setChecked(autorun);
connect(autorunAction,SIGNAL(triggered()),this,SLOT(setAutorun()));
//connect(autorunAction,SIGNAL(triggered()),this,SLOT(updatePreferences()));
dockIconAction=new QAction("Show Dock Icon",this);
dockIconAction->setCheckable(true);
dockIconAction->setChecked(dockIcon);
connect(dockIconAction,SIGNAL(triggered()),this,SLOT(showhideDockIcon()));
//connect(dockIconAction,SIGNAL(triggered()),this,SLOT(updatePreferences()));
settingAction=new QAction("Open Settings",this);
connect(settingAction,SIGNAL(triggered()),this,SLOT(showNormal()));
alertsAction=new QAction("Reset Alerts",this);
Expand All @@ -905,6 +910,7 @@ void MainWindow::createActions()
serverAction->setCheckable(true);
serverAction->setChecked(enableServer);
connect(serverAction,SIGNAL(triggered()),this,SLOT(startStopServer()));
//connect(serverAction,SIGNAL(triggered()),this,SLOT(updatePreferences()));

// shortcuts don't work apparently in traymenus
//alertsAction->setShortcut(Qt::Key_R | Qt::CTRL);
Expand Down Expand Up @@ -1071,7 +1077,7 @@ void MainWindow::showNormal(){
//viewer.setWindowState( (windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
viewer.requestActivate();
//viewer.activateWindow(); // for Windows
}
}
void MainWindow::playBigButton(int idx){
blink1timer->stop();
QString tmp=bigButtons2.at(idx)->getPatternName();
Expand Down Expand Up @@ -1154,6 +1160,16 @@ void MainWindow::startStopServer(){
addToLog("SERVER IS "+QString::number(httpserver->status()));
}

void MainWindow::updatePreferences() {
qDebug() << "updatePreferences";

serverAction->setChecked( enableServer );
dockIconAction->setChecked( dockIcon );

showhideDockIcon();
startStopServer();

}

QList<QObject*> MainWindow::getPatternsList(){
QList<QObject*> patternsList;
Expand Down
1 change: 1 addition & 0 deletions qt/blink1control/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public slots:
void updatePatternsList();
void changeInputName(QString oldName,QString newName);

void updatePreferences();
void setAutorun();
void showhideDockIcon();
void checkInput(QString key);
Expand Down
1 change: 1 addition & 0 deletions qt/blink1control/myresources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,6 @@
<file>images/layout/dropdown-bg.png</file>
<file>images/layout/select-bg-right.png</file>
<file>images/blink1-icon0-bw.png</file>
<file>images/gear.png</file>
</qresource>
</RCC>
28 changes: 20 additions & 8 deletions qt/blink1control/qml/qml/PreferencesWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Window 2.1

//import "ToolTipTod2Creator.js" as ToolTipCreator

Window {
id: prefsWindow

width: mw.mac() ? 580 : 550 // Win version experimentally determined
height: mw.mac() ? 440 : 390
width: mw.mac() ? 575 : 560 // Win version experimentally determined
height: mw.mac() ? 465 : 410
// FIXME: surely there's a shorter way of saying "no resize"?
maximumWidth: width
maximumHeight: height
Expand All @@ -28,21 +29,26 @@ Window {

ColumnLayout {
id: mainLayout
spacing: 10
spacing: 15
RowLayout {
id: mainbox
spacing: 20
ColumnLayout {
id: leftcolumn
Layout.alignment: Qt.AlignTop
Layout.minimumWidth: 280

Layout.minimumWidth: 260
spacing: 15

GroupBox {
id: groupGeneral
title: "General"
Layout.fillWidth: true
ColumnLayout {
CheckBox {
id: minimizedCheckbox
text: "Start minimized"
checked: mw.startmin
//onHoveredChanged: { console.log("hello "+hovered); }//ToolTipCreator.create("text on the tooltip, yo", parentItem).show() }
}
CheckBox {
id: loginCheckbox
Expand All @@ -60,6 +66,7 @@ Window {
GroupBox {
id: groupAPIServer
title: "API server configuration"
Layout.fillWidth: true
GridLayout {
anchors.fill: parent
columns: 2
Expand All @@ -80,6 +87,7 @@ Window {
GroupBox {
id: groupProxyConfig
title: "Proxy configuration"
Layout.fillWidth: true
ColumnLayout {
spacing: 10
RowLayout {
Expand Down Expand Up @@ -123,11 +131,13 @@ Window {
ColumnLayout {
id: rightcolumn
Layout.alignment: Qt.AlignTop
Layout.minimumWidth: 280
Layout.minimumWidth: 260
spacing: 15

GroupBox {
id: groupBlink1ToUse
title: "blink(1) device to use"
Layout.fillWidth: true
ColumnLayout {
ExclusiveGroup { id: blink1touseGroup }
RadioButton { exclusiveGroup: blink1touseGroup
Expand All @@ -142,8 +152,8 @@ Window {
ComboBox {
id: blink1touseComboBox
model: mw.getBlink1Serials
onCurrentIndexChanged: {
//onActivated: {
onCurrentIndexChanged: {
console.log("blink1 serial: " + currentIndex + " , "+ currentText);
mw.blink1Blink( currentText, "#333333", 500);
}
Expand All @@ -155,7 +165,7 @@ Window {
GroupBox {
id: groupBlink1Startup
title: "blink(1) device no-computer behavior"
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true
ColumnLayout {
ExclusiveGroup { id: blink1startupGroup }
RadioButton { exclusiveGroup: blink1startupGroup
Expand Down Expand Up @@ -237,6 +247,8 @@ Window {
mw.setBlink1Index( 0 );
}

mw.updatePreferences();

prefsWindow.visible = false
}
}
Expand Down
34 changes: 19 additions & 15 deletions qt/blink1control/qml/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,6 @@ Image{
radius: width*0.5
anchors.centerIn: parent
}
Button {
tooltip: "Show Preferences window"
iconSource: "qrc:images/layout/select-bg-right.png"
anchors.right: parent.right
anchors.top: parent.top
anchors.rightMargin:-15
anchors.topMargin:15
//width: 20
style: ButtonStyle {
background: Rectangle {
implicitWidth: 15
}
}
onClicked: prefsWindow.visible = !prefsWindow.visible
}
/*
MouseArea{
anchors.fill: parent
Expand All @@ -173,6 +158,25 @@ Image{
}
*/
}
Button {
tooltip: "Show Preferences window"
//iconSource: "qrc:images/layout/select-bg-right.png"
iconSource: "qrc:images/gear.png"
anchors.right: parent.right
anchors.top: parent.top
anchors.rightMargin:13 //-25
anchors.topMargin:50 //15
style: ButtonStyle {
background: Rectangle {
//implicitWidth: 15
radius: 4
border.color: control.hovered ? "#d2d2d2" : "transparent"
color: control.pressed ? "#f4f4f4" : "transparent"
}
}
onClicked: prefsWindow.visible = !prefsWindow.visible
}

//// KONIEC VIRTUAL BLINK
Text{
text: "Status:"
Expand Down

0 comments on commit b16181f

Please sign in to comment.