mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
refine task
This commit is contained in:
parent
293d04e2c3
commit
7a017e30ea
@ -136,6 +136,16 @@ QString Notebook::getRootFolderAbsolutePath() const
|
||||
return PathUtils::absolutePath(m_rootFolderPath);
|
||||
}
|
||||
|
||||
QString Notebook::getConfigFolderAbsolutePath() const
|
||||
{
|
||||
const auto &folderPath = m_configMgr->getConfigFolderPath();
|
||||
if (folderPath.isEmpty()) {
|
||||
return QString();
|
||||
}
|
||||
|
||||
return getBackend()->getFullPath(folderPath);
|
||||
}
|
||||
|
||||
const QIcon &Notebook::getIcon() const
|
||||
{
|
||||
return m_icon;
|
||||
|
@ -54,6 +54,9 @@ namespace vnotex
|
||||
|
||||
QString getRootFolderAbsolutePath() const;
|
||||
|
||||
// Get the absolute path of the config folder if applicable.
|
||||
QString getConfigFolderAbsolutePath() const;
|
||||
|
||||
const QIcon &getIcon() const;
|
||||
void setIcon(const QIcon &p_icon);
|
||||
|
||||
|
@ -106,3 +106,8 @@ int BundleNotebookConfigMgr::getCodeVersion() const
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
QString BundleNotebookConfigMgr::getConfigFolderPath() const
|
||||
{
|
||||
return c_configFolderName;
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ namespace vnotex
|
||||
|
||||
int getCodeVersion() const Q_DECL_OVERRIDE;
|
||||
|
||||
QString getConfigFolderPath() const Q_DECL_OVERRIDE;
|
||||
|
||||
static const QString &getConfigFolderName();
|
||||
|
||||
static const QString &getConfigName();
|
||||
|
@ -87,6 +87,8 @@ namespace vnotex
|
||||
// Version of the config processing code.
|
||||
virtual int getCodeVersion() const = 0;
|
||||
|
||||
virtual QString getConfigFolderPath() const = 0;
|
||||
|
||||
private:
|
||||
QSharedPointer<INotebookBackend> m_backend;
|
||||
|
||||
|
@ -55,6 +55,13 @@ const QVector<QSharedPointer<Task>> &TaskMgr::getNotebookTasks() const
|
||||
|
||||
QString TaskMgr::getNotebookTaskFolder()
|
||||
{
|
||||
auto nb = VNoteX::getInst().getNotebookMgr().getCurrentNotebook();
|
||||
if (nb) {
|
||||
const auto folderPath = nb->getConfigFolderAbsolutePath();
|
||||
if (!folderPath.isEmpty()) {
|
||||
return PathUtils::concatenateFilePath(folderPath, QStringLiteral("tasks"));
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
@ -80,6 +87,7 @@ void TaskMgr::loadGlobalTasks()
|
||||
|
||||
void TaskMgr::loadTasksFromFolder(QVector<QSharedPointer<Task>> &p_tasks, const QString &p_folder)
|
||||
{
|
||||
qDebug() << "load tasks from folder" << p_folder;
|
||||
p_tasks.clear();
|
||||
|
||||
if (p_folder.isEmpty()) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "terminalviewer.h"
|
||||
#include "consoleviewer.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QPlainTextEdit>
|
||||
@ -12,13 +12,13 @@
|
||||
|
||||
using namespace vnotex;
|
||||
|
||||
TerminalViewer::TerminalViewer(QWidget *p_parent)
|
||||
ConsoleViewer::ConsoleViewer(QWidget *p_parent)
|
||||
: QFrame(p_parent)
|
||||
{
|
||||
setupUI();
|
||||
}
|
||||
|
||||
void TerminalViewer::setupUI()
|
||||
void ConsoleViewer::setupUI()
|
||||
{
|
||||
auto mainLayout = new QVBoxLayout(this);
|
||||
WidgetUtils::setContentsMargins(mainLayout);
|
||||
@ -35,7 +35,7 @@ void TerminalViewer::setupUI()
|
||||
setFocusProxy(m_consoleEdit);
|
||||
}
|
||||
|
||||
void TerminalViewer::setupTitleBar(const QString &p_title, QWidget *p_parent)
|
||||
void ConsoleViewer::setupTitleBar(const QString &p_title, QWidget *p_parent)
|
||||
{
|
||||
m_titleBar = new TitleBar(p_title, true, TitleBar::Action::None, p_parent);
|
||||
m_titleBar->setActionButtonsAlwaysShown(true);
|
||||
@ -43,11 +43,11 @@ void TerminalViewer::setupTitleBar(const QString &p_title, QWidget *p_parent)
|
||||
{
|
||||
auto clearBtn = m_titleBar->addActionButton(QStringLiteral("clear.svg"), tr("Clear"));
|
||||
connect(clearBtn, &QToolButton::triggered,
|
||||
this, &TerminalViewer::clear);
|
||||
this, &ConsoleViewer::clear);
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalViewer::append(const QString &p_text)
|
||||
void ConsoleViewer::append(const QString &p_text)
|
||||
{
|
||||
m_consoleEdit->appendPlainText(p_text);
|
||||
auto scrollBar = m_consoleEdit->verticalScrollBar();
|
||||
@ -56,7 +56,7 @@ void TerminalViewer::append(const QString &p_text)
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalViewer::clear()
|
||||
void ConsoleViewer::clear()
|
||||
{
|
||||
m_consoleEdit->clear();
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
#ifndef TERMINALVIEWER_H
|
||||
#define TERMINALVIEWER_H
|
||||
#ifndef CONSOLEVIEWER_H
|
||||
#define CONSOLEVIEWER_H
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
@ -9,11 +9,11 @@ namespace vnotex
|
||||
{
|
||||
class TitleBar;
|
||||
|
||||
class TerminalViewer : public QFrame
|
||||
class ConsoleViewer : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TerminalViewer(QWidget *p_parent = nullptr);
|
||||
explicit ConsoleViewer(QWidget *p_parent = nullptr);
|
||||
|
||||
void append(const QString &p_text);
|
||||
|
||||
@ -30,4 +30,4 @@ namespace vnotex
|
||||
};
|
||||
}
|
||||
|
||||
#endif // TERMINALVIEWER_H
|
||||
#endif // CONSOLEVIEWER_H
|
@ -25,7 +25,7 @@
|
||||
#include "snippetpanel.h"
|
||||
#include "historypanel.h"
|
||||
#include "tagexplorer.h"
|
||||
#include "terminalviewer.h"
|
||||
#include "consoleviewer.h"
|
||||
|
||||
using namespace vnotex;
|
||||
|
||||
@ -114,7 +114,7 @@ void DockWidgetHelper::setupDocks()
|
||||
|
||||
setupOutlineDock();
|
||||
|
||||
setupTerminalDock();
|
||||
setupConsoleDock();
|
||||
|
||||
setupLocationListDock();
|
||||
|
||||
@ -149,15 +149,15 @@ void DockWidgetHelper::setupOutlineDock()
|
||||
m_mainWindow->addDockWidget(Qt::RightDockWidgetArea, dock);
|
||||
}
|
||||
|
||||
void DockWidgetHelper::setupTerminalDock()
|
||||
void DockWidgetHelper::setupConsoleDock()
|
||||
{
|
||||
auto dock = createDockWidget(DockIndex::TerminalDock, tr("Terminal"), m_mainWindow);
|
||||
auto dock = createDockWidget(DockIndex::ConsoleDock, tr("Console"), m_mainWindow);
|
||||
|
||||
dock->setObjectName(QStringLiteral("TerminalDock.vnotex"));
|
||||
dock->setObjectName(QStringLiteral("ConsoleDock.vnotex"));
|
||||
dock->setAllowedAreas(Qt::AllDockWidgetAreas);
|
||||
|
||||
dock->setWidget(m_mainWindow->m_terminalViewer);
|
||||
dock->setFocusProxy(m_mainWindow->m_terminalViewer);
|
||||
dock->setWidget(m_mainWindow->m_consoleViewer);
|
||||
dock->setFocusProxy(m_mainWindow->m_consoleViewer);
|
||||
m_mainWindow->addDockWidget(Qt::BottomDockWidgetArea, dock);
|
||||
dock->hide();
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ namespace vnotex
|
||||
SearchDock,
|
||||
SnippetDock,
|
||||
OutlineDock,
|
||||
TerminalDock,
|
||||
ConsoleDock,
|
||||
LocationListDock,
|
||||
MaxDock
|
||||
};
|
||||
@ -98,7 +98,7 @@ namespace vnotex
|
||||
|
||||
void setupOutlineDock();
|
||||
|
||||
void setupTerminalDock();
|
||||
void setupConsoleDock();
|
||||
|
||||
void setupSearchDock();
|
||||
|
||||
|
@ -56,7 +56,7 @@
|
||||
#include "tagexplorer.h"
|
||||
#include "toolbarhelper.h"
|
||||
#include "statusbarhelper.h"
|
||||
#include "terminalviewer.h"
|
||||
#include "consoleviewer.h"
|
||||
|
||||
using namespace vnotex;
|
||||
|
||||
@ -258,7 +258,7 @@ void MainWindow::setupDocks()
|
||||
|
||||
setupOutlineViewer();
|
||||
|
||||
setupTerminalViewer();
|
||||
setupConsoleViewer();
|
||||
|
||||
setupHistoryPanel();
|
||||
|
||||
@ -515,15 +515,15 @@ void MainWindow::setupOutlineViewer()
|
||||
this, &MainWindow::focusViewArea);
|
||||
}
|
||||
|
||||
void MainWindow::setupTerminalViewer()
|
||||
void MainWindow::setupConsoleViewer()
|
||||
{
|
||||
m_terminalViewer = new TerminalViewer(this);
|
||||
m_terminalViewer->setObjectName("TerminalViewer.vnotex");
|
||||
m_consoleViewer = new ConsoleViewer(this);
|
||||
m_consoleViewer->setObjectName("ConsoleViewer.vnotex");
|
||||
|
||||
connect(&VNoteX::getInst(), &VNoteX::showOutputRequested,
|
||||
this, [this](const QString &p_text) {
|
||||
m_terminalViewer->append(p_text);
|
||||
m_dockWidgetHelper.activateDock(DockWidgetHelper::TerminalDock);
|
||||
m_consoleViewer->append(p_text);
|
||||
m_dockWidgetHelper.activateDock(DockWidgetHelper::ConsoleDock);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace vnotex
|
||||
class SnippetPanel;
|
||||
class HistoryPanel;
|
||||
class ExportDialog;
|
||||
class TerminalViewer;
|
||||
class ConsoleViewer;
|
||||
|
||||
enum { RESTART_EXIT_CODE = 1000 };
|
||||
|
||||
@ -107,7 +107,7 @@ namespace vnotex
|
||||
|
||||
void setupOutlineViewer();
|
||||
|
||||
void setupTerminalViewer();
|
||||
void setupConsoleViewer();
|
||||
|
||||
void setupSearchPanel();
|
||||
|
||||
@ -168,7 +168,7 @@ namespace vnotex
|
||||
|
||||
OutlineViewer *m_outlineViewer = nullptr;
|
||||
|
||||
TerminalViewer *m_terminalViewer = nullptr;
|
||||
ConsoleViewer *m_consoleViewer = nullptr;
|
||||
|
||||
LocationList *m_locationList = nullptr;
|
||||
|
||||
|
@ -381,8 +381,9 @@ QToolBar *ToolBarHelper::setupTaskToolBar(MainWindow *p_win, QToolBar *p_toolBar
|
||||
MainWindow::connect(taskMenu, &QMenu::triggered,
|
||||
taskMenu, [](QAction *act) {
|
||||
auto task = reinterpret_cast<Task *>(act->data().toULongLong());
|
||||
Q_ASSERT(task);
|
||||
task->run();
|
||||
if (task) {
|
||||
task->run();
|
||||
}
|
||||
});
|
||||
MainWindow::connect(&VNoteX::getInst().getTaskMgr(), &TaskMgr::tasksUpdated,
|
||||
taskMenu, [taskMenu]() {
|
||||
|
@ -3,6 +3,7 @@ SOURCES += \
|
||||
$$PWD/attachmentpopup.cpp \
|
||||
$$PWD/biaction.cpp \
|
||||
$$PWD/combobox.cpp \
|
||||
$$PWD/consoleviewer.cpp \
|
||||
$$PWD/dialogs/dialog.cpp \
|
||||
$$PWD/dialogs/exportdialog.cpp \
|
||||
$$PWD/dialogs/filepropertiesdialog.cpp \
|
||||
@ -89,7 +90,6 @@ SOURCES += \
|
||||
$$PWD/tagexplorer.cpp \
|
||||
$$PWD/tagpopup.cpp \
|
||||
$$PWD/tagviewer.cpp \
|
||||
$$PWD/terminalviewer.cpp \
|
||||
$$PWD/textviewwindow.cpp \
|
||||
$$PWD/toolbarhelper.cpp \
|
||||
$$PWD/treeview.cpp \
|
||||
@ -130,6 +130,7 @@ HEADERS += \
|
||||
$$PWD/attachmentpopup.h \
|
||||
$$PWD/biaction.h \
|
||||
$$PWD/combobox.h \
|
||||
$$PWD/consoleviewer.h \
|
||||
$$PWD/dialogs/dialog.h \
|
||||
$$PWD/dialogs/exportdialog.h \
|
||||
$$PWD/dialogs/importfolderutils.h \
|
||||
@ -219,7 +220,6 @@ HEADERS += \
|
||||
$$PWD/tagexplorer.h \
|
||||
$$PWD/tagpopup.h \
|
||||
$$PWD/tagviewer.h \
|
||||
$$PWD/terminalviewer.h \
|
||||
$$PWD/textviewwindow.h \
|
||||
$$PWD/textviewwindowhelper.h \
|
||||
$$PWD/toolbarhelper.h \
|
||||
|
Loading…
x
Reference in New Issue
Block a user