diff --git a/qt/blink1control/images/gear.png b/qt/blink1control/images/gear.png new file mode 100644 index 00000000..d134cc42 Binary files /dev/null and b/qt/blink1control/images/gear.png differ diff --git a/qt/blink1control/mainwindow.cpp b/qt/blink1control/mainwindow.cpp index e65ba5ab..ccc4bda0 100644 --- a/qt/blink1control/mainwindow.cpp +++ b/qt/blink1control/mainwindow.cpp @@ -16,6 +16,7 @@ #include + #include "patternsReadOnly.h" enum { @@ -34,7 +35,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { fromPattern=false; - mk2=false; + mk2=true; blinkStatus=""; iftttKey=""; blink1Id="none"; @@ -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(); @@ -728,19 +730,19 @@ void MainWindow::loadSettings() inputs.insert( bi->name(), bi ); // find most recent ifttt time if( bi->type() == "ifttt" ) { - //qDebug() << "iftttTime: "<date(); - if( bi->date() > nowSecs || bi->date() == 0 ) { // if bad stored date, fix it + qDebug() << "input name:"<name() <<" iftttTime: "<date() << " nowSecs: "<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() ) { @@ -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); @@ -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); @@ -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); @@ -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(); @@ -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 MainWindow::getPatternsList(){ QList patternsList; diff --git a/qt/blink1control/mainwindow.h b/qt/blink1control/mainwindow.h index 6b4c9cc6..f5a04559 100644 --- a/qt/blink1control/mainwindow.h +++ b/qt/blink1control/mainwindow.h @@ -188,6 +188,7 @@ public slots: void updatePatternsList(); void changeInputName(QString oldName,QString newName); + void updatePreferences(); void setAutorun(); void showhideDockIcon(); void checkInput(QString key); diff --git a/qt/blink1control/myresources.qrc b/qt/blink1control/myresources.qrc index 5852b343..b1176442 100644 --- a/qt/blink1control/myresources.qrc +++ b/qt/blink1control/myresources.qrc @@ -172,5 +172,6 @@ images/layout/dropdown-bg.png images/layout/select-bg-right.png images/blink1-icon0-bw.png + images/gear.png diff --git a/qt/blink1control/qml/qml/PreferencesWindow.qml b/qt/blink1control/qml/qml/PreferencesWindow.qml index ffa22208..9b0f7873 100644 --- a/qt/blink1control/qml/qml/PreferencesWindow.qml +++ b/qt/blink1control/qml/qml/PreferencesWindow.qml @@ -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 @@ -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 @@ -60,6 +66,7 @@ Window { GroupBox { id: groupAPIServer title: "API server configuration" + Layout.fillWidth: true GridLayout { anchors.fill: parent columns: 2 @@ -80,6 +87,7 @@ Window { GroupBox { id: groupProxyConfig title: "Proxy configuration" + Layout.fillWidth: true ColumnLayout { spacing: 10 RowLayout { @@ -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 @@ -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); } @@ -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 @@ -237,6 +247,8 @@ Window { mw.setBlink1Index( 0 ); } + mw.updatePreferences(); + prefsWindow.visible = false } } diff --git a/qt/blink1control/qml/qml/main.qml b/qt/blink1control/qml/qml/main.qml index d7faa7c6..962d3c7f 100644 --- a/qt/blink1control/qml/qml/main.qml +++ b/qt/blink1control/qml/qml/main.qml @@ -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 @@ -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:"