- refactor task properties to dedicated widget
This commit is contained in:
parent
37e70ab252
commit
6bc7985b44
@ -111,7 +111,9 @@ AttachmentsList::~AttachmentsList()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttachmentsList::setTask(PTask task)
|
void AttachmentsList::setTask(const PTask& task)
|
||||||
|
{
|
||||||
|
if (mTask != task)
|
||||||
{
|
{
|
||||||
mTask = task;
|
mTask = task;
|
||||||
AttachmentArray aa;
|
AttachmentArray aa;
|
||||||
@ -126,6 +128,12 @@ void AttachmentsList::setTask(PTask task)
|
|||||||
// Set model to list view
|
// Set model to list view
|
||||||
ui->mListView->setModel(mModel);
|
ui->mListView->setModel(mModel);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PTask AttachmentsList::task() const
|
||||||
|
{
|
||||||
|
return mTask;
|
||||||
|
}
|
||||||
|
|
||||||
void AttachmentsList::setParentWidget(QWidget *w)
|
void AttachmentsList::setParentWidget(QWidget *w)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -42,7 +42,8 @@ class AttachmentsList : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit AttachmentsList(QWidget *parent = 0);
|
explicit AttachmentsList(QWidget *parent = 0);
|
||||||
~AttachmentsList();
|
~AttachmentsList();
|
||||||
void setTask(PTask task);
|
void setTask(const PTask& task);
|
||||||
|
PTask task() const;
|
||||||
void setParentWidget(QWidget* w);
|
void setParentWidget(QWidget* w);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -41,8 +41,6 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#define SETTINGS mSettings->data()
|
|
||||||
|
|
||||||
const int ViewIndex_Main = 0;
|
const int ViewIndex_Main = 0;
|
||||||
const int ViewIndex_OpenOrCreateDb = 1;
|
const int ViewIndex_OpenOrCreateDb = 1;
|
||||||
const int ViewIndex_DbPassword = 2;
|
const int ViewIndex_DbPassword = 2;
|
||||||
@ -51,10 +49,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
mPasswordFailed(false), mFindInTasksDlg(this), mDockRecentMenu(nullptr)
|
mPasswordFailed(false), mFindInTasksDlg(this), mDockRecentMenu(nullptr)
|
||||||
{
|
{
|
||||||
mSettings = QSharedPointer<Settings>(new Settings());
|
|
||||||
|
|
||||||
// Dark theme if needed
|
// Dark theme if needed
|
||||||
helper::theme::applyCurrent(*mSettings);
|
helper::theme::applyCurrent(SETTINGS);
|
||||||
|
|
||||||
// Restore window size & position from last run
|
// Restore window size & position from last run
|
||||||
setUpdatesEnabled(false);
|
setUpdatesEnabled(false);
|
||||||
@ -75,7 +71,7 @@ MainWindow::~MainWindow()
|
|||||||
void MainWindow::attachDatabase()
|
void MainWindow::attachDatabase()
|
||||||
{
|
{
|
||||||
// Find default database file exists
|
// Find default database file exists
|
||||||
QString path = mSettings->getDatabasePath();
|
QString path = SETTINGS.getDatabasePath();
|
||||||
|
|
||||||
QString folder = QFileInfo(path).absoluteDir().path();
|
QString folder = QFileInfo(path).absoluteDir().path();
|
||||||
Storage::instance().setPath(path);
|
Storage::instance().setPath(path);
|
||||||
@ -84,7 +80,7 @@ void MainWindow::attachDatabase()
|
|||||||
askNewDbPassword();
|
askNewDbPassword();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mSettings->data()[KEY_AUTOSAVE_PASSWORD].toBool())
|
if (SETTINGS.data()[KEY_AUTOSAVE_PASSWORD].toBool())
|
||||||
{
|
{
|
||||||
QString password = helper::password::loadFromKeychain();
|
QString password = helper::password::loadFromKeychain();
|
||||||
if (password.isEmpty())
|
if (password.isEmpty())
|
||||||
@ -120,11 +116,11 @@ void MainWindow::connectUiToDatabase()
|
|||||||
if (mTaskTreeModel->hasChildren())
|
if (mTaskTreeModel->hasChildren())
|
||||||
ui->mTaskTree->setCurrentIndex(mTaskTreeModel->index(0,0, QModelIndex()));
|
ui->mTaskTree->setCurrentIndex(mTaskTreeModel->index(0,0, QModelIndex()));
|
||||||
|
|
||||||
mTaskTreeModel->setExpandedState(mSettings->data()[KEY_EXPANDED_TASKS].toString(), *ui->mTaskTree);
|
mTaskTreeModel->setExpandedState(SETTINGS.data()[KEY_EXPANDED_TASKS].toString(), *ui->mTaskTree);
|
||||||
mTaskTreeModel->setSelected(mSettings->data()[KEY_SELECTED_TASKS].toString(), *ui->mTaskTree);
|
mTaskTreeModel->setSelected(SETTINGS.data()[KEY_SELECTED_TASKS].toString(), *ui->mTaskTree);
|
||||||
|
|
||||||
// Load recent tasks
|
// Load recent tasks
|
||||||
QString recent = mSettings->data()[KEY_RECENT_TASKS].toString();
|
QString recent = SETTINGS.data()[KEY_RECENT_TASKS].toString();
|
||||||
QStringList recentList = recent.split(";", QString::SkipEmptyParts);
|
QStringList recentList = recent.split(";", QString::SkipEmptyParts);
|
||||||
for (QString& s: recentList)
|
for (QString& s: recentList)
|
||||||
{
|
{
|
||||||
@ -182,7 +178,7 @@ void MainWindow::initClient()
|
|||||||
ui->mCheckForUpdatesAction->setMenuRole(QAction::ApplicationSpecificRole);
|
ui->mCheckForUpdatesAction->setMenuRole(QAction::ApplicationSpecificRole);
|
||||||
|
|
||||||
// Build tray icon if system support this one
|
// Build tray icon if system support this one
|
||||||
if (QSystemTrayIcon::isSystemTrayAvailable() && mSettings->data()[KEY_SHOW_TRAY_ICON].toBool())
|
if (QSystemTrayIcon::isSystemTrayAvailable() && SETTINGS.data()[KEY_SHOW_TRAY_ICON].toBool())
|
||||||
initTrayIcon();
|
initTrayIcon();
|
||||||
|
|
||||||
setWindowIcon(getAppIcon());
|
setWindowIcon(getAppIcon());
|
||||||
@ -295,7 +291,7 @@ QSharedPointer<QByteArray> MainWindow::getUndoStack() const
|
|||||||
|
|
||||||
void MainWindow::saveGeometry()
|
void MainWindow::saveGeometry()
|
||||||
{
|
{
|
||||||
AppGeometry g(*mSettings);
|
AppGeometry g(SETTINGS);
|
||||||
g.setMaximized(isMaximized());
|
g.setMaximized(isMaximized());
|
||||||
g.setWindowRect(this->geometry());
|
g.setWindowRect(this->geometry());
|
||||||
g.setSplitterPos(0, {ui->mSplitter->sizes().front(), ui->mSplitter->sizes().back()});
|
g.setSplitterPos(0, {ui->mSplitter->sizes().front(), ui->mSplitter->sizes().back()});
|
||||||
@ -303,8 +299,8 @@ void MainWindow::saveGeometry()
|
|||||||
|
|
||||||
if (mTaskTreeModel)
|
if (mTaskTreeModel)
|
||||||
{
|
{
|
||||||
mSettings->data()[KEY_EXPANDED_TASKS] = this->mTaskTreeModel->getExpandedState(*ui->mTaskTree);
|
SETTINGS.data()[KEY_EXPANDED_TASKS] = this->mTaskTreeModel->getExpandedState(*ui->mTaskTree);
|
||||||
mSettings->data()[KEY_SELECTED_TASKS] = this->mTaskTreeModel->getSelected(*ui->mTaskTree);
|
SETTINGS.data()[KEY_SELECTED_TASKS] = this->mTaskTreeModel->getSelected(*ui->mTaskTree);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save recent list
|
// Save recent list
|
||||||
@ -313,13 +309,13 @@ void MainWindow::saveGeometry()
|
|||||||
{
|
{
|
||||||
recent += QString::number(t->id()) + ";";
|
recent += QString::number(t->id()) + ";";
|
||||||
}
|
}
|
||||||
mSettings->data()[KEY_RECENT_TASKS] = recent;
|
SETTINGS.data()[KEY_RECENT_TASKS] = recent;
|
||||||
mSettings->save();
|
SETTINGS.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::loadGeometry()
|
void MainWindow::loadGeometry()
|
||||||
{
|
{
|
||||||
auto g = AppGeometry(*mSettings);
|
auto g = AppGeometry(SETTINGS);
|
||||||
|
|
||||||
if (g.isMaximized())
|
if (g.isMaximized())
|
||||||
this->showMaximized();
|
this->showMaximized();
|
||||||
@ -415,7 +411,7 @@ void MainWindow::onDatabaseAvailable()
|
|||||||
|
|
||||||
void MainWindow::preferences()
|
void MainWindow::preferences()
|
||||||
{
|
{
|
||||||
PreferencesDlg pref(this, *mSettings);
|
PreferencesDlg pref(this, SETTINGS);
|
||||||
|
|
||||||
if (pref.exec() == QDialog::Accepted)
|
if (pref.exec() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
@ -428,20 +424,20 @@ void MainWindow::preferences()
|
|||||||
emit onTimeFormatChanged();
|
emit onTimeFormatChanged();
|
||||||
|
|
||||||
// Delete autosaved password if needed
|
// Delete autosaved password if needed
|
||||||
if (mSettings->data()[KEY_AUTOSAVE_PASSWORD].toBool() == false)
|
if (SETTINGS.data()[KEY_AUTOSAVE_PASSWORD].toBool() == false)
|
||||||
{
|
{
|
||||||
// Reset password in keychain
|
// Reset password in keychain
|
||||||
helper::password::saveToKeychain(QString(""));
|
helper::password::saveToKeychain(QString(""));
|
||||||
|
|
||||||
//mSettings->data()[KEY_PASSWORD] = NOPASSWORDSTRING;
|
//mSettings->data()[KEY_PASSWORD] = NOPASSWORDSTRING;
|
||||||
mSettings->save();
|
SETTINGS.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide/Show tray icon if need
|
// Hide/Show tray icon if need
|
||||||
if (mSettings->data()[KEY_SHOW_TRAY_ICON].toBool() && !mTrayIcon && QSystemTrayIcon::isSystemTrayAvailable())
|
if (SETTINGS.data()[KEY_SHOW_TRAY_ICON].toBool() && !mTrayIcon && QSystemTrayIcon::isSystemTrayAvailable())
|
||||||
initTrayIcon();
|
initTrayIcon();
|
||||||
else
|
else
|
||||||
if (!mSettings->data()[KEY_SHOW_TRAY_ICON].toBool() && mTrayIcon)
|
if (!SETTINGS.data()[KEY_SHOW_TRAY_ICON].toBool() && mTrayIcon)
|
||||||
removeTrayIcon();
|
removeTrayIcon();
|
||||||
|
|
||||||
updateData();
|
updateData();
|
||||||
@ -573,7 +569,7 @@ void MainWindow::deleteTask()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mSettings->data()[KEY_ASK_BEFORE_DELETE].toBool())
|
if (SETTINGS.data()[KEY_ASK_BEFORE_DELETE].toBool())
|
||||||
{
|
{
|
||||||
auto reply = QMessageBox::question(this,
|
auto reply = QMessageBox::question(this,
|
||||||
tr("Are you sure?"),
|
tr("Are you sure?"),
|
||||||
@ -714,9 +710,9 @@ void MainWindow::idleDetected()
|
|||||||
mActivityTracker->acceptIdleState();
|
mActivityTracker->acceptIdleState();
|
||||||
|
|
||||||
// Check if settings allow smart stop
|
// Check if settings allow smart stop
|
||||||
if (SETTINGS[KEY_SMART_STOP].toBool() && SETTINGS[KEY_SMART_STOP_MINUTES].toInt() > 0)
|
if (SETTINGS.data()[KEY_SMART_STOP].toBool() && SETTINGS.data()[KEY_SMART_STOP_MINUTES].toInt() > 0)
|
||||||
{
|
{
|
||||||
if (SETTINGS[KEY_ASK_STOP].toBool())
|
if (SETTINGS.data()[KEY_ASK_STOP].toBool())
|
||||||
{
|
{
|
||||||
// Stop activity tracker to not be confused with following user activity
|
// Stop activity tracker to not be confused with following user activity
|
||||||
mActivityTracker->stop();
|
mActivityTracker->stop();
|
||||||
@ -736,7 +732,7 @@ void MainWindow::activityDetected()
|
|||||||
mActivityTracker->acceptUserActiveState();
|
mActivityTracker->acceptUserActiveState();
|
||||||
|
|
||||||
// Check if settings allow smart start
|
// Check if settings allow smart start
|
||||||
if (SETTINGS[KEY_SMART_START].toBool() && mStopReason == TSR_Automatic)
|
if (SETTINGS.data()[KEY_SMART_START].toBool() && mStopReason == TSR_Automatic)
|
||||||
{
|
{
|
||||||
/*if (SETTINGS[KEY_ASK_START].toBool())
|
/*if (SETTINGS[KEY_ASK_START].toBool())
|
||||||
{
|
{
|
||||||
@ -902,9 +898,9 @@ void MainWindow::startTracking(PTask t)
|
|||||||
updateTrayIcon(Tray_ShowMessage);
|
updateTrayIcon(Tray_ShowMessage);
|
||||||
|
|
||||||
// Start activity tracker if needed
|
// Start activity tracker if needed
|
||||||
if (mSettings->data()[KEY_SMART_STOP].toBool() && mSettings->data()[KEY_SMART_STOP_MINUTES].toInt() > 0)
|
if (SETTINGS.data()[KEY_SMART_STOP].toBool() && SETTINGS.data()[KEY_SMART_STOP_MINUTES].toInt() > 0)
|
||||||
{
|
{
|
||||||
mActivityTracker->setInterval(mSettings->data()[KEY_SMART_STOP_MINUTES].toInt() * 60);
|
mActivityTracker->setInterval(SETTINGS.data()[KEY_SMART_STOP_MINUTES].toInt() * 60);
|
||||||
mActivityTracker->start();
|
mActivityTracker->start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -917,7 +913,7 @@ void MainWindow::startTracking()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Trigger permission dialog if needed
|
// Trigger permission dialog if needed
|
||||||
if (mSettings->data()[KEY_SMART_STOP].toBool())
|
if (SETTINGS.data()[KEY_SMART_STOP].toBool())
|
||||||
{
|
{
|
||||||
if (!helper::activityTracker::ensureSmartTrackingIsPossible())
|
if (!helper::activityTracker::ensureSmartTrackingIsPossible())
|
||||||
mTrayIcon->showMessage(tr("No smart tracking stop/start"), tr("Problem with obtaining permissions"), QSystemTrayIcon::Warning);
|
mTrayIcon->showMessage(tr("No smart tracking stop/start"), tr("Problem with obtaining permissions"), QSystemTrayIcon::Warning);
|
||||||
@ -1296,26 +1292,14 @@ void MainWindow::timeFormatChanged()
|
|||||||
void MainWindow::showTimeForSelectedTask()
|
void MainWindow::showTimeForSelectedTask()
|
||||||
{
|
{
|
||||||
PTask t = mTaskTreeModel->getTask(ui->mTaskTree->currentIndex());
|
PTask t = mTaskTreeModel->getTask(ui->mTaskTree->currentIndex());
|
||||||
bool showSeconds = mSettings->data()[KEY_SHOW_SECONDS].toBool();
|
ui->mProperties->setTask(t);
|
||||||
|
|
||||||
// Show stats for current task
|
|
||||||
if (t)
|
|
||||||
{
|
|
||||||
if (!t->timeline())
|
|
||||||
t->loadContent();
|
|
||||||
|
|
||||||
int spentSecondsToday = t->timeline()->today();
|
|
||||||
int spentSecondsMonth = t->timeline()->month();
|
|
||||||
ui->mTodaySpentTimeLabel->setText(QString::fromStdString(helper::chrono::secondsToDisplay(spentSecondsToday, showSeconds)));
|
|
||||||
ui->mThisMonthSpentTimeLabel->setText(QString::fromStdString(helper::chrono::secondsToDisplay(spentSecondsMonth, showSeconds)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showTimeForTrackingTask()
|
void MainWindow::showTimeForTrackingTask()
|
||||||
{
|
{
|
||||||
if (mCurrentTask)
|
if (mCurrentTask)
|
||||||
{
|
{
|
||||||
bool showSeconds = mSettings->data()[KEY_SHOW_SECONDS].toBool();
|
bool showSeconds = SETTINGS.data()[KEY_SHOW_SECONDS].toBool();
|
||||||
|
|
||||||
// Update status bar
|
// Update status bar
|
||||||
QString path;
|
QString path;
|
||||||
@ -1369,7 +1353,7 @@ void MainWindow::updateTrayIcon(TrayShowMessage flag)
|
|||||||
QString tooltip;
|
QString tooltip;
|
||||||
if (mCurrentTask)
|
if (mCurrentTask)
|
||||||
{
|
{
|
||||||
bool showSeconds = mSettings->data()[KEY_SHOW_SECONDS].toBool();
|
bool showSeconds = SETTINGS.data()[KEY_SHOW_SECONDS].toBool();
|
||||||
int spentSecondsToday = mCurrentTask->timeline()->today();
|
int spentSecondsToday = mCurrentTask->timeline()->today();
|
||||||
QString timeString = QString::fromStdString(helper::chrono::secondsToDisplay(spentSecondsToday, showSeconds));
|
QString timeString = QString::fromStdString(helper::chrono::secondsToDisplay(spentSecondsToday, showSeconds));
|
||||||
tooltip = tr("Noo is tracking ") + mCurrentTask->title() + ".\n" +
|
tooltip = tr("Noo is tracking ") + mCurrentTask->title() + ".\n" +
|
||||||
@ -1408,7 +1392,7 @@ void MainWindow::showTimeline()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
PTask t = mTaskTreeModel->getTask(ui->mTaskTree->currentIndex());
|
PTask t = mTaskTreeModel->getTask(ui->mTaskTree->currentIndex());
|
||||||
TimeTreeDlg dlg(this, t->timeline(), *mSettings);
|
TimeTreeDlg dlg(this, t->timeline(), SETTINGS);
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
|
|
||||||
// Refresh current timeline stats
|
// Refresh current timeline stats
|
||||||
@ -1417,7 +1401,7 @@ void MainWindow::showTimeline()
|
|||||||
|
|
||||||
void MainWindow::showTimeReport()
|
void MainWindow::showTimeReport()
|
||||||
{
|
{
|
||||||
TimeReportWizard trz(*mSettings, this);
|
TimeReportWizard trz(SETTINGS, this);
|
||||||
trz.exec();
|
trz.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1652,7 +1636,7 @@ void MainWindow::trayWindowDestroyed(QObject */*object*/)
|
|||||||
void MainWindow::onDbPasswordEntered(const QString& password)
|
void MainWindow::onDbPasswordEntered(const QString& password)
|
||||||
{
|
{
|
||||||
// Save password to keychain if needed
|
// Save password to keychain if needed
|
||||||
if (mSettings->data()[KEY_AUTOSAVE_PASSWORD].toBool())
|
if (SETTINGS.data()[KEY_AUTOSAVE_PASSWORD].toBool())
|
||||||
helper::password::saveToKeychain(password);
|
helper::password::saveToKeychain(password);
|
||||||
|
|
||||||
// Try to open database
|
// Try to open database
|
||||||
@ -1674,7 +1658,7 @@ void MainWindow::onDbPasswordCancelled()
|
|||||||
void MainWindow::onNewDbPasswordEntered(const QString& password)
|
void MainWindow::onNewDbPasswordEntered(const QString& password)
|
||||||
{
|
{
|
||||||
// Save password to keychain if needed
|
// Save password to keychain if needed
|
||||||
if (mSettings->data()[KEY_AUTOSAVE_PASSWORD].toBool())
|
if (SETTINGS.data()[KEY_AUTOSAVE_PASSWORD].toBool())
|
||||||
helper::password::saveToKeychain(password);
|
helper::password::saveToKeychain(password);
|
||||||
|
|
||||||
// Configure storage
|
// Configure storage
|
||||||
@ -1695,8 +1679,8 @@ void MainWindow::onNewDbPasswordEntered(const QString& password)
|
|||||||
void MainWindow::onDatabaseChanged(const QString& path)
|
void MainWindow::onDatabaseChanged(const QString& path)
|
||||||
{
|
{
|
||||||
// Bind to specific database
|
// Bind to specific database
|
||||||
mSettings->data()[KEY_DB_FILENAME] = path;
|
SETTINGS.data()[KEY_DB_FILENAME] = path;
|
||||||
mSettings->save();
|
SETTINGS.save();
|
||||||
Storage::instance().setPath(path);
|
Storage::instance().setPath(path);
|
||||||
|
|
||||||
// Try to open database
|
// Try to open database
|
||||||
|
|||||||
@ -63,7 +63,6 @@ private:
|
|||||||
QLabel* mCurrentIntervalLabel = nullptr;
|
QLabel* mCurrentIntervalLabel = nullptr;
|
||||||
QLabel* mDuplicationSignalLabel = nullptr;;
|
QLabel* mDuplicationSignalLabel = nullptr;;
|
||||||
QSystemTrayIcon *mTrayIcon = nullptr;
|
QSystemTrayIcon *mTrayIcon = nullptr;
|
||||||
QSharedPointer<Settings> mSettings;
|
|
||||||
bool mPasswordFailed = false;
|
bool mPasswordFailed = false;
|
||||||
PasswordDlg* mPasswordDlg = nullptr;
|
PasswordDlg* mPasswordDlg = nullptr;
|
||||||
NewPasswordDlg* mNewPasswordDlg = nullptr;
|
NewPasswordDlg* mNewPasswordDlg = nullptr;
|
||||||
|
|||||||
@ -81,36 +81,9 @@
|
|||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Raised</enum>
|
<enum>QFrame::Raised</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<property name="leftMargin">
|
<item>
|
||||||
<number>2</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>2</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QSplitter" name="mTimeSplitter">
|
<widget class="QSplitter" name="mTimeSplitter">
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>4000</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="lineWidth">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -210,59 +183,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QFrame" name="mTimeFrame">
|
<widget class="NodePropertiesWidget" name="mProperties" native="true"/>
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Ignored" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>100</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>4000</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>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -771,6 +692,12 @@
|
|||||||
<extends>QPlainTextEdit</extends>
|
<extends>QPlainTextEdit</extends>
|
||||||
<header>qmarkdowntextedit/qmarkdowntextedit.h</header>
|
<header>qmarkdowntextedit/qmarkdowntextedit.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>NodePropertiesWidget</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>nodepropertieswidget.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="mainwindow.qrc"/>
|
<include location="mainwindow.qrc"/>
|
||||||
|
|||||||
52
client/nodepropertieswidget.cpp
Normal file
52
client/nodepropertieswidget.cpp
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#include "nodepropertieswidget.h"
|
||||||
|
#include "ui_nodepropertieswidget.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
|
NodePropertiesWidget::NodePropertiesWidget(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::NodePropertiesWidget)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
NodePropertiesWidget::~NodePropertiesWidget()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodePropertiesWidget::setTask(const PTask& task)
|
||||||
|
{
|
||||||
|
if (mTask != task)
|
||||||
|
{
|
||||||
|
mTask = task;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PTask NodePropertiesWidget::task() const
|
||||||
|
{
|
||||||
|
return mTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodePropertiesWidget::refresh()
|
||||||
|
{
|
||||||
|
bool showSeconds = SETTINGS.data()[KEY_SHOW_SECONDS].toBool();
|
||||||
|
|
||||||
|
if (mTask != nullptr)
|
||||||
|
{
|
||||||
|
ui->mFileListView->setTask(mTask);
|
||||||
|
if (!mTask->timeline())
|
||||||
|
mTask->loadContent();
|
||||||
|
|
||||||
|
int spentSecondsToday = mTask->timeline()->today();
|
||||||
|
int spentSecondsMonth = mTask->timeline()->month();
|
||||||
|
ui->mTodaySpentTimeLabel->setText(QString::fromStdString(helper::chrono::secondsToDisplay(spentSecondsToday, showSeconds)));
|
||||||
|
ui->mThisMonthSpentTimeLabel->setText(QString::fromStdString(helper::chrono::secondsToDisplay(spentSecondsMonth, showSeconds)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->mTimeFrame->setVisible(false);
|
||||||
|
ui->mFileListView->setTask(PTask());
|
||||||
|
}
|
||||||
|
}
|
||||||
29
client/nodepropertieswidget.h
Normal file
29
client/nodepropertieswidget.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#ifndef NODEPROPERTIESWIDGET_H
|
||||||
|
#define NODEPROPERTIESWIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include "task.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class NodePropertiesWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
class NodePropertiesWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit NodePropertiesWidget(QWidget *parent = nullptr);
|
||||||
|
~NodePropertiesWidget();
|
||||||
|
|
||||||
|
void setTask(const PTask& task);
|
||||||
|
PTask task() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::NodePropertiesWidget *ui;
|
||||||
|
|
||||||
|
void refresh();
|
||||||
|
PTask mTask;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NODEPROPERTIESWIDGET_H
|
||||||
90
client/nodepropertieswidget.ui
Normal file
90
client/nodepropertieswidget.ui
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>NodePropertiesWidget</class>
|
||||||
|
<widget class="QWidget" name="NodePropertiesWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>449</width>
|
||||||
|
<height>470</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QSplitter" name="splitter">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QFrame" name="mTimeFrame">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Ignored" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>4000</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 class="AttachmentsList" name="mFileListView" native="true"/>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>AttachmentsList</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>attachmentslist.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
@ -52,6 +52,7 @@ INCLUDEPATH += $$PWD/../lib/include
|
|||||||
|
|
||||||
SOURCES += main.cpp \
|
SOURCES += main.cpp \
|
||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
|
nodepropertieswidget.cpp \
|
||||||
storage.cpp \
|
storage.cpp \
|
||||||
task.cpp \
|
task.cpp \
|
||||||
tasktreemodel.cpp \
|
tasktreemodel.cpp \
|
||||||
@ -91,6 +92,7 @@ SOURCES += main.cpp \
|
|||||||
|
|
||||||
|
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
|
nodepropertieswidget.h \
|
||||||
storage.h \
|
storage.h \
|
||||||
task.h \
|
task.h \
|
||||||
tasktreemodel.h \
|
tasktreemodel.h \
|
||||||
@ -150,6 +152,7 @@ unix {
|
|||||||
|
|
||||||
FORMS += mainwindow.ui \
|
FORMS += mainwindow.ui \
|
||||||
newpassworddlg.ui \
|
newpassworddlg.ui \
|
||||||
|
nodepropertieswidget.ui \
|
||||||
passworddlg.ui \
|
passworddlg.ui \
|
||||||
preferencesdlg.ui \
|
preferencesdlg.ui \
|
||||||
timetreedlg.ui \
|
timetreedlg.ui \
|
||||||
|
|||||||
@ -61,6 +61,8 @@ protected:
|
|||||||
QVariantMap mData;
|
QVariantMap mData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define SETTINGS Settings::instance()
|
||||||
|
|
||||||
class AppGeometry
|
class AppGeometry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user