src: split indexing dialog to multiple classes
This commit is contained in:
@@ -295,22 +295,36 @@ add_files(
|
|||||||
qt/window/QtEulaWindow.h
|
qt/window/QtEulaWindow.h
|
||||||
qt/window/QtIndexingDialog.cpp
|
qt/window/QtIndexingDialog.cpp
|
||||||
qt/window/QtIndexingDialog.h
|
qt/window/QtIndexingDialog.h
|
||||||
|
qt/window/QtIndexingProgressDialog.cpp
|
||||||
|
qt/window/QtIndexingProgressDialog.h
|
||||||
|
qt/window/QtIndexingReportDialog.cpp
|
||||||
|
qt/window/QtIndexingReportDialog.h
|
||||||
|
qt/window/QtIndexingStartDialog.cpp
|
||||||
|
qt/window/QtIndexingStartDialog.h
|
||||||
qt/window/QtKeyboardShortcuts.cpp
|
qt/window/QtKeyboardShortcuts.cpp
|
||||||
qt/window/QtKeyboardShortcuts.h
|
qt/window/QtKeyboardShortcuts.h
|
||||||
|
qt/window/QtKnownProgressDialog.cpp
|
||||||
|
qt/window/QtKnownProgressDialog.h
|
||||||
qt/window/QtMainWindow.cpp
|
qt/window/QtMainWindow.cpp
|
||||||
qt/window/QtMainWindow.h
|
qt/window/QtMainWindow.h
|
||||||
qt/window/QtPathListDialog.cpp
|
qt/window/QtPathListDialog.cpp
|
||||||
qt/window/QtPathListDialog.h
|
qt/window/QtPathListDialog.h
|
||||||
qt/window/QtPreferencesWindow.cpp
|
qt/window/QtPreferencesWindow.cpp
|
||||||
qt/window/QtPreferencesWindow.h
|
qt/window/QtPreferencesWindow.h
|
||||||
|
qt/window/QtProgressBarDialog.cpp
|
||||||
|
qt/window/QtProgressBarDialog.h
|
||||||
qt/window/QtSelectPathsDialog.cpp
|
qt/window/QtSelectPathsDialog.cpp
|
||||||
qt/window/QtSelectPathsDialog.h
|
qt/window/QtSelectPathsDialog.h
|
||||||
qt/window/QtStartScreen.cpp
|
qt/window/QtStartScreen.cpp
|
||||||
qt/window/QtStartScreen.h
|
qt/window/QtStartScreen.h
|
||||||
qt/window/QtTextEditDialog.cpp
|
qt/window/QtTextEditDialog.cpp
|
||||||
qt/window/QtTextEditDialog.h
|
qt/window/QtTextEditDialog.h
|
||||||
|
qt/window/QtUnknownProgressDialog.cpp
|
||||||
|
qt/window/QtUnknownProgressDialog.h
|
||||||
qt/window/QtWindow.cpp
|
qt/window/QtWindow.cpp
|
||||||
qt/window/QtWindow.h
|
qt/window/QtWindow.h
|
||||||
|
qt/window/QtWindowBase.cpp
|
||||||
|
qt/window/QtWindowBase.h
|
||||||
qt/window/QtWindowStack.cpp
|
qt/window/QtWindowStack.cpp
|
||||||
qt/window/QtWindowStack.h
|
qt/window/QtWindowStack.h
|
||||||
|
|
||||||
|
|||||||
@@ -31,11 +31,11 @@ public slots:
|
|||||||
void commentToggled();
|
void commentToggled();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
|
virtual void resizeEvent(QResizeEvent* event) override;
|
||||||
virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
|
virtual void showEvent(QShowEvent* event) override;
|
||||||
|
|
||||||
virtual void enterEvent(QEvent *event) Q_DECL_OVERRIDE;
|
virtual void enterEvent(QEvent *event) override;
|
||||||
virtual void leaveEvent(QEvent *event) Q_DECL_OVERRIDE;
|
virtual void leaveEvent(QEvent *event) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void activateClicked();
|
void activateClicked();
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ public:
|
|||||||
QtLineNumberArea(QtCodeArea* codeArea);
|
QtLineNumberArea(QtCodeArea* codeArea);
|
||||||
virtual ~QtLineNumberArea();
|
virtual ~QtLineNumberArea();
|
||||||
|
|
||||||
QSize sizeHint() const Q_DECL_OVERRIDE;
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE;
|
virtual void paintEvent(QPaintEvent* event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QtCodeArea* m_codeArea;
|
QtCodeArea* m_codeArea;
|
||||||
@@ -62,7 +62,7 @@ public:
|
|||||||
);
|
);
|
||||||
virtual ~QtCodeArea();
|
virtual ~QtCodeArea();
|
||||||
|
|
||||||
virtual QSize sizeHint() const Q_DECL_OVERRIDE;
|
virtual QSize sizeHint() const override;
|
||||||
|
|
||||||
void lineNumberAreaPaintEvent(QPaintEvent* event);
|
void lineNumberAreaPaintEvent(QPaintEvent* event);
|
||||||
int lineNumberDigits() const;
|
int lineNumberDigits() const;
|
||||||
@@ -93,13 +93,13 @@ public:
|
|||||||
void ensureLocationIdVisible(Id locationId, int parentWidth, bool animated);
|
void ensureLocationIdVisible(Id locationId, int parentWidth, bool animated);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
|
virtual void resizeEvent(QResizeEvent* event) override;
|
||||||
virtual void mouseReleaseEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
|
virtual void mouseReleaseEvent(QMouseEvent* event) override;
|
||||||
virtual void mousePressEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
|
virtual void mousePressEvent(QMouseEvent* event) override;
|
||||||
virtual void mouseMoveEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
|
virtual void mouseMoveEvent(QMouseEvent* event) override;
|
||||||
virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
|
virtual void wheelEvent(QWheelEvent *event) override;
|
||||||
|
|
||||||
virtual void contextMenuEvent(QContextMenuEvent* event) Q_DECL_OVERRIDE;
|
virtual void contextMenuEvent(QContextMenuEvent* event) override;
|
||||||
|
|
||||||
virtual void focusTokenIds(const std::vector<Id>& tokenIds) override;
|
virtual void focusTokenIds(const std::vector<Id>& tokenIds) override;
|
||||||
virtual void defocusTokenIds(const std::vector<Id>& tokenIds) override;
|
virtual void defocusTokenIds(const std::vector<Id>& tokenIds) override;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public:
|
|||||||
|
|
||||||
~QtCodeField();
|
~QtCodeField();
|
||||||
|
|
||||||
virtual QSize sizeHint() const Q_DECL_OVERRIDE;
|
virtual QSize sizeHint() const override;
|
||||||
|
|
||||||
size_t getStartLineNumber() const;
|
size_t getStartLineNumber() const;
|
||||||
size_t getEndLineNumber() const;
|
size_t getEndLineNumber() const;
|
||||||
@@ -44,14 +44,14 @@ public:
|
|||||||
void annotateText();
|
void annotateText();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE;
|
virtual void paintEvent(QPaintEvent* event) override;
|
||||||
virtual void enterEvent(QEvent* event) Q_DECL_OVERRIDE;
|
virtual void enterEvent(QEvent* event) override;
|
||||||
virtual void leaveEvent(QEvent* event) Q_DECL_OVERRIDE;
|
virtual void leaveEvent(QEvent* event) override;
|
||||||
|
|
||||||
virtual void mouseMoveEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
|
virtual void mouseMoveEvent(QMouseEvent* event) override;
|
||||||
virtual void mouseReleaseEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
|
virtual void mouseReleaseEvent(QMouseEvent* event) override;
|
||||||
|
|
||||||
virtual void contextMenuEvent(QContextMenuEvent* event) Q_DECL_OVERRIDE;
|
virtual void contextMenuEvent(QContextMenuEvent* event) override;
|
||||||
|
|
||||||
virtual void focusTokenIds(const std::vector<Id>& tokenIds);
|
virtual void focusTokenIds(const std::vector<Id>& tokenIds);
|
||||||
virtual void defocusTokenIds(const std::vector<Id>& tokenIds);
|
virtual void defocusTokenIds(const std::vector<Id>& tokenIds);
|
||||||
|
|||||||
@@ -9,6 +9,11 @@
|
|||||||
|
|
||||||
#include "StorageAccess.h"
|
#include "StorageAccess.h"
|
||||||
#include "QtIndexingDialog.h"
|
#include "QtIndexingDialog.h"
|
||||||
|
#include "QtIndexingProgressDialog.h"
|
||||||
|
#include "QtIndexingReportDialog.h"
|
||||||
|
#include "QtIndexingStartDialog.h"
|
||||||
|
#include "QtKnownProgressDialog.h"
|
||||||
|
#include "QtUnknownProgressDialog.h"
|
||||||
#include "QtMainWindow.h"
|
#include "QtMainWindow.h"
|
||||||
#include "QtWindow.h"
|
#include "QtWindow.h"
|
||||||
#include "MessageIndexingStatus.h"
|
#include "MessageIndexingStatus.h"
|
||||||
@@ -83,13 +88,11 @@ void QtDialogView::showProgressDialog(const std::wstring& title, const std::wstr
|
|||||||
[=]()
|
[=]()
|
||||||
{
|
{
|
||||||
bool sendStatusMessage = true;
|
bool sendStatusMessage = true;
|
||||||
QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
|
QtKnownProgressDialog* window = dynamic_cast<QtKnownProgressDialog*>(m_windowStack.getTopWindow());
|
||||||
if (!window || window->getType() != QtIndexingDialog::DIALOG_PROGRESS)
|
if (!window)
|
||||||
{
|
{
|
||||||
m_windowStack.clearWindows();
|
m_windowStack.clearWindows();
|
||||||
|
window = createWindow<QtKnownProgressDialog>(m_dialogsHideable);
|
||||||
window = createWindow();
|
|
||||||
window->setupProgress(m_dialogsHideable);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -119,8 +122,8 @@ void QtDialogView::hideProgressDialog()
|
|||||||
m_onQtThread(
|
m_onQtThread(
|
||||||
[=]()
|
[=]()
|
||||||
{
|
{
|
||||||
QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
|
QtKnownProgressDialog* window = dynamic_cast<QtKnownProgressDialog*>(m_windowStack.getTopWindow());
|
||||||
if (window && window->getType() == QtIndexingDialog::DIALOG_PROGRESS)
|
if (window)
|
||||||
{
|
{
|
||||||
m_windowStack.popWindow();
|
m_windowStack.popWindow();
|
||||||
}
|
}
|
||||||
@@ -146,9 +149,9 @@ void QtDialogView::startIndexingDialog(
|
|||||||
m_dialogsVisible = true;
|
m_dialogsVisible = true;
|
||||||
m_windowStack.clearWindows();
|
m_windowStack.clearWindows();
|
||||||
|
|
||||||
QtIndexingDialog* window = createWindow();
|
QtIndexingStartDialog* window = createWindow<QtIndexingStartDialog>(enabledModes, initialMode);
|
||||||
|
|
||||||
connect(window, &QtIndexingDialog::setMode,
|
std::function<void(RefreshMode)> onRefreshModeChanged = (
|
||||||
[=](RefreshMode refreshMode)
|
[=](RefreshMode refreshMode)
|
||||||
{
|
{
|
||||||
auto it = m_refreshInfos.find(refreshMode);
|
auto it = m_refreshInfos.find(refreshMode);
|
||||||
@@ -191,7 +194,9 @@ void QtDialogView::startIndexingDialog(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
connect(window, &QtIndexingDialog::startIndexing,
|
connect(window, &QtIndexingStartDialog::setMode, onRefreshModeChanged);
|
||||||
|
|
||||||
|
connect(window, &QtIndexingStartDialog::startIndexing,
|
||||||
[=](RefreshMode refreshMode)
|
[=](RefreshMode refreshMode)
|
||||||
{
|
{
|
||||||
RefreshInfo info = m_refreshInfos.find(refreshMode)->second;
|
RefreshInfo info = m_refreshInfos.find(refreshMode)->second;
|
||||||
@@ -206,7 +211,7 @@ void QtDialogView::startIndexingDialog(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
connect(window, &QtWindow::canceled,
|
connect(window, &QtIndexingDialog::canceled,
|
||||||
[=]()
|
[=]()
|
||||||
{
|
{
|
||||||
Task::dispatch(TabId::app(), std::make_shared<TaskLambda>(
|
Task::dispatch(TabId::app(), std::make_shared<TaskLambda>(
|
||||||
@@ -220,7 +225,8 @@ void QtDialogView::startIndexingDialog(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
window->setupStart(enabledModes, initialMode);
|
onRefreshModeChanged(initialMode);
|
||||||
|
|
||||||
window->hide();
|
window->hide();
|
||||||
setUIBlocked(true);
|
setUIBlocked(true);
|
||||||
}
|
}
|
||||||
@@ -245,20 +251,17 @@ void QtDialogView::updateIndexingDialog(
|
|||||||
MessageStatus(stati, false, false, m_dialogsVisible).dispatch();
|
MessageStatus(stati, false, false, m_dialogsVisible).dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
|
QtIndexingProgressDialog* window = dynamic_cast<QtIndexingProgressDialog*>(m_windowStack.getTopWindow());
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
m_windowStack.clearWindows();
|
m_windowStack.clearWindows();
|
||||||
|
|
||||||
window = createWindow();
|
window = createWindow<QtIndexingProgressDialog>(m_dialogsHideable);
|
||||||
window->setupIndexing(m_dialogsHideable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window && window->getType() == QtIndexingDialog::DIALOG_INDEXING)
|
window->updateIndexingProgress(
|
||||||
{
|
finishedFileCount, totalFileCount, sourcePaths.empty() ? FilePath() : sourcePaths.back());
|
||||||
window->updateIndexingProgress(
|
|
||||||
finishedFileCount, totalFileCount, sourcePaths.empty() ? FilePath() : sourcePaths.back());
|
|
||||||
}
|
|
||||||
m_mainWindow->setWindowsTaskbarProgress(float(finishedFileCount) / totalFileCount);
|
m_mainWindow->setWindowsTaskbarProgress(float(finishedFileCount) / totalFileCount);
|
||||||
|
|
||||||
setUIBlocked(m_dialogsVisible);
|
setUIBlocked(m_dialogsVisible);
|
||||||
@@ -274,8 +277,8 @@ void QtDialogView::updateCustomIndexingDialog(
|
|||||||
m_onQtThread(
|
m_onQtThread(
|
||||||
[=]()
|
[=]()
|
||||||
{
|
{
|
||||||
QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
|
QtIndexingProgressDialog* window = dynamic_cast<QtIndexingProgressDialog*>(m_windowStack.getTopWindow());
|
||||||
if (window && window->getType() == QtIndexingDialog::DIALOG_INDEXING)
|
if (window)
|
||||||
{
|
{
|
||||||
window->updateTitle("Executing Commands");
|
window->updateTitle("Executing Commands");
|
||||||
}
|
}
|
||||||
@@ -296,10 +299,9 @@ DatabasePolicy QtDialogView::finishedIndexingDialog(
|
|||||||
m_dialogsVisible = true;
|
m_dialogsVisible = true;
|
||||||
m_windowStack.clearWindows();
|
m_windowStack.clearWindows();
|
||||||
|
|
||||||
QtIndexingDialog* window = createWindow();
|
QtIndexingReportDialog* window = createWindow<QtIndexingReportDialog>(indexedFileCount, totalIndexedFileCount, completedFileCount, totalFileCount, time, interrupted);
|
||||||
window->setupReport(indexedFileCount, totalIndexedFileCount, completedFileCount, totalFileCount, time, interrupted);
|
|
||||||
window->updateErrorCount(errorInfo.total, errorInfo.fatal);
|
window->updateErrorCount(errorInfo.total, errorInfo.fatal);
|
||||||
connect(window, &QtWindow::finished,
|
connect(window, &QtIndexingDialog::finished,
|
||||||
[this, &policy]()
|
[this, &policy]()
|
||||||
{
|
{
|
||||||
setUIBlocked(false);
|
setUIBlocked(false);
|
||||||
@@ -307,7 +309,7 @@ DatabasePolicy QtDialogView::finishedIndexingDialog(
|
|||||||
m_resultReady = true;
|
m_resultReady = true;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
connect(window, &QtWindow::canceled,
|
connect(window, &QtIndexingDialog::canceled,
|
||||||
[this, &policy]()
|
[this, &policy]()
|
||||||
{
|
{
|
||||||
setUIBlocked(false);
|
setUIBlocked(false);
|
||||||
@@ -380,13 +382,13 @@ void QtDialogView::setParentWindow(QtWindow* window)
|
|||||||
|
|
||||||
void QtDialogView::showUnknownProgress(const std::wstring& title, const std::wstring& message, bool stacked)
|
void QtDialogView::showUnknownProgress(const std::wstring& title, const std::wstring& message, bool stacked)
|
||||||
{
|
{
|
||||||
QtIndexingDialog* window = nullptr;
|
QtUnknownProgressDialog* window = nullptr;
|
||||||
|
|
||||||
if (!stacked)
|
if (!stacked)
|
||||||
{
|
{
|
||||||
window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
|
window = dynamic_cast<QtUnknownProgressDialog*>(m_windowStack.getTopWindow());
|
||||||
|
|
||||||
if (window && window->getType() != QtIndexingDialog::DIALOG_UNKNOWN_PROGRESS)
|
if (!window)
|
||||||
{
|
{
|
||||||
m_windowStack.clearWindows();
|
m_windowStack.clearWindows();
|
||||||
window = nullptr;
|
window = nullptr;
|
||||||
@@ -395,8 +397,7 @@ void QtDialogView::showUnknownProgress(const std::wstring& title, const std::wst
|
|||||||
|
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
window = createWindow();
|
window = createWindow<QtUnknownProgressDialog>(m_dialogsHideable);
|
||||||
window->setupUnknownProgress(m_dialogsHideable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window->updateTitle(QString::fromStdWString(title));
|
window->updateTitle(QString::fromStdWString(title));
|
||||||
@@ -407,8 +408,8 @@ void QtDialogView::showUnknownProgress(const std::wstring& title, const std::wst
|
|||||||
|
|
||||||
void QtDialogView::hideUnknownProgress()
|
void QtDialogView::hideUnknownProgress()
|
||||||
{
|
{
|
||||||
QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
|
QtUnknownProgressDialog* window = dynamic_cast<QtUnknownProgressDialog*>(m_windowStack.getTopWindow());
|
||||||
if (window && window->getType() == QtIndexingDialog::DIALOG_UNKNOWN_PROGRESS)
|
if (window)
|
||||||
{
|
{
|
||||||
m_windowStack.popWindow();
|
m_windowStack.popWindow();
|
||||||
}
|
}
|
||||||
@@ -494,40 +495,12 @@ void QtDialogView::handleMessage(MessageWindowClosed* message)
|
|||||||
|
|
||||||
void QtDialogView::updateErrorCount(size_t errorCount, size_t fatalCount)
|
void QtDialogView::updateErrorCount(size_t errorCount, size_t fatalCount)
|
||||||
{
|
{
|
||||||
if (QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow()))
|
if (QtIndexingProgressDialog* progressWindow = dynamic_cast<QtIndexingProgressDialog*>(m_windowStack.getTopWindow()))
|
||||||
{
|
{
|
||||||
window->updateErrorCount(errorCount, fatalCount);
|
progressWindow->updateErrorCount(errorCount, fatalCount);
|
||||||
|
}
|
||||||
|
else if (QtIndexingReportDialog* reportWindow = dynamic_cast<QtIndexingReportDialog*>(m_windowStack.getTopWindow()))
|
||||||
|
{
|
||||||
|
reportWindow->updateErrorCount(errorCount, fatalCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QtIndexingDialog* QtDialogView::createWindow()
|
|
||||||
{
|
|
||||||
QtIndexingDialog* window = nullptr;
|
|
||||||
if (m_parentWindow)
|
|
||||||
{
|
|
||||||
window = new QtIndexingDialog(m_parentWindow);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
window = new QtIndexingDialog(m_mainWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(window, &QtWindow::canceled, &m_windowStack, &QtWindowStack::popWindow);
|
|
||||||
connect(window, &QtWindow::finished, &m_windowStack, &QtWindowStack::clearWindows);
|
|
||||||
|
|
||||||
connect(window, &QtIndexingDialog::visibleChanged, this, &QtDialogView::dialogVisibilityChanged);
|
|
||||||
|
|
||||||
if (m_mainWindow)
|
|
||||||
{
|
|
||||||
connect(m_mainWindow, &QtMainWindow::hideIndexingDialog, window, &QtWindow::handleClosePress);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_windowStack.pushWindow(window);
|
|
||||||
|
|
||||||
if (!m_dialogsVisible)
|
|
||||||
{
|
|
||||||
window->hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
return window;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
#include "MessageIndexingShowDialog.h"
|
#include "MessageIndexingShowDialog.h"
|
||||||
#include "MessageWindowClosed.h"
|
#include "MessageWindowClosed.h"
|
||||||
|
|
||||||
class QtIndexingDialog;
|
|
||||||
class QtMainWindow;
|
class QtMainWindow;
|
||||||
class QtWindow;
|
class QtWindow;
|
||||||
|
|
||||||
@@ -66,7 +65,40 @@ private:
|
|||||||
|
|
||||||
void updateErrorCount(size_t errorCount, size_t fatalCount);
|
void updateErrorCount(size_t errorCount, size_t fatalCount);
|
||||||
|
|
||||||
QtIndexingDialog* createWindow();
|
template <typename DialogType, typename... ParamTypes>
|
||||||
|
DialogType* createWindow(ParamTypes... params)
|
||||||
|
{
|
||||||
|
DialogType* window = nullptr;
|
||||||
|
if (m_parentWindow)
|
||||||
|
{
|
||||||
|
window = new DialogType(params..., m_parentWindow);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
window = new DialogType(params..., m_mainWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(window, &QtIndexingDialog::canceled, &m_windowStack, &QtWindowStack::popWindow);
|
||||||
|
connect(window, &QtIndexingDialog::finished, &m_windowStack, &QtWindowStack::clearWindows);
|
||||||
|
connect(window, &QtIndexingDialog::visibleChanged, this, &QtDialogView::dialogVisibilityChanged);
|
||||||
|
|
||||||
|
if (m_mainWindow)
|
||||||
|
{
|
||||||
|
connect(
|
||||||
|
m_mainWindow, &QtMainWindow::hideIndexingDialog,
|
||||||
|
std::bind(&QtDialogView::dialogVisibilityChanged, this, true)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_windowStack.pushWindow(window);
|
||||||
|
|
||||||
|
if (!m_dialogsVisible)
|
||||||
|
{
|
||||||
|
window->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
|
||||||
QtMainWindow* m_mainWindow;
|
QtMainWindow* m_mainWindow;
|
||||||
QtWindow* m_parentWindow;
|
QtWindow* m_parentWindow;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public:
|
|||||||
void setBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks);
|
void setBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
|
virtual void resizeEvent(QResizeEvent* event) override;
|
||||||
|
|
||||||
virtual void handleClose() override;
|
virtual void handleClose() override;
|
||||||
virtual void handleNext() override;
|
virtual void handleNext() override;
|
||||||
|
|||||||
@@ -1,507 +1,26 @@
|
|||||||
#include "QtIndexingDialog.h"
|
#include "QtIndexingDialog.h"
|
||||||
|
|
||||||
#include <QCheckBox>
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QRadioButton>
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
#include "MessageErrorsHelpMessage.h"
|
#include "MessageErrorsHelpMessage.h"
|
||||||
#include "MessageIndexingInterrupted.h"
|
#include "QtDeviceScaledPixmap.h"
|
||||||
#include "QtHelpButton.h"
|
#include "QtHelpButton.h"
|
||||||
#include "QtProgressBar.h"
|
|
||||||
#include "ResourcePaths.h"
|
#include "ResourcePaths.h"
|
||||||
#include "TimeStamp.h"
|
|
||||||
#include "utilityQt.h"
|
#include "utilityQt.h"
|
||||||
|
|
||||||
QtIndexingDialog::QtIndexingDialog(QWidget* parent)
|
QLabel* QtIndexingDialog::createTitleLabel(QString title, QBoxLayout* layout)
|
||||||
: QtWindow(true, parent)
|
|
||||||
, m_type(DIALOG_MESSAGE)
|
|
||||||
, m_top(nullptr)
|
|
||||||
, m_topRatio(0)
|
|
||||||
, m_progressBar(nullptr)
|
|
||||||
, m_percentLabel(nullptr)
|
|
||||||
, m_messageLabel(nullptr)
|
|
||||||
, m_filePathLabel(nullptr)
|
|
||||||
, m_errorWidget(nullptr)
|
|
||||||
, m_sizeHint(QSize(450, 450))
|
|
||||||
{
|
{
|
||||||
setSizeGripStyle(false);
|
QLabel* label = new QLabel(title);
|
||||||
}
|
label->setObjectName("title");
|
||||||
|
label->setAlignment(Qt::AlignRight | Qt::AlignBottom);
|
||||||
|
|
||||||
QSize QtIndexingDialog::sizeHint() const
|
if (layout)
|
||||||
{
|
|
||||||
return m_sizeHint;
|
|
||||||
}
|
|
||||||
|
|
||||||
QtIndexingDialog::DialogType QtIndexingDialog::getType() const
|
|
||||||
{
|
|
||||||
return m_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::setupStart(const std::vector<RefreshMode>& enabledModes, const RefreshMode initialMode)
|
|
||||||
{
|
|
||||||
setType(DIALOG_START_INDEXING);
|
|
||||||
|
|
||||||
QBoxLayout* layout = createLayout();
|
|
||||||
|
|
||||||
addTitle("Start Indexing", layout);
|
|
||||||
layout->addSpacing(5);
|
|
||||||
|
|
||||||
m_clearLabel = createMessageLabel(layout);
|
|
||||||
m_indexLabel = createMessageLabel(layout);
|
|
||||||
|
|
||||||
m_clearLabel->setVisible(false);
|
|
||||||
m_indexLabel->setVisible(false);
|
|
||||||
|
|
||||||
layout->addStretch();
|
|
||||||
|
|
||||||
QHBoxLayout* subLayout = new QHBoxLayout();
|
|
||||||
subLayout->addStretch();
|
|
||||||
|
|
||||||
QVBoxLayout* modeLayout = new QVBoxLayout();
|
|
||||||
modeLayout->setSpacing(7);
|
|
||||||
|
|
||||||
QHBoxLayout* modeTitleLayout = new QHBoxLayout();
|
|
||||||
modeTitleLayout->setSpacing(7);
|
|
||||||
|
|
||||||
QLabel* modeLabel = createMessageLabel(modeTitleLayout);
|
|
||||||
modeLabel->setText("Mode:");
|
|
||||||
modeLabel->setAlignment(Qt::AlignLeft);
|
|
||||||
|
|
||||||
QtHelpButton* helpButton = new QtHelpButton(
|
|
||||||
"Indexing Modes",
|
|
||||||
"<b>Updated files:</b> Reindexes all files that were modified since the last indexing, all files depending "
|
|
||||||
"on those and new files.<br /><br />"
|
|
||||||
"<b>Incomplete & updated files:</b> Reindexes all files that had errors during last indexing, all files "
|
|
||||||
"depending on those and all updated files.<br /><br />"
|
|
||||||
"<b>All files:</b> Deletes the previous index and reindexes all files.<br /><br />"
|
|
||||||
);
|
|
||||||
helpButton->setColor(Qt::white);
|
|
||||||
modeTitleLayout->addWidget(helpButton);
|
|
||||||
|
|
||||||
modeTitleLayout->addStretch();
|
|
||||||
|
|
||||||
modeLayout->addLayout(modeTitleLayout);
|
|
||||||
modeLayout->addSpacing(5);
|
|
||||||
|
|
||||||
m_refreshModeButtons.emplace(REFRESH_UPDATED_FILES, new QRadioButton("Updated files"));
|
|
||||||
m_refreshModeButtons.emplace(REFRESH_UPDATED_AND_INCOMPLETE_FILES, new QRadioButton("Incomplete && updated files"));
|
|
||||||
m_refreshModeButtons.emplace(REFRESH_ALL_FILES, new QRadioButton("All files"));
|
|
||||||
|
|
||||||
std::function<void(bool)> func =
|
|
||||||
[=](bool checked)
|
|
||||||
{
|
|
||||||
if (!checked)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto p : m_refreshModeButtons)
|
|
||||||
{
|
|
||||||
if (p.second->isChecked())
|
|
||||||
{
|
|
||||||
emit setMode(p.first);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for (auto p : m_refreshModeButtons)
|
|
||||||
{
|
{
|
||||||
QRadioButton* button = p.second;
|
layout->addWidget(label, 0, Qt::AlignRight);
|
||||||
button->setObjectName("option");
|
|
||||||
button->setEnabled(false);
|
|
||||||
if (p.first == initialMode)
|
|
||||||
{
|
|
||||||
button->setChecked(true);
|
|
||||||
}
|
|
||||||
modeLayout->addWidget(button);
|
|
||||||
connect(button, &QRadioButton::toggled, func);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (RefreshMode mode : enabledModes)
|
return label;
|
||||||
{
|
|
||||||
m_refreshModeButtons[mode]->setEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
subLayout->addLayout(modeLayout);
|
|
||||||
layout->addLayout(subLayout);
|
|
||||||
|
|
||||||
layout->addSpacing(20);
|
|
||||||
|
|
||||||
addButtons(layout);
|
|
||||||
updateNextButton("Start");
|
|
||||||
updateCloseButton("Cancel");
|
|
||||||
|
|
||||||
m_sizeHint = QSize(350, 310);
|
|
||||||
|
|
||||||
finishSetup();
|
|
||||||
|
|
||||||
emit setMode(initialMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::updateRefreshInfo(const RefreshInfo& info)
|
|
||||||
{
|
|
||||||
QRadioButton* button = m_refreshModeButtons.find(info.mode)->second;
|
|
||||||
if (!button->isChecked())
|
|
||||||
{
|
|
||||||
button->setChecked(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t clearCount = info.filesToClear.size();
|
|
||||||
size_t indexCount = info.filesToIndex.size();
|
|
||||||
|
|
||||||
m_clearLabel->setText("Files to clear: " + QString::number(clearCount));
|
|
||||||
m_indexLabel->setText("Source files to index: " + QString::number(indexCount));
|
|
||||||
|
|
||||||
m_clearLabel->setVisible(clearCount && info.mode != REFRESH_ALL_FILES);
|
|
||||||
m_indexLabel->setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::setupIndexing(bool hideable)
|
|
||||||
{
|
|
||||||
setType(DIALOG_INDEXING);
|
|
||||||
|
|
||||||
QBoxLayout* layout = createLayout();
|
|
||||||
|
|
||||||
addTopAndProgressBar(0.38);
|
|
||||||
addTitle("Indexing Files", layout);
|
|
||||||
|
|
||||||
addPercentLabel(layout);
|
|
||||||
addMessageLabel(layout);
|
|
||||||
addFilePathLabel(layout);
|
|
||||||
|
|
||||||
layout->addSpacing(12);
|
|
||||||
addErrorWidget(layout);
|
|
||||||
|
|
||||||
layout->addStretch();
|
|
||||||
|
|
||||||
addButtons(layout);
|
|
||||||
updateNextButton("Hide");
|
|
||||||
setNextVisible(hideable);
|
|
||||||
updateCloseButton("Stop");
|
|
||||||
|
|
||||||
m_sizeHint = QSize(350, 350);
|
|
||||||
|
|
||||||
finishSetup();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::setupReport(
|
|
||||||
size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount,
|
|
||||||
float time, bool interrupted)
|
|
||||||
{
|
|
||||||
setType(DIALOG_REPORT);
|
|
||||||
|
|
||||||
QBoxLayout* layout = createLayout();
|
|
||||||
|
|
||||||
addTitle("Finished Indexing", layout);
|
|
||||||
layout->addSpacing(5);
|
|
||||||
|
|
||||||
createMessageLabel(layout)->setText(
|
|
||||||
"Source files indexed: " + QString::number(indexedFileCount) + "/" + QString::number(totalIndexedFileCount)
|
|
||||||
);
|
|
||||||
|
|
||||||
createMessageLabel(layout)->setText(
|
|
||||||
"Total files completed: " + QString::number(completedFileCount) + "/" + QString::number(totalFileCount)
|
|
||||||
);
|
|
||||||
|
|
||||||
layout->addSpacing(12);
|
|
||||||
createMessageLabel(layout)->setText("Time: " + QString::fromStdString(TimeStamp::secondsToString(time)));
|
|
||||||
|
|
||||||
layout->addSpacing(12);
|
|
||||||
addErrorWidget(layout);
|
|
||||||
|
|
||||||
layout->addStretch();
|
|
||||||
|
|
||||||
addButtons(layout);
|
|
||||||
if (interrupted)
|
|
||||||
{
|
|
||||||
updateNextButton("Keep");
|
|
||||||
updateCloseButton("Discard");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
updateNextButton("OK");
|
|
||||||
setCloseVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_sizeHint = QSize(interrupted ? 400 : 430, 280);
|
|
||||||
|
|
||||||
if (interrupted)
|
|
||||||
{
|
|
||||||
updateTitle("Interrupted Indexing");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
addFlag();
|
|
||||||
}
|
|
||||||
|
|
||||||
finishSetup();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::setupUnknownProgress(bool hideable)
|
|
||||||
{
|
|
||||||
setType(DIALOG_UNKNOWN_PROGRESS);
|
|
||||||
|
|
||||||
QBoxLayout* layout = createLayout();
|
|
||||||
|
|
||||||
addTopAndProgressBar(0.5);
|
|
||||||
addTitle("Status", layout);
|
|
||||||
addMessageLabel(layout);
|
|
||||||
|
|
||||||
layout->addStretch();
|
|
||||||
|
|
||||||
if (hideable)
|
|
||||||
{
|
|
||||||
addButtons(layout);
|
|
||||||
updateNextButton("Hide");
|
|
||||||
setCloseVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_sizeHint = QSize(350, 280);
|
|
||||||
|
|
||||||
m_progressBar->showUnknownProgressAnimated();
|
|
||||||
|
|
||||||
setCancelAble(false);
|
|
||||||
|
|
||||||
finishSetup();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::setupProgress(bool hideable)
|
|
||||||
{
|
|
||||||
setType(DIALOG_PROGRESS);
|
|
||||||
|
|
||||||
QBoxLayout* layout = createLayout();
|
|
||||||
|
|
||||||
addTopAndProgressBar(0.5);
|
|
||||||
addTitle("Progress", layout);
|
|
||||||
addPercentLabel(layout);
|
|
||||||
addMessageLabel(layout);
|
|
||||||
|
|
||||||
layout->addStretch();
|
|
||||||
|
|
||||||
if (hideable)
|
|
||||||
{
|
|
||||||
addButtons(layout);
|
|
||||||
updateNextButton("Hide");
|
|
||||||
setCloseVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_sizeHint = QSize(350, 280);
|
|
||||||
|
|
||||||
setCancelAble(false);
|
|
||||||
|
|
||||||
finishSetup();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::updateTitle(const QString& title)
|
|
||||||
{
|
|
||||||
if (m_title)
|
|
||||||
{
|
|
||||||
m_title->setText(title);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::updateMessage(const QString& message)
|
|
||||||
{
|
|
||||||
if (m_messageLabel)
|
|
||||||
{
|
|
||||||
m_messageLabel->setText(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring QtIndexingDialog::getMessage() const
|
|
||||||
{
|
|
||||||
if (m_messageLabel)
|
|
||||||
{
|
|
||||||
return m_messageLabel->text().toStdWString();
|
|
||||||
}
|
|
||||||
return L"";
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::updateProgress(size_t progress)
|
|
||||||
{
|
|
||||||
size_t percent = std::min<size_t>(std::max<size_t>(progress, 0), 100);
|
|
||||||
|
|
||||||
m_progressBar->showProgress(percent);
|
|
||||||
m_percentLabel->setText(QString::number(percent) + "% Progress");
|
|
||||||
setGeometries();
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t QtIndexingDialog::getProgress() const
|
|
||||||
{
|
|
||||||
return m_progressBar->getProgress();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::updateIndexingProgress(size_t fileCount, size_t totalFileCount, const FilePath& sourcePath)
|
|
||||||
{
|
|
||||||
updateMessage(QString::number(fileCount) + "/" + QString::number(totalFileCount) + " File" + (totalFileCount > 1 ? "s" : ""));
|
|
||||||
|
|
||||||
int progress = 0;
|
|
||||||
if (totalFileCount > 0)
|
|
||||||
{
|
|
||||||
progress = fileCount * 100 / totalFileCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sourcePath.empty())
|
|
||||||
{
|
|
||||||
m_sourcePath = QString::fromStdWString(sourcePath.wstr());
|
|
||||||
}
|
|
||||||
|
|
||||||
updateProgress(progress);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::updateErrorCount(size_t errorCount, size_t fatalCount)
|
|
||||||
{
|
|
||||||
if (m_errorWidget && errorCount)
|
|
||||||
{
|
|
||||||
QString str = QString::number(errorCount) + " Error";
|
|
||||||
if (errorCount > 1)
|
|
||||||
{
|
|
||||||
str += "s";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fatalCount)
|
|
||||||
{
|
|
||||||
str += " (" + QString::number(fatalCount) + " Fatal)";
|
|
||||||
}
|
|
||||||
|
|
||||||
QPushButton* errorCount = m_errorWidget->findChild<QPushButton*>("errorCount");
|
|
||||||
errorCount->setText(str);
|
|
||||||
|
|
||||||
m_errorWidget->show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::resizeEvent(QResizeEvent* event)
|
|
||||||
{
|
|
||||||
QtWindow::resizeEvent(event);
|
|
||||||
|
|
||||||
setGeometries();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::handleNext()
|
|
||||||
{
|
|
||||||
if (m_type == DIALOG_START_INDEXING)
|
|
||||||
{
|
|
||||||
for (auto p : m_refreshModeButtons)
|
|
||||||
{
|
|
||||||
if (p.second->isChecked())
|
|
||||||
{
|
|
||||||
emit startIndexing(p.first);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_type == DIALOG_INDEXING || m_type == DIALOG_PROGRESS || m_type == DIALOG_UNKNOWN_PROGRESS)
|
|
||||||
{
|
|
||||||
emit visibleChanged(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_type == DIALOG_REPORT)
|
|
||||||
{
|
|
||||||
MessageErrorsHelpMessage().dispatch();
|
|
||||||
}
|
|
||||||
|
|
||||||
QtWindow::handleNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::handleClose()
|
|
||||||
{
|
|
||||||
if (m_type == DIALOG_INDEXING || m_type == DIALOG_PROGRESS || m_type == DIALOG_UNKNOWN_PROGRESS)
|
|
||||||
{
|
|
||||||
emit visibleChanged(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QtWindow::handleClose();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::handleCancelPress()
|
|
||||||
{
|
|
||||||
if (m_type == DIALOG_INDEXING)
|
|
||||||
{
|
|
||||||
if (isVisible())
|
|
||||||
{
|
|
||||||
MessageIndexingInterrupted().dispatch();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QtWindow::handleClose();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::setType(DialogType type)
|
|
||||||
{
|
|
||||||
m_type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
QBoxLayout* QtIndexingDialog::createLayout()
|
|
||||||
{
|
|
||||||
m_window->setStyleSheet(
|
|
||||||
m_window->styleSheet() +
|
|
||||||
"#window { "
|
|
||||||
"background: #2E3C86;"
|
|
||||||
"border: none;"
|
|
||||||
"}"
|
|
||||||
);
|
|
||||||
|
|
||||||
setStyleSheet((
|
|
||||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(L"window/window.css")) +
|
|
||||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(L"indexing_dialog/indexing_dialog.css"))
|
|
||||||
).c_str());
|
|
||||||
|
|
||||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
|
||||||
layout->setContentsMargins(20, 20, 20, 0);
|
|
||||||
layout->setSpacing(3);
|
|
||||||
|
|
||||||
m_content->setLayout(layout);
|
|
||||||
|
|
||||||
return layout;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::addTopAndProgressBar(float topRatio)
|
|
||||||
{
|
|
||||||
m_topRatio = topRatio;
|
|
||||||
|
|
||||||
m_top = new QWidget(m_window);
|
|
||||||
m_top->setObjectName("topHalf");
|
|
||||||
m_top->setGeometry(0, 0, 0, 0);
|
|
||||||
m_top->show();
|
|
||||||
m_top->lower();
|
|
||||||
|
|
||||||
m_progressBar = new QtProgressBar(m_window);
|
|
||||||
m_progressBar->setGeometry(0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::addTitle(QString title, QBoxLayout* layout)
|
|
||||||
{
|
|
||||||
m_title = new QLabel(title, this);
|
|
||||||
m_title->setObjectName("title");
|
|
||||||
m_title->setAlignment(Qt::AlignRight | Qt::AlignBottom);
|
|
||||||
|
|
||||||
if (m_top)
|
|
||||||
{
|
|
||||||
m_title->show();
|
|
||||||
}
|
|
||||||
else if (layout)
|
|
||||||
{
|
|
||||||
layout->addWidget(m_title, 0, Qt::AlignRight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::addPercentLabel(QBoxLayout* layout)
|
|
||||||
{
|
|
||||||
m_percentLabel = new QLabel("0% Progress");
|
|
||||||
m_percentLabel->setObjectName("percent");
|
|
||||||
layout->addWidget(m_percentLabel, 0, Qt::AlignRight);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::addMessageLabel(QBoxLayout* layout)
|
|
||||||
{
|
|
||||||
m_messageLabel = createMessageLabel(layout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QLabel* QtIndexingDialog::createMessageLabel(QBoxLayout* layout)
|
QLabel* QtIndexingDialog::createMessageLabel(QBoxLayout* layout)
|
||||||
@@ -514,18 +33,10 @@ QLabel* QtIndexingDialog::createMessageLabel(QBoxLayout* layout)
|
|||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtIndexingDialog::addFilePathLabel(QBoxLayout* layout)
|
QWidget* QtIndexingDialog::createErrorWidget(QBoxLayout* layout)
|
||||||
{
|
{
|
||||||
m_filePathLabel = new QLabel();
|
QWidget* errorWidget = new QWidget();
|
||||||
m_filePathLabel->setObjectName("filePath");
|
QHBoxLayout* errorLayout = new QHBoxLayout(errorWidget);
|
||||||
m_filePathLabel->setAlignment(Qt::AlignRight);
|
|
||||||
layout->addWidget(m_filePathLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::addErrorWidget(QBoxLayout* layout)
|
|
||||||
{
|
|
||||||
m_errorWidget = new QWidget();
|
|
||||||
QHBoxLayout* errorLayout = new QHBoxLayout(m_errorWidget);
|
|
||||||
errorLayout->setContentsMargins(0, 0, 0, 0);
|
errorLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
errorLayout->setSpacing(5);
|
errorLayout->setSpacing(5);
|
||||||
|
|
||||||
@@ -550,76 +61,88 @@ void QtIndexingDialog::addErrorWidget(QBoxLayout* layout)
|
|||||||
|
|
||||||
errorLayout->addWidget(helpButton);
|
errorLayout->addWidget(helpButton);
|
||||||
|
|
||||||
layout->addWidget(m_errorWidget, 0, Qt::AlignRight);
|
layout->addWidget(errorWidget, 0, Qt::AlignRight);
|
||||||
m_errorWidget->hide();
|
errorWidget->hide();
|
||||||
|
return errorWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtIndexingDialog::addButtons(QBoxLayout* layout)
|
QLabel* QtIndexingDialog::createFlagLabel(QWidget* parent)
|
||||||
{
|
|
||||||
m_nextButton = new QPushButton("Next");
|
|
||||||
m_nextButton->setObjectName("windowButton");
|
|
||||||
connect(m_nextButton, &QPushButton::clicked, this, &QtIndexingDialog::handleNextPress);
|
|
||||||
|
|
||||||
m_closeButton = new QPushButton("Cancel");
|
|
||||||
m_closeButton->setObjectName("windowButton");
|
|
||||||
connect(m_closeButton, &QPushButton::clicked, this, &QtIndexingDialog::handleCancelPress);
|
|
||||||
|
|
||||||
QHBoxLayout* buttons = new QHBoxLayout();
|
|
||||||
buttons->addWidget(m_closeButton);
|
|
||||||
buttons->addStretch();
|
|
||||||
buttons->addWidget(m_nextButton);
|
|
||||||
|
|
||||||
layout->addLayout(buttons);
|
|
||||||
|
|
||||||
setNextDefault(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtIndexingDialog::addFlag()
|
|
||||||
{
|
{
|
||||||
QtDeviceScaledPixmap flag(QString::fromStdWString(
|
QtDeviceScaledPixmap flag(QString::fromStdWString(
|
||||||
ResourcePaths::getGuiPath().concatenate(L"indexing_dialog/flag.png").wstr()));
|
ResourcePaths::getGuiPath().concatenate(L"indexing_dialog/flag.png").wstr()));
|
||||||
flag.scaleToWidth(120);
|
flag.scaleToWidth(120);
|
||||||
|
|
||||||
QLabel* flagLabel = new QLabel(this);
|
QLabel* flagLabel = new QLabel(parent);
|
||||||
flagLabel->setPixmap(flag.pixmap());
|
flagLabel->setPixmap(flag.pixmap());
|
||||||
flagLabel->resize(flag.width(), flag.height());
|
flagLabel->resize(flag.width(), flag.height());
|
||||||
flagLabel->move(15, 75);
|
flagLabel->move(15, 75);
|
||||||
flagLabel->show();
|
flagLabel->show();
|
||||||
|
|
||||||
|
return flagLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtIndexingDialog::setGeometries()
|
|
||||||
|
|
||||||
|
QtIndexingDialog::QtIndexingDialog(bool isSubWindow, QWidget* parent)
|
||||||
|
: QtWindowBase(isSubWindow, parent)
|
||||||
{
|
{
|
||||||
if (m_top)
|
m_window->setStyleSheet(
|
||||||
{
|
m_window->styleSheet() +
|
||||||
QMargins margins = m_content->layout()->contentsMargins();
|
"#window { "
|
||||||
margins.setTop(m_window->size().height() * m_topRatio + 10);
|
"background: #2E3C86;"
|
||||||
m_content->layout()->setContentsMargins(margins);
|
"border: none;"
|
||||||
|
"}"
|
||||||
|
);
|
||||||
|
|
||||||
m_top->setGeometry(0, 0, m_window->size().width(), m_window->size().height() * m_topRatio);
|
setStyleSheet((
|
||||||
|
utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(L"window/window.css")) +
|
||||||
|
utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(L"indexing_dialog/indexing_dialog.css"))
|
||||||
|
).c_str());
|
||||||
|
|
||||||
m_title->setGeometry(
|
m_layout = new QVBoxLayout(this);
|
||||||
45,
|
m_layout->setContentsMargins(20, 20, 20, 0);
|
||||||
m_window->size().height() * m_topRatio - 50,
|
m_layout->setSpacing(3);
|
||||||
m_window->size().width() - 60,
|
|
||||||
40
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_progressBar)
|
m_content->setLayout(m_layout);
|
||||||
{
|
|
||||||
m_progressBar->setGeometry(0, m_window->size().height() * m_topRatio - 5, m_window->size().width(), 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_filePathLabel)
|
|
||||||
{
|
|
||||||
m_filePathLabel->setText(m_filePathLabel->fontMetrics().elidedText(
|
|
||||||
m_sourcePath, Qt::ElideLeft, m_filePathLabel->width()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtIndexingDialog::finishSetup()
|
void QtIndexingDialog::resizeEvent(QResizeEvent* event)
|
||||||
{
|
{
|
||||||
setupDone();
|
QSize size = event->size();
|
||||||
|
|
||||||
setGeometries();
|
if (size.width() < 300)
|
||||||
|
{
|
||||||
|
size.setWidth(300);
|
||||||
|
resize(size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size.height() < 200)
|
||||||
|
{
|
||||||
|
size.setHeight(200);
|
||||||
|
resize(size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_isSubWindow)
|
||||||
|
{
|
||||||
|
m_window->resize(size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QSize windowSize = size - QSize(30, 30);
|
||||||
|
|
||||||
|
m_window->resize(windowSize);
|
||||||
|
m_window->move(15, 15);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtIndexingDialog::setupDone()
|
||||||
|
{
|
||||||
|
QSize actualSize = m_window->sizeHint() + QSize(50, 50);
|
||||||
|
QSize preferredSize = sizeHint();
|
||||||
|
|
||||||
|
QSize size(qMax(actualSize.width(), preferredSize.width()), qMax(actualSize.height(), preferredSize.height()));
|
||||||
|
resize(size);
|
||||||
|
|
||||||
|
moveToCenter();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,107 +1,45 @@
|
|||||||
#ifndef QT_INDEXING_DIALOG_H
|
#ifndef QT_INDEXING_DIALOG_H
|
||||||
#define QT_INDEXING_DIALOG_H
|
#define QT_INDEXING_DIALOG_H
|
||||||
|
|
||||||
#include <functional>
|
#include <QHBoxLayout>
|
||||||
|
#include <QResizeEvent>
|
||||||
|
#include <QSizeGrip>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
#include "RefreshInfo.h"
|
#include "QtWindowStack.h"
|
||||||
#include "QtWindow.h"
|
#include "QtWindowBase.h"
|
||||||
|
|
||||||
class QCheckBox;
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QRadioButton;
|
class QPushButton;
|
||||||
class QtProgressBar;
|
class QVBoxLayout;
|
||||||
|
|
||||||
class QtIndexingDialog
|
class QtIndexingDialog
|
||||||
: public QtWindow
|
: public QtWindowBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
signals:
|
protected:
|
||||||
void setMode(RefreshMode mode);
|
static QBoxLayout* createLayout(QWidget* parent);
|
||||||
void startIndexing(RefreshMode mode);
|
static QLabel* createTitleLabel(QString title, QBoxLayout* layout);
|
||||||
void visibleChanged(bool visible);
|
static QLabel* createMessageLabel(QBoxLayout* layout);
|
||||||
|
static QWidget* createErrorWidget(QBoxLayout* layout);
|
||||||
|
static QLabel* QtIndexingDialog::createFlagLabel(QWidget* parent);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum DialogType
|
QtIndexingDialog(bool isSubWindow, QWidget* parent = nullptr);
|
||||||
{
|
virtual QSize sizeHint() const = 0;
|
||||||
DIALOG_MESSAGE,
|
|
||||||
DIALOG_UNKNOWN_PROGRESS,
|
|
||||||
DIALOG_PROGRESS,
|
|
||||||
DIALOG_START_INDEXING,
|
|
||||||
DIALOG_INDEXING,
|
|
||||||
DIALOG_REPORT
|
|
||||||
};
|
|
||||||
|
|
||||||
QtIndexingDialog(QWidget* parent = 0);
|
signals:
|
||||||
QSize sizeHint() const override;
|
void finished();
|
||||||
|
void canceled();
|
||||||
DialogType getType() const;
|
void visibleChanged(bool visible);
|
||||||
|
|
||||||
void setupStart(const std::vector<RefreshMode>& enabledModes, const RefreshMode initialMode);
|
|
||||||
void updateRefreshInfo(const RefreshInfo& info);
|
|
||||||
|
|
||||||
void setupIndexing(bool hideable);
|
|
||||||
void setupReport(
|
|
||||||
size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount,
|
|
||||||
float time, bool interrupted);
|
|
||||||
|
|
||||||
void setupUnknownProgress(bool hideable);
|
|
||||||
void setupProgress(bool hideable);
|
|
||||||
|
|
||||||
void updateTitle(const QString& title);
|
|
||||||
void updateMessage(const QString& message);
|
|
||||||
std::wstring getMessage() const;
|
|
||||||
void updateProgress(size_t progress);
|
|
||||||
size_t getProgress() const;
|
|
||||||
void updateIndexingProgress(size_t fileCount, size_t totalFileCount, const FilePath& sourcePath);
|
|
||||||
void updateErrorCount(size_t errorCount, size_t fatalCount);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
|
|
||||||
virtual void handleNext() override;
|
void setupDone();
|
||||||
virtual void handleClose() override;
|
|
||||||
|
|
||||||
private slots:
|
QVBoxLayout* m_layout;
|
||||||
void handleCancelPress();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setType(DialogType type);
|
|
||||||
|
|
||||||
QBoxLayout* createLayout();
|
|
||||||
void addTopAndProgressBar(float topRatio);
|
|
||||||
void addTitle(QString title, QBoxLayout* layout);
|
|
||||||
|
|
||||||
void addPercentLabel(QBoxLayout* layout);
|
|
||||||
void addMessageLabel(QBoxLayout* layout);
|
|
||||||
QLabel* createMessageLabel(QBoxLayout* layout);
|
|
||||||
void addFilePathLabel(QBoxLayout* layout);
|
|
||||||
void addErrorWidget(QBoxLayout* layout);
|
|
||||||
|
|
||||||
void addButtons(QBoxLayout* layout);
|
|
||||||
void addFlag();
|
|
||||||
|
|
||||||
void setGeometries();
|
|
||||||
void finishSetup();
|
|
||||||
|
|
||||||
DialogType m_type;
|
|
||||||
|
|
||||||
QWidget* m_top;
|
|
||||||
float m_topRatio;
|
|
||||||
QtProgressBar* m_progressBar;
|
|
||||||
|
|
||||||
QLabel* m_percentLabel;
|
|
||||||
QLabel* m_messageLabel;
|
|
||||||
QLabel* m_filePathLabel;
|
|
||||||
QWidget* m_errorWidget;
|
|
||||||
|
|
||||||
// start indexing
|
|
||||||
QLabel* m_clearLabel;
|
|
||||||
QLabel* m_indexLabel;
|
|
||||||
std::map<RefreshMode, QRadioButton*> m_refreshModeButtons;
|
|
||||||
|
|
||||||
QSize m_sizeHint;
|
|
||||||
QString m_sourcePath;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QT_INDEXING_DIALOG_H
|
#endif // QT_INDEXING_DIALOG_H
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
#include "QtIndexingProgressDialog.h"
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
#include "MessageIndexingInterrupted.h"
|
||||||
|
|
||||||
|
QtIndexingProgressDialog::QtIndexingProgressDialog(bool hideable, QWidget* parent)
|
||||||
|
: QtProgressBarDialog(0.38, true, parent)
|
||||||
|
, m_filePathLabel(nullptr)
|
||||||
|
, m_errorWidget(nullptr)
|
||||||
|
{
|
||||||
|
setSizeGripStyle(false);
|
||||||
|
|
||||||
|
updateTitle("Indexing Files");
|
||||||
|
|
||||||
|
m_filePathLabel = new QLabel();
|
||||||
|
m_filePathLabel->setObjectName("filePath");
|
||||||
|
m_filePathLabel->setAlignment(Qt::AlignRight);
|
||||||
|
m_layout->addWidget(m_filePathLabel);
|
||||||
|
|
||||||
|
m_layout->addSpacing(12);
|
||||||
|
m_errorWidget = QtIndexingDialog::createErrorWidget(m_layout);
|
||||||
|
|
||||||
|
m_layout->addStretch();
|
||||||
|
|
||||||
|
{
|
||||||
|
QHBoxLayout* buttons = new QHBoxLayout();
|
||||||
|
|
||||||
|
QPushButton* stopButton = new QPushButton("Stop");
|
||||||
|
stopButton->setObjectName("windowButton");
|
||||||
|
connect(stopButton, &QPushButton::clicked, this, &QtIndexingProgressDialog::onStopPressed);
|
||||||
|
buttons->addWidget(stopButton);
|
||||||
|
|
||||||
|
buttons->addStretch();
|
||||||
|
|
||||||
|
QPushButton* hideButton = new QPushButton("Hide");
|
||||||
|
hideButton->setObjectName("windowButton");
|
||||||
|
hideButton->setDefault(true);
|
||||||
|
connect(hideButton, &QPushButton::clicked, this, &QtIndexingProgressDialog::onHidePressed);
|
||||||
|
buttons->addWidget(hideButton);
|
||||||
|
|
||||||
|
m_layout->addLayout(buttons);
|
||||||
|
}
|
||||||
|
|
||||||
|
setupDone();
|
||||||
|
setGeometries();
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize QtIndexingProgressDialog::sizeHint() const
|
||||||
|
{
|
||||||
|
return QSize(350, 350);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtIndexingProgressDialog::updateIndexingProgress(size_t fileCount, size_t totalFileCount, const FilePath& sourcePath)
|
||||||
|
{
|
||||||
|
updateMessage(QString::number(fileCount) + "/" + QString::number(totalFileCount) + " File" + (totalFileCount > 1 ? "s" : ""));
|
||||||
|
|
||||||
|
int progress = 0;
|
||||||
|
if (totalFileCount > 0)
|
||||||
|
{
|
||||||
|
progress = fileCount * 100 / totalFileCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sourcePath.empty())
|
||||||
|
{
|
||||||
|
m_sourcePath = QString::fromStdWString(sourcePath.wstr());
|
||||||
|
}
|
||||||
|
|
||||||
|
updateProgress(progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtIndexingProgressDialog::updateErrorCount(size_t errorCount, size_t fatalCount)
|
||||||
|
{
|
||||||
|
if (m_errorWidget && errorCount)
|
||||||
|
{
|
||||||
|
QString str = QString::number(errorCount) + " Error";
|
||||||
|
if (errorCount > 1)
|
||||||
|
{
|
||||||
|
str += "s";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fatalCount)
|
||||||
|
{
|
||||||
|
str += " (" + QString::number(fatalCount) + " Fatal)";
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton* errorCount = m_errorWidget->findChild<QPushButton*>("errorCount");
|
||||||
|
errorCount->setText(str);
|
||||||
|
|
||||||
|
m_errorWidget->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtIndexingProgressDialog::onHidePressed()
|
||||||
|
{
|
||||||
|
emit visibleChanged(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtIndexingProgressDialog::onStopPressed()
|
||||||
|
{
|
||||||
|
if (isVisible())
|
||||||
|
{
|
||||||
|
MessageIndexingInterrupted().dispatch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtIndexingProgressDialog::closeEvent(QCloseEvent* event)
|
||||||
|
{
|
||||||
|
emit visibleChanged(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtIndexingProgressDialog::setGeometries()
|
||||||
|
{
|
||||||
|
QtProgressBarDialog::setGeometries();
|
||||||
|
|
||||||
|
if (m_filePathLabel)
|
||||||
|
{
|
||||||
|
m_filePathLabel->setText(m_filePathLabel->fontMetrics().elidedText(
|
||||||
|
m_sourcePath, Qt::ElideLeft, m_filePathLabel->width()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef QT_INDEXING_PROGRESS_DIALOG_H
|
||||||
|
#define QT_INDEXING_PROGRESS_DIALOG_H
|
||||||
|
|
||||||
|
#include "QtProgressBarDialog.h"
|
||||||
|
|
||||||
|
class QLabel;
|
||||||
|
|
||||||
|
class QtIndexingProgressDialog
|
||||||
|
: public QtProgressBarDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
QtIndexingProgressDialog(bool hideable, QWidget* parent = 0);
|
||||||
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
|
void updateIndexingProgress(size_t fileCount, size_t totalFileCount, const FilePath& sourcePath);
|
||||||
|
void updateErrorCount(size_t errorCount, size_t fatalCount);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void closeEvent(QCloseEvent* event) override;
|
||||||
|
void setGeometries() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void onHidePressed();
|
||||||
|
void onStopPressed();
|
||||||
|
|
||||||
|
QLabel* m_filePathLabel;
|
||||||
|
QWidget* m_errorWidget;
|
||||||
|
QString m_sourcePath;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QT_INDEXING_PROGRESS_DIALOG_H
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
#include "QtIndexingReportDialog.h"
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
#include "MessageErrorsHelpMessage.h"
|
||||||
|
#include "TimeStamp.h"
|
||||||
|
|
||||||
|
QtIndexingReportDialog::QtIndexingReportDialog(
|
||||||
|
size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount, float time, bool interrupted, QWidget* parent)
|
||||||
|
: QtIndexingDialog(true, parent)
|
||||||
|
, m_interrupted(interrupted)
|
||||||
|
{
|
||||||
|
setSizeGripStyle(false);
|
||||||
|
|
||||||
|
if (interrupted)
|
||||||
|
{
|
||||||
|
QtIndexingDialog::createTitleLabel("Interrupted Indexing", m_layout);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QtIndexingDialog::createTitleLabel("Finished Indexing", m_layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_layout->addSpacing(5);
|
||||||
|
|
||||||
|
QtIndexingDialog::createMessageLabel(m_layout)->setText(
|
||||||
|
"Source files indexed: " + QString::number(indexedFileCount) + "/" + QString::number(totalIndexedFileCount)
|
||||||
|
);
|
||||||
|
|
||||||
|
QtIndexingDialog::createMessageLabel(m_layout)->setText(
|
||||||
|
"Total files completed: " + QString::number(completedFileCount) + "/" + QString::number(totalFileCount)
|
||||||
|
);
|
||||||
|
|
||||||
|
m_layout->addSpacing(12);
|
||||||
|
QtIndexingDialog::createMessageLabel(m_layout)->setText("Time: " + QString::fromStdString(TimeStamp::secondsToString(time)));
|
||||||
|
|
||||||
|
m_layout->addSpacing(12);
|
||||||
|
m_errorWidget = QtIndexingDialog::createErrorWidget(m_layout);
|
||||||
|
|
||||||
|
m_layout->addStretch();
|
||||||
|
|
||||||
|
{
|
||||||
|
QHBoxLayout* buttons = new QHBoxLayout();
|
||||||
|
if (interrupted)
|
||||||
|
{
|
||||||
|
QPushButton* discardButton = new QPushButton("Discard");
|
||||||
|
discardButton->setObjectName("windowButton");
|
||||||
|
connect(discardButton, &QPushButton::clicked, this, &QtIndexingReportDialog::onDiscardPressed);
|
||||||
|
buttons->addWidget(discardButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
buttons->addStretch();
|
||||||
|
|
||||||
|
QPushButton* confirmButton = new QPushButton(interrupted ? "Keep" : "OK");
|
||||||
|
confirmButton->setObjectName("windowButton");
|
||||||
|
confirmButton->setDefault(true);
|
||||||
|
connect(confirmButton, &QPushButton::clicked, this, &QtIndexingReportDialog::onConfirmPressed);
|
||||||
|
buttons->addWidget(confirmButton);
|
||||||
|
|
||||||
|
m_layout->addLayout(buttons);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!interrupted)
|
||||||
|
{
|
||||||
|
QtIndexingDialog::createFlagLabel(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
setupDone();
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize QtIndexingReportDialog::sizeHint() const
|
||||||
|
{
|
||||||
|
return QSize(m_interrupted ? 400 : 430, 280);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtIndexingReportDialog::updateErrorCount(size_t errorCount, size_t fatalCount)
|
||||||
|
{
|
||||||
|
if (m_errorWidget && errorCount)
|
||||||
|
{
|
||||||
|
QString str = QString::number(errorCount) + " Error";
|
||||||
|
if (errorCount > 1)
|
||||||
|
{
|
||||||
|
str += "s";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fatalCount)
|
||||||
|
{
|
||||||
|
str += " (" + QString::number(fatalCount) + " Fatal)";
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton* errorCount = m_errorWidget->findChild<QPushButton*>("errorCount");
|
||||||
|
errorCount->setText(str);
|
||||||
|
|
||||||
|
m_errorWidget->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtIndexingReportDialog::closeEvent(QCloseEvent* event)
|
||||||
|
{
|
||||||
|
emit QtIndexingDialog::canceled();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtIndexingReportDialog::keyPressEvent(QKeyEvent* event)
|
||||||
|
{
|
||||||
|
if (!m_interrupted) // in this case we only show one button, so it is clear what to do
|
||||||
|
{
|
||||||
|
switch (event->key())
|
||||||
|
{
|
||||||
|
case Qt::Key_Escape:
|
||||||
|
case Qt::Key_Return:
|
||||||
|
onConfirmPressed();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget::keyPressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtIndexingReportDialog::onConfirmPressed()
|
||||||
|
{
|
||||||
|
MessageErrorsHelpMessage().dispatch();
|
||||||
|
|
||||||
|
emit QtIndexingDialog::finished();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtIndexingReportDialog::onDiscardPressed()
|
||||||
|
{
|
||||||
|
emit QtIndexingDialog::canceled();
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
#ifndef QT_INDEXING_REPORT_DIALOG_H
|
||||||
|
#define QT_INDEXING_REPORT_DIALOG_H
|
||||||
|
|
||||||
|
#include "QtIndexingDialog.h"
|
||||||
|
|
||||||
|
class QtIndexingReportDialog
|
||||||
|
: public QtIndexingDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
QtIndexingReportDialog(size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount, float time, bool interrupted, QWidget* parent = 0);
|
||||||
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
|
void updateErrorCount(size_t errorCount, size_t fatalCount);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void closeEvent(QCloseEvent* event) override;
|
||||||
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void onConfirmPressed();
|
||||||
|
void onDiscardPressed();
|
||||||
|
|
||||||
|
QWidget* m_errorWidget;
|
||||||
|
bool m_interrupted;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QT_INDEXING_REPORT_DIALOG_H
|
||||||
@@ -0,0 +1,184 @@
|
|||||||
|
#include "QtIndexingStartDialog.h"
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QRadioButton>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
#include "QtHelpButton.h"
|
||||||
|
|
||||||
|
QtIndexingStartDialog::QtIndexingStartDialog(const std::vector<RefreshMode>& enabledModes, const RefreshMode initialMode, QWidget* parent)
|
||||||
|
: QtIndexingDialog(true, parent)
|
||||||
|
{
|
||||||
|
setSizeGripStyle(false);
|
||||||
|
|
||||||
|
QtIndexingDialog::createTitleLabel("Start Indexing", m_layout);
|
||||||
|
m_layout->addSpacing(5);
|
||||||
|
|
||||||
|
m_clearLabel = QtIndexingDialog::createMessageLabel(m_layout);
|
||||||
|
m_indexLabel = QtIndexingDialog::createMessageLabel(m_layout);
|
||||||
|
|
||||||
|
m_clearLabel->setVisible(false);
|
||||||
|
m_indexLabel->setVisible(false);
|
||||||
|
|
||||||
|
m_layout->addStretch();
|
||||||
|
|
||||||
|
QHBoxLayout* subLayout = new QHBoxLayout();
|
||||||
|
subLayout->addStretch();
|
||||||
|
|
||||||
|
QVBoxLayout* modeLayout = new QVBoxLayout();
|
||||||
|
modeLayout->setSpacing(7);
|
||||||
|
|
||||||
|
QHBoxLayout* modeTitleLayout = new QHBoxLayout();
|
||||||
|
modeTitleLayout->setSpacing(7);
|
||||||
|
|
||||||
|
QLabel* modeLabel = QtIndexingDialog::createMessageLabel(modeTitleLayout);
|
||||||
|
modeLabel->setText("Mode:");
|
||||||
|
modeLabel->setAlignment(Qt::AlignLeft);
|
||||||
|
|
||||||
|
QtHelpButton* helpButton = new QtHelpButton(
|
||||||
|
"Indexing Modes",
|
||||||
|
"<b>Updated files:</b> Reindexes all files that were modified since the last indexing, all files depending "
|
||||||
|
"on those and new files.<br /><br />"
|
||||||
|
"<b>Incomplete & updated files:</b> Reindexes all files that had errors during last indexing, all files "
|
||||||
|
"depending on those and all updated files.<br /><br />"
|
||||||
|
"<b>All files:</b> Deletes the previous index and reindexes all files.<br /><br />"
|
||||||
|
);
|
||||||
|
helpButton->setColor(Qt::white);
|
||||||
|
modeTitleLayout->addWidget(helpButton);
|
||||||
|
|
||||||
|
modeTitleLayout->addStretch();
|
||||||
|
|
||||||
|
modeLayout->addLayout(modeTitleLayout);
|
||||||
|
modeLayout->addSpacing(5);
|
||||||
|
|
||||||
|
m_refreshModeButtons.emplace(REFRESH_UPDATED_FILES, new QRadioButton("Updated files"));
|
||||||
|
m_refreshModeButtons.emplace(REFRESH_UPDATED_AND_INCOMPLETE_FILES, new QRadioButton("Incomplete && updated files"));
|
||||||
|
m_refreshModeButtons.emplace(REFRESH_ALL_FILES, new QRadioButton("All files"));
|
||||||
|
|
||||||
|
std::function<void(bool)> func =
|
||||||
|
[=](bool checked)
|
||||||
|
{
|
||||||
|
if (!checked)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto p : m_refreshModeButtons)
|
||||||
|
{
|
||||||
|
if (p.second->isChecked())
|
||||||
|
{
|
||||||
|
emit setMode(p.first);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (auto p : m_refreshModeButtons)
|
||||||
|
{
|
||||||
|
QRadioButton* button = p.second;
|
||||||
|
button->setObjectName("option");
|
||||||
|
button->setEnabled(false);
|
||||||
|
if (p.first == initialMode)
|
||||||
|
{
|
||||||
|
button->setChecked(true);
|
||||||
|
}
|
||||||
|
modeLayout->addWidget(button);
|
||||||
|
connect(button, &QRadioButton::toggled, func);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (RefreshMode mode : enabledModes)
|
||||||
|
{
|
||||||
|
m_refreshModeButtons[mode]->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
subLayout->addLayout(modeLayout);
|
||||||
|
m_layout->addLayout(subLayout);
|
||||||
|
|
||||||
|
m_layout->addSpacing(20);
|
||||||
|
|
||||||
|
{
|
||||||
|
QHBoxLayout* buttons = new QHBoxLayout();
|
||||||
|
QPushButton* cancelButton = new QPushButton("Cancel");
|
||||||
|
cancelButton->setObjectName("windowButton");
|
||||||
|
connect(cancelButton, &QPushButton::clicked, this, &QtIndexingStartDialog::onCancelPressed);
|
||||||
|
buttons->addWidget(cancelButton);
|
||||||
|
|
||||||
|
buttons->addStretch();
|
||||||
|
|
||||||
|
QPushButton* startButton = new QPushButton("Start");
|
||||||
|
startButton->setObjectName("windowButton");
|
||||||
|
startButton->setDefault(true);
|
||||||
|
connect(startButton, &QPushButton::clicked, this, &QtIndexingStartDialog::onStartPressed);
|
||||||
|
buttons->addWidget(startButton);
|
||||||
|
m_layout->addLayout(buttons);
|
||||||
|
}
|
||||||
|
|
||||||
|
setupDone();
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize QtIndexingStartDialog::sizeHint() const
|
||||||
|
{
|
||||||
|
return QSize(350, 310);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtIndexingStartDialog::updateRefreshInfo(const RefreshInfo& info)
|
||||||
|
{
|
||||||
|
QRadioButton* button = m_refreshModeButtons.find(info.mode)->second;
|
||||||
|
if (!button->isChecked())
|
||||||
|
{
|
||||||
|
button->setChecked(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t clearCount = info.filesToClear.size();
|
||||||
|
size_t indexCount = info.filesToIndex.size();
|
||||||
|
|
||||||
|
m_clearLabel->setText("Files to clear: " + QString::number(clearCount));
|
||||||
|
m_indexLabel->setText("Source files to index: " + QString::number(indexCount));
|
||||||
|
|
||||||
|
m_clearLabel->setVisible(clearCount && info.mode != REFRESH_ALL_FILES);
|
||||||
|
m_indexLabel->setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtIndexingStartDialog::resizeEvent(QResizeEvent* event)
|
||||||
|
{
|
||||||
|
QtIndexingDialog::resizeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtIndexingStartDialog::closeEvent(QCloseEvent* event)
|
||||||
|
{
|
||||||
|
emit QtIndexingDialog::canceled();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtIndexingStartDialog::keyPressEvent(QKeyEvent* event)
|
||||||
|
{
|
||||||
|
switch (event->key())
|
||||||
|
{
|
||||||
|
case Qt::Key_Escape:
|
||||||
|
onCancelPressed();
|
||||||
|
break;
|
||||||
|
case Qt::Key_Return:
|
||||||
|
onStartPressed();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget::keyPressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtIndexingStartDialog::onStartPressed()
|
||||||
|
{
|
||||||
|
for (auto p : m_refreshModeButtons)
|
||||||
|
{
|
||||||
|
if (p.second->isChecked())
|
||||||
|
{
|
||||||
|
emit startIndexing(p.first);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emit finished();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtIndexingStartDialog::onCancelPressed()
|
||||||
|
{
|
||||||
|
emit canceled();
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#ifndef QT_INDEXING_START_DIALOG_H
|
||||||
|
#define QT_INDEXING_START_DIALOG_H
|
||||||
|
|
||||||
|
#include "RefreshInfo.h"
|
||||||
|
#include "QtIndexingDialog.h"
|
||||||
|
|
||||||
|
class QLabel;
|
||||||
|
class QRadioButton;
|
||||||
|
|
||||||
|
class QtIndexingStartDialog
|
||||||
|
: public QtIndexingDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void setMode(RefreshMode mode);
|
||||||
|
void startIndexing(RefreshMode mode);
|
||||||
|
|
||||||
|
public:
|
||||||
|
QtIndexingStartDialog(const std::vector<RefreshMode>& enabledModes, const RefreshMode initialMode, QWidget* parent = 0);
|
||||||
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
|
void updateRefreshInfo(const RefreshInfo& info);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void closeEvent(QCloseEvent* event) override;
|
||||||
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void onStartPressed();
|
||||||
|
void onCancelPressed();
|
||||||
|
|
||||||
|
QLabel* m_clearLabel;
|
||||||
|
QLabel* m_indexLabel;
|
||||||
|
std::map<RefreshMode, QRadioButton*> m_refreshModeButtons;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QT_INDEXING_START_DIALOG_H
|
||||||
@@ -15,7 +15,7 @@ public:
|
|||||||
void updateSize();
|
void updateSize();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
|
virtual void wheelEvent(QWheelEvent *event) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QtKeyboardShortcuts
|
class QtKeyboardShortcuts
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
#include "QtKnownProgressDialog.h"
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
QtKnownProgressDialog::QtKnownProgressDialog(bool hideable, QWidget* parent)
|
||||||
|
: QtProgressBarDialog(0.5, true, parent)
|
||||||
|
{
|
||||||
|
setSizeGripStyle(false);
|
||||||
|
|
||||||
|
updateTitle("Progress");
|
||||||
|
|
||||||
|
m_layout->addStretch();
|
||||||
|
|
||||||
|
if (hideable)
|
||||||
|
{
|
||||||
|
QHBoxLayout* buttons = new QHBoxLayout();
|
||||||
|
buttons->addStretch();
|
||||||
|
|
||||||
|
QPushButton* hideButton = new QPushButton("Hide");
|
||||||
|
hideButton->setObjectName("windowButton");
|
||||||
|
hideButton->setDefault(true);
|
||||||
|
connect(hideButton, &QPushButton::clicked, this, &QtKnownProgressDialog::onHidePressed);
|
||||||
|
buttons->addWidget(hideButton);
|
||||||
|
|
||||||
|
m_layout->addLayout(buttons);
|
||||||
|
}
|
||||||
|
|
||||||
|
setupDone();
|
||||||
|
setGeometries();
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize QtKnownProgressDialog::sizeHint() const
|
||||||
|
{
|
||||||
|
return QSize(350, 280);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtKnownProgressDialog::closeEvent(QCloseEvent* event)
|
||||||
|
{
|
||||||
|
emit visibleChanged(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtKnownProgressDialog::onHidePressed()
|
||||||
|
{
|
||||||
|
emit visibleChanged(false);
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef QT_KNOWN_PROGRESS_DIALOG_H
|
||||||
|
#define QT_KNOWN_PROGRESS_DIALOG_H
|
||||||
|
|
||||||
|
#include "QtProgressBarDialog.h"
|
||||||
|
|
||||||
|
class QtKnownProgressDialog
|
||||||
|
: public QtProgressBarDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
QtKnownProgressDialog(bool hideable, QWidget* parent = 0);
|
||||||
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void closeEvent(QCloseEvent* event) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void onHidePressed();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QT_KNOWN_PROGRESS_DIALOG_H
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
#include "QtProgressBarDialog.h"
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
#include "QtProgressBar.h"
|
||||||
|
|
||||||
|
QtProgressBarDialog::QtProgressBarDialog(float topRatio, bool hideable, QWidget* parent)
|
||||||
|
: QtIndexingDialog(true, parent)
|
||||||
|
, m_title(nullptr)
|
||||||
|
, m_topRatio(topRatio)
|
||||||
|
{
|
||||||
|
m_top = new QWidget(m_window);
|
||||||
|
m_top->setObjectName("topHalf");
|
||||||
|
m_top->setGeometry(0, 0, 0, 0);
|
||||||
|
m_top->show();
|
||||||
|
m_top->lower();
|
||||||
|
|
||||||
|
m_progressBar = new QtProgressBar(m_window);
|
||||||
|
m_progressBar->setGeometry(0, 0, 0, 0);
|
||||||
|
|
||||||
|
m_title = new QLabel("", this);
|
||||||
|
m_title->setObjectName("title");
|
||||||
|
m_title->setAlignment(Qt::AlignRight | Qt::AlignBottom);
|
||||||
|
m_title->show();
|
||||||
|
|
||||||
|
m_percentLabel = new QLabel("0% Progress");
|
||||||
|
m_percentLabel->setObjectName("percent");
|
||||||
|
m_layout->addWidget(m_percentLabel, 0, Qt::AlignRight);
|
||||||
|
|
||||||
|
m_messageLabel = QtIndexingDialog::createMessageLabel(m_layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtProgressBarDialog::updateTitle(const QString& title)
|
||||||
|
{
|
||||||
|
if (m_title)
|
||||||
|
{
|
||||||
|
m_title->setText(title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring QtProgressBarDialog::getTitle() const
|
||||||
|
{
|
||||||
|
if (m_title)
|
||||||
|
{
|
||||||
|
return m_title->text().toStdWString();
|
||||||
|
}
|
||||||
|
return L"";
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtProgressBarDialog::updateMessage(const QString& message)
|
||||||
|
{
|
||||||
|
if (m_messageLabel)
|
||||||
|
{
|
||||||
|
m_messageLabel->setText(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring QtProgressBarDialog::getMessage() const
|
||||||
|
{
|
||||||
|
if (m_messageLabel)
|
||||||
|
{
|
||||||
|
return m_messageLabel->text().toStdWString();
|
||||||
|
}
|
||||||
|
return L"";
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtProgressBarDialog::setUnknownProgress()
|
||||||
|
{
|
||||||
|
m_progressBar->showUnknownProgressAnimated();
|
||||||
|
m_percentLabel->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtProgressBarDialog::updateProgress(size_t progress)
|
||||||
|
{
|
||||||
|
size_t percent = std::min<size_t>(std::max<size_t>(progress, 0), 100);
|
||||||
|
|
||||||
|
m_progressBar->showProgress(percent);
|
||||||
|
m_percentLabel->setText(QString::number(percent) + "% Progress");
|
||||||
|
m_percentLabel->show();
|
||||||
|
setGeometries();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t QtProgressBarDialog::getProgress() const
|
||||||
|
{
|
||||||
|
return m_progressBar->getProgress();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtProgressBarDialog::resizeEvent(QResizeEvent* event)
|
||||||
|
{
|
||||||
|
QtIndexingDialog::resizeEvent(event);
|
||||||
|
setGeometries();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtProgressBarDialog::setGeometries()
|
||||||
|
{
|
||||||
|
if (m_top)
|
||||||
|
{
|
||||||
|
QMargins margins = m_content->layout()->contentsMargins();
|
||||||
|
margins.setTop(m_window->size().height() * m_topRatio + 10);
|
||||||
|
m_content->layout()->setContentsMargins(margins);
|
||||||
|
|
||||||
|
m_top->setGeometry(0, 0, m_window->size().width(), m_window->size().height() * m_topRatio);
|
||||||
|
|
||||||
|
m_title->setGeometry(
|
||||||
|
45,
|
||||||
|
m_window->size().height() * m_topRatio - 50,
|
||||||
|
m_window->size().width() - 60,
|
||||||
|
40
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_progressBar)
|
||||||
|
{
|
||||||
|
m_progressBar->setGeometry(0, m_window->size().height() * m_topRatio - 5, m_window->size().width(), 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
#ifndef QT_PROGRESS_BAR_DIALOG_H
|
||||||
|
#define QT_PROGRESS_BAR_DIALOG_H
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
#include "RefreshInfo.h"
|
||||||
|
#include "QtIndexingDialog.h"
|
||||||
|
|
||||||
|
class QCheckBox;
|
||||||
|
class QLabel;
|
||||||
|
class QRadioButton;
|
||||||
|
class QtProgressBar;
|
||||||
|
|
||||||
|
class QtProgressBarDialog
|
||||||
|
: public QtIndexingDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
QtProgressBarDialog(float topRatio, bool hideable, QWidget* parent = 0);
|
||||||
|
void updateTitle(const QString& title);
|
||||||
|
std::wstring getTitle() const;
|
||||||
|
void updateMessage(const QString& message);
|
||||||
|
std::wstring getMessage() const;
|
||||||
|
void setUnknownProgress();
|
||||||
|
void updateProgress(size_t progress);
|
||||||
|
size_t getProgress() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
|
virtual void setGeometries();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLabel* m_title;
|
||||||
|
QWidget* m_top;
|
||||||
|
float m_topRatio;
|
||||||
|
QtProgressBar* m_progressBar;
|
||||||
|
QLabel* m_percentLabel;
|
||||||
|
QLabel* m_messageLabel;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QT_PROGRESS_BAR_DIALOG_H
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
#include "QtUnknownProgressDialog.h"
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
QtUnknownProgressDialog::QtUnknownProgressDialog(bool hideable, QWidget* parent)
|
||||||
|
: QtProgressBarDialog(0.5, true, parent)
|
||||||
|
{
|
||||||
|
setSizeGripStyle(false);
|
||||||
|
|
||||||
|
updateTitle("Status");
|
||||||
|
|
||||||
|
m_layout->addStretch();
|
||||||
|
|
||||||
|
if (hideable)
|
||||||
|
{
|
||||||
|
QHBoxLayout* buttons = new QHBoxLayout();
|
||||||
|
buttons->addStretch();
|
||||||
|
|
||||||
|
QPushButton* hideButton = new QPushButton("Hide");
|
||||||
|
hideButton->setObjectName("windowButton");
|
||||||
|
hideButton->setDefault(true);
|
||||||
|
connect(hideButton, &QPushButton::clicked, this, &QtUnknownProgressDialog::onHidePressed);
|
||||||
|
buttons->addWidget(hideButton);
|
||||||
|
|
||||||
|
m_layout->addLayout(buttons);
|
||||||
|
}
|
||||||
|
|
||||||
|
setUnknownProgress();
|
||||||
|
|
||||||
|
setupDone();
|
||||||
|
setGeometries();
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize QtUnknownProgressDialog::sizeHint() const
|
||||||
|
{
|
||||||
|
return QSize(350, 280);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtUnknownProgressDialog::closeEvent(QCloseEvent* event)
|
||||||
|
{
|
||||||
|
emit visibleChanged(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtUnknownProgressDialog::onHidePressed()
|
||||||
|
{
|
||||||
|
emit visibleChanged(false);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef QT_UNKNOWN_PROGRESS_DIALOG_H
|
||||||
|
#define QT_UNKNOWN_PROGRESS_DIALOG_H
|
||||||
|
|
||||||
|
#include "QtProgressBarDialog.h"
|
||||||
|
|
||||||
|
class QtUnknownProgressDialog
|
||||||
|
: public QtProgressBarDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
QtUnknownProgressDialog(bool hideable, QWidget* parent = 0);
|
||||||
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void closeEvent(QCloseEvent* event) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void onHidePressed();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QT_UNKNOWN_PROGRESS_DIALOG_H
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "QtWindow.h"
|
#include "QtWindow.h"
|
||||||
|
|
||||||
#include <QGraphicsDropShadowEffect>
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
@@ -11,9 +10,7 @@
|
|||||||
#include "ResourcePaths.h"
|
#include "ResourcePaths.h"
|
||||||
|
|
||||||
QtWindow::QtWindow(bool isSubWindow, QWidget* parent)
|
QtWindow::QtWindow(bool isSubWindow, QWidget* parent)
|
||||||
: QtWindowStackElement(parent)
|
: QtWindowBase(isSubWindow, parent)
|
||||||
, m_isSubWindow(isSubWindow)
|
|
||||||
, m_window(nullptr)
|
|
||||||
, m_title(nullptr)
|
, m_title(nullptr)
|
||||||
, m_subTitle(nullptr)
|
, m_subTitle(nullptr)
|
||||||
, m_nextButton(nullptr)
|
, m_nextButton(nullptr)
|
||||||
@@ -22,68 +19,7 @@ QtWindow::QtWindow(bool isSubWindow, QWidget* parent)
|
|||||||
, m_cancelAble(true)
|
, m_cancelAble(true)
|
||||||
, m_scrollAble(false)
|
, m_scrollAble(false)
|
||||||
, m_hasLogo(false)
|
, m_hasLogo(false)
|
||||||
, m_mousePressedInWindow(false)
|
|
||||||
, m_sizeGrip(nullptr)
|
|
||||||
{
|
{
|
||||||
if (isSubWindow)
|
|
||||||
{
|
|
||||||
setWindowFlags(Qt::SubWindow | Qt::FramelessWindowHint);
|
|
||||||
setAttribute(Qt::WA_TranslucentBackground, true);
|
|
||||||
setFocusPolicy(Qt::StrongFocus);
|
|
||||||
setFocus();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setWindowFlags(Qt::Window);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_window = new QWidget(this);
|
|
||||||
m_window->setObjectName("window");
|
|
||||||
|
|
||||||
QVBoxLayout* layout = new QVBoxLayout(m_window);
|
|
||||||
layout->setSpacing(0);
|
|
||||||
|
|
||||||
m_content = new QWidget();
|
|
||||||
layout->addWidget(m_content);
|
|
||||||
|
|
||||||
if (isSubWindow)
|
|
||||||
{
|
|
||||||
std::string frameStyle =
|
|
||||||
"#window {"
|
|
||||||
" border: 1px solid lightgray;"
|
|
||||||
" border-radius: 15px;"
|
|
||||||
" background: white;"
|
|
||||||
"}";
|
|
||||||
m_window->setStyleSheet(frameStyle.c_str());
|
|
||||||
|
|
||||||
QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect;
|
|
||||||
effect->setBlurRadius(15);
|
|
||||||
effect->setXOffset(0);
|
|
||||||
effect->setYOffset(5);
|
|
||||||
effect->setColor(Qt::darkGray);
|
|
||||||
m_window->setGraphicsEffect(effect);
|
|
||||||
|
|
||||||
QHBoxLayout* gripLayout = new QHBoxLayout();
|
|
||||||
m_sizeGrip = new QSizeGrip(m_window);
|
|
||||||
setSizeGripStyle(true);
|
|
||||||
gripLayout->addWidget(new QWidget());
|
|
||||||
gripLayout->addWidget(m_sizeGrip);
|
|
||||||
layout->addLayout(gripLayout);
|
|
||||||
}
|
|
||||||
|
|
||||||
resize(sizeHint());
|
|
||||||
|
|
||||||
moveToCenter();
|
|
||||||
|
|
||||||
this->raise();
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize QtWindow::sizeHint() const
|
|
||||||
{
|
|
||||||
return QSize(
|
|
||||||
ApplicationSettings::getInstance()->getWindowBaseWidth(),
|
|
||||||
ApplicationSettings::getInstance()->getWindowBaseHeight()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtWindow::setup()
|
void QtWindow::setup()
|
||||||
@@ -143,24 +79,6 @@ void QtWindow::setup()
|
|||||||
setupDone();
|
setupDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtWindow::setSizeGripStyle(bool isBlack)
|
|
||||||
{
|
|
||||||
if (!m_sizeGrip)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::wstring path = isBlack ? L"size_grip_black.png" : L"size_grip_white.png";
|
|
||||||
|
|
||||||
m_sizeGrip->setStyleSheet(QString::fromStdWString(
|
|
||||||
L"QSizeGrip {"
|
|
||||||
" max-height: 16px;"
|
|
||||||
" max-width: 16px;"
|
|
||||||
" border-image: url(" + ResourcePaths::getGuiPath().wstr() + L"window/" + path + L");"
|
|
||||||
"}"
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtWindow::setCancelAble(bool cancelable)
|
void QtWindow::setCancelAble(bool cancelable)
|
||||||
{
|
{
|
||||||
setCloseEnabled(cancelable);
|
setCloseEnabled(cancelable);
|
||||||
@@ -178,32 +96,6 @@ bool QtWindow::isScrollAble() const
|
|||||||
return m_scrollAble;
|
return m_scrollAble;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QtWindow::isSubWindow() const
|
|
||||||
{
|
|
||||||
return m_isSubWindow;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtWindow::moveToCenter()
|
|
||||||
{
|
|
||||||
if (parentWidget())
|
|
||||||
{
|
|
||||||
if (m_isSubWindow)
|
|
||||||
{
|
|
||||||
move(
|
|
||||||
parentWidget()->width() / 2 - sizeHint().width() / 2,
|
|
||||||
parentWidget()->height() / 2 - sizeHint().height() / 2
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
move(
|
|
||||||
parentWidget()->pos().x() + parentWidget()->width() / 2 - sizeHint().width() / 2,
|
|
||||||
parentWidget()->pos().y() + parentWidget()->height() / 2 - sizeHint().height() / 2
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtWindow::updateTitle(const QString& title)
|
void QtWindow::updateTitle(const QString& title)
|
||||||
{
|
{
|
||||||
if (m_title)
|
if (m_title)
|
||||||
@@ -325,16 +217,6 @@ void QtWindow::setCloseDefault(bool isDefault)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtWindow::showWindow()
|
|
||||||
{
|
|
||||||
show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtWindow::hideWindow()
|
|
||||||
{
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtWindow::closeEvent(QCloseEvent* event)
|
void QtWindow::closeEvent(QCloseEvent* event)
|
||||||
{
|
{
|
||||||
handleClose();
|
handleClose();
|
||||||
@@ -423,53 +305,6 @@ void QtWindow::keyPressEvent(QKeyEvent* event)
|
|||||||
QWidget::keyPressEvent(event);
|
QWidget::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtWindow::mouseMoveEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
if (event->buttons() & Qt::LeftButton && m_mousePressedInWindow)
|
|
||||||
{
|
|
||||||
if (m_isSubWindow)
|
|
||||||
{
|
|
||||||
QPoint pos = event->globalPos() - m_dragPosition;
|
|
||||||
QRect parentRect = parentWidget()->rect();
|
|
||||||
|
|
||||||
if (pos.x() < parentRect.left())
|
|
||||||
{
|
|
||||||
pos.setX(parentRect.left());
|
|
||||||
}
|
|
||||||
pos.setX(qBound(parentRect.left(), parentRect.right() - width(), pos.x()));
|
|
||||||
pos.setY(qBound(parentRect.top(), parentRect.bottom() - height(), pos.y()));
|
|
||||||
|
|
||||||
move(pos);
|
|
||||||
event->accept();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
move(event->globalPos() - m_dragPosition);
|
|
||||||
event->accept();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtWindow::mousePressEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
if (event->button() == Qt::LeftButton)
|
|
||||||
{
|
|
||||||
m_dragPosition = event->globalPos() - frameGeometry().topLeft();
|
|
||||||
event->accept();
|
|
||||||
m_mousePressedInWindow = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtWindow::mouseReleaseEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
if (event->button() == Qt::LeftButton)
|
|
||||||
{
|
|
||||||
m_dragPosition = event->globalPos() - frameGeometry().topLeft();
|
|
||||||
event->accept();
|
|
||||||
m_mousePressedInWindow = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtWindow::populateWindow(QWidget* widget)
|
void QtWindow::populateWindow(QWidget* widget)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,32 +7,26 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include "QtWindowStack.h"
|
#include "QtWindowStack.h"
|
||||||
|
#include "QtWindowBase.h"
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
|
|
||||||
class QtWindow
|
class QtWindow
|
||||||
: public QtWindowStackElement
|
: public QtWindowBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QtWindow(bool isSubWindow, QWidget* parent = nullptr);
|
QtWindow(bool isSubWindow, QWidget* parent = nullptr);
|
||||||
|
|
||||||
QSize sizeHint() const override;
|
|
||||||
|
|
||||||
void setup();
|
void setup();
|
||||||
|
|
||||||
void setSizeGripStyle(bool isBlack);
|
|
||||||
|
|
||||||
void setCancelAble(bool cancelAble);
|
void setCancelAble(bool cancelAble);
|
||||||
void setScrollAble(bool scrollAble);
|
void setScrollAble(bool scrollAble);
|
||||||
|
|
||||||
bool isScrollAble() const;
|
bool isScrollAble() const;
|
||||||
bool isSubWindow() const;
|
|
||||||
|
|
||||||
void moveToCenter();
|
|
||||||
|
|
||||||
void updateTitle(const QString& title);
|
void updateTitle(const QString& title);
|
||||||
std::wstring getTitle() const;
|
std::wstring getTitle() const;
|
||||||
@@ -54,11 +48,6 @@ public:
|
|||||||
void setPreviousDefault(bool isDefault);
|
void setPreviousDefault(bool isDefault);
|
||||||
void setCloseDefault(bool isDefault);
|
void setCloseDefault(bool isDefault);
|
||||||
|
|
||||||
// QtWindowStackElement implementation
|
|
||||||
virtual void showWindow() override;
|
|
||||||
virtual void hideWindow() override;
|
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void finished();
|
void finished();
|
||||||
void canceled();
|
void canceled();
|
||||||
@@ -67,12 +56,9 @@ signals:
|
|||||||
void previous();
|
void previous();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE;
|
void closeEvent(QCloseEvent* event) override;
|
||||||
void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
void mouseMoveEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
|
|
||||||
void mousePressEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
|
|
||||||
void mouseReleaseEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
|
|
||||||
|
|
||||||
virtual void populateWindow(QWidget* widget);
|
virtual void populateWindow(QWidget* widget);
|
||||||
virtual void windowReady();
|
virtual void windowReady();
|
||||||
@@ -85,11 +71,6 @@ protected:
|
|||||||
void addLogo();
|
void addLogo();
|
||||||
QHBoxLayout* createButtons();
|
QHBoxLayout* createButtons();
|
||||||
|
|
||||||
bool m_isSubWindow;
|
|
||||||
|
|
||||||
QWidget* m_window;
|
|
||||||
QWidget* m_content;
|
|
||||||
|
|
||||||
QLabel* m_title;
|
QLabel* m_title;
|
||||||
QLabel* m_subTitle;
|
QLabel* m_subTitle;
|
||||||
|
|
||||||
@@ -107,11 +88,6 @@ private:
|
|||||||
bool m_scrollAble;
|
bool m_scrollAble;
|
||||||
|
|
||||||
bool m_hasLogo;
|
bool m_hasLogo;
|
||||||
|
|
||||||
QPoint m_dragPosition;
|
|
||||||
bool m_mousePressedInWindow;
|
|
||||||
|
|
||||||
QSizeGrip* m_sizeGrip;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QT_WINDOW_H
|
#endif // QT_WINDOW_H
|
||||||
|
|||||||
@@ -0,0 +1,178 @@
|
|||||||
|
#include "QtWindowBase.h"
|
||||||
|
|
||||||
|
#include <QGraphicsDropShadowEffect>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
#include "ApplicationSettings.h"
|
||||||
|
#include "ResourcePaths.h"
|
||||||
|
|
||||||
|
QtWindowBase::QtWindowBase(bool isSubWindow, QWidget* parent)
|
||||||
|
: QtWindowStackElement(parent)
|
||||||
|
, m_isSubWindow(isSubWindow)
|
||||||
|
, m_window(nullptr)
|
||||||
|
, m_content(nullptr)
|
||||||
|
, m_sizeGrip(nullptr)
|
||||||
|
, m_mousePressedInWindow(false)
|
||||||
|
{
|
||||||
|
if (isSubWindow)
|
||||||
|
{
|
||||||
|
setWindowFlags(Qt::SubWindow | Qt::FramelessWindowHint);
|
||||||
|
setAttribute(Qt::WA_TranslucentBackground, true);
|
||||||
|
setFocusPolicy(Qt::StrongFocus);
|
||||||
|
setFocus();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setWindowFlags(Qt::Window);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_window = new QWidget(this);
|
||||||
|
m_window->setObjectName("window");
|
||||||
|
|
||||||
|
QVBoxLayout* layout = new QVBoxLayout(m_window);
|
||||||
|
layout->setSpacing(0);
|
||||||
|
|
||||||
|
m_content = new QWidget();
|
||||||
|
layout->addWidget(m_content);
|
||||||
|
|
||||||
|
if (isSubWindow)
|
||||||
|
{
|
||||||
|
std::string frameStyle =
|
||||||
|
"#window {"
|
||||||
|
" border: 1px solid lightgray;"
|
||||||
|
" border-radius: 15px;"
|
||||||
|
" background: white;"
|
||||||
|
"}";
|
||||||
|
m_window->setStyleSheet(frameStyle.c_str());
|
||||||
|
|
||||||
|
QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect;
|
||||||
|
effect->setBlurRadius(15);
|
||||||
|
effect->setXOffset(0);
|
||||||
|
effect->setYOffset(5);
|
||||||
|
effect->setColor(Qt::darkGray);
|
||||||
|
m_window->setGraphicsEffect(effect);
|
||||||
|
|
||||||
|
QHBoxLayout* gripLayout = new QHBoxLayout();
|
||||||
|
m_sizeGrip = new QSizeGrip(m_window);
|
||||||
|
setSizeGripStyle(true);
|
||||||
|
gripLayout->addWidget(new QWidget());
|
||||||
|
gripLayout->addWidget(m_sizeGrip);
|
||||||
|
layout->addLayout(gripLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
resize(sizeHint());
|
||||||
|
|
||||||
|
moveToCenter();
|
||||||
|
|
||||||
|
this->raise();
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize QtWindowBase::sizeHint() const
|
||||||
|
{
|
||||||
|
return QSize(
|
||||||
|
ApplicationSettings::getInstance()->getWindowBaseWidth(),
|
||||||
|
ApplicationSettings::getInstance()->getWindowBaseHeight()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtWindowBase::setSizeGripStyle(bool isBlack)
|
||||||
|
{
|
||||||
|
if (!m_sizeGrip)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::wstring path = isBlack ? L"size_grip_black.png" : L"size_grip_white.png";
|
||||||
|
|
||||||
|
m_sizeGrip->setStyleSheet(QString::fromStdWString(
|
||||||
|
L"QSizeGrip {"
|
||||||
|
" max-height: 16px;"
|
||||||
|
" max-width: 16px;"
|
||||||
|
" border-image: url(" + ResourcePaths::getGuiPath().wstr() + L"window/" + path + L");"
|
||||||
|
"}"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QtWindowBase::isSubWindow() const
|
||||||
|
{
|
||||||
|
return m_isSubWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtWindowBase::moveToCenter()
|
||||||
|
{
|
||||||
|
if (parentWidget())
|
||||||
|
{
|
||||||
|
if (m_isSubWindow)
|
||||||
|
{
|
||||||
|
move(
|
||||||
|
parentWidget()->width() / 2 - sizeHint().width() / 2,
|
||||||
|
parentWidget()->height() / 2 - sizeHint().height() / 2
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
move(
|
||||||
|
parentWidget()->pos().x() + parentWidget()->width() / 2 - sizeHint().width() / 2,
|
||||||
|
parentWidget()->pos().y() + parentWidget()->height() / 2 - sizeHint().height() / 2
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtWindowBase::showWindow()
|
||||||
|
{
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtWindowBase::hideWindow()
|
||||||
|
{
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtWindowBase::mouseMoveEvent(QMouseEvent* event)
|
||||||
|
{
|
||||||
|
if (event->buttons() & Qt::LeftButton && m_mousePressedInWindow)
|
||||||
|
{
|
||||||
|
if (m_isSubWindow)
|
||||||
|
{
|
||||||
|
QPoint pos = event->globalPos() - m_dragPosition;
|
||||||
|
QRect parentRect = parentWidget()->rect();
|
||||||
|
|
||||||
|
if (pos.x() < parentRect.left())
|
||||||
|
{
|
||||||
|
pos.setX(parentRect.left());
|
||||||
|
}
|
||||||
|
pos.setX(qBound(parentRect.left(), parentRect.right() - width(), pos.x()));
|
||||||
|
pos.setY(qBound(parentRect.top(), parentRect.bottom() - height(), pos.y()));
|
||||||
|
|
||||||
|
move(pos);
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
move(event->globalPos() - m_dragPosition);
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtWindowBase::mousePressEvent(QMouseEvent* event)
|
||||||
|
{
|
||||||
|
if (event->button() == Qt::LeftButton)
|
||||||
|
{
|
||||||
|
m_dragPosition = event->globalPos() - frameGeometry().topLeft();
|
||||||
|
event->accept();
|
||||||
|
m_mousePressedInWindow = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtWindowBase::mouseReleaseEvent(QMouseEvent* event)
|
||||||
|
{
|
||||||
|
if (event->button() == Qt::LeftButton)
|
||||||
|
{
|
||||||
|
m_dragPosition = event->globalPos() - frameGeometry().topLeft();
|
||||||
|
event->accept();
|
||||||
|
m_mousePressedInWindow = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
#ifndef QT_WINDOW_BASE_H
|
||||||
|
#define QT_WINDOW_BASE_H
|
||||||
|
|
||||||
|
#include <QSizeGrip>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "QtWindowStack.h"
|
||||||
|
|
||||||
|
class QLabel;
|
||||||
|
class QPushButton;
|
||||||
|
class QVBoxLayout;
|
||||||
|
class QMouseEvent;
|
||||||
|
|
||||||
|
class QtWindowBase
|
||||||
|
: public QtWindowStackElement
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
QtWindowBase(bool isSubWindow, QWidget* parent);
|
||||||
|
|
||||||
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
|
void setSizeGripStyle(bool isBlack);
|
||||||
|
|
||||||
|
bool isSubWindow() const;
|
||||||
|
|
||||||
|
void moveToCenter();
|
||||||
|
|
||||||
|
// QtWindowStackElement implementation
|
||||||
|
virtual void showWindow() override;
|
||||||
|
virtual void hideWindow() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void mouseMoveEvent(QMouseEvent* event) override;
|
||||||
|
void mousePressEvent(QMouseEvent* event) override;
|
||||||
|
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||||
|
|
||||||
|
bool m_isSubWindow;
|
||||||
|
|
||||||
|
QWidget* m_window;
|
||||||
|
QWidget* m_content;
|
||||||
|
|
||||||
|
QPoint m_dragPosition;
|
||||||
|
bool m_mousePressedInWindow;
|
||||||
|
|
||||||
|
QSizeGrip* m_sizeGrip;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QT_WINDOW_BASE_H
|
||||||
Reference in New Issue
Block a user