very well, we need to paint time entries ourselves by hand
- */
- switch (view->Type) {
- case 0:
- layoutTimeEntry(painter, option, view);
- break;
- case 1:
- layoutTask(painter, option, view);
- break;
- case 2:
- layoutProject(painter, option, view);
- break;
- default: {
- QTextDocument doc;
- doc.setTextWidth(option.rect.width());
- doc.setHtml(format(view));
-
- option.widget->style()->drawControl(QStyle::CE_ItemViewItem, &option, painter);
-
- painter->translate(option.rect.left(), option.rect.top());
- QRect clip(0, 0, option.rect.width(), option.rect.height());
- doc.drawContents(painter, clip);
- }}
-
- painter->restore();
-}
-
-void AutoCompleteItemDelegate::layoutProject(QPainter *painter, const QStyleOptionViewItem &option, AutocompleteView *view) const {
- // set up the basic stuff, fonts, colors and font metrics to measure text sizes
- int lineWidth = option.rect.width();
- QFont font;
- font.setPixelSize(12);
- QFontMetrics metrics(font);
- QPen colorPen;
- if (!view->ProjectColor.isEmpty())
- colorPen.setColor(QColor(view->ProjectColor));
-
- // center the string vertically
- int topMargin = (24 - metrics.height()) / 2;
- // some margins to please the eye
- int leftMargin = 18;
- int rightMargin = 12;
-
- // then lay out the project
- QTextLayout projectLayout;
- int projectWidth = lineWidth - leftMargin - rightMargin - 1;
- QString elidedProject = metrics.elidedText(view->ProjectLabel, option.textElideMode, projectWidth);
- projectLayout.setText(" • " + elidedProject);
- projectLayout.setFont(font);
- projectWidth = metrics.width(" • " + elidedProject) + 1;
-
- projectLayout.beginLayout();
- auto projectLine = projectLayout.createLine();
- projectLine.setLineWidth(projectWidth + 1);
- projectLine.setPosition({qreal(leftMargin), qreal(topMargin)});
- projectLayout.endLayout();
-
- // and this is the actual painting part
- // this asks Qt to paint the item background (for the highlighted items, especially)
- option.widget->style()->drawControl(QStyle::CE_ItemViewItem, &option, painter);
- // set the pen to match the project color and render project name
- painter->setPen(colorPen);
- projectLayout.draw(painter, QPointF(option.rect.left(), option.rect.top()));
-}
-
-void AutoCompleteItemDelegate::layoutTask(QPainter *painter, const QStyleOptionViewItem &option, AutocompleteView *view) const {
- // set up the basic stuff, fonts, colors and font metrics to measure text sizes
- int lineWidth = option.rect.width();
- QFont font;
- font.setPixelSize(12);
- QFontMetrics metrics(font);
- QPen grayPen;
- grayPen.setColor(Qt::darkGray);
-
- // center the string vertically
- int topMargin = (24 - metrics.height()) / 2;
- // some margins to please the eye
- int leftMargin = 30;
- int rightMargin = 12;
-
- // do line trimming
- QTextLayout taskLayout;
- int taskWidth = lineWidth - leftMargin - rightMargin - 1;
- QString elidedTask = metrics.elidedText(view->TaskLabel, option.textElideMode, taskWidth);
- taskLayout.setText(elidedTask);
- taskLayout.setFont(font);
- taskWidth = metrics.width(elidedTask) + 1;
-
- // here we do the actual layout of the line
- taskLayout.beginLayout();
- auto taskLine = taskLayout.createLine();
- taskLine.setLineWidth(taskWidth + 1);
- taskLine.setPosition({qreal(leftMargin), qreal(topMargin)});
- taskLayout.endLayout();
-
- // and this is the actual painting part
- // this asks Qt to paint the item background (for the highlighted items, especially)
- option.widget->style()->drawControl(QStyle::CE_ItemViewItem, &option, painter);
- // set the pen to gray
- painter->setPen(grayPen);
- // render the task label
- taskLayout.draw(painter, QPointF(option.rect.left(), option.rect.top()));
-}
-
-void AutoCompleteItemDelegate::layoutTimeEntry(QPainter *painter, const QStyleOptionViewItem &option, AutocompleteView *view) const {
- // set up the basic stuff, fonts, colors and font metrics to measure text sizes
- int lineWidth = option.rect.width();
- QFont font;
- font.setPixelSize(12);
- QFontMetrics metrics(font);
- QPen defaultPen(painter->pen());
- QPen colorPen(defaultPen);
- if (!view->ProjectColor.isEmpty())
- colorPen.setColor(QColor(view->ProjectColor));
- QPen grayPen(defaultPen);
- grayPen.setColor(Qt::darkGray);
-
- // center the string vertically
- int topMargin = (24 - metrics.height()) / 2;
- // some margins to please the eye
- int leftMargin = 18;
- int rightMargin = 6;
-
- // first lay out the client (rightmost string)
- QTextLayout clientLayout;
- int clientWidth = 0;
- if (!view->ClientLabel.isEmpty()) {
- QString elidedClient = metrics.elidedText(view->ClientLabel, option.textElideMode, lineWidth / 3);
- clientLayout.setText(elidedClient);
- clientLayout.setFont(font);
- clientWidth = metrics.width(elidedClient) + 1;
- }
-
- // then lay out the project
- QTextLayout projectLayout;
- int projectWidth = 0;
- if (!view->ProjectLabel.isEmpty()) {
- QString elidedProject = metrics.elidedText(view->ProjectLabel, option.textElideMode, lineWidth / 2);
- projectLayout.setText(" • " + elidedProject);
- projectLayout.setFont(font);
- projectWidth = metrics.width(" • " + elidedProject) + 1;
- }
-
- // and finally the description, since it can be cropped by the project and client
- QTextLayout descriptionLayout;
- // crop the potential length by the margins and client/project widths
- int descriptionWidth = lineWidth - projectWidth - clientWidth - leftMargin - rightMargin + 1;
- // metrics will do the ellipsis for us
- QString elidedDescription = metrics.elidedText(view->Description, option.textElideMode, descriptionWidth);
- // and now we measure the actual length of the ellided string so everything aligns nicely
- descriptionWidth = metrics.width(elidedDescription);
- descriptionLayout.setText(elidedDescription);
- descriptionLayout.setFont(font);
-
- // here we do the actual layout of the line
- descriptionLayout.beginLayout();
- auto descriptionLine = descriptionLayout.createLine();
- descriptionLine.setLineWidth(descriptionWidth + 1);
- descriptionLine.setPosition({qreal(leftMargin), qreal(topMargin)});
- descriptionLayout.endLayout();
-
- projectLayout.beginLayout();
- auto projectLine = projectLayout.createLine();
- projectLine.setLineWidth(projectWidth + 1);
- projectLine.setPosition({qreal(leftMargin + descriptionWidth + 1), qreal(topMargin)});
- projectLayout.endLayout();
-
- clientLayout.beginLayout();
- auto clientLine = clientLayout.createLine();
- clientLine.setLineWidth(clientWidth + 1);
- clientLine.setPosition({qreal(leftMargin + descriptionWidth + projectWidth + 2), qreal(topMargin)});
- clientLayout.endLayout();
-
- // and this is the actual painting part
- // this asks Qt to paint the item background (for the highlighted items, especially)
- option.widget->style()->drawControl(QStyle::CE_ItemViewItem, &option, painter);
- // paint the description with the default pen first
- descriptionLayout.draw(painter, QPointF(option.rect.left(), option.rect.top()));
- // set the pen to match the project color and render project name
- painter->setPen(colorPen);
- projectLayout.draw(painter, QPointF(option.rect.left(), option.rect.top()));
- // and finally, paint the client in gray
- painter->setPen(grayPen);
- clientLayout.draw(painter, QPointF(option.rect.left(), option.rect.top()));
-}
-
-QSize AutoCompleteItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const {
- return { 320, 24 };
-}
-
-QString AutoCompleteItemDelegate::format(const AutocompleteView *view) const {
- QString label;
- QString transparent = "background-color: transparent;";
-
- // Format is: Description - TaskName · ProjectName - ClientName
-
- switch (view->Type) {
- case 13: // Workspace row
- return "" + view->Description + "
";
- case 11: // Category row
- return "" + view->Description + "
";
- case 12: { // Client row / no project row
- return "" + view->Description + "
";
- }
- case 2: { // Project items rows
- label.append("• " + view->ProjectLabel + "
");
- return label;
- }
- case 1: { // Task row
- QString row = QString("");
- row += view->TaskLabel;
- row += "
";
- return row;
- }
- case 0: { // Item rows (projects/time entries)
- // !!! UNUSED
- QString table("");
- if (!view->Description.isEmpty())
- table.append(view->Description + " ");
- if (view->TaskID)
- table.append(view->TaskLabel + " ");
- //table.append("
");
- if (view->ProjectID)
- table.append(" • " + view->ProjectLabel + " ");
- if (view->ClientID)
- table.append(" " + view->ClientLabel + "");
- table.append("
");
- return table;
- }
- default:
- //ui->label->setStyleSheet(transparent + "padding-top:7px;padding-left:15px;font-size:9pt;");
- return "" + view->ProjectLabel + view->TaskLabel + view->ClientLabel + view->Description + "";
- }
-}
-
-AutocompleteView *AutoCompleteItemDelegate::getCurrentView(const QModelIndex &index) const {
- return qvariant_cast(index.data(Qt::UserRole));
-}
diff --git a/src/ui/linux/TogglDesktop/autocompletelistview.h b/src/ui/linux/TogglDesktop/autocompletelistview.h
deleted file mode 100644
index 91e98c6244..0000000000
--- a/src/ui/linux/TogglDesktop/autocompletelistview.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef AUTOCOMPLETELISTVIEW_H
-#define AUTOCOMPLETELISTVIEW_H
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "./autocompleteview.h"
-
-class AutocompleteListView : public QListView
-{
- Q_OBJECT
- friend class AutocompleteComboBox;
-public:
- explicit AutocompleteListView(QWidget *parent = 0);
-
- void paintEvent(QPaintEvent *e) override;
-
- QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
-
- void showEvent(QShowEvent *event) override;
- void hideEvent(QHideEvent *event) override;
-
-signals:
- void visibleChanged();
- void selected(AutocompleteView *item);
-
-protected:
- void keyPressEvent(QKeyEvent *e);
-
-};
-
-class AutoCompleteItemDelegate : public QItemDelegate
-{
- Q_OBJECT
-public:
- AutoCompleteItemDelegate(QObject *parent = nullptr);
- void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
- void layoutProject(QPainter *painter, const QStyleOptionViewItem &option, AutocompleteView *view) const;
- void layoutTask(QPainter *painter, const QStyleOptionViewItem &option, AutocompleteView *view) const;
- void layoutTimeEntry(QPainter *painter, const QStyleOptionViewItem &option, AutocompleteView *view) const;
- QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
-
-private:
- QString format(const AutocompleteView *view) const;
- AutocompleteView *getCurrentView(const QModelIndex &index) const;
-};
-
-#endif // AUTOCOMPLETELISTVIEW_H
diff --git a/src/ui/linux/TogglDesktop/autocompleteview.h b/src/ui/linux/TogglDesktop/autocompleteview.h
index b106f2f109..171c9fd9bc 100644
--- a/src/ui/linux/TogglDesktop/autocompleteview.h
+++ b/src/ui/linux/TogglDesktop/autocompleteview.h
@@ -8,15 +8,7 @@
#include
#include "./toggl_api.h"
-
-enum AutocompleteType {
- AC_TIME_ENTRY = 0,
- AC_TASK = 1,
- AC_PROJECT = 2,
- AC_HEADER = 11,
- AC_CLIENT = 12,
- AC_WORKSPACE = 13
-};
+#include "./common.h"
class AutocompleteView : public QObject {
Q_OBJECT
@@ -24,6 +16,16 @@ class AutocompleteView : public QObject {
public:
explicit AutocompleteView(QObject *parent = 0);
+ enum AutocompleteType {
+ AC_TIME_ENTRY = 0,
+ AC_TASK = 1,
+ AC_PROJECT = 2,
+ AC_HEADER = 11,
+ AC_CLIENT = 12,
+ AC_WORKSPACE = 13
+ };
+ Q_ENUMS(AutocompleteType)
+
static QVector importAll(
TogglAutocompleteView *first) {
QVector result;
@@ -38,25 +40,25 @@ class AutocompleteView : public QObject {
while (it) {
AutocompleteView *view = new AutocompleteView();
- view->Text = QString(it->Text);
- view->Description = QString(it->Description);
- view->ProjectAndTaskLabel = QString(it->ProjectAndTaskLabel);
- view->ProjectLabel = QString(it->ProjectLabel);
- view->ClientLabel = QString(it->ClientLabel);
- view->ProjectColor = QString(it->ProjectColor);
+ view->Text = toQString(it->Text);
+ view->Description = toQString(it->Description);
+ view->ProjectAndTaskLabel = toQString(it->ProjectAndTaskLabel);
+ view->ProjectLabel = toQString(it->ProjectLabel);
+ view->ClientLabel = toQString(it->ClientLabel);
+ view->ProjectColor = toQString(it->ProjectColor);
view->ClientID = it->ClientID;
view->TaskID = it->TaskID;
- view->TaskLabel = it->TaskLabel;
+ view->TaskLabel = toQString(it->TaskLabel);
view->ProjectID = it->ProjectID;
view->WorkspaceID = it->WorkspaceID;
view->WorkspaceName = QString(it->WorkspaceName).toUpper();
- view->Type = it->Type;
+ view->Type = AutocompleteType(it->Type);
view->Billable = it->Billable;
- view->Tags = QString(it->Tags);
+ view->Tags = toQString(it->Tags);
if (!currentWorkspace || currentWorkspace->Description != view->WorkspaceName) {
currentWorkspace = new AutocompleteView();
- currentWorkspace->Type = 13;
+ currentWorkspace->Type = AC_WORKSPACE;
currentWorkspace->Description = view->WorkspaceName;
result.push_back(currentWorkspace);
currentLevel1Header = nullptr;
@@ -74,7 +76,7 @@ class AutocompleteView : public QObject {
currentLevel3Header = nullptr;
currentLevel2Header = nullptr;
currentLevel1Header = new AutocompleteView();
- currentLevel1Header->Type = 11;
+ currentLevel1Header->Type = AC_HEADER;
switch (view->Type) {
case 0:
currentLevel1Header->Description = "TIME ENTRIES";
@@ -96,7 +98,7 @@ class AutocompleteView : public QObject {
if (view->Type == 2 && (!currentLevel2Header || currentLevel2Header->ClientLabel != view->ClientLabel)) {
currentLevel3Header = nullptr;
currentLevel2Header = new AutocompleteView();
- currentLevel2Header->Type = 12;
+ currentLevel2Header->Type = AC_CLIENT;
currentLevel2Header->ClientLabel = view->ClientLabel;
if (view->ClientLabel.isEmpty())
currentLevel2Header->Description = "No client";
@@ -128,23 +130,26 @@ class AutocompleteView : public QObject {
return result;
}
- QString Text {};
- QString Description {};
- QString ProjectAndTaskLabel {};
- QString ProjectLabel {};
- QString ClientLabel {};
- QString TaskLabel {};
- QString WorkspaceName {};
- QString ProjectColor {};
- uint64_t TaskID { 0 };
- uint64_t ProjectID { 0 };
- uint64_t ClientID { 0 };
- uint64_t WorkspaceID { 0 };
- uint64_t Type { 0 };
- bool Billable { false };
- QString Tags {};
-
+ PROPERTY(QString, Text)
+ PROPERTY(QString, Description)
+ PROPERTY(QString, ProjectAndTaskLabel)
+ PROPERTY(QString, ProjectLabel)
+ PROPERTY(QString, ClientLabel)
+ PROPERTY(QString, TaskLabel)
+ PROPERTY(QString, WorkspaceName)
+ PROPERTY(QString, ProjectColor)
+ PROPERTY(uint64_t, TaskID)
+ PROPERTY(uint64_t, ProjectID)
+ PROPERTY(uint64_t, ClientID)
+ PROPERTY(uint64_t, WorkspaceID)
+ PROPERTY(AutocompleteType, Type)
+ PROPERTY(bool, Billable)
+ PROPERTY(QString, Tags)
QList _Children;
+
+private:
+ mutable QMutex propertyMutex_;
+
};
#endif // SRC_UI_LINUX_TOGGLDESKTOP_AUTOCOMPLETEVIEW_H_
diff --git a/src/ui/linux/TogglDesktop/clickablelabel.cpp b/src/ui/linux/TogglDesktop/clickablelabel.cpp
deleted file mode 100644
index f65363e47c..0000000000
--- a/src/ui/linux/TogglDesktop/clickablelabel.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2014 Toggl Desktop developers.
-
-#include "./clickablelabel.h"
-#include "./toggl.h"
-#include "./timeentrycellwidget.h"
-
-ClickableLabel::ClickableLabel(QWidget * parent) : QLabel(parent) {
-}
-
-ClickableLabel::~ClickableLabel() {
-}
-
-void ClickableLabel::mousePressEvent(QMouseEvent * event) {
- Q_UNUSED(event);
- QWidget* parentObject = this->parentWidget();
-
- while (parentObject->objectName().compare("TimeEntryCellWidget") != 0) {
- parentObject = parentObject->parentWidget();
- }
-
- TimeEntryCellWidget *Cell =
- qobject_cast(parentObject);
- Cell->labelClicked(this->objectName());
-}
diff --git a/src/ui/linux/TogglDesktop/clickablelabel.h b/src/ui/linux/TogglDesktop/clickablelabel.h
deleted file mode 100644
index 0a7659a432..0000000000
--- a/src/ui/linux/TogglDesktop/clickablelabel.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2014 Toggl Desktop developers.
-
-#ifndef SRC_UI_LINUX_TOGGLDESKTOP_CLICKABLELABEL_H_
-#define SRC_UI_LINUX_TOGGLDESKTOP_CLICKABLELABEL_H_
-
-#include
-#include
-
-class ClickableLabel : public QLabel {
- public:
- explicit ClickableLabel(QWidget * parent = 0);
- ~ClickableLabel();
-
- signals:
- void clicked();
-
- protected:
- void mousePressEvent(QMouseEvent * event);
-};
-
-#endif // SRC_UI_LINUX_TOGGLDESKTOP_CLICKABLELABEL_H_
diff --git a/src/ui/linux/TogglDesktop/colorpicker.cpp b/src/ui/linux/TogglDesktop/colorpicker.cpp
deleted file mode 100644
index 2a89e51c60..0000000000
--- a/src/ui/linux/TogglDesktop/colorpicker.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright 2016 Toggl Desktop developers.
-
-#include
-#include "colorpicker.h"
-#include "ui_colorpicker.h"
-#include "timeentryeditorwidget.h"
-
-ColorPicker::ColorPicker(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::ColorPicker)
-{
- ui->setupUi(this);
- setModal(true);
- setWindowTitle("Color Select");
- setWindowFlags( Qt::Popup );
-
- // Add shadow
- setAttribute(Qt::WA_TranslucentBackground); //enable MainWindow to be transparent
-
- QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
- effect->setOffset(0);
- effect->setBlurRadius(5);
- ui->verticalWidget->setGraphicsEffect(effect);
-}
-
-ColorPicker::~ColorPicker()
-{
- delete ui;
-}
-
-void ColorPicker::setColors(QVector list) {
- int row = 0;
- int cell = 0;
-
- for (int i = 0; i < list.size(); i++) {
- QPushButton* colorButton = new QPushButton(this);
- colorButton->setText(QString("■"));
- colorButton->setMinimumSize(QSize(20, 20));
- colorButton->setMaximumSize(QSize(20, 20));
- colorButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- QString style = "color:" + QString::fromUtf8(list.at(i)) + ";";
- colorButton->setStyleSheet(style);
- connect(colorButton,SIGNAL(clicked()),this,SLOT(color_clicked()));
-
- ui->gridLayout->addWidget(colorButton,row,cell);
-
- cell++;
-
- // Keep 5 items in 1 row
- if ((i+1) % 5 == 0) {
- row++;
- cell = 0;
- }
- }
-}
-
-void ColorPicker::color_clicked() {
- QString color = (qobject_cast(sender()))->styleSheet();
- TimeEntryEditorWidget *p = qobject_cast(parent());
- p->setSelectedColor(color);
- close();
-}
-
-void ColorPicker::on_closeButton_clicked()
-{
- close();
-}
diff --git a/src/ui/linux/TogglDesktop/colorpicker.h b/src/ui/linux/TogglDesktop/colorpicker.h
deleted file mode 100644
index 07be4a8bc4..0000000000
--- a/src/ui/linux/TogglDesktop/colorpicker.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2016 Toggl Desktop developers.
-
-#ifndef SRC_UI_LINUX_TOGGLDESKTOP_COLORPICKER_H
-#define SRC_UI_LINUX_TOGGLDESKTOP_COLORPICKER_H
-
-#include
-#include
-
-namespace Ui {
-class ColorPicker;
-}
-
-class ColorPicker : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit ColorPicker(QWidget *parent = 0);
- ~ColorPicker();
-
-private:
- Ui::ColorPicker *ui;
-
-public:
- void setColors(QVector list);
-
-private slots:
- void color_clicked();
- void on_closeButton_clicked();
-};
-
-#endif // SRC_UI_LINUX_TOGGLDESKTOP_COLORPICKER_H
diff --git a/src/ui/linux/TogglDesktop/colorpicker.ui b/src/ui/linux/TogglDesktop/colorpicker.ui
deleted file mode 100644
index b31a5392f0..0000000000
--- a/src/ui/linux/TogglDesktop/colorpicker.ui
+++ /dev/null
@@ -1,98 +0,0 @@
-
-
- ColorPicker
-
-
-
- 0
- 0
- 170
- 175
-
-
-
-
- 170
- 175
-
-
-
- Form
-
-
-
-
- 10
- 10
- 150
- 155
-
-
-
-
- 150
- 155
-
-
-
-
- 150
- 155
-
-
-
- true
-
-
-
-
- 0
- 0
- 150
- 110
-
-
-
-
- 150
- 110
-
-
-
-
- 150
- 110
-
-
-
- font-size:72px;
-
-
-
-
-
-
- 90
- 120
- 50
- 25
-
-
-
- close
-
-
- false
-
-
- false
-
-
- false
-
-
-
-
-
-
-
diff --git a/src/ui/linux/TogglDesktop/common.h b/src/ui/linux/TogglDesktop/common.h
new file mode 100644
index 0000000000..2feac321f8
--- /dev/null
+++ b/src/ui/linux/TogglDesktop/common.h
@@ -0,0 +1,61 @@
+// Copyright 2019 Toggl Desktop developers.
+
+#ifndef SRC_COMMON_H_
+#define SRC_COMMON_H_
+
+#include
+#include
+
+#ifdef _WIN32
+#define toQString(x) QString::fromWCharArray(x)
+#define toLocalString(x) x.toStdWString().c_str()
+#define strLiteral(x) L"" x
+#else
+#define toQString(x) QString(x)
+#define toLocalString(x) (x).toStdString().c_str()
+#define strLiteral(x) x
+#endif
+
+#ifndef TOGGL_SAFE_PROPERTIES
+
+#define PROPERTY(type, name, ...) \
+private: Q_PROPERTY(type name READ name##Get WRITE name##Set NOTIFY name##Changed) \
+public: type name { __VA_ARGS__ }; \
+ type name##Get() const { \
+ auto value = name; \
+ return value; \
+ } \
+ Q_SLOT Q_INVOKABLE void name##Set(const type &val) { \
+ if (name != val) { \
+ name = val; \
+ emit name##Changed(); \
+ } \
+ } \
+ Q_SIGNAL void name##Changed();
+
+#else // TOGGL_SAFE_PROPERTIES
+
+#define PROPERTY(type, name, ...) \
+private: Q_PROPERTY(type name READ name##Get WRITE name##Set NOTIFY name##Changed) \
+public: type name { __VA_ARGS__ }; \
+ type name##Get() const { \
+ propertyMutex_.lock(); \
+ auto value = name; \
+ propertyMutex_.unlock(); \
+ return value; \
+ } \
+ Q_SLOT Q_INVOKABLE void name##Set(const type &val) { \
+ propertyMutex_.lock(); \
+ if (name != val) { \
+ name = val; \
+ propertyMutex_.unlock(); \
+ emit name##Changed(); \
+ } \
+ else \
+ propertyMutex_.unlock(); \
+ } \
+ Q_SIGNAL void name##Changed();
+
+#endif // TOGGL_SAFE_PROPERTIES
+
+#endif // SRC_COMMON_H_
diff --git a/src/ui/linux/TogglDesktop/countryview.h b/src/ui/linux/TogglDesktop/countryview.h
index dbf904523e..b67e427008 100644
--- a/src/ui/linux/TogglDesktop/countryview.h
+++ b/src/ui/linux/TogglDesktop/countryview.h
@@ -5,6 +5,7 @@
#include
#include "./toggl_api.h"
+#include "./common.h"
class CountryView : public QObject
{
@@ -20,24 +21,26 @@ class CountryView : public QObject
CountryView *view = new CountryView();
view->ID = it->ID;
view->VatApplicable = it->VatApplicable;
- view->Text = QString(it->Name);
- view->Name = QString(it->Name);
+ view->Text = toQString(it->Name);
+ view->Name = toQString(it->Name);
result.push_back(view);
- view->Name = QString(it->VatPercentage);
- view->Name = QString(it->VatRegex);
- view->Name = QString(it->Code);
+ view->Name = toQString(it->VatPercentage);
+ view->Name = toQString(it->VatRegex);
+ view->Name = toQString(it->Code);
it = static_cast(it->Next);
}
return result;
}
- uint64_t ID;
- QString Text;
- QString Name;
- bool VatApplicable;
- QString VatPercentage;
- QString VatRegex;
- QString Code;
+ mutable QMutex propertyMutex_;
+
+ PROPERTY(uint64_t, ID)
+ PROPERTY(QString, Text)
+ PROPERTY(QString, Name)
+ PROPERTY(bool, VatApplicable)
+ PROPERTY(QString, VatPercentage)
+ PROPERTY(QString, VatRegex)
+ PROPERTY(QString, Code)
signals:
diff --git a/src/ui/linux/TogglDesktop/errorviewcontroller.cpp b/src/ui/linux/TogglDesktop/errorviewcontroller.cpp
deleted file mode 100644
index 1eed9628f1..0000000000
--- a/src/ui/linux/TogglDesktop/errorviewcontroller.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2014 Toggl Desktop developers.
-
-#include "./errorviewcontroller.h"
-#include "./ui_errorviewcontroller.h"
-#include "./toggl.h"
-
-ErrorViewController::ErrorViewController(QWidget *parent)
- : QWidget(parent)
-, ui(new Ui::ErrorViewController)
-, loginError(false)
-, uid(0) {
- ui->setupUi(this);
- setVisible(false);
-
- connect(TogglApi::instance, SIGNAL(displayError(QString,bool)), // NOLINT
- this, SLOT(displayError(QString,bool))); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(displayOnlineState(int64_t)), // NOLINT
- this, SLOT(displayOnlineState(int64_t))); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(displayLogin(bool,uint64_t)), // NOLINT
- this, SLOT(displayLogin(bool,uint64_t))); // NOLINT
-}
-
-ErrorViewController::~ErrorViewController() {
- delete ui;
-}
-
-void ErrorViewController::on_pushButton_clicked() {
- setVisible(false);
-}
-
-void ErrorViewController::displayError(
- const QString errmsg,
- const bool user_error) {
- loginError = !uid;
- ui->errorMessage->setText(errmsg);
- ui->errorMessage->setToolTip(
- QString("" +
- errmsg + "
"));
- setVisible(true);
- if (!user_error) {
- TogglApi::notifyBugsnag("error in shared lib", errmsg,
- "ErrorViewController");
- }
-}
-
-void ErrorViewController::displayOnlineState(
- int64_t state) {
- Q_UNUSED(state);
- // FIXME: need separate online state label
-}
-
-void ErrorViewController::displayLogin(
- const bool open,
- const uint64_t user_id) {
- Q_UNUSED(open);
- uid = user_id;
- if (user_id && isVisible() && loginError) {
- loginError = false;
- setVisible(false);
- }
-}
diff --git a/src/ui/linux/TogglDesktop/errorviewcontroller.h b/src/ui/linux/TogglDesktop/errorviewcontroller.h
deleted file mode 100644
index 420a6f922b..0000000000
--- a/src/ui/linux/TogglDesktop/errorviewcontroller.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2014 Toggl Desktop developers.
-
-#ifndef SRC_UI_LINUX_TOGGLDESKTOP_ERRORVIEWCONTROLLER_H_
-#define SRC_UI_LINUX_TOGGLDESKTOP_ERRORVIEWCONTROLLER_H_
-
-#include
-
-#include
-
-namespace Ui {
-class ErrorViewController;
-}
-
-class ErrorViewController : public QWidget {
- Q_OBJECT
-
- public:
- explicit ErrorViewController(QWidget *parent = 0);
- ~ErrorViewController();
-
- private slots: // NOLINT
- void on_pushButton_clicked();
-
- void displayError(
- const QString errmsg,
- const bool user_error);
-
- void displayOnlineState(
- int64_t state);
-
- void displayLogin(
- const bool open,
- const uint64_t user_id);
-
- private:
- Ui::ErrorViewController *ui;
-
- bool networkError;
- bool loginError;
- uint64_t uid;
-};
-
-#endif // SRC_UI_LINUX_TOGGLDESKTOP_ERRORVIEWCONTROLLER_H_
diff --git a/src/ui/linux/TogglDesktop/errorviewcontroller.ui b/src/ui/linux/TogglDesktop/errorviewcontroller.ui
deleted file mode 100644
index 13e8a26127..0000000000
--- a/src/ui/linux/TogglDesktop/errorviewcontroller.ui
+++ /dev/null
@@ -1,143 +0,0 @@
-
-
- ErrorViewController
-
-
-
- 0
- 0
- 258
- 40
-
-
-
-
- 0
- 0
-
-
-
-
- 0
- 40
-
-
-
-
- 16777215
- 40
-
-
-
- Form
-
-
- false
-
-
- background-color: rgb(236, 223, 95);color:rgb(85, 85, 85);font-size:13px;
-
-
-
- 0
-
-
- QLayout::SetMaximumSize
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
- -
-
-
-
- 0
- 40
-
-
-
-
- 16777215
- 40
-
-
-
- Qt::LeftToRight
-
-
- QFrame::NoFrame
-
-
- QFrame::Raised
-
-
-
- 0
-
-
- 6
-
-
- 0
-
-
- 6
-
-
- 0
-
-
-
-
-
-
- 0
- 0
-
-
-
- An error has occured!
-
-
- false
-
-
-
- -
-
-
-
- 20
- 20
-
-
-
-
- 20
- 20
-
-
-
- Qt::NoFocus
-
-
- X
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/ui/linux/TogglDesktop/feedbackdialog.cpp b/src/ui/linux/TogglDesktop/feedbackdialog.cpp
deleted file mode 100644
index a9115857c6..0000000000
--- a/src/ui/linux/TogglDesktop/feedbackdialog.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2014 Toggl Desktop developers.
-
-#include "./feedbackdialog.h"
-#include "./ui_feedbackdialog.h"
-
-#include // NOLINT
-#include // NOLINT
-#include // NOLINT
-
-#include "./toggl.h"
-
-FeedbackDialog::FeedbackDialog(QWidget *parent) : QDialog(parent),
-ui(new Ui::FeedbackDialog) {
- ui->setupUi(this);
-
- ui->topic->addItem("Bug report");
- ui->topic->addItem("Feature request");
- ui->topic->addItem("Other");
- ui->topic->setCurrentIndex(0);
-}
-
-FeedbackDialog::~FeedbackDialog() {
- delete ui;
-}
-
-void FeedbackDialog::on_uploadImageButton_clicked() {
- path = QFileDialog::getOpenFileName(this, "Select an image to upload");
- QFileInfo info(path);
- ui->selectedImageFilename->setText(info.fileName());
-}
-
-void FeedbackDialog::on_sendButton_clicked() {
- QString content = ui->content->toPlainText();
- if (content.isEmpty()) {
- QMessageBox(QMessageBox::Information,
- "Feedback not sent!",
- "Please type in your feedback before sending.",
- QMessageBox::Ok).exec();
- ui->content->setFocus();
- return;
- }
- if (!TogglApi::instance->sendFeedback(ui->topic->currentText(),
- ui->content->toPlainText(),
- path)) {
- QMessageBox(QMessageBox::Information,
- "Feedback not sent!",
- "Please check that file you are sending is not larger than 5MB.",
- QMessageBox::Ok).exec();
- return;
- }
- ui->topic->setCurrentIndex(0);
- ui->content->clear();
- ui->selectedImageFilename->setText("");
- path = "";
- hide();
-
- QMessageBox(QMessageBox::Information,
- "Thank you!",
- "Your feedback was sent successfully.",
- QMessageBox::Ok).exec();
-}
diff --git a/src/ui/linux/TogglDesktop/feedbackdialog.h b/src/ui/linux/TogglDesktop/feedbackdialog.h
deleted file mode 100644
index fef9565cb2..0000000000
--- a/src/ui/linux/TogglDesktop/feedbackdialog.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2014 Toggl Desktop developers.
-
-#ifndef SRC_UI_LINUX_TOGGLDESKTOP_FEEDBACKDIALOG_H_
-#define SRC_UI_LINUX_TOGGLDESKTOP_FEEDBACKDIALOG_H_
-
-#include
-
-namespace Ui {
-class FeedbackDialog;
-}
-
-class FeedbackDialog : public QDialog {
- Q_OBJECT
-
- public:
- explicit FeedbackDialog(QWidget *parent = 0);
- ~FeedbackDialog();
-
- private slots: // NOLINT
- void on_uploadImageButton_clicked();
-
- void on_sendButton_clicked();
-
- private:
- Ui::FeedbackDialog *ui;
-
- QString path;
-};
-
-#endif // SRC_UI_LINUX_TOGGLDESKTOP_FEEDBACKDIALOG_H_
diff --git a/src/ui/linux/TogglDesktop/feedbackdialog.ui b/src/ui/linux/TogglDesktop/feedbackdialog.ui
deleted file mode 100644
index 3bd6e1d3e0..0000000000
--- a/src/ui/linux/TogglDesktop/feedbackdialog.ui
+++ /dev/null
@@ -1,135 +0,0 @@
-
-
- FeedbackDialog
-
-
-
- 0
- 0
- 400
- 300
-
-
-
- Send Feedback
-
-
- font-size:13px;
-
-
- -
-
-
- Send us your feedback and questions
-
-
-
- -
-
-
-
-
-
-
- -
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 0
-
-
- 6
-
-
- 0
-
-
- 6
-
-
-
-
-
- (maximum image size 5MB)
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 152
- 20
-
-
-
-
- -
-
-
-
- 100
- 0
-
-
-
-
- 100
- 16777215
-
-
-
- Upload image
-
-
- false
-
-
-
-
-
-
- -
-
-
-
- 0
-
-
- 0
-
-
-
-
-
-
- 100
- 0
-
-
-
- Send
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/ui/linux/TogglDesktop/genericview.h b/src/ui/linux/TogglDesktop/genericview.h
index 44b203ac38..2f36001a38 100644
--- a/src/ui/linux/TogglDesktop/genericview.h
+++ b/src/ui/linux/TogglDesktop/genericview.h
@@ -7,6 +7,7 @@
#include
#include "./toggl_api.h"
+#include "./common.h"
class GenericView : public QObject {
Q_OBJECT
@@ -21,8 +22,8 @@ class GenericView : public QObject {
GenericView *view = new GenericView();
view->ID = it->ID;
view->WID = it->WID;
- view->GUID = QString(it->GUID);
- view->Name = QString(it->Name);
+ view->GUID = toQString(it->GUID);
+ view->Name = toQString(it->Name);
result.push_back(view);
it = static_cast(it->Next);
}
diff --git a/src/ui/linux/TogglDesktop/idlenotificationwidget.cpp b/src/ui/linux/TogglDesktop/idlenotificationwidget.cpp
index cc96df1815..fb7838c822 100644
--- a/src/ui/linux/TogglDesktop/idlenotificationwidget.cpp
+++ b/src/ui/linux/TogglDesktop/idlenotificationwidget.cpp
@@ -6,7 +6,9 @@
#include "./toggl.h"
#include "./settingsview.h"
+#ifdef __linux
#include // NOLINT
+#endif
IdleNotificationWidget::IdleNotificationWidget(QStackedWidget *parent)
: QWidget(parent),
@@ -18,8 +20,10 @@ IdleNotificationWidget::IdleNotificationWidget(QStackedWidget *parent)
idleHintTimer(new QTimer(this)) {
ui->setupUi(this);
+#ifdef __linux
screensaver = new QDBusInterface("org.freedesktop.ScreenSaver", "/org/freedesktop/ScreenSaver", "org.freedesktop.ScreenSaver", QDBusConnection::sessionBus(), this);
-
+ connect(screensaver, SIGNAL(ActiveChanged(bool)), this, SLOT(onScreensaverActiveChanged(bool)));
+#endif
connect(TogglApi::instance, &TogglApi::displayIdleNotification, this, &IdleNotificationWidget::displayIdleNotification);
connect(TogglApi::instance, SIGNAL(displaySettings(bool,SettingsView*)), // NOLINT
@@ -31,7 +35,6 @@ IdleNotificationWidget::IdleNotificationWidget(QStackedWidget *parent)
connect(TogglApi::instance, SIGNAL(displayLogin(bool,uint64_t)), // NOLINT
this, SLOT(displayLogin(bool,uint64_t))); // NOLINT
- connect(screensaver, SIGNAL(ActiveChanged(bool)), this, SLOT(onScreensaverActiveChanged(bool)));
connect(idleHintTimer, &QTimer::timeout, this, &IdleNotificationWidget::requestIdleHint);
idleHintTimer->setInterval(5000);
@@ -47,6 +50,7 @@ void IdleNotificationWidget::displaySettings(const bool open, SettingsView *sett
}
void IdleNotificationWidget::requestIdleHint() {
+#ifdef __linux
if (dbusApiAvailable) {
auto pendingCall = screensaver->asyncCall("GetSessionIdleTime");
auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
@@ -65,9 +69,12 @@ void IdleNotificationWidget::requestIdleHint() {
XFree(info);
XCloseDisplay(display);
}
+#endif
}
+#ifdef __linux
void IdleNotificationWidget::idleHintReceived(QDBusPendingCallWatcher *watcher) {
+
QDBusPendingReply reply = *watcher;
if (reply.isError()) {
dbusApiAvailable = false;
@@ -80,6 +87,7 @@ void IdleNotificationWidget::idleHintReceived(QDBusPendingCallWatcher *watcher)
}
watcher->deleteLater();
}
+#endif
void IdleNotificationWidget::onScreensaverActiveChanged(bool active) {
screenLocked = active;
diff --git a/src/ui/linux/TogglDesktop/idlenotificationwidget.h b/src/ui/linux/TogglDesktop/idlenotificationwidget.h
index b0b7c6b702..0fd75f2563 100644
--- a/src/ui/linux/TogglDesktop/idlenotificationwidget.h
+++ b/src/ui/linux/TogglDesktop/idlenotificationwidget.h
@@ -33,7 +33,9 @@ class IdleNotificationWidget : public QWidget {
private slots: // NOLINT
void requestIdleHint();
+#ifdef __linux
void idleHintReceived(QDBusPendingCallWatcher *watcher);
+#endif
void onScreensaverActiveChanged(bool active);
@@ -65,7 +67,9 @@ class IdleNotificationWidget : public QWidget {
QWidget *previousView;
uint64_t idleStarted;
+#ifdef __linux
QDBusInterface *screensaver;
+#endif
bool dbusApiAvailable;
bool screenLocked;
uint64_t lastActiveTime;
diff --git a/src/ui/linux/TogglDesktop/images/logo.png b/src/ui/linux/TogglDesktop/images/logo.png
index a4e8be4ba2..2b1da4f669 100644
Binary files a/src/ui/linux/TogglDesktop/images/logo.png and b/src/ui/linux/TogglDesktop/images/logo.png differ
diff --git a/src/ui/linux/TogglDesktop/loginwidget.cpp b/src/ui/linux/TogglDesktop/loginwidget.cpp
deleted file mode 100644
index cc9bc1b897..0000000000
--- a/src/ui/linux/TogglDesktop/loginwidget.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-// Copyright 2014 Toggl Desktop developers.
-
-#include
-#include "./loginwidget.h"
-#include "./ui_loginwidget.h"
-
-#include "./toggl.h"
-
-LoginWidget::LoginWidget(QStackedWidget *parent) : QWidget(parent),
-ui(new Ui::LoginWidget),
-oauth2(new OAuth2(this)) {
- ui->setupUi(this);
-
- connect(TogglApi::instance, SIGNAL(displayLogin(bool,uint64_t)), // NOLINT
- this, SLOT(displayLogin(bool,uint64_t))); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(setCountries(QVector)), // NOLINT
- this, SLOT(setCountries(QVector))); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(displayError(QString,bool)), // NOLINT
- this, SLOT(displayError(QString,bool))); // NOLINT
-
- oauth2->setScope("profile email");
- oauth2->setAppName("Toggl Desktop");
- oauth2->setClientID("426090949585.apps.googleusercontent.com");
- oauth2->setRedirectURI("http://www.google.com/robots.txt");
-
- connect(oauth2, SIGNAL(loginDone()), this, SLOT(loginDone()));
-
- signupVisible = true;
- countriesLoaded = false;
- selectedCountryId = UINT64_MAX;
-
- on_viewchangelabel_linkActivated("");
-}
-
-LoginWidget::~LoginWidget() {
- delete ui;
-}
-
-void LoginWidget::displayError(
- const QString errmsg,
- const bool user_error) {
- Q_UNUSED(errmsg);
- Q_UNUSED(user_error);
- enableAllControls(true);
-}
-
-void LoginWidget::enableAllControls(const bool enable) {
- ui->email->setEnabled(enable);
- ui->password->setEnabled(enable);
- ui->login->setEnabled(enable);
- ui->signup->setEnabled(enable);
- ui->googleLogin->setEnabled(enable);
- ui->forgotPassword->setEnabled(enable);
- ui->viewchangelabel->setEnabled(enable);
-}
-
-void LoginWidget::display() {
- signupVisible = true;
- on_viewchangelabel_linkActivated("");
- qobject_cast(parent())->setCurrentWidget(this);
-}
-
-void LoginWidget::keyPressEvent(QKeyEvent* event) {
- if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
- if (signupVisible) {
- on_signup_clicked();
- } else {
- on_login_clicked();
- }
- }
-}
-
-void LoginWidget::mousePressEvent(QMouseEvent* event) {
- Q_UNUSED(event);
- setFocus();
-}
-
-void LoginWidget::displayLogin(
- const bool open,
- const uint64_t user_id) {
-
- if (open) {
- display();
- ui->email->setFocus();
- }
- if (user_id) {
- ui->password->clear();
- }
-
- // Enable all
- enableAllControls(true);
-}
-
-void LoginWidget::on_login_clicked() {
- if (!validateFields(false)) {
- return;
- }
- enableAllControls(false);
- TogglApi::instance->login(ui->email->text(), ui->password->text());
-}
-
-void LoginWidget::on_googleLogin_linkActivated(const QString &link) {
- Q_UNUSED(link)
- oauth2->startLogin(true);
-}
-
-void LoginWidget::on_googleSignup_linkActivated(const QString &link) {
- Q_UNUSED(link)
- if (validateFields(true, true)) {
- oauth2->startLogin(true);
- }
-}
-
-void LoginWidget::loginDone() {
- if (signupVisible) {
- TogglApi::instance->googleSignup(oauth2->accessToken(), selectedCountryId);
- }
- else {
- TogglApi::instance->googleLogin(oauth2->accessToken());
- }
-}
-
-bool LoginWidget::validateFields(bool signup, bool google) {
- if (google)
- signup = true;
- if (!google) {
- if (ui->email->text().isEmpty()) {
- ui->email->setFocus();
- TogglApi::instance->displayError(QString("Please enter valid email address"), true);
- return false;
- }
- if (ui->password->text().isEmpty()) {
- ui->password->setFocus();
- TogglApi::instance->displayError(QString("A password is required"), true);
- return false;
- }
- }
- if (signup) {
- if (selectedCountryId == UINT64_MAX) {
- ui->countryComboBox->setFocus();
- TogglApi::instance->displayError(QString("Please select Country before signing up"), true);
- return false;
- }
- if (ui->tosCheckBox->checkState() == Qt::Unchecked) {
- ui->tosCheckBox->setFocus();
- TogglApi::instance->displayError(QString("You must agree to the terms of service and privacy policy to use Toggl"), true);
- return false;
- }
- }
- return true;
-}
-
-void LoginWidget::on_signup_clicked() {
- if (!validateFields(true)) {
- return;
- }
- TogglApi::instance->signup(ui->email->text(), ui->password->text(), selectedCountryId);
-}
-
-void LoginWidget::setCountries(
- QVector list) {
- ui->countryComboBox->clear();
- ui->countryComboBox->addItem(" -- Select country -- ");
- foreach(CountryView *view, list) {
- ui->countryComboBox->addItem(view->Text, QVariant::fromValue(view));
- }
-}
-
-void LoginWidget::on_viewchangelabel_linkActivated(const QString &link)
-{
- Q_UNUSED(link)
- if (signupVisible) {
- ui->signupWidget->hide();
- ui->loginWidget->show();
- ui->viewchangelabel->setText("Sign up for free");
- signupVisible = false;
- } else {
- ui->loginWidget->hide();
- ui->signupWidget->show();
- ui->viewchangelabel->setText("Back to login");
- signupVisible = true;
- if (!countriesLoaded) {
- TogglApi::instance->getCountries();
- countriesLoaded = true;
- }
- }
-}
-
-void LoginWidget::on_countryComboBox_currentIndexChanged(int index)
-{
- if (index == 0) {
- selectedCountryId = UINT64_MAX;
- return;
- }
- QVariant data = ui->countryComboBox->currentData();
- if (data.canConvert()) {
- CountryView *view = data.value();
- selectedCountryId = view->ID;
- }
-}
diff --git a/src/ui/linux/TogglDesktop/loginwidget.h b/src/ui/linux/TogglDesktop/loginwidget.h
deleted file mode 100644
index f7c6a98f17..0000000000
--- a/src/ui/linux/TogglDesktop/loginwidget.h
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2014 Toggl Desktop developers.
-
-#ifndef SRC_UI_LINUX_TOGGLDESKTOP_LOGINWIDGET_H_
-#define SRC_UI_LINUX_TOGGLDESKTOP_LOGINWIDGET_H_
-
-#include
-#include
-#include
-
-#include
-
-#include "./timeentryview.h"
-#include "./countryview.h"
-#include "./oauth2.h"
-
-namespace Ui {
-class LoginWidget;
-}
-
-class LoginWidget : public QWidget {
- Q_OBJECT
-
- public:
- explicit LoginWidget(QStackedWidget *parent = nullptr);
- ~LoginWidget();
-
- void display();
-
- protected:
- virtual void keyPressEvent(QKeyEvent *event);
- void mousePressEvent(QMouseEvent *event);
-
- private slots: // NOLINT
- void on_login_clicked();
-
- void displayLogin(
- const bool open,
- const uint64_t user_id);
-
- void on_googleLogin_linkActivated(const QString &link);
- void on_googleSignup_linkActivated(const QString &link);
-
- void loginDone();
- bool validateFields(bool signup, bool google = false);
-
- void on_signup_clicked();
-
- void setCountries(
- QVector list);
-
- void on_viewchangelabel_linkActivated(const QString &link);
-
- void on_countryComboBox_currentIndexChanged(int index);
-
- void displayError(
- const QString errmsg,
- const bool user_error);
-
- private:
- Ui::LoginWidget *ui;
-
- OAuth2 *oauth2;
-
- bool signupVisible;
-
- bool countriesLoaded;
- uint64_t selectedCountryId;
-
- void enableAllControls(const bool enable);
-};
-
-#endif // SRC_UI_LINUX_TOGGLDESKTOP_LOGINWIDGET_H_
diff --git a/src/ui/linux/TogglDesktop/loginwidget.ui b/src/ui/linux/TogglDesktop/loginwidget.ui
deleted file mode 100644
index 1038286b4d..0000000000
--- a/src/ui/linux/TogglDesktop/loginwidget.ui
+++ /dev/null
@@ -1,499 +0,0 @@
-
-
- LoginWidget
-
-
-
- 0
- 0
- 427
- 556
-
-
-
-
- 0
- 0
-
-
-
- Form
-
-
- false
-
-
- font-size:13px;
-
-
-
- 12
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
- -
-
-
- background-color: rgb(45, 45, 45);
-
-
- QFrame::NoFrame
-
-
- QFrame::Raised
-
-
- 0
-
-
-
-
-
-
- QFrame::NoFrame
-
-
- QFrame::Raised
-
-
- 0
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
- padding:12px
-
-
-
-
-
- :/images/logo.png
-
-
- Qt::AlignCenter
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 320
- 35
-
-
-
- false
-
-
- background-color: rgb(255, 255, 255);color:rgb(85, 85, 85);
-
-
- Your e-mail address
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 320
- 35
-
-
-
- false
-
-
- background-color: rgb(255, 255, 255);color:rgb(85, 85, 85);
-
-
-
-
-
- QLineEdit::Password
-
-
- Password
-
-
-
- -
-
-
-
- 320
- 0
-
-
-
-
- 1
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
-
- -1
-
-
-
- true
-
-
- color:#fff;padding-bottom:24px;
-
-
- <a href="https://www.toggl.com/forgot-password"><span style=" text-decoration: underline; color:#fff;">Forgot password?</span></a>
-
-
- Qt::RichText
-
-
- Qt::AlignHCenter|Qt::AlignTop
-
-
- true
-
-
- Qt::TextBrowserInteraction
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 320
- 35
-
-
-
- false
-
-
- background-color: rgb(255, 255, 255);color:rgb(85, 85, 85);
-
-
- Log in
-
-
-
- -
-
-
- true
-
-
-
- -1
-
-
-
- color:#fff;padding-top:6px
-
-
- <html><head/><body><p><a href="#google_login"><span style=" text-decoration: underline; color:#fff;">Log in with Google Account</span></a></p></body></html>
-
-
- Qt::RichText
-
-
- Qt::AlignCenter
-
-
- Qt::TextBrowserInteraction
-
-
-
- -
-
-
- color:#fff;padding-top:18px
-
-
- or you can
-
-
- Qt::AlignCenter
-
-
-
-
-
-
- -
-
-
-
-
-
-
- color:#fff;padding-top:18px
-
-
- Select country
-
-
- Qt::AlignCenter
-
-
-
- -
-
-
-
- 320
- 35
-
-
-
- color:#fff;
-
-
-
- -
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 0
- 20
-
-
-
-
- -
-
-
- color:#fff;
-
-
-
-
-
-
- -
-
-
- color:#fff;
-
-
- <p style="color:#fff;">I agree to <a href="https://toggl.com/legal/terms/" style=" text-decoration: underline; color:#fff;">terms of service</a> and <a href="https://toggl.com/legal/privacy/" style=" text-decoration: underline; color:#fff;">privacy policy</a>
-
-
- true
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 0
- 20
-
-
-
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 320
- 35
-
-
-
- false
-
-
- background-color: rgb(255, 255, 255);color:rgb(85, 85, 85);
-
-
- Sign up
-
-
- false
-
-
- false
-
-
-
- -
-
-
-
- -1
-
-
-
- true
-
-
- color:#fff;padding-bottom:6px;
-
-
- <html><head/><body><p><a href="#google_signup"><span style=" text-decoration: underline; color:#fff;">Sign up with Google Account</span></a></p></body></html>
-
-
- Qt::RichText
-
-
- Qt::AlignHCenter|Qt::AlignTop
-
-
- false
-
-
- Qt::TextBrowserInteraction
-
-
-
-
-
-
- -
-
-
-
- -1
-
-
-
-
-
-
- <html><head/><body><a href="#" style="text-decoration:none;color:#fff">Sign up for free</a></body></html>
-
-
- Qt::RichText
-
-
- Qt::AlignCenter
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/ui/linux/TogglDesktop/macosSpecific.h b/src/ui/linux/TogglDesktop/macosSpecific.h
new file mode 100644
index 0000000000..104e9fb4a7
--- /dev/null
+++ b/src/ui/linux/TogglDesktop/macosSpecific.h
@@ -0,0 +1,8 @@
+#ifndef SRC_MACOS_SPECIFIC_H_
+#define SRC_MACOS_SPECIFIC_H_
+
+
+void changeTitleBarColor(WId view, double r, double g, double b);
+
+
+#endif SRC_MACOS_SPECIFIC_H
diff --git a/src/ui/linux/TogglDesktop/macosSpecific.mm b/src/ui/linux/TogglDesktop/macosSpecific.mm
new file mode 100644
index 0000000000..37fdedefe5
--- /dev/null
+++ b/src/ui/linux/TogglDesktop/macosSpecific.mm
@@ -0,0 +1,11 @@
+#include
+#include
+
+#include
+
+void changeTitleBarColor(WId id, double r, double g, double b) {
+ NSView *view = (NSView*) id;
+ NSWindow* window = [view window];
+ window.titlebarAppearsTransparent = YES;
+ window.backgroundColor = [NSColor colorWithRed:r green:g blue:b alpha:1.];
+}
diff --git a/src/ui/linux/TogglDesktop/main.cpp b/src/ui/linux/TogglDesktop/main.cpp
index a23b4cf380..729c2fea32 100644
--- a/src/ui/linux/TogglDesktop/main.cpp
+++ b/src/ui/linux/TogglDesktop/main.cpp
@@ -7,27 +7,36 @@
#include
#include
#include
+#include
+
+#include
+#include
#include
#include
#include
#include
+#ifndef _WIN32
#include
+#endif
#include "singleapplication.h" // NOLINT
#include "./autocompleteview.h"
#include "./bugsnag.h"
#include "./genericview.h"
-#include "./mainwindowcontroller.h"
#include "./toggl.h"
+#include "./timeentryview.h"
+#include "./countryview.h"
+#include "./autocompletelistmodel.h"
-MainWindowController *w = nullptr;
+#include "mainwindow.h"
class TogglApplication : public SingleApplication {
public:
- TogglApplication(int &argc, char **argv) // NOLINT
- : SingleApplication(argc, argv) {}
+ TogglApplication(int &argc, char **argv)
+ : SingleApplication(argc, argv)
+ {}
virtual bool notify(QObject *receiver, QEvent *event);
};
@@ -36,27 +45,57 @@ bool TogglApplication::notify(QObject *receiver, QEvent *event) {
try {
return SingleApplication::notify(receiver, event);
} catch(std::exception &e) {
- TogglApi::notifyBugsnag("std::exception", e.what(),
- receiver->objectName());
+ TogglApi::notifyBugsnag("std::exception", e.what(), receiver->objectName());
} catch(...) {
- TogglApi::notifyBugsnag("unspecified", "exception",
- receiver->objectName());
+ TogglApi::notifyBugsnag("unspecified", "exception", receiver->objectName());
}
return true;
}
-int main(int argc, char *argv[]) try {
- Bugsnag::apiKey = "aa13053a88d5133b688db0f25ec103b7";
+void setOptions(const TogglApplication &a) {
+ QCommandLineParser parser;
+ parser.setApplicationDescription("Toggl Desktop");
+ parser.addHelpOption();
+ parser.addVersionOption();
- TogglApplication::setQuitOnLastWindowClosed(false);
+ QCommandLineOption logPathOption("log-path", " of the app log file", "path");
+ parser.addOption(logPathOption);
+ QCommandLineOption dbPathOption("db-path", " of the app DB file", "path");
+ parser.addOption(dbPathOption);
+
+ // A boolean option with multiple names (-b, --background)
+ QCommandLineOption forceOption({ "b", "background" }, "Start app in background.");
+ parser.addOption(forceOption);
+
+ parser.process(a);
+}
+
+void registerTypes() {
qRegisterMetaType("uint64_t");
qRegisterMetaType("int64_t");
qRegisterMetaType("bool_t");
+ qRegisterMetaType("char_t");
qRegisterMetaType >("QVector");
qRegisterMetaType >("QVector");
qRegisterMetaType >("QVector");
+ qmlRegisterUncreatableType("toggl", 1, 0, "Country", "Created by backend code");
+ qmlRegisterUncreatableType("toggl", 1, 0, "TimeEntry", "Created by backend code");
+ qmlRegisterUncreatableType("toggl", 1, 0, "TimeEntryList", "Created by backend code");
+ qmlRegisterUncreatableType("toggl", 1, 0, "Autocomplete", "Created by backend code");
+ qmlRegisterUncreatableType("toggl", 1, 0, "AutocompleteListModel", "Created by backend code");
+ qmlRegisterUncreatableType("toggl", 1, 0, "AutocompleteProxyModel", "Created by backend code");
+}
+
+
+int main(int argc, char *argv[]) try {
+ Bugsnag::apiKey = "aa13053a88d5133b688db0f25ec103b7";
+ Bugsnag::app.version = APP_VERSION;
+
+ qputenv("QML_DISABLE_DISTANCEFIELD", "1");
+
+ TogglApplication::setQuitOnLastWindowClosed(false);
QApplication::setApplicationName("Toggl Desktop");
QApplication::setOrganizationName("Toggl");
@@ -65,22 +104,29 @@ int main(int argc, char *argv[]) try {
qDebug() << "An instance of the app is already running";
return 0;
}
+ a.setApplicationVersion(APP_VERSION);
+ setOptions(a);
QtWebEngine::initialize();
- a.setApplicationVersion(APP_VERSION);
- Bugsnag::app.version = APP_VERSION;
+ registerTypes();
- QCommandLineParser parser;
- parser.setApplicationDescription("Toggl Desktop");
- parser.addHelpOption();
- parser.addVersionOption();
+ /*
+ QQmlApplicationEngine engine;
+ engine.rootContext()->setContextProperty("toggl", new TogglApi(nullptr));
+ engine.load(QUrl(QStringLiteral("qrc:/MainWindow.qml")));
+ */
- QCommandLineOption logPathOption(
- QStringList() << "log-path",
- " of the app log file",
- "path");
- parser.addOption(logPathOption);
+ auto w = new MainWindow();
+ w->show();
+ if (!TogglApi::instance->startEvents()) {
+ QMessageBox(QMessageBox::Warning,
+ "Error",
+ "The application could not start. Please inspect the log file.",
+ QMessageBox::Ok|QMessageBox::Cancel)
+ .exec();
+ return 1;
+ /* TODO readd
QCommandLineOption dbPathOption(
QStringList() << "db-path",
" of the app DB file",
@@ -110,12 +156,14 @@ int main(int argc, char *argv[]) try {
w->show();
if (parser.isSet(forceOption)) {
QTimer::singleShot(1, w, &MainWindowController::hide);
+ */
}
+
return a.exec();
-} catch (std::exception &e) { // NOLINT
+} catch (std::exception &e) {
TogglApi::notifyBugsnag("std::exception", e.what(), "main");
return 1;
-} catch (...) { // NOLINT
+} catch (...) {
TogglApi::notifyBugsnag("unspecified", "exception", "main");
return 1;
}
diff --git a/src/ui/linux/TogglDesktop/mainwindow.cpp b/src/ui/linux/TogglDesktop/mainwindow.cpp
new file mode 100644
index 0000000000..8216639c56
--- /dev/null
+++ b/src/ui/linux/TogglDesktop/mainwindow.cpp
@@ -0,0 +1,82 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include
+#include
+#include
+
+#include
+
+#ifdef __APPLE__
+#include "macosSpecific.h"
+#endif
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+ , ui(new Ui::MainWindow)
+ , preferences_(new PreferencesDialog(this))
+{
+ ui->setupUi(this);
+ ui->centralwidget->engine()->rootContext()->setContextProperty("toggl", new TogglApi(nullptr));
+ ui->centralwidget->setSource(QUrl("qrc:/MainWindow.qml"));
+#ifdef __APPLE__
+ auto color = QPalette().color(QPalette::Base);
+ changeTitleBarColor(effectiveWinId(), color.redF(), color.greenF(), color.blueF());
+#endif
+}
+
+MainWindow::~MainWindow() {
+ delete ui;
+}
+
+void MainWindow::on_actionAbout_triggered() {
+ // TODO
+}
+
+void MainWindow::on_actionHelp_triggered() {
+ TogglApi::instance->getSupport();
+}
+
+void MainWindow::on_actionUpdateCheck_triggered() {
+ // TODO
+}
+
+void MainWindow::on_actionPreferences_triggered() {
+ preferences_->show();
+}
+
+void MainWindow::on_actionQuit_triggered() {
+ qApp->quit();
+}
+
+void MainWindow::on_actionNew_triggered() {
+ TogglApi::instance->start("", "", 0, 0, nullptr, false);
+}
+
+void MainWindow::on_actionContinue_triggered() {
+ TogglApi::instance->continueLatestTimeEntry();
+}
+
+void MainWindow::on_actionStop_triggered() {
+ TogglApi::instance->stop();
+}
+
+void MainWindow::on_actionShow_triggered() {
+ // TODO
+}
+
+void MainWindow::on_actionEdit_triggered() {
+ TogglApi::instance->editRunningTimeEntry("description");
+}
+
+void MainWindow::on_actionSync_triggered() {
+ TogglApi::instance->sync();
+}
+
+void MainWindow::on_actionClearCache_triggered() {
+ // TODO
+}
+
+void MainWindow::on_actionLogout_triggered() {
+ TogglApi::instance->logout();
+}
diff --git a/src/ui/linux/TogglDesktop/mainwindow.h b/src/ui/linux/TogglDesktop/mainwindow.h
new file mode 100644
index 0000000000..c990eacc11
--- /dev/null
+++ b/src/ui/linux/TogglDesktop/mainwindow.h
@@ -0,0 +1,42 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include
+
+#include "preferencesdialog.h"
+
+namespace Ui {
+class MainWindow;
+}
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit MainWindow(QWidget *parent = nullptr);
+ ~MainWindow();
+
+private slots:
+ void on_actionAbout_triggered();
+ void on_actionHelp_triggered();
+ void on_actionUpdateCheck_triggered();
+ void on_actionPreferences_triggered();
+ void on_actionQuit_triggered();
+
+ void on_actionNew_triggered();
+ void on_actionContinue_triggered();
+ void on_actionStop_triggered();
+ void on_actionShow_triggered();
+ void on_actionEdit_triggered();
+
+ void on_actionSync_triggered();
+ void on_actionClearCache_triggered();
+ void on_actionLogout_triggered();
+private:
+ Ui::MainWindow *ui;
+
+ PreferencesDialog *preferences_;
+};
+
+#endif // MAINWINDOW_H
diff --git a/src/ui/linux/TogglDesktop/mainwindow.ui b/src/ui/linux/TogglDesktop/mainwindow.ui
new file mode 100644
index 0000000000..3c5008152b
--- /dev/null
+++ b/src/ui/linux/TogglDesktop/mainwindow.ui
@@ -0,0 +1,154 @@
+
+
+ MainWindow
+
+
+
+ 0
+ 0
+ 360
+ 480
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 240
+ 64
+
+
+
+ Toggl
+
+
+
+ QQuickWidget::SizeRootObjectToView
+
+
+
+
+
+ About Toggl Desktop
+
+
+
+
+ Check for updates
+
+
+
+
+ Preferences
+
+
+
+
+ Quit
+
+
+
+
+ Sync
+
+
+
+
+ Clear cache
+
+
+
+
+ Logout
+
+
+
+
+ New
+
+
+
+
+ Continue
+
+
+
+
+ Stop
+
+
+
+
+ Show
+
+
+
+
+ Edit
+
+
+
+
+ Help
+
+
+
+
+
+ QQuickWidget
+ QWidget
+ QtQuickWidgets/QQuickWidget
+
+
+
+
+
diff --git a/src/ui/linux/TogglDesktop/mainwindowcontroller.cpp b/src/ui/linux/TogglDesktop/mainwindowcontroller.cpp
deleted file mode 100644
index b0e44adb79..0000000000
--- a/src/ui/linux/TogglDesktop/mainwindowcontroller.cpp
+++ /dev/null
@@ -1,576 +0,0 @@
-// Copyright 2014 Toggl Desktop developers.
-
-#include "./mainwindowcontroller.h"
-#include "./ui_mainwindowcontroller.h"
-
-#include // NOLINT
-
-#include // NOLINT
-#include // NOLINT
-#include // NOLINT
-#include // NOLINT
-#include // NOLINT
-#include // NOLINT
-#include // NOLINT
-#include // NOLINT
-#include // NOLINT
-#include // NOLINT
-#include // NOLINT
-#include // NOLINT
-#include // NOLINT
-#include // NOLINT
-
-#include "./toggl.h"
-#include "./timeentryeditorwidget.h"
-#include "./timeentrylistwidget.h"
-#include "./timerwidget.h"
-#include "./errorviewcontroller.h"
-#include "./timeentrycellwidget.h"
-
-MainWindowController::MainWindowController(
- QWidget *parent,
- QString logPathOverride,
- QString dbPathOverride,
- QString scriptPath)
- : QMainWindow(parent),
- ui(new Ui::MainWindowController),
- togglApi(new TogglApi(nullptr, logPathOverride, dbPathOverride)),
- tracking(false),
- loggedIn(false),
- preferencesDialog(new PreferencesDialog(this)),
- aboutDialog(new AboutDialog(this)),
- feedbackDialog(new FeedbackDialog(this)),
- icon(":/icons/1024x1024/toggldesktop.png"),
- iconDisabled(":/icons/1024x1024/toggldesktop_gray.png"),
- trayIcon(nullptr),
- pomodoro(false),
- script(scriptPath),
- powerManagement(new PowerManagement(this)),
- networkManagement(new NetworkManagement(this)),
- shortcutDelete(QKeySequence(Qt::CTRL + Qt::Key_Delete), this),
- shortcutPause(QKeySequence(Qt::CTRL + Qt::Key_Space), this),
- shortcutConfirm(QKeySequence(Qt::CTRL + Qt::Key_Return), this),
- shortcutGroupOpen(QKeySequence(Qt::Key_Right), this),
- shortcutGroupClose(QKeySequence(Qt::Key_Left), this),
- ui_started(false) {
- ui->setupUi(this);
-
- ui->menuBar->setVisible(true);
-
- readSettings();
-
- connect(TogglApi::instance, SIGNAL(displayApp(bool)), // NOLINT
- this, SLOT(displayApp(bool))); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(displayStoppedTimerState()), // NOLINT
- this, SLOT(displayStoppedTimerState())); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(displayRunningTimerState(TimeEntryView*)), // NOLINT
- this, SLOT(displayRunningTimerState(TimeEntryView*))); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(displayLogin(bool,uint64_t)), // NOLINT
- this, SLOT(displayLogin(bool,uint64_t))); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(displayPomodoro(QString,QString)), // NOLINT
- this, SLOT(displayPomodoro(QString,QString))); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(displayPomodoroBreak(QString,QString)), // NOLINT
- this, SLOT(displayPomodoroBreak(QString,QString))); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(displayUpdate(QString)), // NOLINT
- this, SLOT(displayUpdate(QString))); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(displayOnlineState(int64_t)), // NOLINT
- this, SLOT(displayOnlineState(int64_t))); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(updateShowHideShortcut()), // NOLINT
- this, SLOT(updateShowHideShortcut())); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(updateContinueStopShortcut()), // NOLINT
- this, SLOT(updateContinueStopShortcut())); // NOLINT
-
- setWindowIcon(icon);
- trayIcon = new SystemTray(this, icon);
-
- setShortcuts();
- connectMenuActions();
- enableMenuActions();
-
- connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
- this, SLOT(toggleWindow(QSystemTrayIcon::ActivationReason)));
- connect(networkManagement, &NetworkManagement::onlineStateChanged,
- this, &MainWindowController::onOnlineStateChanged);
- onOnlineStateChanged();
- restoreLastWindowsFrame();
-}
-
-MainWindowController::~MainWindowController() {
- delete togglApi;
- togglApi = nullptr;
-
- delete ui;
-}
-
-void MainWindowController::toggleWindow(QSystemTrayIcon::ActivationReason r) {
- if (r == QSystemTrayIcon::Trigger) {
- if (!this->isVisible()) {
- this->show();
- } else {
- this->hide();
- }
- }
-}
-
-void MainWindowController::displayOnlineState(
- int64_t state) {
-
- switch (state) {
- case 0: // online
- statusBar()->clearMessage();
- break;
- case 1: // no network
- statusBar()->showMessage("Status: Offline, no network");
- break;
- case 2: // backend down
- statusBar()->showMessage("Status: Offline, Toggl not responding");
- break;
- default:
- qDebug() << "Unknown online state " << state;
- break;
- }
-}
-
-void MainWindowController::displayPomodoro(
- const QString title,
- const QString informative_text) {
-
- if (pomodoro) {
- return;
- }
- pomodoro = true;
-
- QMessageBox msgBox;
- msgBox.setWindowTitle("Pomodoro Timer");
- msgBox.setText(title);
- msgBox.setInformativeText(informative_text);
- QPushButton *continueButton =
- msgBox.addButton(tr("Continue"), QMessageBox::YesRole);
- QPushButton *closeButton =
- msgBox.addButton(tr("Close"), QMessageBox::NoRole);
- msgBox.setDefaultButton(closeButton);
- msgBox.setEscapeButton(closeButton);
-
- msgBox.exec();
-
- if (msgBox.clickedButton() == continueButton) {
- TogglApi::instance->continueLatestTimeEntry();
- }
-
- pomodoro = false;
-}
-
-void MainWindowController::displayPomodoroBreak(
- const QString title,
- const QString informative_text) {
-
- if (pomodoro) {
- return;
- }
- pomodoro = true;
-
- QMessageBox msgBox;
- msgBox.setWindowTitle("Pomodoro Break Timer");
- msgBox.setText(title);
- msgBox.setInformativeText(informative_text);
- QPushButton *continueButton =
- msgBox.addButton(tr("Continue"), QMessageBox::YesRole);
- QPushButton *closeButton =
- msgBox.addButton(tr("Close"), QMessageBox::NoRole);
- msgBox.setDefaultButton(closeButton);
- msgBox.setEscapeButton(closeButton);
-
- msgBox.exec();
-
- if (msgBox.clickedButton() == continueButton) {
- TogglApi::instance->continueLatestTimeEntry();
- }
-
- pomodoro = false;
-}
-
-void MainWindowController::displayLogin(
- const bool open,
- const uint64_t user_id) {
-
- loggedIn = !open && user_id;
- enableMenuActions();
-}
-
-void MainWindowController::displayRunningTimerState(
- TimeEntryView *te) {
- Q_UNUSED(te);
- tracking = true;
- enableMenuActions();
-}
-
-void MainWindowController::displayStoppedTimerState() {
- tracking = false;
- enableMenuActions();
-}
-
-void MainWindowController::enableMenuActions() {
- ui->actionNew->setEnabled(loggedIn);
- ui->actionContinue->setEnabled(loggedIn && !tracking);
- ui->actionStop->setEnabled(loggedIn && tracking);
- ui->actionSync->setEnabled(loggedIn);
- ui->actionLogout->setEnabled(loggedIn);
- ui->actionClear_Cache->setEnabled(loggedIn);
- ui->actionSend_Feedback->setEnabled(loggedIn);
- ui->actionReports->setEnabled(loggedIn);
- ui->actionEmail->setText(TogglApi::instance->userEmail());
- if (tracking) {
- setWindowIcon(icon);
- trayIcon->setIcon(icon);
- } else {
- setWindowIcon(iconDisabled);
- trayIcon->setIcon(iconDisabled);
- }
-}
-
-void MainWindowController::showHideHotkeyPressed() {
- if (this->isVisible()) {
- if (this->isActiveWindow()) {
- hide();
- } else {
- activateWindow();
- }
- } else {
- onActionShow();
- activateWindow();
- }
-}
-
-void MainWindowController::continueStopHotkeyPressed() {
- if (tracking) {
- onActionStop();
- } else {
- onActionContinue();
- }
-}
-
-void MainWindowController::updateShowHideShortcut() {
- showHide->setShortcut(
- QKeySequence(TogglApi::instance->getShowHideKey()));
-}
-
-void MainWindowController::updateContinueStopShortcut() {
- continueStop->setShortcut(
- QKeySequence(TogglApi::instance->getContinueStopKey()));
-}
-
-void MainWindowController::onOnlineStateChanged() {
- if (networkManagement->isOnline()) {
- TogglApi::instance->setOnline();
- }
-}
-
-void MainWindowController::onShortcutDelete() {
- if (ui->stackedWidget->currentWidget() == ui->timeEntryListWidget) {
- if (ui->timeEntryListWidget->focusWidget() &&
- ui->timeEntryListWidget->focusWidget()->parentWidget() &&
- qobject_cast(ui->timeEntryListWidget->focusWidget()->parentWidget())) {
- qobject_cast(ui->timeEntryListWidget->focusWidget()->parentWidget())->deleteTimeEntry();
- }
- else {
- ui->timeEntryListWidget->timer()->deleteTimeEntry();
- }
- }
- else if (ui->stackedWidget->currentWidget() == ui->timeEntryEditorWidget) {
- ui->timeEntryEditorWidget->deleteTimeEntry();
- }
-}
-
-void MainWindowController::onShortcutPause() {
- auto w = focusWidget();
- while (w) {
- auto timer = qobject_cast(w);
- auto timeEntryList = qobject_cast(w);
- auto timeEntryEdit = qobject_cast(w);
- if (timer) {
- continueStopHotkeyPressed();
- return;
- }
- else if (timeEntryList) {
- bool thisItem = !timeEntryList->timer()->currentEntryGuid().isEmpty() &&
- timeEntryList->highlightedCell() &&
- timeEntryList->timer()->currentEntryGuid() == timeEntryList->highlightedCell()->entryGuid();
- QString selectedGuid = timeEntryList->highlightedCell() ? timeEntryList->highlightedCell()->entryGuid() : QString();
- if (tracking) {
- onActionStop();
- }
- if (!thisItem) {
- TogglApi::instance->continueTimeEntry(selectedGuid);
- }
- return;
- }
- else if (timeEntryEdit) {
- return;
- }
- w = w->parentWidget();
- }
-}
-
-void MainWindowController::onShortcutConfirm() {
- auto w = focusWidget();
- while (w) {
- auto timer = qobject_cast(w);
- auto timeEntryList = qobject_cast(w);
- auto timeEntryEdit = qobject_cast(w);
- if (timer) {
- TogglApi::instance->editRunningTimeEntry("");
- return;
- }
- else if (timeEntryList) {
- QString selectedGuid = timeEntryList->highlightedCell() ? timeEntryList->highlightedCell()->entryGuid() : QString();
- TogglApi::instance->editTimeEntry(selectedGuid, "description");
- return;
- }
- else if (timeEntryEdit) {
- timeEntryEdit->clickDone();
- return;
- }
- w = w->parentWidget();
- }
-}
-
-void MainWindowController::onShortcutGroupOpen() {
- if (ui->stackedWidget->currentWidget() == ui->timeEntryListWidget) {
- if (ui->timeEntryListWidget->focusWidget() &&
- ui->timeEntryListWidget->focusWidget()->parentWidget() &&
- qobject_cast(ui->timeEntryListWidget->focusWidget()->parentWidget())) {
- qobject_cast(ui->timeEntryListWidget->focusWidget()->parentWidget())->toggleGroup(true);
- }
- }
-}
-
-void MainWindowController::onShortcutGroupClose() {
- if (ui->stackedWidget->currentWidget() == ui->timeEntryListWidget) {
- if (ui->timeEntryListWidget->focusWidget() &&
- ui->timeEntryListWidget->focusWidget()->parentWidget() &&
- qobject_cast(ui->timeEntryListWidget->focusWidget()->parentWidget())) {
- qobject_cast(ui->timeEntryListWidget->focusWidget()->parentWidget())->toggleGroup(false);
- }
- }
-}
-
-void MainWindowController::setShortcuts() {
- showHide = new QxtGlobalShortcut(this);
- connect(showHide, SIGNAL(activated()),
- this, SLOT(showHideHotkeyPressed()));
-
- updateShowHideShortcut();
-
- continueStop = new QxtGlobalShortcut(this);
- connect(continueStop, SIGNAL(activated()),
- this, SLOT(continueStopHotkeyPressed()));
-
- updateContinueStopShortcut();
-
- connect(&shortcutDelete, &QShortcut::activated,
- this, &MainWindowController::onShortcutDelete);
- connect(&shortcutPause, &QShortcut::activated,
- this, &MainWindowController::onShortcutPause);
- connect(&shortcutConfirm, &QShortcut::activated,
- this, &MainWindowController::onShortcutConfirm);
- connect(&shortcutGroupOpen, &QShortcut::activated,
- this, &MainWindowController::onShortcutGroupOpen);
- connect(&shortcutGroupClose, &QShortcut::activated,
- this, &MainWindowController::onShortcutGroupClose);
-}
-
-void MainWindowController::connectMenuActions() {
- connect(ui->actionNew, &QAction::triggered, this, &MainWindowController::onActionNew);
- connect(ui->actionContinue, &QAction::triggered, this, &MainWindowController::onActionContinue);
- connect(ui->actionStop, &QAction::triggered, this, &MainWindowController::onActionStop);
- connect(ui->actionSync, &QAction::triggered, this, &MainWindowController::onActionSync);
- connect(ui->actionLogout, &QAction::triggered, this, &MainWindowController::onActionLogout);
- connect(ui->actionClear_Cache, &QAction::triggered, this, &MainWindowController::onActionClear_Cache);
- connect(ui->actionSend_Feedback, &QAction::triggered, this, &MainWindowController::onActionSend_Feedback);
- connect(ui->actionReports, &QAction::triggered, this, &MainWindowController::onActionReports);
- connect(ui->actionShow, &QAction::triggered, this, &MainWindowController::onActionShow);
- connect(ui->actionPreferences, &QAction::triggered, this, &MainWindowController::onActionPreferences);
- connect(ui->actionAbout, &QAction::triggered, this, &MainWindowController::onActionAbout);
- connect(ui->actionQuit, &QAction::triggered, this, &MainWindowController::onActionQuit);
- connect(ui->actionHelp, &QAction::triggered, this, &MainWindowController::onActionHelp);
-
- QMenu *trayMenu = new QMenu(this);
-for (auto act : ui->menuToggl_Desktop->actions()) {
- trayMenu->addAction(act);
- }
-
- trayIcon->setContextMenu(trayMenu);
-}
-
-void MainWindowController::onActionNew() {
- TogglApi::instance->start("", "", 0, 0, nullptr, false);
-}
-
-void MainWindowController::onActionContinue() {
- TogglApi::instance->continueLatestTimeEntry();
-}
-
-void MainWindowController::onActionStop() {
- TogglApi::instance->stop();
-}
-
-void MainWindowController::onActionShow() {
- displayApp(true);
-}
-
-void MainWindowController::onActionSync() {
- TogglApi::instance->sync();
-}
-
-void MainWindowController::onActionReports() {
- TogglApi::instance->openInBrowser();
-}
-
-void MainWindowController::onActionPreferences() {
- TogglApi::instance->editPreferences();
-}
-
-void MainWindowController::onActionAbout() {
- aboutDialog->show();
-}
-
-void MainWindowController::onActionSend_Feedback() {
- feedbackDialog->show();
-}
-
-void MainWindowController::onActionLogout() {
- TogglApi::instance->logout();
-}
-
-void MainWindowController::onActionQuit() {
- quitApp();
-}
-
-void MainWindowController::quitApp() {
- TogglApi::instance->shutdown = true;
- TogglApi::instance->clear();
- qApp->exit(0);
-}
-
-void MainWindowController::onActionClear_Cache() {
- if (QMessageBox::Ok == QMessageBox(
- QMessageBox::Question,
- "Clear Cache?",
- "Clearing cache will delete any unsaved time entries and log you out.",
- QMessageBox::Ok|QMessageBox::Cancel).exec()) {
- TogglApi::instance->clearCache();
- }
-}
-
-void MainWindowController::onActionHelp() {
- TogglApi::instance->getSupport();
-}
-
-void MainWindowController::displayApp(const bool open) {
- if (open) {
- show();
- raise();
- }
-}
-
-void MainWindowController::readSettings() {
- QSettings settings("Toggl", "TogglDesktop");
- restoreGeometry(settings.value("geometry").toByteArray());
- restoreState(settings.value("windowState").toByteArray());
-}
-
-void MainWindowController::writeSettings() {
- QSettings settings("Toggl", "TogglDesktop");
- settings.setValue("geometry", saveGeometry());
- settings.setValue("windowState", saveState());
-}
-
-void MainWindowController::showEvent(QShowEvent *event) {
- QMainWindow::showEvent(event);
-
- // Avoid 'user already logged in' error from double UI start
- if (ui_started) {
- return;
- }
- ui_started = true;
-
- if (!TogglApi::instance->startEvents()) {
- QMessageBox(
- QMessageBox::Warning,
- "Error",
- "The application could not start. Please inspect the log file.",
- QMessageBox::Ok|QMessageBox::Cancel).exec();
- return;
- }
- if (script.isEmpty()) {
- // qDebug() << "no script to run";
- return;
- }
- qDebug() << "will run script: " << script;
-}
-
-void MainWindowController::closeEvent(QCloseEvent *event) {
-
- // Window manager has requested the app to quit so just quit
- if (powerManagement->aboutToShutdown()) {
- QMainWindow::closeEvent(event);
- return;
- }
-
- // Save current windows frame
- TogglApi::instance->setWindowsFrameSetting(QRect(pos().x(),
- pos().y(),
- size().width(),
- size().height()));
-
- if (trayIcon->isVisible()) {
- event->ignore();
- hide();
- return;
- }
-
- QMessageBox::StandardButton dialog;
- dialog = QMessageBox::question(this,
- "Quit Toggl Desktop",
- "Really quit the app?",
- QMessageBox::Ok | QMessageBox::Cancel);
- if (QMessageBox::Ok == dialog) {
- writeSettings();
- close();
- } else {
- event->ignore();
- return;
- }
-
- QMainWindow::closeEvent(event);
-}
-
-void MainWindowController::displayUpdate(const QString url) {
- if (aboutDialog->isVisible()
- || url.isEmpty()) {
- return;
- }
- if (QMessageBox::Yes == QMessageBox(
- QMessageBox::Question,
- "Download new version?",
- "A new version of Toggl Desktop is available. Continue with download?",
- QMessageBox::No|QMessageBox::Yes).exec()) {
- QDesktopServices::openUrl(QUrl(url));
- quitApp();
- }
-}
-
-void MainWindowController::restoreLastWindowsFrame() {
- const QRect frame = TogglApi::instance->getWindowsFrameSetting();
- move(frame.x(), frame.y());
- resize(frame.width(), frame.height());
-}
diff --git a/src/ui/linux/TogglDesktop/mainwindowcontroller.h b/src/ui/linux/TogglDesktop/mainwindowcontroller.h
deleted file mode 100644
index e9dcc92cd5..0000000000
--- a/src/ui/linux/TogglDesktop/mainwindowcontroller.h
+++ /dev/null
@@ -1,148 +0,0 @@
-// Copyright 2014 Toggl Desktop developers.
-
-#ifndef SRC_UI_LINUX_TOGGLDESKTOP_MAINWINDOWCONTROLLER_H_
-#define SRC_UI_LINUX_TOGGLDESKTOP_MAINWINDOWCONTROLLER_H_
-
-#include
-#include
-#include // NOLINT
-#include
-
-#include
-#include
-
-#include "./toggl.h"
-#include "./preferencesdialog.h"
-#include "./aboutdialog.h"
-#include "./feedbackdialog.h"
-#include "./qxtglobalshortcut.h"
-#include "./systemtray.h"
-#include "./powermanagement.h"
-#include "./networkmanagement.h"
-#include "./overlaywidget.h"
-#include "./loginwidget.h"
-#include "./timeentrylistwidget.h"
-#include "./timeentryeditorwidget.h"
-#include "./idlenotificationwidget.h"
-
-namespace Ui {
-class MainWindowController;
-}
-
-class MainWindowController : public QMainWindow {
- Q_OBJECT
-
- public:
- MainWindowController(
- QWidget *parent = 0,
- QString logPathOverride = "",
- QString dbPathOverride = "",
- QString scriptPath = "");
- ~MainWindowController();
-
- static MainWindowController *Instance;
-
- void quitApp();
- void setShortcuts();
-
- protected:
- void showEvent(QShowEvent *event);
- void closeEvent(QCloseEvent *event);
-
- private slots: // NOLINT
- void toggleWindow(QSystemTrayIcon::ActivationReason r);
-
- void displayApp(const bool open);
-
- void displayRunningTimerState(TimeEntryView *te);
-
- void displayStoppedTimerState();
-
- void displayLogin(
- const bool open,
- const uint64_t user_id);
-
- void displayPomodoro(
- const QString title,
- const QString informative_text);
-
- void displayPomodoroBreak(
- const QString title,
- const QString informative_text);
-
- void displayUpdate(const QString url);
-
- void displayOnlineState(int64_t);
- void showHideHotkeyPressed();
- void continueStopHotkeyPressed();
-
- void onActionNew();
- void onActionContinue();
- void onActionStop();
- void onActionShow();
- void onActionSync();
- void onActionReports();
- void onActionPreferences();
- void onActionAbout();
- void onActionSend_Feedback();
- void onActionLogout();
- void onActionQuit();
- void onActionClear_Cache();
- void onActionHelp();
-
- void updateShowHideShortcut();
- void updateContinueStopShortcut();
-
- void onOnlineStateChanged();
-
- void onShortcutDelete();
- void onShortcutPause();
- void onShortcutConfirm();
- void onShortcutGroupOpen();
- void onShortcutGroupClose();
-
- private:
- Ui::MainWindowController *ui;
-
- TogglApi *togglApi;
-
- bool tracking;
- bool loggedIn;
- bool startInBackground;
-
- QxtGlobalShortcut* showHide;
- QxtGlobalShortcut* continueStop;
-
- PreferencesDialog *preferencesDialog;
- AboutDialog *aboutDialog;
- FeedbackDialog *feedbackDialog;
-
- QIcon icon;
- QIcon iconDisabled;
- SystemTray *trayIcon;
-
- bool pomodoro;
-
- QString script;
-
- PowerManagement *powerManagement;
- NetworkManagement *networkManagement;
-
- QShortcut shortcutDelete;
- QShortcut shortcutPause;
- QShortcut shortcutConfirm;
- QShortcut shortcutGroupOpen;
- QShortcut shortcutGroupClose;
-
- void readSettings();
- void writeSettings();
-
- void connectMenuActions();
- void enableMenuActions();
-
- bool ui_started;
-
- void restoreLastWindowsFrame();
-};
-
-#endif // SRC_UI_LINUX_TOGGLDESKTOP_MAINWINDOWCONTROLLER_H_
diff --git a/src/ui/linux/TogglDesktop/mainwindowcontroller.ui b/src/ui/linux/TogglDesktop/mainwindowcontroller.ui
deleted file mode 100644
index d88d1ed89b..0000000000
--- a/src/ui/linux/TogglDesktop/mainwindowcontroller.ui
+++ /dev/null
@@ -1,221 +0,0 @@
-
-
- MainWindowController
-
-
-
- 0
- 0
- 350
- 420
-
-
-
-
- 0
- 0
-
-
-
- Toggl Desktop
-
-
- false
-
-
-
-
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
- -
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
- &New
-
-
- Ctrl+N
-
-
-
-
- &Continue
-
-
- Ctrl+O
-
-
-
-
- &Stop
-
-
- Ctrl+S
-
-
-
-
- S&ync
-
-
- Ctrl+R
-
-
-
-
- &Reports
-
-
-
-
- &Preferences
-
-
-
-
- &About
-
-
-
-
- Send &Feedback
-
-
-
-
- &Logout
-
-
-
-
- &Quit
-
-
-
-
- Clear Cache
-
-
-
-
- &Help
-
-
-
-
- false
-
-
- &email
-
-
-
-
- Sh&ow
-
-
-
-
-
-
- ErrorViewController
- QWidget
-
- 1
-
-
- OverlayWidget
- QWidget
-
-
-
- LoginWidget
- QWidget
-
-
-
- TimeEntryEditorWidget
- QWidget
-
-
-
- TimeEntryListWidget
- QWidget
-
-
-
- IdleNotificationWidget
- QWidget
-
-
-
-
-
-
diff --git a/src/ui/linux/TogglDesktop/overlaywidget.cpp b/src/ui/linux/TogglDesktop/overlaywidget.cpp
deleted file mode 100644
index 88ce1b252f..0000000000
--- a/src/ui/linux/TogglDesktop/overlaywidget.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-#include "overlaywidget.h"
-#include "ui_overlaywidget.h"
-#include "./toggl.h"
-
-OverlayWidget::OverlayWidget(QStackedWidget *parent) :
- QWidget(parent),
- ui(new Ui::OverlayWidget)
-{
- ui->setupUi(this);
- current_type = -1;
-
- ui->bottomText->setCursor(Qt::PointingHandCursor);
-
- connect(TogglApi::instance, SIGNAL(displayLogin(bool,uint64_t)), // NOLINT
- this, SLOT(displayLogin(bool,uint64_t))); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(displayOverlay(int64_t)), // NOLINT
- this, SLOT(displayOverlay(int64_t))); // NOLINT
-}
-
-OverlayWidget::~OverlayWidget()
-{
- delete ui;
-}
-
-void OverlayWidget::display() {
- qobject_cast(parent())->setCurrentWidget(this);
-}
-
-void OverlayWidget::displayOverlay(const int64_t type) {
- current_type = type;
- QString top("");
- QString button("");
- QString bottom("");
- // setup overlay content
- if (type == 0) {
- // missing ws
- top.append("You no longer have access to your last Workspace. Create a new workspace on Toggl.com to continue tracking");
-
- bottom.append("");
- bottom.append("Created your new workspace?
");
- bottom.append("");
- bottom.append("Force sync
");
-
- button.append("Log in to Toggl.com");
- } else if (type == 1) {
- // tos accept
- top.append("Our Terms of Service and Privacy Policy have changed
");
- top.append("Please read and accept our updated ");
- top.append("");
- top.append("");
- top.append("Terms of Service and ");
- top.append("");
- top.append("");
- top.append("Privacy policy to continuue using Toggl");
- bottom.append("If you have any questions, contact us at support@toggl.com");
- button.append("I accept");
- }
-
- ui->topText->setText(top);
- ui->actionButton->setText(button);
- ui->bottomText->setText(bottom);
- display();
-}
-
-void OverlayWidget::displayLogin(
- const bool open,
- const uint64_t user_id) {
-
- if (open || user_id) {
- }
-}
-
-void OverlayWidget::on_actionButton_clicked()
-{
- if (current_type == 0) {
- TogglApi::instance->openInBrowser();
- } else if (current_type == 1) {
- TogglApi::instance->tosAccept();
- }
-}
-
-void OverlayWidget::on_bottomText_linkActivated(const QString &link)
-{
- Q_UNUSED(link);
- if (current_type == 0) {
- TogglApi::instance->fullSync();
- }
-}
-
-void OverlayWidget::on_topText_linkActivated(const QString &link)
-{
- if (current_type == 1) {
- TogglApi::instance->openLegal(link);
- }
-}
diff --git a/src/ui/linux/TogglDesktop/overlaywidget.h b/src/ui/linux/TogglDesktop/overlaywidget.h
deleted file mode 100644
index a7ac6998fc..0000000000
--- a/src/ui/linux/TogglDesktop/overlaywidget.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef OVERLAYWIDGET_H
-#define OVERLAYWIDGET_H
-
-#include
-#include
-#include
-#include "./timeentryview.h"
-
-namespace Ui {
-class OverlayWidget;
-}
-
-class OverlayWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit OverlayWidget(QStackedWidget *parent = nullptr);
- ~OverlayWidget();
- void display();
-
-private:
- Ui::OverlayWidget *ui;
- int64_t current_type;
-
-private slots: // NOLINT
-
- void displayOverlay(const int64_t type);
-
- void displayLogin(
- const bool open,
- const uint64_t user_id);
-
- void on_actionButton_clicked();
- void on_bottomText_linkActivated(const QString &link);
- void on_topText_linkActivated(const QString &link);
-};
-
-
-#endif // OVERLAYWIDGET_H
diff --git a/src/ui/linux/TogglDesktop/overlaywidget.ui b/src/ui/linux/TogglDesktop/overlaywidget.ui
deleted file mode 100644
index 77e7e8b1b1..0000000000
--- a/src/ui/linux/TogglDesktop/overlaywidget.ui
+++ /dev/null
@@ -1,82 +0,0 @@
-
-
- OverlayWidget
-
-
-
- 0
- 0
- 400
- 300
-
-
-
- Form
-
-
- -
-
-
- <html><head/><body><p align="center">Created your new workspace?<br/><a href="#force-sync"><span style=" text-decoration: underline; color:#0000ff;">Force sync</span></a></p></body></html>
-
-
- Qt::RichText
-
-
-
- -
-
-
- QLayout::SetMinAndMaxSize
-
-
-
-
-
-
- 160
- 30
-
-
-
- Log in to Toggl.com
-
-
- true
-
-
- true
-
-
- false
-
-
-
-
-
- -
-
-
-
- 16777215
- 16777215
-
-
-
- You no longer have access to your last Workspace. Create a new workspace on Toggl.com to continue tracking
-
-
- Qt::AlignCenter
-
-
- true
-
-
- 20
-
-
-
-
-
-
-
-
diff --git a/src/ui/linux/TogglDesktop/preferencesdialog.ui b/src/ui/linux/TogglDesktop/preferencesdialog.ui
index a8f5c9cb1f..2bfe0f9a9d 100644
--- a/src/ui/linux/TogglDesktop/preferencesdialog.ui
+++ b/src/ui/linux/TogglDesktop/preferencesdialog.ui
@@ -20,7 +20,7 @@
-
- 2
+ 0
diff --git a/src/ui/linux/TogglDesktop/qmlobjectlist.cc b/src/ui/linux/TogglDesktop/qmlobjectlist.cc
new file mode 100644
index 0000000000..10eb6ca07d
--- /dev/null
+++ b/src/ui/linux/TogglDesktop/qmlobjectlist.cc
@@ -0,0 +1,93 @@
+#include "qmlobjectlist.h"
+#include
+#include
+#include
+
+#define ValidateIndex(m_i) (m_i < 0 || m_i >= rowCount())
+
+void QmlObjectList::append(const QVariantMap& properties)
+{
+ QObject* newObj = mMetaObject.newInstance();
+ if(newObj == Q_NULLPTR) {
+ qWarning("invalid constructor");
+ return;
+ }
+ for(const QString& key : properties.keys()) {
+ if(!newObj->setProperty(key.toUtf8().data(), properties.value(key)))
+ qWarning()<<"append object with invalid property"<metaObject() == &mMetaObject);
+ beginInsertRows(QModelIndex(), 0, 0);
+ mData.prepend(QObjectPointer(object));
+ endInsertRows();
+}
+
+void QmlObjectList::append(QObject *object)
+{
+ insert(rowCount(), object);
+}
+
+bool QmlObjectList::insert(const int& i, QObject* object)
+{
+ Q_ASSERT(object->metaObject() == &mMetaObject);
+ if(i < 0 || i > rowCount())
+ return false;
+ beginInsertRows(QModelIndex(), i, i);
+ mData.insert(i, QObjectPointer(object));
+ endInsertRows();
+ return true;
+}
+
+int QmlObjectList::count() {
+ return rowCount();
+}
+
+bool QmlObjectList::removeRow(int row, const QModelIndex &parent)
+{
+ const int first = row;
+ const int last = row;
+ if(ValidateIndex(first) || ValidateIndex(last))
+ return false;
+ beginRemoveRows(parent, first, last);
+ mData.removeAt(row);
+ endRemoveRows();
+ return true;
+}
+
+QVariant QmlObjectList::data(const QModelIndex &index, int role) const
+{
+ if(ValidateIndex(index.row()))
+ return QVariant();
+ const QObjectPointer& data = mData[index.row()];
+ if(data.isNull()) {
+ qWarning()<<__FUNCTION__<<"data is null";
+ return QVariant();
+ }
+ return QVariant::fromValue(data.data());
+}
+
+QHash QmlObjectList::roleNames() const
+{
+ return { { Qt::UserRole, "modelData" } };
+}
+
+int QmlObjectList::rowCount(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent);
+ return mData.count();
+}
+
+QmlObjectList::QmlObjectList(const QMetaObject &m, QObject *parent) :
+ QAbstractListModel(parent),
+ mMetaObject(m)
+{ }
+
+void QmlObjectList::clear() {
+ beginResetModel();
+ mData.clear();
+ endResetModel();
+}
diff --git a/src/ui/linux/TogglDesktop/qmlobjectlist.h b/src/ui/linux/TogglDesktop/qmlobjectlist.h
new file mode 100644
index 0000000000..bed64352e0
--- /dev/null
+++ b/src/ui/linux/TogglDesktop/qmlobjectlist.h
@@ -0,0 +1,73 @@
+#ifndef QMLOBJECTLIST_H
+#define QMLOBJECTLIST_H
+
+#include
+#include
+#include
+
+typedef QSharedPointer QObjectPointer;
+
+class QmlObjectList : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ Q_DISABLE_COPY(QmlObjectList)
+ virtual ~QmlObjectList() {
+ mData.clear();
+ }
+
+ template
+ inline static QmlObjectList* create(QObject *parent = Q_NULLPTR) {
+ return new QmlObjectList(T::staticMetaObject, parent);
+ }
+
+ void prepend(QObject* object);
+ void append(QObject *object);
+
+ bool insert(const int& i, QObject *object);
+
+ int count();
+
+ void clear();
+
+ Q_INVOKABLE
+ /**
+ * @brief append
+ * append an object to list and assign given properties.
+ * @param properties
+ * @warning if append new Object from QML is needed
+ * have to assign the default value for the parameters,
+ * and adding Q_INVOKABLE to constructor.
+ */
+ void append(const QVariantMap& properties);
+
+ Q_INVOKABLE bool removeRow(int row, const QModelIndex &parent = QModelIndex());
+
+ Q_INVOKABLE inline void removeFirst() {
+ if(!mData.isEmpty())
+ removeRow(0);
+ }
+
+ Q_INVOKABLE inline void removeLast() {
+ if(!mData.isEmpty())
+ removeRow(rowCount() - 1);
+ }
+
+ Q_INVOKABLE inline QVariant at(const int& i) {
+ return QVariant::fromValue(mData.at(i));
+ }
+
+protected:
+ QVariant data(const QModelIndex &index, int role) const;
+
+ QHash roleNames() const;
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+private:
+ QmlObjectList(const QMetaObject& m, QObject *parent = Q_NULLPTR);
+
+ const QMetaObject& mMetaObject;
+ QList mData;
+};
+
+#endif // QMLOBJECTLIST_H
diff --git a/src/ui/linux/TogglDesktop/settingsview.h b/src/ui/linux/TogglDesktop/settingsview.h
index ee628fc25f..06a297805b 100644
--- a/src/ui/linux/TogglDesktop/settingsview.h
+++ b/src/ui/linux/TogglDesktop/settingsview.h
@@ -7,6 +7,7 @@
#include
#include "./toggl_api.h"
+#include "./common.h"
class SettingsView : public QObject {
Q_OBJECT
@@ -18,10 +19,10 @@ class SettingsView : public QObject {
SettingsView *result = new SettingsView();
result->AutodetectProxy = view->AutodetectProxy;
result->UseProxy = view->UseProxy;
- result->ProxyHost = QString(view->ProxyHost);
+ result->ProxyHost = toQString(view->ProxyHost);
result->ProxyPort = view->ProxyPort;
- result->ProxyUsername = QString(view->ProxyUsername);
- result->ProxyPassword = QString(view->ProxyPassword);
+ result->ProxyUsername = toQString(view->ProxyUsername);
+ result->ProxyPassword = toQString(view->ProxyPassword);
result->UseIdleDetection = view->UseIdleDetection;
result->MenubarTimer = view->MenubarTimer;
result->DockIcon = view->DockIcon;
@@ -43,8 +44,8 @@ class SettingsView : public QObject {
result->RemindOnFriday = view->RemindFri;
result->RemindOnSaturday = view->RemindSat;
result->RemindOnSunday = view->RemindSun;
- result->RemindStartTime = QTime::fromString(view->RemindStarts, "HH:mm");
- result->RemindEndTime = QTime::fromString(view->RemindEnds, "HH:mm");
+ result->RemindStartTime = QTime::fromString(toQString(view->RemindStarts), "HH:mm");
+ result->RemindEndTime = QTime::fromString(toQString(view->RemindEnds), "HH:mm");
result->StopEntryOnShutdownSleep = view->StopEntryOnShutdownSleep;
return result;
}
diff --git a/src/ui/linux/TogglDesktop/systemtray.cpp b/src/ui/linux/TogglDesktop/systemtray.cpp
index 5858c9da1d..8ab018c3fb 100644
--- a/src/ui/linux/TogglDesktop/systemtray.cpp
+++ b/src/ui/linux/TogglDesktop/systemtray.cpp
@@ -2,12 +2,12 @@
#include
#include
+#include
#include "./toggl.h"
#include "./systemtray.h"
-#include "./mainwindowcontroller.h"
-SystemTray::SystemTray(MainWindowController *parent, QIcon defaultIcon) :
+SystemTray::SystemTray(QObject *parent, QIcon defaultIcon) :
QSystemTrayIcon(parent),
notificationsPresent(true)
{
@@ -31,10 +31,6 @@ SystemTray::SystemTray(MainWindowController *parent, QIcon defaultIcon) :
connect(watcher, &QDBusPendingCallWatcher::finished, this, &SystemTray::notificationCapabilitiesReceived);
}
-MainWindowController *SystemTray::mainWindow() {
- return qobject_cast(parent());
-}
-
bool SystemTray::isVisible() const {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
return true;
@@ -125,9 +121,11 @@ void SystemTray::notificationClosed(uint id, uint reason) {
void SystemTray::notificationActionInvoked(uint id, const QString &action) {
Q_UNUSED(id);
+ /* TODO
if (action == "default") {
mainWindow()->setWindowState(Qt::WindowActive);
}
+ */
}
void SystemTray::displayIdleNotification(
diff --git a/src/ui/linux/TogglDesktop/systemtray.h b/src/ui/linux/TogglDesktop/systemtray.h
index cbd3aeefca..4e1a649172 100644
--- a/src/ui/linux/TogglDesktop/systemtray.h
+++ b/src/ui/linux/TogglDesktop/systemtray.h
@@ -6,16 +6,13 @@
#include
#include
-class MainWindowController;
class SettingsView;
class SystemTray : public QSystemTrayIcon
{
Q_OBJECT
public:
- SystemTray(MainWindowController *parent = nullptr, QIcon defaultIcon = QIcon());
-
- MainWindowController *mainWindow();
+ SystemTray(QObject *parent = nullptr, QIcon defaultIcon = QIcon());
bool isVisible() const;
bool notificationsAvailable();
diff --git a/src/ui/linux/TogglDesktop/timeentrycellwidget.cpp b/src/ui/linux/TogglDesktop/timeentrycellwidget.cpp
deleted file mode 100644
index a51c9b5213..0000000000
--- a/src/ui/linux/TogglDesktop/timeentrycellwidget.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-// Copyright 2014 Toggl Desktop developers.
-
-#include "./timeentrycellwidget.h"
-#include "./ui_timeentrycellwidget.h"
-
-#include
-#include
-#include
-
-#include "./toggl.h"
-
-TimeEntryCellWidget::TimeEntryCellWidget(QListWidgetItem *item) : QWidget(nullptr),
-ui(new Ui::TimeEntryCellWidget),
-item(item),
-description(""),
-project(""),
-guid(""),
-group(false),
-groupOpen(false),
-groupName(""),
-timeEntry(nullptr) {
- ui->setupUi(this);
- ui->dataFrame->installEventFilter(this);
- setStyleSheet(
- "* { font-size: 13px }"
- "QFrame { background-color:transparent; border:none; margin:0 }"
- "QPushButton#dataFrame { background-color:#fefefe; border: none; border-bottom:1px solid #cacaca; margin: 0 }"
- "QPushButton#dataFrame:flat { background-color:transparent; }"
- );
- ui->groupButton->setStyleSheet(
- "QPushButton { outline:none; border:none; font-size:11px; color:#a4a4a4 }"
- "QPushButton:!checked { background:url(:/images/group_icon_closed.svg) no-repeat; }"
- "QPushButton:checked { background:url(:/images/group_icon_open.svg) no-repeat; }"
- );
-}
-
-void TimeEntryCellWidget::display(TimeEntryView *view) {
- setLoadMore(false);
- guid = view->GUID;
- groupName = view->GroupName;
- timeEntry = view;
- description =
- (view->Description.length() > 0) ?
- view->Description : "(no description)";
- project = view->ProjectAndTaskLabel;
-
- setEllipsisTextToLabel(ui->description, description);
- setEllipsisTextToLabel(ui->project, project);
- ui->project->setStyleSheet("color: '" + getProjectColor(view->Color) + "'");
- ui->duration->setText(view->Duration);
-
- ui->billable->setVisible(view->Billable);
- ui->tags->setVisible(!view->Tags.isEmpty());
-
- ui->headerFrame->setVisible(view->IsHeader);
- ui->date->setText(view->DateHeader);
- ui->dateDuration->setText(view->DateDuration);
-
- ui->unsyncedicon->setVisible(view->Unsynced);
-
- if (view->StartTimeString.length() > 0 &&
- view->EndTimeString.length() > 0) {
- ui->duration->setToolTip(
- QString("
" +
- view->StartTimeString + " - " +
- view->EndTimeString+"
"));
- }
-
- ui->tags->setToolTip(
- QString("" +
- (view->Tags).replace(QString("\t"), QString(", ")) + "
"));
- if (view->Description.length() > 0) {
- ui->description->setToolTip(
- QString("" +
- view->Description + "
"));
- }
- if (view->ProjectAndTaskLabel.length() > 0) {
- ui->project->setToolTip(
- QString("" +
- view->ProjectAndTaskLabel + "
"));
- }
- setupGroupedMode(view);
-}
-
-void TimeEntryCellWidget::setLoadMore(bool load_more) {
- ui->headerFrame->setVisible(false);
- ui->loadMoreButton->setEnabled(load_more);
- ui->loadMoreButton->setVisible(load_more);
- ui->descProjFrame->setVisible(!load_more);
- ui->groupFrame->setVisible(!load_more);
- ui->frame->setVisible(!load_more);
- ui->dataFrame->setFlat(load_more);
- ui->dataFrame->setStyleSheet(load_more ? "QPushButton#dataFrame { border:none }" : "");
- ui->dataFrame->setFocusPolicy(load_more ? Qt::NoFocus : Qt::StrongFocus);
- if (load_more) {
- ui->unsyncedicon->setVisible(false);
- }
-}
-
-QString TimeEntryCellWidget::entryGuid() {
- return guid;
-}
-
-void TimeEntryCellWidget::deleteTimeEntry() {
- if (guid.isEmpty())
- return;
-
- if (timeEntry->confirmlessDelete() || QMessageBox::Ok == QMessageBox(
- QMessageBox::Question,
- "Delete this time entry?",
- "Deleted time entries cannot be restored.",
- QMessageBox::Ok|QMessageBox::Cancel).exec()) {
- TogglApi::instance->deleteTimeEntry(guid);
- }
-}
-
-bool TimeEntryCellWidget::eventFilter(QObject *watched, QEvent *event) {
- if (event->type() == QEvent::FocusIn) {
- auto fe = reinterpret_cast(event);
- if (fe->reason() == Qt::TabFocusReason || fe->reason() == Qt::BacktabFocusReason)
- focusInEvent(fe);
- }
- return QWidget::eventFilter(watched, event);
-}
-
-void TimeEntryCellWidget::focusInEvent(QFocusEvent *event) {
- item->listWidget()->scrollToItem(item, QAbstractItemView::PositionAtCenter);
-}
-
-void TimeEntryCellWidget::setupGroupedMode(TimeEntryView *view) {
- // Grouped Mode Setup
- group = view->Group;
- QString style = "#dataFrame{border-right:2px solid palette(alternate-base);border-bottom:2px solid palette(alternate-base);background-color: palette(base);}";
- QString count = "";
- QString continueIcon = ":/images/continue_light.svg";
- QString descriptionStyle = "border:none;";
- int left = 0;
- if (view->GroupItemCount && view->GroupOpen && !view->Group) {
- left = 10;
- descriptionStyle = "border:none;color:palette(mid)";
- }
- ui->description->setStyleSheet(descriptionStyle);
- ui->descProjFrame->layout()->setContentsMargins(left, 9, 9, 9);
- ui->dataFrame->setStyleSheet(style);
-
- if (view->Group) {
- ui->groupButton->setChecked(view->GroupOpen);
- if (!view->GroupOpen)
- count = QString::number(view->GroupItemCount);
- continueIcon = ":/images/continue_regular.svg";
- }
- ui->groupButton->setText(count);
- ui->continueButton->setIcon(QIcon(continueIcon));
- ui->groupFrame->setVisible(view->Group);
-}
-
-void TimeEntryCellWidget::setEllipsisTextToLabel(ClickableLabel *label, QString text)
-{
- QFontMetrics metrix(label->font());
- int width = label->width() - 2;
- QString clippedText = metrix.elidedText(text, Qt::ElideRight, width);
- label->setText(clippedText);
-}
-
-void TimeEntryCellWidget::labelClicked(QString field_name) {
- if (group) {
- on_groupButton_clicked();
- return;
- }
- TogglApi::instance->editTimeEntry(guid, field_name);
-}
-
-TimeEntryCellWidget::~TimeEntryCellWidget() {
- delete ui;
-}
-
-QSize TimeEntryCellWidget::getSizeHint(bool is_header) {
- if (is_header) {
- return QSize(minimumWidth(), sizeHint().height());
- }
- return QSize(minimumWidth(), ui->dataFrame->height());
-}
-
-void TimeEntryCellWidget::on_continueButton_clicked() {
- TogglApi::instance->continueTimeEntry(guid);
-}
-
-QString TimeEntryCellWidget::getProjectColor(QString color) {
- if (color.length() == 0) {
- return QString("#9d9d9d");
- }
- return color;
-}
-
-void TimeEntryCellWidget::toggleGroup(bool open)
-{
- if (group && groupOpen != open) {
- groupOpen = open;
- TogglApi::instance->toggleEntriesGroup(groupName);
- }
-}
-
-void TimeEntryCellWidget::on_groupButton_clicked()
-{
- TogglApi::instance->toggleEntriesGroup(groupName);
-}
-
-void TimeEntryCellWidget::resizeEvent(QResizeEvent* event)
-{
- setEllipsisTextToLabel(ui->description, description);
- setEllipsisTextToLabel(ui->project, project);
- QWidget::resizeEvent(event);
-}
-
-void TimeEntryCellWidget::on_loadMoreButton_clicked()
-{
- TogglApi::instance->loadMore();
- ui->loadMoreButton->setEnabled(false);
- ui->loadMoreButton->setText("Loading ...");
-}
-
-void TimeEntryCellWidget::on_dataFrame_clicked() {
- if (group)
- on_groupButton_clicked();
- else
- TogglApi::instance->editTimeEntry(guid, "description");
-}
diff --git a/src/ui/linux/TogglDesktop/timeentrycellwidget.h b/src/ui/linux/TogglDesktop/timeentrycellwidget.h
deleted file mode 100644
index c348f5eeae..0000000000
--- a/src/ui/linux/TogglDesktop/timeentrycellwidget.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2014 Toggl Desktop developers.
-
-#ifndef SRC_UI_LINUX_TOGGLDESKTOP_TIMEENTRYCELLWIDGET_H_
-#define SRC_UI_LINUX_TOGGLDESKTOP_TIMEENTRYCELLWIDGET_H_
-
-#include
-
-#include "./timeentryview.h"
-#include "./clickablelabel.h"
-
-namespace Ui {
-class TimeEntryCellWidget;
-}
-
-class QListWidgetItem;
-
-class TimeEntryCellWidget : public QWidget {
- Q_OBJECT
-
- public:
- TimeEntryCellWidget(QListWidgetItem *item);
- ~TimeEntryCellWidget();
-
- void display(TimeEntryView *view);
- QSize getSizeHint(bool is_header);
- void labelClicked(QString field_name);
- void setLoadMore(bool load_more);
-
- QString entryGuid();
- void toggleGroup(bool open);
-
- public slots:
- void deleteTimeEntry();
-
- protected:
- virtual bool eventFilter(QObject *watched, QEvent *event) override;
- virtual void focusInEvent(QFocusEvent *event) override;
- virtual void resizeEvent(QResizeEvent *) override;
-
- private slots: // NOLINT
- void on_continueButton_clicked();
- void on_groupButton_clicked();
- void on_loadMoreButton_clicked();
- void on_dataFrame_clicked();
-
- private:
- Ui::TimeEntryCellWidget *ui;
- QListWidgetItem *item;
-
- QString description;
- QString project;
- QString guid;
- bool group;
- bool groupOpen;
- QString groupName;
- TimeEntryView *timeEntry;
- QString getProjectColor(QString color);
-
- void setupGroupedMode(TimeEntryView *view);
- void setEllipsisTextToLabel(ClickableLabel *label, QString text);
-};
-
-#endif // SRC_UI_LINUX_TOGGLDESKTOP_TIMEENTRYCELLWIDGET_H_
diff --git a/src/ui/linux/TogglDesktop/timeentrycellwidget.ui b/src/ui/linux/TogglDesktop/timeentrycellwidget.ui
deleted file mode 100644
index cdaead0451..0000000000
--- a/src/ui/linux/TogglDesktop/timeentrycellwidget.ui
+++ /dev/null
@@ -1,484 +0,0 @@
-
-
- TimeEntryCellWidget
-
-
-
- 0
- 0
- 372
- 138
-
-
-
-
- 0
- 77
-
-
-
-
- 16777215
- 138
-
-
-
- Form
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
- -
-
-
- QFrame::NoFrame
-
-
- QFrame::Raised
-
-
- 0
-
-
-
-
-
-
- Thu 22. Jan
-
-
-
- -
-
-
- Qt::Horizontal
-
-
- QSizePolicy::MinimumExpanding
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- 2 h 12 min
-
-
-
-
-
-
- -
-
-
-
- 0
- 77
-
-
-
-
- 16777215
- 77
-
-
-
- Qt::TabFocus
-
-
-
-
-
- false
-
-
-
- 0
-
-
- QLayout::SetNoConstraint
-
-
- 11
-
-
- 0
-
-
- 11
-
-
- 0
-
-
-
-
-
-
- 12
- 12
-
-
-
-
- 12
- 12
-
-
-
- Time Entry has not been synced to the server
-
-
-
-
-
-
-
-
- :/windows/TogglDesktop/TogglDesktop/Resources/warning-icon.png
-
-
- true
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
-
-
-
- -
-
-
-
- 0
- 30
-
-
-
-
- 90
- 30
-
-
-
- Load more
-
-
- false
-
-
- false
-
-
- false
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
-
-
-
- QLayout::SetMinimumSize
-
-
- 0
-
-
-
-
-
-
-
-
- Blogpost about this
-
-
- true
-
-
-
- -
-
-
-
-
-
- NEW - TOGGL
-
-
- true
-
-
-
-
-
-
- -
-
-
-
- 46
- 42
-
-
-
-
- 46
- 42
-
-
-
-
-
-
-
- 5
-
-
- 7
-
-
- 5
-
-
- 7
-
-
- 5
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 32
- 32
-
-
-
-
- 32
- 32
-
-
-
- Qt::NoFocus
-
-
-
-
-
-
-
-
-
- 32
- 32
-
-
-
- true
-
-
- true
-
-
-
-
-
-
- -
-
-
-
- 0
- 77
-
-
-
-
- 137
- 77
-
-
-
-
-
-
-
- 0
-
-
- QLayout::SetFixedSize
-
-
- 0
-
-
- 0
-
-
-
-
-
-
- 23
- 31
-
-
-
-
- 23
- 31
-
-
-
-
-
-
-
-
-
- :/images/icon-tags.png
-
-
-
- -
-
-
-
- 17
- 31
-
-
-
-
- 17
- 31
-
-
-
-
-
-
-
-
-
- :/images/icon-billable.png
-
-
-
- -
-
-
-
- 32
- 32
-
-
-
-
- 32
- 32
-
-
-
- Qt::NoFocus
-
-
-
-
-
-
-
-
-
- :/images/continue_regular.svg:/images/continue_regular.svg
-
-
-
- 32
- 32
-
-
-
- true
-
-
-
- -
-
-
-
- 65
- 0
-
-
-
-
- 90
- 16777215
-
-
-
-
-
-
- 00:00:00
-
-
- true
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
-
-
-
-
-
-
-
-
-
-
- ClickableLabel
- QLabel
-
-
-
-
-
-
-
-
diff --git a/src/ui/linux/TogglDesktop/timeentryeditorwidget.cpp b/src/ui/linux/TogglDesktop/timeentryeditorwidget.cpp
deleted file mode 100644
index 43d0e7151c..0000000000
--- a/src/ui/linux/TogglDesktop/timeentryeditorwidget.cpp
+++ /dev/null
@@ -1,664 +0,0 @@
-// Copyright 2014 Toggl Desktop developers.
-
-#include "./timeentryeditorwidget.h"
-#include "./ui_timeentryeditorwidget.h"
-
-#include // NOLINT
-#include // NOLINT
-#include // NOLINT
-#include // NOLINT
-#include // NOLINT
-#include // NOLINT
-
-#include "./autocompletelistview.h"
-#include "./autocompletelistmodel.h"
-#include "./autocompleteview.h"
-#include "./genericview.h"
-#include "./timeentryview.h"
-#include "./toggl.h"
-
-TimeEntryEditorWidget::TimeEntryEditorWidget(QStackedWidget *parent) : QWidget(parent),
-ui(new Ui::TimeEntryEditorWidget),
-guid(""),
-timeEntryAutocompleteNeedsUpdate(false),
-projectAutocompleteNeedsUpdate(false),
-workspaceSelectNeedsUpdate(false),
-clientSelectNeedsUpdate(false),
-colorPicker(new ColorPicker(this)),
-timer(new QTimer(this)),
-duration(0),
-previousTagList(""),
-descriptionModel(new AutocompleteListModel(this, QVector())),
-projectModel(new AutocompleteListModel(this, QVector(), AC_PROJECT))
-{
- ui->setupUi(this);
-
- ui->description->setModel(descriptionModel);
- ui->project->setModel(projectModel);
-
- ui->description->installEventFilter(this);
- ui->project->installEventFilter(this);
-
- connect(ui->description, &AutocompleteComboBox::returnPressed, [this]() {
- focusNextChild();
- });
- connect(ui->project, &AutocompleteComboBox::returnPressed, [this]() {
- focusNextChild();
- });
-
- connect(ui->newProjectWorkspace, QOverload::of(&QComboBox::activated), [this](int) {
- focusNextChild();
- });
- connect(ui->newProjectClient, QOverload::of(&QComboBox::activated), [this](int) {
- focusNextChild();
- });
-
- toggleNewClientMode(false);
-
- connect(TogglApi::instance, SIGNAL(displayLogin(bool,uint64_t)), // NOLINT
- this, SLOT(displayLogin(bool,uint64_t))); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(aboutToDisplayTimeEntryList()), // NOLINT
- this, SLOT(aboutToDisplayTimeEntryList())); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(displayTimeEntryEditor(bool,TimeEntryView*,QString)), // NOLINT
- this, SLOT(displayTimeEntryEditor(bool,TimeEntryView*,QString))); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(displayTags(QVector)), // NOLINT
- this, SLOT(displayTags(QVector))); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(displayWorkspaceSelect(QVector)), // NOLINT
- this, SLOT(displayWorkspaceSelect(QVector))); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(displayProjectAutocomplete(QVector)), // NOLINT
- this, SLOT(displayProjectAutocomplete(QVector))); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(displayTimeEntryAutocomplete(QVector)), // NOLINT
- this, SLOT(displayTimeEntryAutocomplete(QVector))); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(displayClientSelect(QVector)), // NOLINT
- this, SLOT(displayClientSelect(QVector))); // NOLINT
-
- connect(TogglApi::instance, SIGNAL(setProjectColors(QVector)), // NOLINT
- this, SLOT(setProjectColors(QVector))); // NOLINT
-
- connect(timer, SIGNAL(timeout()), this, SLOT(timeout()));
-
- TogglApi::instance->getProjectColors();
-}
-
-TimeEntryEditorWidget::~TimeEntryEditorWidget() {
- delete ui;
-}
-
-void TimeEntryEditorWidget::setSelectedColor(QString color) {
- QString style = "font-size:72px;" + color;
- ui->colorButton->setStyleSheet(style);
-}
-
-void TimeEntryEditorWidget::display() {
- qobject_cast(parent())->setCurrentWidget(this);
-}
-
-void TimeEntryEditorWidget::deleteTimeEntry() {
- if (timeEntry->confirmlessDelete() || QMessageBox::Ok == QMessageBox(
- QMessageBox::Question,
- "Delete this time entry?",
- "Deleted time entries cannot be restored.",
- QMessageBox::Ok|QMessageBox::Cancel).exec()) {
- TogglApi::instance->deleteTimeEntry(guid);
- }
-}
-
-void TimeEntryEditorWidget::clickDone()
-{
- on_doneButton_clicked();
-}
-
-void TimeEntryEditorWidget::displayClientSelect(
- QVector list) {
- clientSelectUpdate = list;
- clientSelectNeedsUpdate = true;
- if (ui->newProjectClient->hasFocus()) {
- return;
- }
-
- bool selectingNewClient = !recentlyAddedClient.isEmpty();
- QString lastSelectedItem = ui->newProjectClient->currentText();
- uint64_t workspaceID = 0;
- QVariant data = ui->newProjectWorkspace->currentData();
- if (data.canConvert()) {
- GenericView *view = data.value();
- workspaceID = view->ID;
- }
- ui->newProjectClient->clear();
- ui->newProjectClient->addItem("");
- int index = 0;
- int selectedIndex = 0;
- foreach(GenericView *view, clientSelectUpdate) {
- if (workspaceID && workspaceID != view->WID) {
- continue;
- }
- ui->newProjectClient->addItem(view->Name, QVariant::fromValue(view));
- index++;
- if (selectingNewClient && view->Name == recentlyAddedClient) {
- selectedIndex = index;
- recentlyAddedClient = QString();
- }
- if (!selectingNewClient && view->Name == lastSelectedItem) {
- selectedIndex = index;
- }
- }
- ui->newProjectClient->setCurrentIndex(selectedIndex);
- clientSelectNeedsUpdate = false;
-}
-
-void TimeEntryEditorWidget::displayTimeEntryAutocomplete(
- QVector list) {
- timeEntryAutocompleteUpdate = list;
- timeEntryAutocompleteNeedsUpdate = true;
- if (ui->description->hasFocus()) {
- return;
- }
- QString currentText = ui->description->currentText();
- ui->description->clear();
- descriptionModel->setList(list);
- timeEntryAutocompleteNeedsUpdate = false;
- ui->description->setEditText(currentText);
-}
-
-void TimeEntryEditorWidget::displayProjectAutocomplete(
- QVector list) {
- projectAutocompleteUpdate = list;
- projectAutocompleteNeedsUpdate = true;
- if (ui->project->hasFocus()) {
- return;
- }
- ui->project->clear();
- ui->project->addItem("");
-
- projectModel->setList(list);
- projectAutocompleteNeedsUpdate = false;
-}
-
-void TimeEntryEditorWidget::displayWorkspaceSelect(
- QVector list) {
- workspaceSelectUpdate = list;
- workspaceSelectNeedsUpdate = true;
- if (ui->newProjectWorkspace->hasFocus()) {
- return;
- }
- ui->newProjectWorkspace->clear();
- foreach(GenericView *view, workspaceSelectUpdate) {
- ui->newProjectWorkspace->addItem(view->Name, QVariant::fromValue(view));
- }
- workspaceSelectNeedsUpdate = false;
-}
-
-void TimeEntryEditorWidget::displayLogin(
- const bool open,
- const uint64_t user_id) {
- if (open || !user_id) {
- timer->stop();
- }
-}
-
-void TimeEntryEditorWidget::aboutToDisplayTimeEntryList() {
- timer->stop();
-}
-
-void TimeEntryEditorWidget::displayTimeEntryEditor(
- const bool open,
- TimeEntryView *view,
- const QString focused_field_name) {
-
- timeEntry = view;
-
- if (!ui->description->hasFocus()) {
- ui->description->setEditText(view->Description);
- }
- if (!ui->project->hasFocus()) {
- ui->project->setEditText(view->ProjectAndTaskLabel);
- }
- if (!ui->duration->hasFocus()) {
- ui->duration->setText(view->Duration);
- }
-
- if (open) {
- // Show the dialog first, hide items later (to preserve size)
- display();
-
- // Reset adding new project
- ui->newProject->setVisible(false);
- ui->project->setVisible(true);
- ui->addNewProject->setVisible(true);
- ui->newProjectName->setText("");
- ui->publicProject->setChecked(false);
- ui->newProjectWorkspace->setCurrentIndex(-1);
- ui->newProjectClient->setCurrentIndex(-1);
- ui->newProjectClient->clear();
-
- // Reset adding new client
- toggleNewClientMode(false);
- toggleNewTagMode(false);
-
- if (focused_field_name == TogglApi::Duration) {
- ui->duration->setFocus();
- } else if (focused_field_name == TogglApi::Description) {
- ui->description->setFocus();
- } else if (focused_field_name == TogglApi::Project) {
- ui->project->setFocus();
- }
- }
-
- guid = view->GUID;
- duration = view->DurationInSeconds;
-
- if (duration < 0) {
- timer->start(1000);
- }
-
- if (!ui->start->hasFocus()) {
- ui->start->setText(view->StartTimeString);
- }
- if (!ui->stop->hasFocus()) {
- ui->stop->setText(view->EndTimeString);
- }
- ui->stop->setVisible(duration >= 0);
- ui->timeSeparator->setVisible(duration >= 0);
- if (!ui->dateEdit->hasFocus()) {
- ui->dateEdit->setDateTime(QDateTime::fromTime_t(view->Started));
- }
-
- ui->billable->setChecked(view->Billable);
-
- ui->lastUpdate->setVisible(view->UpdatedAt);
- ui->lastUpdate->setText(view->lastUpdate());
-
- ui->billable->setVisible(view->CanSeeBillable);
- if (!view->CanAddProjects) {
- ui->newProject->setVisible(false);
- ui->addNewProject->setVisible(false);
- }
-
- QStringList tags = view->Tags.split("\t", QString::SkipEmptyParts);
- tags.sort();
- previousTagList = tags.join("\t");
-
- recentlyAddedClient = QString();
-
- for (int i = 0; i < ui->tags->count(); i++) {
- QListWidgetItem *item = ui->tags->item(i);
- if (tags.contains(item->text())) {
- item->setCheckState(Qt::Checked);
- } else {
- item->setCheckState(Qt::Unchecked);
- }
- }
-
- ui->workspaceNameLabel->setText(view->WorkspaceName);
-}
-
-void TimeEntryEditorWidget::on_doneButton_clicked() {
- if (applyNewProject()) {
- TogglApi::instance->viewTimeEntryList();
- }
-}
-
-bool TimeEntryEditorWidget::applyNewProject() {
- if (!ui->newProject->isVisible()) {
- return true;
- }
-
- if (ui->newProjectName->text().isEmpty()) {
- return true;
- }
-
- QVariant workspace = ui->newProjectWorkspace->currentData();
- if (!workspace.canConvert()) {
- return false;
- }
- uint64_t workspaceID = workspace.value()->ID;
-
- uint64_t clientID = 0;
- QString clientGUID = "";
- QVariant client = ui->newProjectClient->currentData();
- if (client.canConvert()) {
- clientID = client.value()->ID;
- if (clientID == 0)
- clientGUID = client.value()->GUID;
- }
- // Get the selected project color from stylesheet
- QString colorCode = ui->colorButton->styleSheet()
- .replace("font-size:72px;color:", "")
- .replace(";", "");
-
- QString projectGUID = TogglApi::instance->addProject(guid,
- workspaceID,
- clientID,
- clientGUID,
- ui->newProjectName->text(),
- !ui->publicProject->isChecked(),
- colorCode);
-
- ui->project->setVisible(true);
-
- return !projectGUID.isEmpty();
-}
-
-bool TimeEntryEditorWidget::eventFilter(QObject *object, QEvent *event) {
- if (event->type() == QEvent::FocusOut) {
- if (object == ui->description && !guid.isEmpty()) {
- TogglApi::instance->setTimeEntryDescription(guid,
- ui->description->currentText());
- }
-
- if (object == ui->project && ui->project->currentText().length() == 0) {
- TogglApi::instance->setTimeEntryProject(guid,
- 0,
- 0,
- "");
- }
- }
- if (event->type() == QEvent::KeyPress) {
- if (object == ui->description) {
- ui->deleteButton->setFocusPolicy(Qt::StrongFocus);
- auto ke = static_cast(event);
- if (ke && ke->key() == Qt::Key_Backtab) {
- // this is an ugly hack for the focus chain - backtabbing selected the date picker for some reason
- ui->deleteButton->setFocus(Qt::FocusReason::MouseFocusReason);
- return true;
- }
- }
- }
-
- return false;
-}
-
-void TimeEntryEditorWidget::on_deleteButton_clicked() {
- deleteTimeEntry();
-}
-
-void TimeEntryEditorWidget::on_addNewProject_clicked() {
- bool hasMultipleWorkspaces = ui->newProjectWorkspace->count() > 1;
- ui->newProjectWorkspace->setVisible(hasMultipleWorkspaces);
- ui->newProjectWorkspaceLabel->setVisible(hasMultipleWorkspaces);
-
- ui->newProject->setVisible(true);
- ui->addNewProject->setVisible(false);
- ui->project->setVisible(false);
-
- if (!hasMultipleWorkspaces) {
- ui->newProjectWorkspace->setCurrentIndex(0);
- } else {
- int i = 0;
- foreach(GenericView *view, workspaceSelectUpdate) {
- if(view->ID == timeEntry->WID) {
- ui->newProjectWorkspace->setCurrentIndex(i);
- break;
- }
- i++;
- }
- }
-}
-
-void TimeEntryEditorWidget::on_newProjectWorkspace_currentIndexChanged(
- int index) {
- Q_UNUSED(index);
- displayClientSelect(clientSelectUpdate);
-}
-
-void TimeEntryEditorWidget::on_description_activated(int index) {
- AutocompleteView *view = ui->description->currentView();
- if (view) {
- ui->description->setEditText(view->Description);
- ui->project->setFocus();
- ui->description->setFocus();
- TogglApi::instance->setTimeEntryProject(guid,
- view->TaskID,
- view->ProjectID,
- "");
- if (view->Billable) {
- TogglApi::instance->setTimeEntryBillable(guid, view->Billable);
- }
-
- if (!view->Tags.isEmpty() && ui->tags->count() > 0) {
- bool tagsSet = false;
- for (int i = 0; i < ui->tags->count(); i++) {
- QListWidgetItem *widgetItem = ui->tags->item(i);
- if (widgetItem->checkState() == Qt::Checked) {
- tagsSet = true;
- break;
- }
- }
- if (!tagsSet) {
- TogglApi::instance->setTimeEntryTags(guid, view->Tags);
- }
- }
- }
-}
-
-void TimeEntryEditorWidget::on_project_activated(int index) {
- Q_UNUSED(index);
- AutocompleteView *view = ui->project->currentView();
- if (view) {
- TogglApi::instance->setTimeEntryProject(guid,
- view->TaskID,
- view->ProjectID,
- "");
- }
-}
-
-void TimeEntryEditorWidget::on_duration_editingFinished() {
- TogglApi::instance->setTimeEntryDuration(guid,
- ui->duration->text());
-}
-
-void TimeEntryEditorWidget::on_start_editingFinished() {
- TogglApi::instance->setTimeEntryStart(guid,
- ui->start->text());
-}
-
-void TimeEntryEditorWidget::on_stop_editingFinished() {
- TogglApi::instance->setTimeEntryStop(guid,
- ui->stop->text());
-}
-
-void TimeEntryEditorWidget::on_dateEdit_editingFinished() {
- TogglApi::instance->setTimeEntryDate(guid,
- ui->dateEdit->dateTime().toTime_t());
-}
-
-void TimeEntryEditorWidget::displayTags(
- QVector tags) {
- ui->tags->clear();
- QStringList tagList;
- foreach(GenericView *view, tags) {
- tagList << view->Name;
- }
-
- QSet actuallyAddedTags;
-for (auto recentlyAddedTag : recentlyAddedTags) {
- if (!recentlyAddedTag.isEmpty() && !tagList.contains(recentlyAddedTag)) {
- tagList << recentlyAddedTag;
- }
- if (!recentlyAddedTag.isEmpty() && tagList.contains(recentlyAddedTag)) {
- actuallyAddedTags.insert(recentlyAddedTag);
- }
- }
- tagList.sort();
- recentlyAddedTags = recentlyAddedTags - actuallyAddedTags;
-
-for(auto tag : tagList) {
- QListWidgetItem *item = new QListWidgetItem(tag, ui->tags);
- item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
- item->setCheckState(Qt::Unchecked);
- }
-}
-
-void TimeEntryEditorWidget::on_billable_clicked(bool checked) {
- TogglApi::instance->setTimeEntryBillable(guid, checked);
-}
-
-void TimeEntryEditorWidget::timeout() {
- if (duration < 0 &&
- ui->duration->isVisible() &&
- !ui->duration->hasFocus()) {
- ui->duration->setText(
- TogglApi::formatDurationInSecondsHHMMSS(duration));
- }
-}
-
-void TimeEntryEditorWidget::toggleNewTagMode(bool visible) {
- ui->addNewTagButton->setVisible(!visible);
- ui->newTagLabel->setVisible(visible);
- ui->newTagButton->setVisible(visible);
- ui->newTag->setVisible(visible);
- if (visible)
- ui->newTag->setFocus();
- else
- ui->addNewTagButton->setFocus();
-}
-
-void TimeEntryEditorWidget::on_tags_itemClicked(QListWidgetItem *item) {
- Q_UNUSED(item);
- QStringList tags;
- for (int i = 0; i < ui->tags->count(); i++) {
- QListWidgetItem *widgetItem = ui->tags->item(i);
- if (widgetItem->checkState() == Qt::Checked) {
- tags.push_back(widgetItem->text());
- }
- }
-
- tags.sort();
- QString list = tags.join("\t");
-
- if (previousTagList != list) {
- TogglApi::instance->setTimeEntryTags(guid, list);
- }
-}
-
-void TimeEntryEditorWidget::toggleNewClientMode(const bool visible) {
- // First hide stuff, to avoid expanding
- ui->cancelNewClient->setVisible(false);
- ui->addNewClient->setVisible(false);
- ui->newProjectClient->setVisible(false);
- ui->newClientName->setVisible(false);
- ui->addClientButton->setVisible(false);
-
- // No display whats needed
- ui->cancelNewClient->setVisible(visible);
- ui->addNewClient->setVisible(!visible);
- ui->newProjectClient->setVisible(!visible);
- ui->newClientName->setVisible(visible);
- ui->addClientButton->setVisible(visible);
-
- ui->newProjectClient->setFocus();
- ui->newClientName->setFocus();
-
- ui->newClientName->setText("");
-}
-
-void TimeEntryEditorWidget::on_addNewClient_clicked() {
- toggleNewClientMode(true);
-}
-
-void TimeEntryEditorWidget::on_addClientButton_clicked() {
- QString name = ui->newClientName->text();
- if (name.isEmpty()) {
- ui->newClientName->setFocus();
- return;
- }
- QVariant workspace = ui->newProjectWorkspace->currentData();
- if (!workspace.canConvert()) {
- ui->newProjectWorkspace->setFocus();
- return;
- }
- uint64_t wid = workspace.value()->ID;
- if (!wid) {
- ui->newProjectWorkspace->setFocus();
- return;
- }
- recentlyAddedClient = name;
- QString clientGUID = TogglApi::instance->createClient(wid, name);
- if (clientGUID.isEmpty()) {
- return;
- }
- toggleNewClientMode(false);
-}
-
-void TimeEntryEditorWidget::on_cancelNewClient_clicked() {
- toggleNewClientMode(false);
-}
-
-void TimeEntryEditorWidget::on_colorButton_clicked()
-{
- int newX = window()->pos().x() + window()->width() - colorPicker->width() + 5;
- int newY = window()->pos().y() + ui->newProject->pos().y()+80;
-
- colorPicker->move(newX, newY);
- colorPicker->show();
-}
-
-void TimeEntryEditorWidget::on_newTagButton_clicked() {
- QStringList tags;
- QStringList allTags;
- QString newTag = ui->newTag->text();
-
- if (!newTag.isEmpty()) {
- ui->newTag->clear();
- for (int i = 0; i < ui->tags->count(); i++) {
- QListWidgetItem *widgetItem = ui->tags->item(i);
- if (widgetItem->text() == newTag) {
- if (widgetItem->checkState() != Qt::Checked) {
- widgetItem->setCheckState(Qt::Checked);
- on_tags_itemClicked(widgetItem);
- }
- return;
- }
- allTags << widgetItem->text();
- if (widgetItem->checkState() == Qt::Checked) {
- tags.push_back(widgetItem->text());
- }
- }
- tags.push_back(newTag);
- tags.sort();
- allTags.push_back(newTag);
- allTags.sort();
-
- QString list = tags.join("\t");
- if (previousTagList != list) {
- TogglApi::instance->setTimeEntryTags(guid, list);
- recentlyAddedTags.insert(newTag);
- }
- previousTagList = list;
-
- ui->tags->clear();
- for (int i = 0; i < allTags.count(); i++) {
- auto item = new QListWidgetItem(allTags[i], ui->tags);
- item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
- if (tags.contains(allTags[i]))
- item->setCheckState(Qt::Checked);
- else
- item->setCheckState(Qt::Unchecked);
- ui->tags->addItem(item);
- }
- }
-
- QTimer::singleShot(0, [this]() {
- toggleNewTagMode(false);
- });
-}
-
-void TimeEntryEditorWidget::on_newTag_returnPressed() {
- on_newTagButton_clicked();
-}
-
-void TimeEntryEditorWidget::on_addNewTagButton_clicked() {
- toggleNewTagMode(true);
-}
-
-void TimeEntryEditorWidget::setProjectColors(QVector list) {
- colorPicker->setColors(list);
-}
-
diff --git a/src/ui/linux/TogglDesktop/timeentryeditorwidget.h b/src/ui/linux/TogglDesktop/timeentryeditorwidget.h
deleted file mode 100644
index 3259d0f771..0000000000
--- a/src/ui/linux/TogglDesktop/timeentryeditorwidget.h
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright 2014 Toggl Desktop developers.
-
-#ifndef SRC_UI_LINUX_TOGGLDESKTOP_TIMEENTRYEDITORWIDGET_H_
-#define SRC_UI_LINUX_TOGGLDESKTOP_TIMEENTRYEDITORWIDGET_H_
-
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include "./colorpicker.h"
-
-namespace Ui {
-class TimeEntryEditorWidget;
-}
-
-class AutocompleteView;
-class AutocompleteListModel;
-class GenericView;
-class TimeEntryView;
-
-class TimeEntryEditorWidget : public QWidget {
- Q_OBJECT
-
- public:
- explicit TimeEntryEditorWidget(QStackedWidget *parent = nullptr);
- ~TimeEntryEditorWidget();
- void setSelectedColor(QString color);
-
- void display();
-
- public slots:
- void deleteTimeEntry();
- void clickDone();
-
- private:
- Ui::TimeEntryEditorWidget *ui;
-
- QString guid;
-
- QVector timeEntryAutocompleteUpdate;
- bool timeEntryAutocompleteNeedsUpdate;
-
- QVector projectAutocompleteUpdate;
- bool projectAutocompleteNeedsUpdate;
-
- QVector workspaceSelectUpdate;
- bool workspaceSelectNeedsUpdate;
-
- QVector clientSelectUpdate;
- bool clientSelectNeedsUpdate;
- QString recentlyAddedClient;
-
- ColorPicker *colorPicker;
-
- QTimer *timer;
-
- int64_t duration;
-
- QString previousTagList;
- QSet recentlyAddedTags;
-
- TimeEntryView *timeEntry;
-
- AutocompleteListModel *descriptionModel;
- AutocompleteListModel *projectModel;
-
- bool applyNewProject();
- bool eventFilter(QObject *object, QEvent *event);
- void toggleNewClientMode(const bool visible);
- void toggleNewTagMode(bool visible);
-
- private slots: // NOLINT
- void displayLogin(
- const bool open,
- const uint64_t user_id);
-
- void aboutToDisplayTimeEntryList();
-
- void displayTimeEntryEditor(
- const bool open,
- TimeEntryView *view,
- const QString focused_field_name);
-
- void displayTags(
- QVector list);
-
- void displayWorkspaceSelect(
- QVector list);
-
- void displayClientSelect(
- QVector list);
-
- void displayTimeEntryAutocomplete(
- QVector list);
-
- void displayProjectAutocomplete(
- QVector list);
-
- void setProjectColors(QVector list);
-
- void timeout();
-
- void on_doneButton_clicked();
- void on_deleteButton_clicked();
- void on_addNewProject_clicked();
- void on_newProjectWorkspace_currentIndexChanged(int index);
- void on_description_activated(int index);
- void on_project_activated(int index);
- void on_duration_editingFinished();
- void on_start_editingFinished();
- void on_stop_editingFinished();
- void on_dateEdit_editingFinished();
- void on_billable_clicked(bool checked);
- void on_tags_itemClicked(QListWidgetItem *item);
- void on_addNewClient_clicked();
- void on_addClientButton_clicked();
- void on_cancelNewClient_clicked();
- void on_colorButton_clicked();
- void on_newTagButton_clicked();
- void on_newTag_returnPressed();
- void on_addNewTagButton_clicked();
-};
-
-#endif // SRC_UI_LINUX_TOGGLDESKTOP_TIMEENTRYEDITORWIDGET_H_
diff --git a/src/ui/linux/TogglDesktop/timeentryeditorwidget.ui b/src/ui/linux/TogglDesktop/timeentryeditorwidget.ui
deleted file mode 100644
index b567a8b2c1..0000000000
--- a/src/ui/linux/TogglDesktop/timeentryeditorwidget.ui
+++ /dev/null
@@ -1,779 +0,0 @@
-
-
- TimeEntryEditorWidget
-
-
-
- 0
- 0
- 387
- 674
-
-
-
- Form
-
-
- font-size:13px;
-
-
-
- 10
-
-
- 10
-
-
- 5
-
- -
-
-
-
- 0
- 0
-
-
-
- combobox-popup: 0;
-
-
- true
-
-
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- combobox-popup: 0;
-
-
- true
-
-
-
- -
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- padding:1;text-align:right;color:palette(link);text-decoration:underline
-
-
- Add new project
-
-
- true
-
-
-
-
-
-
- -
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
-
- 0
- 30
-
-
-
-
- 5
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- Select project color
-
-
- Project name
-
-
-
- -
-
-
-
- 23
- 23
-
-
-
-
- -1
-
-
-
- false
-
-
- font-size:72px;color:#06aaf5;
-
-
- ■
-
-
-
-
-
-
- -
-
-
- Public (Visible to the whole team)
-
-
-
- -
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- -
-
-
-
- 99
- 0
-
-
-
- Workspace:
-
-
-
- -
-
-
- Client:
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
-