Added tray icon
This commit is contained in:
parent
7e18e2fd2f
commit
1294d65618
@ -29,6 +29,13 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
ui->etmpspin->installEventFilter(this);
|
ui->etmpspin->installEventFilter(this);
|
||||||
ui->btmpspin->installEventFilter(this);
|
ui->btmpspin->installEventFilter(this);
|
||||||
recentMenu = new QMenu(this);
|
recentMenu = new QMenu(this);
|
||||||
|
trayIcon = new QSystemTrayIcon(this);
|
||||||
|
trayIcon->setIcon(QIcon(":icons/repraptor.png"));
|
||||||
|
trayIconMenu = new QMenu(this);
|
||||||
|
trayIconMenu->addAction(ui->actionOpen);
|
||||||
|
trayIconMenu->addAction(ui->actionExit);
|
||||||
|
trayIcon->setToolTip(tr("RepRaptor running in the background"));
|
||||||
|
trayIcon->setContextMenu(trayIconMenu);
|
||||||
recentMenu->setTitle("Recent files");
|
recentMenu->setTitle("Recent files");
|
||||||
ui->menuFile->insertMenu(ui->actionSettings, recentMenu);
|
ui->menuFile->insertMenu(ui->actionSettings, recentMenu);
|
||||||
ui->menuFile->insertSeparator(ui->actionSettings);
|
ui->menuFile->insertSeparator(ui->actionSettings);
|
||||||
@ -79,6 +86,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
statusTimer->setInterval(settings.value("core/statusinterval", 3000).toInt());
|
statusTimer->setInterval(settings.value("core/statusinterval", 3000).toInt());
|
||||||
feedrate = settings.value("feedrate", 1500).toInt();
|
feedrate = settings.value("feedrate", 1500).toInt();
|
||||||
extruderFeedrate = settings.value("extruderfeedrate", 200).toInt();
|
extruderFeedrate = settings.value("extruderfeedrate", 200).toInt();
|
||||||
|
trayIconEnabled = settings.value("core/trayiconenabled", 1).toBool();
|
||||||
int size = settings.beginReadArray("user/recentfiles");
|
int size = settings.beginReadArray("user/recentfiles");
|
||||||
for(int i = 0; i < size; ++i)
|
for(int i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
@ -107,6 +115,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
//Internal signal-slots
|
//Internal signal-slots
|
||||||
connect(statusTimer, &QTimer::timeout, this, &MainWindow::checkStatus);
|
connect(statusTimer, &QTimer::timeout, this, &MainWindow::checkStatus);
|
||||||
connect(progressSDTimer, &QTimer::timeout, this, &MainWindow::checkSDStatus);
|
connect(progressSDTimer, &QTimer::timeout, this, &MainWindow::checkSDStatus);
|
||||||
|
connect(trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::trayIconClicked);
|
||||||
|
|
||||||
//Parser thread signal-slots and init
|
//Parser thread signal-slots and init
|
||||||
parserWorker->moveToThread(parserThread);
|
parserWorker->moveToThread(parserThread);
|
||||||
@ -157,6 +166,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
|
|
||||||
//Update recent files list
|
//Update recent files list
|
||||||
updateRecent();
|
updateRecent();
|
||||||
|
|
||||||
|
//Update icon
|
||||||
|
if(trayIconEnabled) trayIcon->show();
|
||||||
|
else trayIcon->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -189,6 +202,7 @@ MainWindow::~MainWindow()
|
|||||||
|
|
||||||
void MainWindow::open()
|
void MainWindow::open()
|
||||||
{
|
{
|
||||||
|
if(this->isHidden()) this->show();
|
||||||
sdprinting = false;
|
sdprinting = false;
|
||||||
QString filename;
|
QString filename;
|
||||||
QDir home;
|
QDir home;
|
||||||
@ -851,6 +865,8 @@ void MainWindow::receivedSDDone()
|
|||||||
{
|
{
|
||||||
sdprinting=false;
|
sdprinting=false;
|
||||||
ui->progressBar->setValue(0);
|
ui->progressBar->setValue(0);
|
||||||
|
if(trayIconEnabled && (this->isMinimized() || this->isHidden()))
|
||||||
|
trayIcon->showMessage(tr("Done"), tr("Finished printing"));
|
||||||
ui->filename->setText("");
|
ui->filename->setText("");
|
||||||
ui->fileBox->setDisabled(true);
|
ui->fileBox->setDisabled(true);
|
||||||
}
|
}
|
||||||
@ -862,6 +878,8 @@ void MainWindow::updateFileProgress(FileProgress p)
|
|||||||
{
|
{
|
||||||
ui->sendBtn->setText(tr("Send"));
|
ui->sendBtn->setText(tr("Send"));
|
||||||
ui->pauseBtn->setDisabled(true);
|
ui->pauseBtn->setDisabled(true);
|
||||||
|
if(trayIconEnabled && (this->isMinimized() || this->isHidden()))
|
||||||
|
trayIcon->showMessage(tr("Done"), tr("Finished printing"));
|
||||||
sending = false;
|
sending = false;
|
||||||
paused = false;
|
paused = false;
|
||||||
emit pause(paused);
|
emit pause(paused);
|
||||||
@ -981,6 +999,16 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||||||
else event->accept();
|
else event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::trayIconClicked(QSystemTrayIcon::ActivationReason reason)
|
||||||
|
{
|
||||||
|
if(trayIconEnabled && reason == QSystemTrayIcon::Trigger)
|
||||||
|
{
|
||||||
|
if(this->isHidden()) this->show();
|
||||||
|
else this->hide();
|
||||||
|
}
|
||||||
|
else return;
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::recentClicked()
|
void MainWindow::recentClicked()
|
||||||
{
|
{
|
||||||
//Actually a dirty hack, but it is fast and simple
|
//Actually a dirty hack, but it is fast and simple
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QSystemTrayIcon>
|
||||||
#include <QtSerialPort/QtSerialPort>
|
#include <QtSerialPort/QtSerialPort>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
@ -48,7 +49,9 @@ protected:
|
|||||||
QQueue <QString> userCommands;
|
QQueue <QString> userCommands;
|
||||||
QTimer *progressSDTimer;
|
QTimer *progressSDTimer;
|
||||||
QTimer *statusTimer;
|
QTimer *statusTimer;
|
||||||
|
QSystemTrayIcon *trayIcon;
|
||||||
QMenu *recentMenu;
|
QMenu *recentMenu;
|
||||||
|
QMenu *trayIconMenu;
|
||||||
QElapsedTimer *sinceLastTemp;
|
QElapsedTimer *sinceLastTemp;
|
||||||
QElapsedTimer *sinceLastSDStatus;
|
QElapsedTimer *sinceLastSDStatus;
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
@ -73,6 +76,7 @@ private:
|
|||||||
bool sdprinting;
|
bool sdprinting;
|
||||||
bool echo;
|
bool echo;
|
||||||
bool chekingSDStatus;
|
bool chekingSDStatus;
|
||||||
|
bool trayIconEnabled;
|
||||||
int firmware;
|
int firmware;
|
||||||
int feedrate;
|
int feedrate;
|
||||||
int extruderFeedrate;
|
int extruderFeedrate;
|
||||||
@ -103,6 +107,7 @@ private slots:
|
|||||||
void recentClicked();
|
void recentClicked();
|
||||||
void updateFileProgress(FileProgress);
|
void updateFileProgress(FileProgress);
|
||||||
void baudrateSetFailed(int b);
|
void baudrateSetFailed(int b);
|
||||||
|
void trayIconClicked(QSystemTrayIcon::ActivationReason reason);
|
||||||
|
|
||||||
void xplus();
|
void xplus();
|
||||||
void yplus();
|
void yplus();
|
||||||
|
|||||||
@ -14,7 +14,7 @@ SettingsWindow::SettingsWindow(QWidget *parent) :
|
|||||||
|
|
||||||
ui->flowcontrolbox->setCurrentIndex(settings.value("core/flowcontrol", 0).toInt());
|
ui->flowcontrolbox->setCurrentIndex(settings.value("core/flowcontrol", 0).toInt());
|
||||||
ui->senderbox->setValue(settings.value("core/senderinterval", 2).toInt());
|
ui->senderbox->setValue(settings.value("core/senderinterval", 2).toInt());
|
||||||
ui->echobox->setChecked(settings.value("core/echo", 0).toBool());
|
ui->traybox->setChecked(settings.value("core/trayiconenabled", 1).toBool());
|
||||||
ui->statusbox->setValue(settings.value("core/statusinterval", 2000).toInt());
|
ui->statusbox->setValue(settings.value("core/statusinterval", 2000).toInt());
|
||||||
ui->bedxbox->setValue(settings.value("printer/bedx", 200).toInt());
|
ui->bedxbox->setValue(settings.value("printer/bedx", 200).toInt());
|
||||||
ui->bedybox->setValue(settings.value("printer/bedy", 200).toInt());
|
ui->bedybox->setValue(settings.value("printer/bedy", 200).toInt());
|
||||||
@ -47,13 +47,13 @@ SettingsWindow::~SettingsWindow()
|
|||||||
void SettingsWindow::on_buttonBox_accepted()
|
void SettingsWindow::on_buttonBox_accepted()
|
||||||
{
|
{
|
||||||
settings.setValue("core/flowcontrol", ui->flowcontrolbox->currentIndex());
|
settings.setValue("core/flowcontrol", ui->flowcontrolbox->currentIndex());
|
||||||
|
settings.setValue("core/trayiconenabled", ui->traybox->isChecked());
|
||||||
settings.setValue("core/senderinterval", ui->senderbox->value());
|
settings.setValue("core/senderinterval", ui->senderbox->value());
|
||||||
settings.setValue("core/statusinterval", ui->statusbox->value());
|
settings.setValue("core/statusinterval", ui->statusbox->value());
|
||||||
settings.setValue("printer/bedy", ui->bedybox->value());
|
settings.setValue("printer/bedy", ui->bedybox->value());
|
||||||
settings.setValue("printer/bedx", ui->bedxbox->value());
|
settings.setValue("printer/bedx", ui->bedxbox->value());
|
||||||
settings.setValue("printer/feedrate", ui->feedrateBox->value());
|
settings.setValue("printer/feedrate", ui->feedrateBox->value());
|
||||||
settings.setValue("printer/extruderfeedrate", ui->extruderFeedrateBox->value());
|
settings.setValue("printer/extruderfeedrate", ui->extruderFeedrateBox->value());
|
||||||
settings.setValue("core/echo", ui->echobox->isChecked());
|
|
||||||
settings.setValue("core/lockcontrols", ui->lockbox->isChecked());
|
settings.setValue("core/lockcontrols", ui->lockbox->isChecked());
|
||||||
settings.setValue("core/checksums", ui->checksumbox->isChecked());
|
settings.setValue("core/checksums", ui->checksumbox->isChecked());
|
||||||
settings.setValue("core/checksdstatus", ui->sdbox->isChecked());
|
settings.setValue("core/checksdstatus", ui->sdbox->isChecked());
|
||||||
|
|||||||
@ -24,16 +24,38 @@
|
|||||||
<string>Internal</string>
|
<string>Internal</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="4" column="0" colspan="3">
|
<item row="1" column="0">
|
||||||
<widget class="QCheckBox" name="echobox">
|
<widget class="QLabel" name="label">
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Show every sent command in console</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Echo commands</string>
|
<string>Sender</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1" colspan="2">
|
||||||
|
<widget class="QComboBox" name="flowcontrolbox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_11">
|
||||||
|
<property name="text">
|
||||||
|
<string>Flow control</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QCheckBox" name="dtrbox">
|
||||||
|
<property name="text">
|
||||||
|
<string>DTR</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>ms</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -62,20 +84,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="2">
|
|
||||||
<widget class="QLabel" name="label_4">
|
|
||||||
<property name="text">
|
|
||||||
<string>ms</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Status</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QSpinBox" name="statusbox">
|
<widget class="QSpinBox" name="statusbox">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
@ -99,28 +107,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0" colspan="3">
|
<item row="9" column="0">
|
||||||
<widget class="QCheckBox" name="lockbox">
|
|
||||||
<property name="text">
|
|
||||||
<string>Lock controls when printing</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Sender</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="7" column="0" colspan="3">
|
|
||||||
<widget class="QCheckBox" name="sdbox">
|
|
||||||
<property name="text">
|
|
||||||
<string>Check SD printing status</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="8" column="0">
|
|
||||||
<widget class="QCheckBox" name="checksumbox">
|
<widget class="QCheckBox" name="checksumbox">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -152,24 +139,37 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QCheckBox" name="dtrbox">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>DTR</string>
|
<string>Status</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="8" column="0" colspan="3">
|
||||||
<widget class="QLabel" name="label_11">
|
<widget class="QCheckBox" name="sdbox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Flow control</string>
|
<string>Check SD printing status</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1" colspan="2">
|
<item row="7" column="0" colspan="3">
|
||||||
<widget class="QComboBox" name="flowcontrolbox">
|
<widget class="QCheckBox" name="lockbox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Lock controls when printing</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<widget class="QCheckBox" name="traybox">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string/>
|
<string>Show tray icon</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Tray icon</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user