- more work to restructure app
This commit is contained in:
parent
d51e37eb2d
commit
f7c4ecc63b
@ -123,7 +123,7 @@ if (TARGET_OSX)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# This will create you executable
|
# This will create you executable
|
||||||
set (EXE_NAME litt_outliner)
|
set (EXE_NAME Litt)
|
||||||
|
|
||||||
add_executable(${EXE_NAME}
|
add_executable(${EXE_NAME}
|
||||||
${ADDITIONAL_EXE_OPTIONS}
|
${ADDITIONAL_EXE_OPTIONS}
|
||||||
|
|||||||
137
client/browserwidget.cpp
Normal file
137
client/browserwidget.cpp
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
#include "browserwidget.h"
|
||||||
|
#include "ui_browserwidget.h"
|
||||||
|
|
||||||
|
BrowserWidget::BrowserWidget(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::BrowserWidget)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
BrowserWidget::~BrowserWidget()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserWidget::newRootTask()
|
||||||
|
{
|
||||||
|
PTask rootTask = mTaskTreeModel->addTask(QModelIndex(), Storage::instance().topOfTaskTree().size());
|
||||||
|
QModelIndex rootIndex = mTaskTreeModel->getIndex(rootTask);
|
||||||
|
ui->mTaskTree->setCurrentIndex(rootIndex);
|
||||||
|
ui->mTaskTree->edit(rootIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserWidget::newTask()
|
||||||
|
{
|
||||||
|
QModelIndex index = ui->mTaskTree->currentIndex();
|
||||||
|
if (index.isValid())
|
||||||
|
ui->mTaskTree->expand(index);
|
||||||
|
PTask parent = mTaskTreeModel->getTask(index);
|
||||||
|
if (!parent)
|
||||||
|
return;
|
||||||
|
|
||||||
|
PTask child = mTaskTreeModel->addTask(index, parent->children().size());
|
||||||
|
if (!child)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QModelIndex childIndex = mTaskTreeModel->getIndex(child);
|
||||||
|
ui->mTaskTree->setCurrentIndex(childIndex);
|
||||||
|
ui->mTaskTree->edit(childIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserWidget::newSibling()
|
||||||
|
{
|
||||||
|
QModelIndex index = ui->mTaskTree->currentIndex();
|
||||||
|
if (!index.isValid())
|
||||||
|
return;
|
||||||
|
PTask currentTask = mTaskTreeModel->getTask(index);
|
||||||
|
if (!currentTask)
|
||||||
|
return;
|
||||||
|
|
||||||
|
PTask t = mTaskTreeModel->addTask(index.parent(), index.row() + 1);
|
||||||
|
QModelIndex i = mTaskTreeModel->getIndex(t);
|
||||||
|
|
||||||
|
ui->mTaskTree->setCurrentIndex(i);
|
||||||
|
ui->mTaskTree->edit(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserWidget::moveUp()
|
||||||
|
{
|
||||||
|
QModelIndex index = ui->mTaskTree->currentIndex();
|
||||||
|
if (!index.isValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
PTask currentTask = mTaskTreeModel->getTask(index);
|
||||||
|
if (!currentTask)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (index.row() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mTaskTreeModel->moveTask(currentTask, -1);
|
||||||
|
ui->mTaskTree->setCurrentIndex(mTaskTreeModel->getIndex(currentTask));
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserWidget::moveDown()
|
||||||
|
{
|
||||||
|
QModelIndex index = ui->mTaskTree->currentIndex();
|
||||||
|
if (!index.isValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
PTask currentTask = mTaskTreeModel->getTask(index);
|
||||||
|
if (!currentTask)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (currentTask->parent())
|
||||||
|
{
|
||||||
|
if (index.row() == currentTask->parent()->children().size() - 1)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (index.row() == Storage::instance().topOfTaskTree().size() - 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mTaskTreeModel->moveTask(currentTask, +1);
|
||||||
|
ui->mTaskTree->setCurrentIndex(mTaskTreeModel->getIndex(currentTask));
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserWidget::renameTask()
|
||||||
|
{
|
||||||
|
QModelIndex index = ui->mTaskTree->currentIndex();
|
||||||
|
if (index.isValid())
|
||||||
|
ui->mTaskTree->edit(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserWidget::deleteTask()
|
||||||
|
{
|
||||||
|
QModelIndex index = ui->mTaskTree->currentIndex();
|
||||||
|
if (!index.isValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
PTask t = mTaskTreeModel->getTask(index);
|
||||||
|
if (!t)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Check if deleted task
|
||||||
|
if (mCurrentTask == t)
|
||||||
|
{
|
||||||
|
alertBox(tr("Problem"), tr("Impossible to delete active task. Please stop tracking before task delete."), AlertType_Warning);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (mSettings->data()[KEY_ASK_BEFORE_DELETE].toBool())
|
||||||
|
{
|
||||||
|
auto reply = QMessageBox::question(this,
|
||||||
|
tr("Are you sure?"),
|
||||||
|
tr("Are you sure you want to delete ") + t->title(),
|
||||||
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
|
if (reply == QMessageBox::No)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mAutomaticTask == t)
|
||||||
|
mAutomaticTask.reset();
|
||||||
|
|
||||||
|
mTaskTreeModel->deleteTask(ui->mTaskTree->currentIndex());
|
||||||
|
}
|
||||||
|
}
|
||||||
32
client/browserwidget.h
Normal file
32
client/browserwidget.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#ifndef BROWSERWIDGET_H
|
||||||
|
#define BROWSERWIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class BrowserWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
class BrowserWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit BrowserWidget(QWidget *parent = 0);
|
||||||
|
~BrowserWidget();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::BrowserWidget *ui;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void onNewRootTask();
|
||||||
|
void onNewTask();
|
||||||
|
void onNewSibling();
|
||||||
|
void onMoveUp();
|
||||||
|
void onMoveDown();
|
||||||
|
void onRenameTask();
|
||||||
|
void onDeleteTask();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BROWSERWIDGET_H
|
||||||
235
client/browserwidget.ui
Normal file
235
client/browserwidget.ui
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>BrowserWidget</class>
|
||||||
|
<widget class="QWidget" name="BrowserWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>989</width>
|
||||||
|
<height>566</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QSplitter" name="mSplitter">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>600</width>
|
||||||
|
<height>200</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="TaskTreeView" name="mTaskTree">
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
|
</property>
|
||||||
|
<property name="dragEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="dragDropMode">
|
||||||
|
<enum>QAbstractItemView::InternalMove</enum>
|
||||||
|
</property>
|
||||||
|
<property name="defaultDropAction">
|
||||||
|
<enum>Qt::MoveAction</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QFrame" name="frame">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QSplitter" name="mTimeSplitter">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="lineWidth">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QFrame" name="mEditFrame">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Plain</enum>
|
||||||
|
</property>
|
||||||
|
<property name="lineWidth">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QMarkdownTextEdit" name="mNoteEdit">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Plain</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="mFindFrame">
|
||||||
|
<property name="autoFillBackground">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">background-color:white;</string>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<property name="lineWidth">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="mFindFrameLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Find:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="mFindEdit"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QFrame" name="mTimeFrame">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>70</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="mTodayTextLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Today:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLabel" name="mTodaySpentTimeLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>0 hours 0 minutes</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="mThisMonthTextLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>This month:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLabel" name="mThisMonthSpentTimeLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>0 hours 0 minutes</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>TaskTreeView</class>
|
||||||
|
<extends>QTreeView</extends>
|
||||||
|
<header>tasktreemodel.h</header>
|
||||||
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>QMarkdownTextEdit</class>
|
||||||
|
<extends>QPlainTextEdit</extends>
|
||||||
|
<header>qmarkdowntextedit/qmarkdowntextedit.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
@ -1,2 +1,2 @@
|
|||||||
// Auto generated file ! Please do not edit !
|
// Auto generated file ! Please do not edit !
|
||||||
#define APP_BUILD_NUMBER 8
|
#define APP_BUILD_NUMBER 38
|
||||||
@ -37,6 +37,10 @@
|
|||||||
|
|
||||||
#define SETTINGS mSettings->data()
|
#define SETTINGS mSettings->data()
|
||||||
|
|
||||||
|
const int ViewIndex_Main = 0;
|
||||||
|
const int ViewIndex_OpenOrCreateDb = 1;
|
||||||
|
const int ViewIndex_DbPassword = 2;
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
mPasswordFailed(false), mFindInTasksDlg(this), mDockRecentMenu(nullptr)
|
mPasswordFailed(false), mFindInTasksDlg(this), mDockRecentMenu(nullptr)
|
||||||
@ -59,13 +63,17 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
loadGeometry();
|
loadGeometry();
|
||||||
|
|
||||||
// Now check if database is already configured
|
// Now check if database is already configured
|
||||||
QWidget* centralWidget = new QWidget(this);
|
mStackedViews = new QStackedWidget(this);
|
||||||
setCentralWidget(centralWidget);
|
setCentralWidget(mStackedViews);
|
||||||
centralWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
mStackedViews->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
||||||
|
buildMainView();
|
||||||
|
buildOpenOrCreateView();
|
||||||
|
buildPasswordView();
|
||||||
|
|
||||||
// Check if database file exists
|
// Find default database file exists
|
||||||
QString path = helper::path::pathToDatabase();
|
QString path = helper::path::pathToDatabase();
|
||||||
|
|
||||||
|
// Find optional custom path to database
|
||||||
if (mSettings->data()[KEY_DB_FILENAME_SPECIFIED].toBool())
|
if (mSettings->data()[KEY_DB_FILENAME_SPECIFIED].toBool())
|
||||||
path = mSettings->data()[KEY_DB_FILENAME].toString();
|
path = mSettings->data()[KEY_DB_FILENAME].toString();
|
||||||
|
|
||||||
@ -591,6 +599,16 @@ void MainWindow::deleteTask()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (mSettings->data()[KEY_ASK_BEFORE_DELETE].toBool())
|
||||||
|
{
|
||||||
|
auto reply = QMessageBox::question(this,
|
||||||
|
tr("Are you sure?"),
|
||||||
|
tr("Are you sure you want to delete ") + t->title(),
|
||||||
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
|
if (reply == QMessageBox::No)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mAutomaticTask == t)
|
if (mAutomaticTask == t)
|
||||||
mAutomaticTask.reset();
|
mAutomaticTask.reset();
|
||||||
|
|
||||||
@ -811,9 +829,6 @@ void MainWindow::updateAttachmentsLabel(PTask t)
|
|||||||
|
|
||||||
void MainWindow::setupMainUi()
|
void MainWindow::setupMainUi()
|
||||||
{
|
{
|
||||||
// Detach old widget
|
|
||||||
setCentralWidget(nullptr);
|
|
||||||
|
|
||||||
// Construct main UI
|
// Construct main UI
|
||||||
ui = new Ui::MainWindow();
|
ui = new Ui::MainWindow();
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -833,31 +848,41 @@ void MainWindow::setupMainUi()
|
|||||||
QApplication::postEvent(this, new AttachDatabaseEvent());
|
QApplication::postEvent(this, new AttachDatabaseEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::buildPasswordView()
|
||||||
|
{
|
||||||
|
if (!mConnectDbWidget)
|
||||||
|
{
|
||||||
|
mConnectDbWidget = new ConnectDbWidget(message, mStackedViews);
|
||||||
|
connect(mConnectDbWidget, SIGNAL(passwordEntered(QString)), this, SLOT(onDbPasswordEntered(QString)));
|
||||||
|
connect(mConnectDbWidget, SIGNAL(cancelled()), this, SLOT(onDbPasswordCancelled()));
|
||||||
|
int index = mStackedViews->addWidget(mConnectDbWidget);
|
||||||
|
assert (index == ViewIndex_DbPassword);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::buildOpenOrCreateView()
|
||||||
|
{
|
||||||
|
if (!mOpenOrCreateDbWidget)
|
||||||
|
{
|
||||||
|
mOpenOrCreateDbWidget = new OpenOrCreateDbWidget(mStackedViews);
|
||||||
|
connect(w, &OpenOrCreateDbWidget::databaseChanged,
|
||||||
|
[this](const QString& path) { onDatabaseChanged(path); });
|
||||||
|
connect(w, &OpenOrCreateDbWidget::passwordEntered,
|
||||||
|
[this](const QString& password) { onNewDbPasswordEntered(password); });
|
||||||
|
int index = mStackedViews->addWidget(mOpenOrCreateDbWidget);
|
||||||
|
assert (index == ViewIndex_OpenOrCreateDb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Ask password
|
// Ask password
|
||||||
void MainWindow::askDbPassword(const QString& message)
|
void MainWindow::askDbPassword(const QString& message)
|
||||||
{
|
{
|
||||||
setCentralWidget(nullptr); setCentralWidget(new QWidget(this));
|
mStackedViews->setCurrentIndex(0);
|
||||||
auto cdw = new ConnectDbWidget(message, centralWidget());
|
|
||||||
connect(cdw, SIGNAL(passwordEntered(QString)), this, SLOT(onDbPasswordEntered(QString)));
|
|
||||||
connect(cdw, SIGNAL(cancelled()), this, SLOT(onDbPasswordCancelled()));
|
|
||||||
|
|
||||||
QVBoxLayout* l = new QVBoxLayout(centralWidget());
|
|
||||||
l->addWidget(cdw);
|
|
||||||
l->setAlignment(Qt::AlignCenter);
|
|
||||||
centralWidget()->setLayout(l);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::askNewDbPassword()
|
void MainWindow::askNewDbPassword()
|
||||||
{
|
{
|
||||||
setCentralWidget(nullptr); setCentralWidget(new QWidget(this));
|
mStackedViews->setCurrentIndex(1);
|
||||||
auto w = new OpenOrCreateDbWidget(centralWidget());
|
|
||||||
connect(w, &OpenOrCreateDbWidget::databaseChanged, [this](const QString& path) { onDatabaseChanged(path); });
|
|
||||||
connect(w, &OpenOrCreateDbWidget::passwordEntered, [this](const QString& password) { onNewDbPasswordEntered(password); });
|
|
||||||
|
|
||||||
auto l = new QVBoxLayout(centralWidget());
|
|
||||||
l->addWidget(w);
|
|
||||||
l->setAlignment(Qt::AlignCenter);
|
|
||||||
centralWidget()->setLayout(l);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::startOrStopTracking()
|
void MainWindow::startOrStopTracking()
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
#include <QTextCharFormat>
|
#include <QTextCharFormat>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QStackedWidget>
|
||||||
|
|
||||||
#include "tasktreemodel.h"
|
#include "tasktreemodel.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
@ -16,6 +17,9 @@
|
|||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "platforms/hidtracker.h"
|
#include "platforms/hidtracker.h"
|
||||||
#include "finddialog.h"
|
#include "finddialog.h"
|
||||||
|
#include "connectdb_widget.h"
|
||||||
|
#include "openorcreatedb_widget.h"
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
#ifdef TARGET_OSX
|
#ifdef TARGET_OSX
|
||||||
@ -91,7 +95,9 @@ private:
|
|||||||
QMenu* mDockRecentMenu;
|
QMenu* mDockRecentMenu;
|
||||||
QDialog* mTrayWindow = nullptr;
|
QDialog* mTrayWindow = nullptr;
|
||||||
QString mPassword = NOPASSWORDSTRING;
|
QString mPassword = NOPASSWORDSTRING;
|
||||||
|
ConnectDbWidget* mConnectDbWidget = nullptr;
|
||||||
|
|
||||||
|
QStackedWidget* mStackedViews = nullptr;
|
||||||
|
|
||||||
void saveGeometry();
|
void saveGeometry();
|
||||||
void loadGeometry();
|
void loadGeometry();
|
||||||
@ -148,6 +154,10 @@ private:
|
|||||||
// Show UI about fatal alert & button to quit app
|
// Show UI about fatal alert & button to quit app
|
||||||
void showFatal(const QString& message);
|
void showFatal(const QString& message);
|
||||||
|
|
||||||
|
void buildPasswordView();
|
||||||
|
void buildOpenOrCreateView();
|
||||||
|
void buildMainView();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void onTimeFormatChanged();
|
void onTimeFormatChanged();
|
||||||
void onTimeChanged();
|
void onTimeChanged();
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
HIDActivityTracker::HIDActivityTracker()
|
HIDActivityTracker::HIDActivityTracker()
|
||||||
:mInterval(600), mTrackerActive(false), mState(None)
|
:mInterval(600), mTrackerActive(false), mState(None), mImpl(nullptr)
|
||||||
{
|
{
|
||||||
#ifdef TARGET_OSX
|
#ifdef TARGET_OSX
|
||||||
mImpl = new HIDTrackerImplOSX();
|
mImpl = new HIDTrackerImplOSX();
|
||||||
|
|||||||
@ -28,6 +28,9 @@ PreferencesDlg::PreferencesDlg(QWidget *parent, Settings& settings) :
|
|||||||
// Show seconds or not?
|
// Show seconds or not?
|
||||||
ui->mShowSecondsCheckbox->setChecked(settings.data().value(KEY_SHOW_SECONDS).toBool());
|
ui->mShowSecondsCheckbox->setChecked(settings.data().value(KEY_SHOW_SECONDS).toBool());
|
||||||
|
|
||||||
|
// Ask confirmation before node delete
|
||||||
|
ui->mAskBeforeDeleteCheckbox->setChecked(settings.data().value(KEY_ASK_BEFORE_DELETE).toBool());
|
||||||
|
|
||||||
// Dark theme ?
|
// Dark theme ?
|
||||||
ui->mDarkThemeCheckbox->setChecked(settings.data().value(KEY_DARK_THEME).toBool());
|
ui->mDarkThemeCheckbox->setChecked(settings.data().value(KEY_DARK_THEME).toBool());
|
||||||
|
|
||||||
@ -79,13 +82,13 @@ void PreferencesDlg::accepted()
|
|||||||
helper::password::save(savePassword ? Storage::instance().key() : QString(""));
|
helper::password::save(savePassword ? Storage::instance().key() : QString(""));
|
||||||
|
|
||||||
mSettings.data()[KEY_SHOW_SECONDS] = ui->mShowSecondsCheckbox->isChecked();
|
mSettings.data()[KEY_SHOW_SECONDS] = ui->mShowSecondsCheckbox->isChecked();
|
||||||
|
mSettings.data()[KEY_ASK_BEFORE_DELETE] = ui->mAskBeforeDeleteCheckbox->isChecked();
|
||||||
mSettings.data()[KEY_DB_FILENAME_SPECIFIED] = ui->mCustomDatabaseFileCheckbox->isChecked();
|
mSettings.data()[KEY_DB_FILENAME_SPECIFIED] = ui->mCustomDatabaseFileCheckbox->isChecked();
|
||||||
mSettings.data()[KEY_DB_FILENAME] = ui->mDatabaseLocation->text();
|
mSettings.data()[KEY_DB_FILENAME] = ui->mDatabaseLocation->text();
|
||||||
mSettings.data()[KEY_SMART_STOP] = ui->mSmartStopTracking->isChecked();
|
mSettings.data()[KEY_SMART_STOP] = ui->mSmartStopTracking->isChecked();
|
||||||
mSettings.data()[KEY_SMART_STOP_MINUTES] = ui->mSmartStopIntervalInMinutes->text().toInt();
|
mSettings.data()[KEY_SMART_STOP_MINUTES] = ui->mSmartStopIntervalInMinutes->text().toInt();
|
||||||
mSettings.data()[KEY_SMART_START] = ui->mSmartStartTracking->isChecked();
|
mSettings.data()[KEY_SMART_START] = ui->mSmartStartTracking->isChecked();
|
||||||
mSettings.data()[KEY_SHOW_TRAY_ICON] = ui->mShowTrayIconCheckbox->isChecked();
|
mSettings.data()[KEY_SHOW_TRAY_ICON] = ui->mShowTrayIconCheckbox->isChecked();
|
||||||
//mSettings.data()[KEY_ASK_START] = ui->mAskQuestionOnStartRadiobutton->isChecked();
|
|
||||||
mSettings.data()[KEY_ASK_STOP] = ui->mAskQuestionOnStopRadiobutton->isChecked();
|
mSettings.data()[KEY_ASK_STOP] = ui->mAskQuestionOnStopRadiobutton->isChecked();
|
||||||
|
|
||||||
if (mSettings.data()[KEY_DARK_THEME].toBool() != ui->mDarkThemeCheckbox->isChecked()) {
|
if (mSettings.data()[KEY_DARK_THEME].toBool() != ui->mDarkThemeCheckbox->isChecked()) {
|
||||||
|
|||||||
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>444</width>
|
<width>586</width>
|
||||||
<height>374</height>
|
<height>452</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -34,6 +34,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="mAskBeforeDeleteCheckbox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Ask before delete</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="mShowTrayIconCheckbox">
|
<widget class="QCheckBox" name="mShowTrayIconCheckbox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|||||||
@ -2,6 +2,9 @@
|
|||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
Settings::Settings()
|
Settings::Settings()
|
||||||
{
|
{
|
||||||
@ -30,6 +33,16 @@ void Settings::save()
|
|||||||
|
|
||||||
void Settings::load()
|
void Settings::load()
|
||||||
{
|
{
|
||||||
|
// Path to settings file
|
||||||
|
QString path = helper::path::pathToSettings();
|
||||||
|
|
||||||
|
// Check if directory exists at all
|
||||||
|
QString dir = QFileInfo(path).absoluteDir().path();
|
||||||
|
|
||||||
|
if (!QDir(dir).exists())
|
||||||
|
QDir().mkdir(dir);
|
||||||
|
|
||||||
|
// Load data itself
|
||||||
QSettings settings(helper::path::pathToSettings(), QSettings::IniFormat);
|
QSettings settings(helper::path::pathToSettings(), QSettings::IniFormat);
|
||||||
mData.clear();
|
mData.clear();
|
||||||
const QStringList keys = settings.allKeys();
|
const QStringList keys = settings.allKeys();
|
||||||
|
|||||||
@ -6,42 +6,43 @@
|
|||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#define KEY_AUTOSAVE_PASSWORD "AutosavePassword"
|
#define KEY_AUTOSAVE_PASSWORD "AutosavePassword"
|
||||||
#define KEY_PASSWORD "Password"
|
#define KEY_PASSWORD "Password"
|
||||||
#define KEY_SHOW_SECONDS "ShowSeconds"
|
#define KEY_SHOW_SECONDS "ShowSeconds"
|
||||||
#define KEY_DB_FILENAME "DbFilename"
|
#define KEY_DB_FILENAME "DbFilename"
|
||||||
#define KEY_DB_FILENAME_SPECIFIED "DbFilenameSpecified"
|
#define KEY_DB_FILENAME_SPECIFIED "DbFilenameSpecified"
|
||||||
#define KEY_TIMECOUNTER_TYPE "TimecounterType"
|
#define KEY_TIMECOUNTER_TYPE "TimecounterType"
|
||||||
|
|
||||||
#define KEY_LEFT "Left"
|
#define KEY_LEFT "Left"
|
||||||
#define KEY_TOP "Top"
|
#define KEY_TOP "Top"
|
||||||
#define KEY_WIDTH "Width"
|
#define KEY_WIDTH "Width"
|
||||||
#define KEY_HEIGHT "Height"
|
#define KEY_HEIGHT "Height"
|
||||||
#define KEY_MAXIMIZED "Maximized"
|
#define KEY_MAXIMIZED "Maximized"
|
||||||
#define KEY_SPLITTEROFFSET1 "SplitterOffset1"
|
#define KEY_SPLITTEROFFSET1 "SplitterOffset1"
|
||||||
#define KEY_SPLITTEROFFSET2 "SplitterOffset2"
|
#define KEY_SPLITTEROFFSET2 "SplitterOffset2"
|
||||||
|
|
||||||
#define KEY_TIMESPLITTER_OFFSET1 "TimeSplitterOffset1"
|
#define KEY_TIMESPLITTER_OFFSET1 "TimeSplitterOffset1"
|
||||||
#define KEY_TIMESPLITTER_OFFSET2 "TimeSplitterOffset2"
|
#define KEY_TIMESPLITTER_OFFSET2 "TimeSplitterOffset2"
|
||||||
|
|
||||||
#define VALUE_TIMECOUNTER_THISDAY "ThisDay"
|
#define VALUE_TIMECOUNTER_THISDAY "ThisDay"
|
||||||
#define VALUE_TIMECOUNTER_THISSESSION "ThisSession"
|
#define VALUE_TIMECOUNTER_THISSESSION "ThisSession"
|
||||||
#define VALUE_TIMECOUNTER_ALLTIME "AllTime"
|
#define VALUE_TIMECOUNTER_ALLTIME "AllTime"
|
||||||
|
|
||||||
#define KEY_SMART_START "SmartStart"
|
#define KEY_SMART_START "SmartStart"
|
||||||
#define KEY_SMART_STOP "SmartStop"
|
#define KEY_SMART_STOP "SmartStop"
|
||||||
#define KEY_SMART_STOP_MINUTES "SmartStopIntervalInMinutes"
|
#define KEY_SMART_STOP_MINUTES "SmartStopIntervalInMinutes"
|
||||||
#define KEY_ASK_START "AskStart"
|
#define KEY_ASK_START "AskStart"
|
||||||
#define KEY_ASK_STOP "AskStop"
|
#define KEY_ASK_STOP "AskStop"
|
||||||
|
|
||||||
#define KEY_SHOW_TRAY_ICON "ShowTrayIcon"
|
#define KEY_SHOW_TRAY_ICON "ShowTrayIcon"
|
||||||
#define KEY_CUMULATIVE_REPORT "CumulativeReport"
|
#define KEY_CUMULATIVE_REPORT "CumulativeReport"
|
||||||
|
|
||||||
#define KEY_SELECTED_TASKS "SelectedTasks"
|
#define KEY_SELECTED_TASKS "SelectedTasks"
|
||||||
#define KEY_EXPANDED_TASKS "ExpandedTasks"
|
#define KEY_EXPANDED_TASKS "ExpandedTasks"
|
||||||
#define KEY_RECENT_TASKS "RecentTasks"
|
#define KEY_RECENT_TASKS "RecentTasks"
|
||||||
|
|
||||||
#define KEY_DARK_THEME "DarkTheme"
|
#define KEY_DARK_THEME "DarkTheme"
|
||||||
|
#define KEY_ASK_BEFORE_DELETE "AskBeforeDelete"
|
||||||
|
|
||||||
class Settings
|
class Settings
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user