ui: Indexing UI
* Added DialogView with QtDialogView implementation to handle information dialogs * Implemented QtIndexingDialog class that covers all different dialogs for indexing * Directly communicate with DialogView from Prpject and all Tasks involved in indexing * Block QtMainWindow UI while indexing
This commit is contained in:
@@ -24,13 +24,14 @@ add_files(
|
||||
qt/element/QtLineEdit.h
|
||||
qt/element/QtLocationPicker.cpp
|
||||
qt/element/QtLocationPicker.h
|
||||
qt/element/QtProgressBar.cpp
|
||||
qt/element/QtProgressBar.h
|
||||
qt/element/QtRefreshBar.cpp
|
||||
qt/element/QtRefreshBar.h
|
||||
qt/element/QtSearchBar.cpp
|
||||
qt/element/QtSearchBar.h
|
||||
qt/element/QtSmartSearchBox.cpp
|
||||
qt/element/QtSmartSearchBox.h
|
||||
|
||||
qt/element/QtStatusBar.cpp
|
||||
qt/element/QtStatusBar.h
|
||||
qt/element/QtUndoRedo.cpp
|
||||
@@ -90,6 +91,8 @@ add_files(
|
||||
qt/view/QtCodeView.h
|
||||
qt/view/QtCompositeView.cpp
|
||||
qt/view/QtCompositeView.h
|
||||
qt/view/QtDialogView.cpp
|
||||
qt/view/QtDialogView.h
|
||||
qt/view/QtGraphView.cpp
|
||||
qt/view/QtGraphView.h
|
||||
qt/view/QtGraphViewStyleImpl.cpp
|
||||
@@ -140,6 +143,8 @@ add_files(
|
||||
qt/window/QtAbout.h
|
||||
qt/window/QtAboutLicense.cpp
|
||||
qt/window/QtAboutLicense.h
|
||||
qt/window/QtIndexingDialog.cpp
|
||||
qt/window/QtIndexingDialog.h
|
||||
qt/window/QtLicense.cpp
|
||||
qt/window/QtLicense.h
|
||||
qt/window/QtMainWindow.cpp
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
#include "qt/element/QtProgressBar.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <QPainter>
|
||||
#include <QPaintEvent>
|
||||
#include <QPixmap>
|
||||
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
QtProgressBar::QtProgressBar(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, m_percent(0)
|
||||
, m_count(0)
|
||||
, m_pixmap((ResourcePaths::getGuiPath() + "indexing_dialog/progress_bar_element.png").c_str())
|
||||
{
|
||||
m_timer = new QTimer(this);
|
||||
connect(m_timer, SIGNAL(timeout()), this, SLOT(animate()));
|
||||
|
||||
m_pixmap.scaleToHeight(20);
|
||||
}
|
||||
|
||||
void QtProgressBar::showProgress(size_t percent)
|
||||
{
|
||||
m_percent = percent;
|
||||
|
||||
stop();
|
||||
show();
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void QtProgressBar::showUnknownProgressAnimated()
|
||||
{
|
||||
start();
|
||||
show();
|
||||
}
|
||||
|
||||
void QtProgressBar::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
if (m_count)
|
||||
{
|
||||
const QPixmap& pixmap = m_pixmap.pixmap();
|
||||
|
||||
for (int x = -36 + (m_count % 36); x < geometry().width(); x += 18)
|
||||
{
|
||||
painter.drawPixmap(QPointF(x, -5), pixmap);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
painter.fillRect(0, 2, geometry().width() * m_percent / 100, 6, "white");
|
||||
}
|
||||
}
|
||||
|
||||
void QtProgressBar::start()
|
||||
{
|
||||
m_timePoint = TimePoint::now();
|
||||
m_timer->start(25);
|
||||
}
|
||||
|
||||
void QtProgressBar::stop()
|
||||
{
|
||||
m_timer->stop();
|
||||
m_count = 0;
|
||||
}
|
||||
|
||||
void QtProgressBar::animate()
|
||||
{
|
||||
TimePoint t = TimePoint::now();
|
||||
size_t dt = t.deltaMS(m_timePoint);
|
||||
|
||||
if (dt < 5)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_timePoint = t;
|
||||
m_count++;
|
||||
|
||||
update();
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#ifndef QT_PROGRESS_BAR_H
|
||||
#define QT_PROGRESS_BAR_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "qt/utility/QtDeviceScaledPixmap.h"
|
||||
#include "utility/TimePoint.h"
|
||||
|
||||
class QTimer;
|
||||
|
||||
class QtProgressBar
|
||||
: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtProgressBar(QWidget* parent = nullptr);
|
||||
|
||||
void showProgress(size_t percent);
|
||||
|
||||
void showUnknownProgressAnimated();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent* event);
|
||||
|
||||
private slots:
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
void animate();
|
||||
|
||||
private:
|
||||
size_t m_percent;
|
||||
|
||||
size_t m_count;
|
||||
QTimer* m_timer;
|
||||
TimePoint m_timePoint;
|
||||
|
||||
QtDeviceScaledPixmap m_pixmap;
|
||||
};
|
||||
|
||||
#endif // QT_PROGRESS_BAR_H
|
||||
@@ -9,6 +9,8 @@
|
||||
QtStatusBar::QtStatusBar()
|
||||
: m_text(this)
|
||||
{
|
||||
addWidget(new QWidget()); // add some space
|
||||
|
||||
QMovie* movie = new QMovie((ResourcePaths::getGuiPath() + "statusbar_view/loader.gif").c_str());
|
||||
// if movie doesn't loop forever, force it to.
|
||||
if (movie->loopCount() != -1)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#ifndef QT_THREADED_FUCTOR_H
|
||||
#define QT_THREADED_FUCTOR_H
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <thread>
|
||||
|
||||
#include <QObject>
|
||||
#include <QSemaphore>
|
||||
@@ -119,4 +121,17 @@ private:
|
||||
std::function<void(void)> m_callback;
|
||||
};
|
||||
|
||||
|
||||
class QtThreadedLambdaFunctor
|
||||
{
|
||||
public:
|
||||
void operator()(std::function<void(void)> callback)
|
||||
{
|
||||
m_helper(callback);
|
||||
}
|
||||
|
||||
private:
|
||||
QtThreadedFunctorHelper m_helper;
|
||||
};
|
||||
|
||||
#endif // QT_THREADED_FUCTOR_H
|
||||
|
||||
@@ -0,0 +1,255 @@
|
||||
#include "qt/view/QtDialogView.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "qt/window/QtIndexingDialog.h"
|
||||
#include "qt/window/QtMainWindow.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
QtDialogView::QtDialogView(QtMainWindow* mainWindow)
|
||||
: m_mainWindow(mainWindow)
|
||||
, m_windowStack(this)
|
||||
{
|
||||
}
|
||||
|
||||
QtDialogView::~QtDialogView()
|
||||
{
|
||||
}
|
||||
|
||||
void QtDialogView::showProgressDialog(const std::string& title, const std::string& message)
|
||||
{
|
||||
MessageStatus(title + ": " + message, false, true).dispatch();
|
||||
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
|
||||
if (!window || window->getType() != QtIndexingDialog::DIALOG_PROGRESS)
|
||||
{
|
||||
m_windowStack.clearWindows();
|
||||
|
||||
window = createWindow<QtIndexingDialog>();
|
||||
window->setupProgress();
|
||||
}
|
||||
|
||||
window->updateTitle(title.c_str());
|
||||
window->updateMessage(message.c_str());
|
||||
|
||||
setUIBlocked(true);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtDialogView::hideProgressDialog()
|
||||
{
|
||||
MessageStatus("", false, false).dispatch();
|
||||
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
|
||||
if (window && window->getType() == QtIndexingDialog::DIALOG_PROGRESS)
|
||||
{
|
||||
m_windowStack.popWindow();
|
||||
}
|
||||
|
||||
setUIBlocked(false);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
bool QtDialogView::startIndexingDialog(size_t cleanFileCount, size_t indexFileCount)
|
||||
{
|
||||
bool result = false;
|
||||
bool done = false;
|
||||
|
||||
m_onQtThread(
|
||||
[=, &result, &done]()
|
||||
{
|
||||
QtIndexingDialog* window = createWindow<QtIndexingDialog>();
|
||||
window->setupStart(cleanFileCount, indexFileCount,
|
||||
[&](bool start)
|
||||
{
|
||||
result = start;
|
||||
done = true;
|
||||
|
||||
setUIBlocked(false);
|
||||
}
|
||||
);
|
||||
|
||||
setUIBlocked(true);
|
||||
}
|
||||
);
|
||||
|
||||
while (!done)
|
||||
{
|
||||
const int SLEEP_TIME_MS = 25;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME_MS));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void QtDialogView::updateIndexingDialog(size_t fileCount, size_t totalFileCount, std::string sourcePath)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "Indexing files: [";
|
||||
ss << fileCount << "/";
|
||||
ss << totalFileCount << "] ";
|
||||
ss << sourcePath;
|
||||
MessageStatus(ss.str(), false, true).dispatch();
|
||||
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
|
||||
if (!window)
|
||||
{
|
||||
m_windowStack.clearWindows();
|
||||
|
||||
window = createWindow<QtIndexingDialog>();
|
||||
window->setupIndexing();
|
||||
}
|
||||
|
||||
if (window && window->getType() == QtIndexingDialog::DIALOG_INDEXING)
|
||||
{
|
||||
window->updateIndexingProgress(fileCount, totalFileCount, sourcePath);
|
||||
setUIBlocked(true);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtDialogView::finishedIndexingDialog(size_t fileCount, size_t totalFileCount, float time, ErrorCountInfo errorInfo)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "Finished indexing: ";
|
||||
ss << fileCount << "/" << totalFileCount << " files; ";
|
||||
ss << utility::timeToString(time);
|
||||
ss << "; " << errorInfo.total << " error" << (errorInfo.total != 1 ? "s" : "");
|
||||
if (errorInfo.fatal > 0)
|
||||
{
|
||||
ss << " (" << errorInfo.fatal << " fatal)";
|
||||
}
|
||||
MessageStatus(ss.str(), false, false).dispatch();
|
||||
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
m_windowStack.clearWindows();
|
||||
|
||||
QtIndexingDialog* window = createWindow<QtIndexingDialog>();
|
||||
window->setupReport(fileCount, totalFileCount, time);
|
||||
window->updateErrorCount(errorInfo.total, errorInfo.fatal);
|
||||
|
||||
setUIBlocked(false);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
int QtDialogView::confirm(const std::string& message, const std::vector<std::string>& options)
|
||||
{
|
||||
int result = -1;
|
||||
bool done = false;
|
||||
|
||||
m_onQtThread(
|
||||
[=, &result, &done]()
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(message.c_str());
|
||||
|
||||
for (const std::string& option : options)
|
||||
{
|
||||
msgBox.addButton(option.c_str(), QMessageBox::AcceptRole);
|
||||
}
|
||||
|
||||
msgBox.exec();
|
||||
|
||||
for (int i = 0; i < msgBox.buttons().size(); i++)
|
||||
{
|
||||
if (msgBox.clickedButton() == msgBox.buttons().at(i))
|
||||
{
|
||||
result = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
done = true;
|
||||
}
|
||||
);
|
||||
|
||||
while (!done)
|
||||
{
|
||||
const int SLEEP_TIME_MS = 25;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME_MS));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void QtDialogView::handleMessage(MessageInterruptTasks* message)
|
||||
{
|
||||
m_onQtThread2(
|
||||
[=]()
|
||||
{
|
||||
QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
|
||||
if (window && window->getType() == QtIndexingDialog::DIALOG_INDEXING)
|
||||
{
|
||||
showProgressDialog("Interrupting Indexing", "Waiting for indexer threads to finish");
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtDialogView::handleMessage(MessageShowErrors* message)
|
||||
{
|
||||
ErrorCountInfo errorInfo = message->errorCount;
|
||||
|
||||
m_onQtThread2(
|
||||
[=]()
|
||||
{
|
||||
updateErrorCount(errorInfo.total, errorInfo.fatal);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtDialogView::updateErrorCount(size_t errorCount, size_t fatalCount)
|
||||
{
|
||||
QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
|
||||
if (window)
|
||||
{
|
||||
window->updateErrorCount(errorCount, fatalCount);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T* QtDialogView::createWindow()
|
||||
{
|
||||
T* window = new T(m_mainWindow);
|
||||
|
||||
connect(window, SIGNAL(canceled()), &m_windowStack, SLOT(popWindow()));
|
||||
connect(window, SIGNAL(finished()), &m_windowStack, SLOT(clearWindows()));
|
||||
|
||||
m_windowStack.pushWindow(window);
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
void QtDialogView::setUIBlocked(bool blocked)
|
||||
{
|
||||
m_mainWindow->setEnabled(!blocked);
|
||||
|
||||
if (blocked)
|
||||
{
|
||||
QWidget* window = m_windowStack.getTopWindow();
|
||||
if (window)
|
||||
{
|
||||
window->setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef QT_DIALOG_VIEW_H
|
||||
#define QT_DIALOG_VIEW_H
|
||||
|
||||
#include "component/view/DialogView.h"
|
||||
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
#include "qt/window/QtWindowStack.h"
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageInterruptTasks.h"
|
||||
#include "utility/messaging/type/MessageShowErrors.h"
|
||||
|
||||
class QtMainWindow;
|
||||
|
||||
class QtDialogView
|
||||
: public QObject
|
||||
, public DialogView
|
||||
, public MessageListener<MessageInterruptTasks>
|
||||
, public MessageListener<MessageShowErrors>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtDialogView(QtMainWindow* mainWindow);
|
||||
virtual ~QtDialogView();
|
||||
|
||||
void showProgressDialog(const std::string& title, const std::string& message) override;
|
||||
void hideProgressDialog() override;
|
||||
|
||||
bool startIndexingDialog(size_t cleanFileCount, size_t indexFileCount) override;
|
||||
void updateIndexingDialog(size_t fileCount, size_t totalFileCount, std::string sourcePath) override;
|
||||
void finishedIndexingDialog(size_t fileCount, size_t totalFileCount, float time, ErrorCountInfo errorInfo) override;
|
||||
|
||||
int confirm(const std::string& message, const std::vector<std::string>& options) override;
|
||||
|
||||
private:
|
||||
void handleMessage(MessageInterruptTasks* message) override;
|
||||
void handleMessage(MessageShowErrors* message) override;
|
||||
|
||||
void updateErrorCount(size_t errorCount, size_t fatalCount);
|
||||
|
||||
template<typename T>
|
||||
T* createWindow();
|
||||
|
||||
void setUIBlocked(bool blocked);
|
||||
|
||||
QtMainWindow* m_mainWindow;
|
||||
|
||||
QtWindowStack m_windowStack;
|
||||
|
||||
QtThreadedLambdaFunctor m_onQtThread;
|
||||
QtThreadedLambdaFunctor m_onQtThread2;
|
||||
};
|
||||
|
||||
#endif // QT_DIALOG_VIEW_H
|
||||
@@ -1,12 +1,5 @@
|
||||
#include "qt/view/QtMainView.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
#include "qt/window/QtMainWindow.h"
|
||||
|
||||
QtMainView::QtMainView()
|
||||
@@ -18,7 +11,6 @@ QtMainView::QtMainView()
|
||||
, m_activateWindowFunctor(std::bind(&QtMainView::doActivateWindow, this))
|
||||
, m_updateRecentProjectMenuFunctor(std::bind(&QtMainView::doUpdateRecentProjectMenu, this))
|
||||
, m_forceLicenseScreenFunctor(std::bind(&QtMainView::doForceLicenseScreen, this, std::placeholders::_1))
|
||||
, m_confirmFunctor(std::bind(&QtMainView::doConfirm, this, std::placeholders::_1, std::placeholders::_2))
|
||||
{
|
||||
m_window = std::make_shared<QtMainWindow>();
|
||||
m_window->show();
|
||||
@@ -28,6 +20,11 @@ QtMainView::~QtMainView()
|
||||
{
|
||||
}
|
||||
|
||||
QtMainWindow* QtMainView::getMainWindow() const
|
||||
{
|
||||
return m_window.get();
|
||||
}
|
||||
|
||||
void QtMainView::addView(View* view)
|
||||
{
|
||||
m_views.push_back(view);
|
||||
@@ -96,30 +93,6 @@ void QtMainView::updateRecentProjectMenu()
|
||||
m_updateRecentProjectMenuFunctor();
|
||||
}
|
||||
|
||||
int QtMainView::confirm(const std::string& message, const std::vector<std::string>& options)
|
||||
{
|
||||
m_confirmDone = false;
|
||||
|
||||
m_confirmFunctor(message, options);
|
||||
|
||||
while (true)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_confirmMutex);
|
||||
|
||||
if (m_confirmDone)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const int SLEEP_TIME_MS = 25;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME_MS));
|
||||
}
|
||||
|
||||
return m_confirmResult;
|
||||
}
|
||||
|
||||
void QtMainView::handleMessage(MessageForceEnterLicense* message)
|
||||
{
|
||||
m_forceLicenseScreenFunctor(message->licenseExpired);
|
||||
@@ -185,30 +158,3 @@ void QtMainView::doForceLicenseScreen(bool expired)
|
||||
{
|
||||
m_window->forceEnterLicense(expired);
|
||||
}
|
||||
|
||||
void QtMainView::doConfirm(const std::string& message, const std::vector<std::string>& options)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(message.c_str());
|
||||
|
||||
for (const std::string& option : options)
|
||||
{
|
||||
msgBox.addButton(option.c_str(), QMessageBox::AcceptRole);
|
||||
}
|
||||
|
||||
msgBox.exec();
|
||||
|
||||
m_confirmResult = -1;
|
||||
|
||||
for (int i = 0; i < msgBox.buttons().size(); i++)
|
||||
{
|
||||
if (msgBox.clickedButton() == msgBox.buttons().at(i))
|
||||
{
|
||||
m_confirmResult = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(m_confirmMutex);
|
||||
m_confirmDone = true;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ public:
|
||||
QtMainView();
|
||||
virtual ~QtMainView();
|
||||
|
||||
QtMainWindow* getMainWindow() const;
|
||||
|
||||
// ViewLayout implementation
|
||||
virtual void addView(View* view);
|
||||
virtual void removeView(View* view);
|
||||
@@ -48,8 +50,6 @@ public:
|
||||
virtual void activateWindow();
|
||||
virtual void updateRecentProjectMenu();
|
||||
|
||||
virtual int confirm(const std::string& message, const std::vector<std::string>& options);
|
||||
|
||||
private:
|
||||
void handleMessage(MessageForceEnterLicense* message);
|
||||
void handleMessage(MessageProjectEdit* message);
|
||||
@@ -65,8 +65,6 @@ private:
|
||||
void doUpdateRecentProjectMenu();
|
||||
void doForceLicenseScreen(bool expired);
|
||||
|
||||
void doConfirm(const std::string& message, const std::vector<std::string>& options);
|
||||
|
||||
std::shared_ptr<QtMainWindow> m_window;
|
||||
std::vector<View*> m_views;
|
||||
|
||||
@@ -78,11 +76,6 @@ private:
|
||||
QtThreadedFunctor<> m_activateWindowFunctor;
|
||||
QtThreadedFunctor<> m_updateRecentProjectMenuFunctor;
|
||||
QtThreadedFunctor<bool> m_forceLicenseScreenFunctor;
|
||||
|
||||
QtThreadedFunctor<const std::string&, const std::vector<std::string>&> m_confirmFunctor;
|
||||
std::mutex m_confirmMutex;
|
||||
bool m_confirmDone;
|
||||
int m_confirmResult;
|
||||
};
|
||||
|
||||
#endif // QT_MAIN_VIEW_H
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "component/view/GraphViewStyle.h"
|
||||
#include "qt/view/QtCodeView.h"
|
||||
#include "qt/view/QtCompositeView.h"
|
||||
#include "qt/view/QtDialogView.h"
|
||||
#include "qt/view/QtGraphView.h"
|
||||
#include "qt/view/QtGraphViewStyleImpl.h"
|
||||
#include "qt/view/QtMainView.h"
|
||||
@@ -63,3 +64,8 @@ std::shared_ptr<UndoRedoView> QtViewFactory::createUndoRedoView(ViewLayout* view
|
||||
{
|
||||
return View::createInitAndAddToLayout<QtUndoRedoView>(viewLayout);
|
||||
}
|
||||
|
||||
std::shared_ptr<DialogView> QtViewFactory::createDialogView(ViewLayout* viewLayout) const
|
||||
{
|
||||
return std::make_shared<QtDialogView>(dynamic_cast<QtMainView*>(viewLayout)->getMainWindow());
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ public:
|
||||
virtual std::shared_ptr<SearchView> createSearchView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<StatusBarView> createStatusBarView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<UndoRedoView> createUndoRedoView(ViewLayout* viewLayout) const;
|
||||
|
||||
virtual std::shared_ptr<DialogView> createDialogView(ViewLayout* viewLayout) const;
|
||||
};
|
||||
|
||||
#endif // QT_VIEW_FACTORY_H
|
||||
|
||||
@@ -0,0 +1,397 @@
|
||||
#include "qt/window/QtIndexingDialog.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QTimer>
|
||||
#include <QPainter>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "qt/element/QtProgressBar.h"
|
||||
#include "utility/messaging/type/MessageInterruptTasks.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
QtIndexingDialog::QtIndexingDialog(QWidget* parent)
|
||||
: QtWindow(parent)
|
||||
, m_type(DIALOG_MESSAGE)
|
||||
, m_top(nullptr)
|
||||
, m_topRatio(0)
|
||||
, m_progressBar(nullptr)
|
||||
, m_percentLabel(nullptr)
|
||||
, m_messageLabel(nullptr)
|
||||
, m_filePathLabel(nullptr)
|
||||
, m_errorLabel(nullptr)
|
||||
, m_sizeHint(QSize(450, 450))
|
||||
, m_callback([](bool){})
|
||||
{
|
||||
// setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||
}
|
||||
|
||||
QSize QtIndexingDialog::sizeHint() const
|
||||
{
|
||||
return m_sizeHint;
|
||||
}
|
||||
|
||||
QtIndexingDialog::DialogType QtIndexingDialog::getType() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
void QtIndexingDialog::setupStart(size_t cleanFileCount, size_t indexFileCount, std::function<void(bool)> callback)
|
||||
{
|
||||
QBoxLayout* layout = createLayout();
|
||||
|
||||
addTitle("Start Indexing", layout);
|
||||
layout->addSpacing(5);
|
||||
|
||||
if (cleanFileCount)
|
||||
{
|
||||
QLabel* cleanLabel = new QLabel("Clear: " + QString::number(cleanFileCount) + " File" + (cleanFileCount > 1 ? "s" : ""));
|
||||
cleanLabel->setObjectName("message");
|
||||
cleanLabel->setAlignment(Qt::AlignRight);
|
||||
layout->addWidget(cleanLabel, 0, Qt::AlignRight);
|
||||
}
|
||||
|
||||
addMessageLabel(layout);
|
||||
updateMessage("Index: " + QString::number(indexFileCount) + " File" + (indexFileCount > 1 ? "s" : ""));
|
||||
|
||||
layout->addStretch();
|
||||
|
||||
addButtons(layout);
|
||||
updateNextButton("Start");
|
||||
updateCloseButton("Cancel");
|
||||
|
||||
m_sizeHint = QSize(350, 250);
|
||||
m_callback = callback;
|
||||
|
||||
finishSetup();
|
||||
}
|
||||
|
||||
void QtIndexingDialog::setupProgress()
|
||||
{
|
||||
setType(DIALOG_PROGRESS);
|
||||
|
||||
QBoxLayout* layout = createLayout();
|
||||
|
||||
addTopAndProgressBar(0.5);
|
||||
addTitle("Clearing", layout);
|
||||
addMessageLabel(layout);
|
||||
|
||||
layout->addStretch();
|
||||
|
||||
m_sizeHint = QSize(350, 350);
|
||||
|
||||
m_progressBar->showUnknownProgressAnimated();
|
||||
|
||||
setCancelAble(false);
|
||||
|
||||
finishSetup();
|
||||
}
|
||||
|
||||
void QtIndexingDialog::setupIndexing()
|
||||
{
|
||||
setType(DIALOG_INDEXING);
|
||||
|
||||
QBoxLayout* layout = createLayout();
|
||||
|
||||
addTopAndProgressBar(0.38);
|
||||
addTitle("Indexing Files", layout);
|
||||
|
||||
addPercentLabel(layout);
|
||||
addMessageLabel(layout);
|
||||
addFilePathLabel(layout);
|
||||
|
||||
layout->addSpacing(12);
|
||||
addErrorLabel(layout);
|
||||
|
||||
layout->addStretch();
|
||||
|
||||
addButtons(layout);
|
||||
setNextVisible(false);
|
||||
updateCloseButton("Stop");
|
||||
|
||||
m_sizeHint = QSize(350, 350);
|
||||
|
||||
finishSetup();
|
||||
}
|
||||
|
||||
void QtIndexingDialog::setupReport(size_t fileCount, size_t totalFileCount, float time)
|
||||
{
|
||||
QBoxLayout* layout = createLayout();
|
||||
|
||||
addTitle("Finished Indexing", layout);
|
||||
layout->addSpacing(5);
|
||||
|
||||
addMessageLabel(layout);
|
||||
updateMessage(
|
||||
QString::number(fileCount) + "/" + QString::number(totalFileCount) + " File" + (totalFileCount > 1 ? "s" : "")
|
||||
);
|
||||
|
||||
QLabel* timeLabel = new QLabel("Total Time: " + QString::fromStdString(utility::timeToString(time)));
|
||||
timeLabel->setObjectName("message");
|
||||
timeLabel->setAlignment(Qt::AlignRight);
|
||||
layout->addWidget(timeLabel, 0, Qt::AlignRight);
|
||||
|
||||
layout->addSpacing(12);
|
||||
addErrorLabel(layout);
|
||||
|
||||
layout->addStretch();
|
||||
|
||||
addButtons(layout);
|
||||
updateNextButton("OK");
|
||||
setCloseVisible(false);
|
||||
|
||||
m_sizeHint = QSize(400, 260);
|
||||
|
||||
if (fileCount != totalFileCount)
|
||||
{
|
||||
updateTitle("Interrupted Indexing");
|
||||
}
|
||||
else
|
||||
{
|
||||
addFlag();
|
||||
}
|
||||
|
||||
finishSetup();
|
||||
}
|
||||
|
||||
void QtIndexingDialog::updateMessage(QString message)
|
||||
{
|
||||
if (m_messageLabel)
|
||||
{
|
||||
m_messageLabel->setText(message);
|
||||
}
|
||||
}
|
||||
|
||||
void QtIndexingDialog::updateIndexingProgress(size_t fileCount, size_t totalFileCount, std::string sourcePath)
|
||||
{
|
||||
updateMessage(QString::number(fileCount) + "/" + QString::number(totalFileCount) + " File" + (totalFileCount > 1 ? "s" : ""));
|
||||
|
||||
if (fileCount > 0)
|
||||
{
|
||||
fileCount--;
|
||||
}
|
||||
|
||||
size_t percent = fileCount * 100 / totalFileCount;
|
||||
m_progressBar->showProgress(percent);
|
||||
m_percentLabel->setText(QString::number(percent) + "% Progress");
|
||||
m_sourcePath = QString::fromStdString(sourcePath);
|
||||
setGeometries();
|
||||
}
|
||||
|
||||
void QtIndexingDialog::updateErrorCount(size_t errorCount, size_t fatalCount)
|
||||
{
|
||||
if (m_errorLabel && errorCount)
|
||||
{
|
||||
QString str = QString::number(errorCount) + " Error";
|
||||
if (errorCount > 1)
|
||||
{
|
||||
str += "s";
|
||||
}
|
||||
|
||||
if (fatalCount)
|
||||
{
|
||||
str += " (" + QString::number(fatalCount) + " Fatal)";
|
||||
}
|
||||
|
||||
m_errorLabel->setText(str);
|
||||
m_errorLabel->show();
|
||||
}
|
||||
}
|
||||
|
||||
void QtIndexingDialog::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
QtWindow::resizeEvent(event);
|
||||
|
||||
setGeometries();
|
||||
}
|
||||
|
||||
void QtIndexingDialog::handleNext()
|
||||
{
|
||||
if (m_type == DIALOG_MESSAGE)
|
||||
{
|
||||
m_callback(true);
|
||||
}
|
||||
|
||||
QtWindow::handleNext();
|
||||
}
|
||||
|
||||
void QtIndexingDialog::handleClose()
|
||||
{
|
||||
if (m_type == DIALOG_MESSAGE)
|
||||
{
|
||||
m_callback(false);
|
||||
}
|
||||
|
||||
if (m_type == DIALOG_INDEXING)
|
||||
{
|
||||
MessageInterruptTasks().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() + "window/window.css") +
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath() + "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, m_window->size().width(), m_window->size().height() * topRatio);
|
||||
m_top->show();
|
||||
m_top->lower();
|
||||
|
||||
m_progressBar = new QtProgressBar(m_window);
|
||||
m_progressBar->setGeometry(0, m_window->size().height() * topRatio - 5, m_window->size().width(), 10);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
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 = new QLabel();
|
||||
m_messageLabel->setObjectName("message");
|
||||
m_messageLabel->setAlignment(Qt::AlignRight);
|
||||
layout->addWidget(m_messageLabel, 0, Qt::AlignRight);
|
||||
}
|
||||
|
||||
void QtIndexingDialog::addFilePathLabel(QBoxLayout* layout)
|
||||
{
|
||||
m_filePathLabel = new QLabel();
|
||||
m_filePathLabel->setObjectName("filePath");
|
||||
m_filePathLabel->setAlignment(Qt::AlignRight);
|
||||
layout->addWidget(m_filePathLabel);
|
||||
}
|
||||
|
||||
void QtIndexingDialog::addErrorLabel(QBoxLayout* layout)
|
||||
{
|
||||
m_errorLabel = new QPushButton();
|
||||
m_errorLabel->setObjectName("errorCount");
|
||||
m_errorLabel->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
|
||||
std::string text = ResourcePaths::getGuiPath() + "indexing_dialog/error.png";
|
||||
m_errorLabel->setIcon(QPixmap(text.c_str()));
|
||||
|
||||
layout->addWidget(m_errorLabel, 0, Qt::AlignRight);
|
||||
m_errorLabel->hide();
|
||||
}
|
||||
|
||||
void QtIndexingDialog::addButtons(QBoxLayout* layout)
|
||||
{
|
||||
m_nextButton = new QPushButton("Next");
|
||||
m_nextButton->setObjectName("windowButton");
|
||||
connect(m_nextButton, SIGNAL(clicked()), this, SLOT(handleNextPress()));
|
||||
|
||||
m_closeButton = new QPushButton("Cancel");
|
||||
m_closeButton->setObjectName("windowButton");
|
||||
connect(m_closeButton, SIGNAL(clicked()), this, SLOT(handleClosePress()));
|
||||
|
||||
QHBoxLayout* buttons = new QHBoxLayout();
|
||||
buttons->addWidget(m_closeButton);
|
||||
buttons->addStretch();
|
||||
buttons->addWidget(m_nextButton);
|
||||
|
||||
layout->addLayout(buttons);
|
||||
|
||||
setNextDefault(true);
|
||||
}
|
||||
|
||||
void QtIndexingDialog::addFlag()
|
||||
{
|
||||
QtDeviceScaledPixmap flag((ResourcePaths::getGuiPath() + "indexing_dialog/flag.png").c_str());
|
||||
flag.scaleToWidth(120);
|
||||
|
||||
QLabel* flagLabel = new QLabel(this);
|
||||
flagLabel->setPixmap(flag.pixmap());
|
||||
flagLabel->resize(flag.width(), flag.height());
|
||||
flagLabel->move(15, 75);
|
||||
flagLabel->show();
|
||||
}
|
||||
|
||||
void QtIndexingDialog::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(
|
||||
margins.left(),
|
||||
m_window->size().height() * m_topRatio - 50,
|
||||
m_window->size().width() - margins.left() - margins.right(),
|
||||
40
|
||||
);
|
||||
}
|
||||
|
||||
if (m_progressBar)
|
||||
{
|
||||
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()
|
||||
{
|
||||
setGeometries();
|
||||
|
||||
setupDone();
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
#ifndef QT_INDEXING_WIZARD_WINDOW_H
|
||||
#define QT_INDEXING_WIZARD_WINDOW_H
|
||||
|
||||
#include "qt/window/QtWindow.h"
|
||||
|
||||
class QLabel;
|
||||
class QtProgressBar;
|
||||
|
||||
class QtIndexingDialog
|
||||
: public QtWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum DialogType
|
||||
{
|
||||
DIALOG_MESSAGE,
|
||||
DIALOG_PROGRESS,
|
||||
DIALOG_INDEXING
|
||||
};
|
||||
|
||||
QtIndexingDialog(QWidget* parent = 0);
|
||||
QSize sizeHint() const override;
|
||||
|
||||
DialogType getType() const;
|
||||
|
||||
void setupStart(size_t cleanFileCount, size_t indexFileCount, std::function<void(bool)> callback);
|
||||
void setupProgress();
|
||||
void setupIndexing();
|
||||
void setupReport(size_t fileCount, size_t totalFileCount, float time);
|
||||
|
||||
void updateMessage(QString message);
|
||||
void updateIndexingProgress(size_t fileCount, size_t totalFileCount, std::string sourcePath);
|
||||
void updateErrorCount(size_t errorCount, size_t fatalCount);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
|
||||
|
||||
virtual void handleNext() override;
|
||||
virtual void handleClose() override;
|
||||
|
||||
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);
|
||||
void addFilePathLabel(QBoxLayout* layout);
|
||||
void addErrorLabel(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;
|
||||
QPushButton* m_errorLabel;
|
||||
|
||||
QSize m_sizeHint;
|
||||
|
||||
std::function<void(bool)> m_callback;
|
||||
QString m_sourcePath;
|
||||
};
|
||||
|
||||
#endif // QT_INDEXING_WIZARD_WINDOW_H
|
||||
@@ -287,7 +287,7 @@ void QtMainWindow::forceEnterLicense(bool expired)
|
||||
|
||||
bool QtMainWindow::event(QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::WindowActivate)
|
||||
if (isEnabled() && event->type() == QEvent::WindowActivate)
|
||||
{
|
||||
MessageWindowFocus().dispatch();
|
||||
}
|
||||
@@ -499,6 +499,34 @@ void QtMainWindow::resetZoom()
|
||||
MessageResetZoom().dispatch();
|
||||
}
|
||||
|
||||
void QtMainWindow::openRecentProject()
|
||||
{
|
||||
QAction *action = qobject_cast<QAction *>(sender());
|
||||
if (action)
|
||||
{
|
||||
openProject(action->data().toString());
|
||||
}
|
||||
}
|
||||
|
||||
void QtMainWindow::updateRecentProjectMenu()
|
||||
{
|
||||
std::vector<FilePath> recentProjects = ApplicationSettings::getInstance()->getRecentProjects();
|
||||
for (int i = 0; i < ApplicationSettings::getInstance()->getMaxRecentProjectsCount(); i++)
|
||||
{
|
||||
if ((size_t)i < recentProjects.size() && recentProjects[i].exists())
|
||||
{
|
||||
FilePath project = recentProjects[i];
|
||||
m_recentProjectAction[i]->setVisible(true);
|
||||
m_recentProjectAction[i]->setText(FileSystem::fileName(project.str()).c_str());
|
||||
m_recentProjectAction[i]->setData(project.str().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_recentProjectAction[i]->setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QtMainWindow::toggleView(View* view, bool fromMenu)
|
||||
{
|
||||
DockWidget* dock = getDockWidgetForView(view);
|
||||
@@ -513,6 +541,11 @@ void QtMainWindow::toggleView(View* view, bool fromMenu)
|
||||
}
|
||||
}
|
||||
|
||||
void QtMainWindow::toggleShowDockWidgetTitleBars()
|
||||
{
|
||||
setShowDockWidgetTitleBars(!m_showDockWidgetTitleBars);
|
||||
}
|
||||
|
||||
void QtMainWindow::setupProjectMenu()
|
||||
{
|
||||
QMenu *menu = new QMenu(tr("&Project"), this);
|
||||
@@ -551,39 +584,6 @@ void QtMainWindow::setupProjectMenu()
|
||||
menu->addAction(tr("E&xit"), QCoreApplication::instance(), SLOT(quit()), QKeySequence::Quit);
|
||||
}
|
||||
|
||||
void QtMainWindow::openRecentProject()
|
||||
{
|
||||
QAction *action = qobject_cast<QAction *>(sender());
|
||||
if (action)
|
||||
{
|
||||
openProject(action->data().toString());
|
||||
}
|
||||
}
|
||||
|
||||
void QtMainWindow::updateRecentProjectMenu()
|
||||
{
|
||||
std::vector<FilePath> recentProjects = ApplicationSettings::getInstance()->getRecentProjects();
|
||||
for (int i = 0; i < ApplicationSettings::getInstance()->getMaxRecentProjectsCount(); i++)
|
||||
{
|
||||
if ((size_t)i < recentProjects.size() && recentProjects[i].exists())
|
||||
{
|
||||
FilePath project = recentProjects[i];
|
||||
m_recentProjectAction[i]->setVisible(true);
|
||||
m_recentProjectAction[i]->setText(FileSystem::fileName(project.str()).c_str());
|
||||
m_recentProjectAction[i]->setData(project.str().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_recentProjectAction[i]->setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QtMainWindow::toggleShowDockWidgetTitleBars()
|
||||
{
|
||||
setShowDockWidgetTitleBars(!m_showDockWidgetTitleBars);
|
||||
}
|
||||
|
||||
void QtMainWindow::setupEditMenu()
|
||||
{
|
||||
QMenu *menu = new QMenu(tr("&Edit"), this);
|
||||
|
||||
@@ -47,6 +47,7 @@ private:
|
||||
size_t m_forwardButton;
|
||||
};
|
||||
|
||||
|
||||
class MouseWheelFilter
|
||||
: public QObject
|
||||
{
|
||||
@@ -111,7 +112,6 @@ public slots:
|
||||
void newProjectFromSolution(const std::string& ideId, const std::string& solutionPath);
|
||||
void openProject(const QString &path = QString());
|
||||
void editProject();
|
||||
void openRecentProject();
|
||||
|
||||
void find();
|
||||
void findFulltext();
|
||||
@@ -129,10 +129,11 @@ public slots:
|
||||
void zoomOut();
|
||||
void resetZoom();
|
||||
|
||||
void toggleView(View* view, bool fromMenu);
|
||||
|
||||
void openRecentProject();
|
||||
void updateRecentProjectMenu();
|
||||
|
||||
void toggleView(View* view, bool fromMenu);
|
||||
|
||||
private slots:
|
||||
void toggleShowDockWidgetTitleBars();
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ QtWindow::QtWindow(QWidget* parent)
|
||||
, m_closeButton(nullptr)
|
||||
, m_cancelAble(true)
|
||||
, m_scrollAble(false)
|
||||
, m_showAsPopup(false)
|
||||
, m_hasLogo(false)
|
||||
, m_mousePressedInWindow(false)
|
||||
{
|
||||
@@ -84,6 +83,7 @@ QSize QtWindow::sizeHint() const
|
||||
void QtWindow::setup()
|
||||
{
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "window/window.css").c_str());
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
layout->setContentsMargins(25, 30, 25, 0);
|
||||
|
||||
@@ -140,13 +140,6 @@ void QtWindow::setup()
|
||||
|
||||
m_content->setLayout(layout);
|
||||
|
||||
if (m_showAsPopup)
|
||||
{
|
||||
updateNextButton("Ok");
|
||||
setCloseVisible(false);
|
||||
setPreviousVisible(false);
|
||||
}
|
||||
|
||||
setupDone();
|
||||
}
|
||||
|
||||
@@ -162,21 +155,11 @@ void QtWindow::setScrollAble(bool scrollAble)
|
||||
m_scrollAble = scrollAble;
|
||||
}
|
||||
|
||||
void QtWindow::setShowAsPopup(bool showAsPopup)
|
||||
{
|
||||
m_showAsPopup = showAsPopup;
|
||||
}
|
||||
|
||||
bool QtWindow::isScrollAble() const
|
||||
{
|
||||
return m_scrollAble;
|
||||
}
|
||||
|
||||
bool QtWindow::isPopup() const
|
||||
{
|
||||
return m_showAsPopup;
|
||||
}
|
||||
|
||||
void QtWindow::updateTitle(QString title)
|
||||
{
|
||||
if (m_title)
|
||||
@@ -249,6 +232,30 @@ void QtWindow::setCloseVisible(bool visible)
|
||||
}
|
||||
}
|
||||
|
||||
void QtWindow::setNextDefault(bool isDefault)
|
||||
{
|
||||
if (m_nextButton)
|
||||
{
|
||||
m_nextButton->setDefault(isDefault);
|
||||
}
|
||||
}
|
||||
|
||||
void QtWindow::setPreviousDefault(bool isDefault)
|
||||
{
|
||||
if (m_previousButton)
|
||||
{
|
||||
m_previousButton->setDefault(isDefault);
|
||||
}
|
||||
}
|
||||
|
||||
void QtWindow::setCloseDefault(bool isDefault)
|
||||
{
|
||||
if (m_closeButton)
|
||||
{
|
||||
m_closeButton->setDefault(isDefault);
|
||||
}
|
||||
}
|
||||
|
||||
void QtWindow::showWindow()
|
||||
{
|
||||
show();
|
||||
@@ -289,14 +296,50 @@ void QtWindow::resizeEvent(QResizeEvent *event)
|
||||
m_window->move(5, displacement + 10);
|
||||
}
|
||||
|
||||
void QtWindow::keyPressEvent(QKeyEvent *event)
|
||||
void QtWindow::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
if (m_cancelAble && event->key() == Qt::Key_Escape)
|
||||
{
|
||||
emit canceled();
|
||||
handleClose();
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<QPushButton*> buttons;
|
||||
if (m_nextButton && m_nextButton->isVisible()) buttons.push_back(m_nextButton);
|
||||
if (m_closeButton && m_closeButton->isVisible()) buttons.push_back(m_closeButton);
|
||||
if (m_previousButton && m_previousButton->isVisible()) buttons.push_back(m_previousButton);
|
||||
|
||||
if (event->key() == Qt::Key_Return)
|
||||
{
|
||||
for (QPushButton* button : buttons)
|
||||
{
|
||||
if (button->isDefault())
|
||||
{
|
||||
button->animateClick();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event->key() == Qt::Key_Tab)
|
||||
{
|
||||
for (size_t i = 0; i < buttons.size(); i++)
|
||||
{
|
||||
if (buttons[i]->isDefault())
|
||||
{
|
||||
buttons[i]->setDefault(false);
|
||||
buttons[(i + 1) % buttons.size()]->setDefault(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (buttons.size())
|
||||
{
|
||||
buttons[0]->setDefault(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,10 +26,8 @@ public:
|
||||
|
||||
void setCancelAble(bool cancelAble);
|
||||
void setScrollAble(bool scrollAble);
|
||||
void setShowAsPopup(bool showAsPopup);
|
||||
|
||||
bool isScrollAble() const;
|
||||
bool isPopup() const;
|
||||
|
||||
void updateTitle(QString title);
|
||||
void updateNextButton(QString text);
|
||||
@@ -43,10 +41,15 @@ public:
|
||||
void setPreviousVisible(bool visible);
|
||||
void setCloseVisible(bool visible);
|
||||
|
||||
void setNextDefault(bool isDefault);
|
||||
void setPreviousDefault(bool isDefault);
|
||||
void setCloseDefault(bool isDefault);
|
||||
|
||||
// QtWindowStackElement implementation
|
||||
virtual void showWindow() override;
|
||||
virtual void hideWindow() override;
|
||||
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
void canceled();
|
||||
@@ -88,7 +91,6 @@ private slots:
|
||||
private:
|
||||
bool m_cancelAble;
|
||||
bool m_scrollAble;
|
||||
bool m_showAsPopup;
|
||||
|
||||
bool m_hasLogo;
|
||||
|
||||
|
||||
@@ -47,8 +47,6 @@ private:
|
||||
QtProjectWizzardWindow* createWindowWithSummary(
|
||||
std::function<void(QtProjectWizzardWindow*, QtProjectWizzardContentSummary*)> func);
|
||||
|
||||
void connectShowFiles(QtProjectWizzardContent* content);
|
||||
|
||||
QtWindowStack m_windowStack;
|
||||
|
||||
std::shared_ptr<ProjectSettings> m_settings;
|
||||
|
||||
@@ -72,12 +72,6 @@ void QtProjectWizzardWindow::windowReady()
|
||||
|
||||
void QtProjectWizzardWindow::handleNext()
|
||||
{
|
||||
if (isPopup())
|
||||
{
|
||||
hide();
|
||||
emit next();
|
||||
}
|
||||
|
||||
m_content->save();
|
||||
|
||||
if (m_content->check())
|
||||
|
||||
Reference in New Issue
Block a user