data: Option to run only C/C++ preprocessor when indexing (issue 297)
* Added as checkbox to indexing start dialog * Only shown for C/C++ projects * Files will be marked incomplete
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#include "qt/element/QtHelpButton.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
QtHelpButton::QtHelpButton(const QString& helpText, QWidget* parent)
|
||||
: QtIconButton(
|
||||
(ResourcePaths::getGuiPath() + "window/help.png").c_str(),
|
||||
(ResourcePaths::getGuiPath() + "window/help_hover.png").c_str(),
|
||||
parent)
|
||||
, m_helpText(helpText)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
setMouseTracking(true);
|
||||
|
||||
setToolTip("help");
|
||||
|
||||
leaveEvent(nullptr);
|
||||
|
||||
connect(this, SIGNAL(clicked()), this, SLOT(handleHelpPress()));
|
||||
}
|
||||
|
||||
void QtHelpButton::handleHelpPress()
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("Help");
|
||||
msgBox.setInformativeText(m_helpText);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.exec();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef QT_HELP_BUTTON_H
|
||||
#define QT_HELP_BUTTON_H
|
||||
|
||||
#include "qt/element/QtIconButton.h"
|
||||
|
||||
class QtHelpButton
|
||||
: public QtIconButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtHelpButton(const QString& helpText, QWidget* parent = nullptr);
|
||||
|
||||
private slots:
|
||||
void handleHelpPress();
|
||||
|
||||
private:
|
||||
QString m_helpText;
|
||||
};
|
||||
|
||||
#endif // QT_HELP_BUTTON_H
|
||||
@@ -1,9 +1,12 @@
|
||||
#include "qt/element/QtIconButton.h"
|
||||
|
||||
#include "qt/utility/utilityQt.h"
|
||||
|
||||
QtIconButton::QtIconButton(QString iconPath, QString hoveredIconPath, QWidget* parent)
|
||||
: QPushButton("", parent)
|
||||
, m_iconPath(iconPath)
|
||||
, m_hoveredIconPath(hoveredIconPath)
|
||||
, m_color(Qt::transparent)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
@@ -14,11 +17,17 @@ QtIconButton::QtIconButton(QString iconPath, QString hoveredIconPath, QWidget* p
|
||||
leaveEvent(nullptr);
|
||||
}
|
||||
|
||||
void QtIconButton::setColor(QColor color)
|
||||
{
|
||||
m_color = color;
|
||||
leaveEvent(nullptr);
|
||||
}
|
||||
|
||||
void QtIconButton::enterEvent(QEvent *event)
|
||||
{
|
||||
if (m_hoveredIconPath.size())
|
||||
{
|
||||
setIcon(QIcon(QPixmap(m_hoveredIconPath)));
|
||||
setIconFromPath(m_hoveredIconPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +35,18 @@ void QtIconButton::leaveEvent(QEvent *event)
|
||||
{
|
||||
if (m_iconPath.size())
|
||||
{
|
||||
setIcon(QIcon(QPixmap(m_iconPath)));
|
||||
setIconFromPath(m_iconPath);
|
||||
}
|
||||
}
|
||||
|
||||
void QtIconButton::setIconFromPath(QString path)
|
||||
{
|
||||
QPixmap pixmap = QPixmap(path);
|
||||
|
||||
if (m_color != Qt::transparent)
|
||||
{
|
||||
pixmap = utility::colorizePixmap(pixmap, m_color);
|
||||
}
|
||||
|
||||
setIcon(QIcon(pixmap));
|
||||
}
|
||||
|
||||
@@ -9,13 +9,19 @@ class QtIconButton
|
||||
public:
|
||||
QtIconButton(QString iconPath, QString hoveredIconPath, QWidget* parent = nullptr);
|
||||
|
||||
void setColor(QColor color);
|
||||
|
||||
protected:
|
||||
void enterEvent(QEvent *event);
|
||||
void leaveEvent(QEvent *event);
|
||||
|
||||
private:
|
||||
void setIconFromPath(QString path);
|
||||
|
||||
QString m_iconPath;
|
||||
QString m_hoveredIconPath;
|
||||
|
||||
QColor m_color;
|
||||
};
|
||||
|
||||
#endif // QT_ICON_BUTTON_H
|
||||
|
||||
@@ -111,23 +111,20 @@ void QtDialogView::hideProgressDialog()
|
||||
}
|
||||
|
||||
|
||||
DialogView::IndexMode QtDialogView::startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, bool forceRefresh, bool needsFullRefresh)
|
||||
DialogView::IndexingOptions QtDialogView::startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, DialogView::IndexingOptions options)
|
||||
{
|
||||
IndexMode result = INDEX_ABORT;
|
||||
DialogView::IndexingOptions result;
|
||||
m_resultReady = false;
|
||||
|
||||
m_onQtThread(
|
||||
[=, &result]()
|
||||
{
|
||||
QtIndexingDialog* window = createWindow<QtIndexingDialog>();
|
||||
window->setupStart(cleanFileCount, indexFileCount, totalFileCount, forceRefresh, needsFullRefresh,
|
||||
[&](bool start, bool fullRefresh)
|
||||
window->setupStart(cleanFileCount, indexFileCount, totalFileCount, options,
|
||||
[&](DialogView::IndexingOptions o)
|
||||
{
|
||||
if (start)
|
||||
{
|
||||
result = (!fullRefresh && !needsFullRefresh ? INDEX_REFRESH : INDEX_FULL);
|
||||
}
|
||||
result = o;
|
||||
m_resultReady = true;
|
||||
|
||||
setUIBlocked(false);
|
||||
|
||||
@@ -34,8 +34,8 @@ public:
|
||||
virtual void showProgressDialog(const std::string& title, const std::string& message, int progress) override;
|
||||
virtual void hideProgressDialog() override;
|
||||
|
||||
virtual DialogView::IndexMode startIndexingDialog(size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount,
|
||||
bool forceRefresh, bool needsFullRefresh) override;
|
||||
virtual DialogView::IndexingOptions startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, DialogView::IndexingOptions options) override;
|
||||
virtual void updateIndexingDialog(size_t fileCount, size_t totalFileCount, std::string sourcePath) override;
|
||||
virtual void finishedIndexingDialog(
|
||||
size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount,
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <QPushButton>
|
||||
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "qt/element/QtHelpButton.h"
|
||||
#include "qt/element/QtProgressBar.h"
|
||||
#include "utility/messaging/type/MessageInterruptTasks.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
@@ -22,11 +23,11 @@ QtIndexingDialog::QtIndexingDialog(QWidget* parent)
|
||||
, m_messageLabel(nullptr)
|
||||
, m_filePathLabel(nullptr)
|
||||
, m_errorLabel(nullptr)
|
||||
, m_checkBox(nullptr)
|
||||
, m_fullRefreshCheckBox(nullptr)
|
||||
, m_preprocessorOnlyCheckBox(nullptr)
|
||||
, m_sizeHint(QSize(450, 450))
|
||||
, m_callback([](bool, bool){})
|
||||
, m_callback([](DialogView::IndexingOptions){})
|
||||
{
|
||||
// setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||
setSizeGripStyle(false);
|
||||
}
|
||||
|
||||
@@ -42,7 +43,7 @@ QtIndexingDialog::DialogType QtIndexingDialog::getType() const
|
||||
|
||||
void QtIndexingDialog::setupStart(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount,
|
||||
bool forceRefresh, bool needsFullRefresh, std::function<void(bool, bool)> callback)
|
||||
DialogView::IndexingOptions options, std::function<void(DialogView::IndexingOptions)> callback)
|
||||
{
|
||||
QBoxLayout* layout = createLayout();
|
||||
|
||||
@@ -59,46 +60,65 @@ void QtIndexingDialog::setupStart(
|
||||
|
||||
layout->addStretch();
|
||||
|
||||
if (needsFullRefresh)
|
||||
if (options.fullRefreshVisible)
|
||||
{
|
||||
m_fullRefreshCheckBox = new QCheckBox("full refresh", this);
|
||||
m_fullRefreshCheckBox->setObjectName("message");
|
||||
|
||||
connect(m_fullRefreshCheckBox, static_cast<void(QCheckBox::*)(bool)>(&QCheckBox::toggled),
|
||||
[=](bool checked = false)
|
||||
{
|
||||
clearLabel->setVisible(!checked);
|
||||
indexLabel->setVisible(!checked);
|
||||
fullLabel->setVisible(checked);
|
||||
}
|
||||
);
|
||||
|
||||
m_fullRefreshCheckBox->setChecked(!options.fullRefresh);
|
||||
m_fullRefreshCheckBox->setChecked(options.fullRefresh);
|
||||
|
||||
QHBoxLayout* subLayout = new QHBoxLayout();
|
||||
subLayout->addStretch();
|
||||
subLayout->addWidget(m_fullRefreshCheckBox);
|
||||
|
||||
layout->addLayout(subLayout);
|
||||
}
|
||||
else
|
||||
{
|
||||
clearLabel->hide();
|
||||
indexLabel->hide();
|
||||
}
|
||||
else
|
||||
|
||||
if (options.preprocessorOnlyVisible)
|
||||
{
|
||||
m_checkBox = new QCheckBox("full refresh", this);
|
||||
m_checkBox->setObjectName("message");
|
||||
m_preprocessorOnlyCheckBox = new QCheckBox("C/C++ preprocessor only", this);
|
||||
m_preprocessorOnlyCheckBox->setObjectName("message");
|
||||
m_preprocessorOnlyCheckBox->setChecked(options.preprocessorOnly);
|
||||
|
||||
connect(m_checkBox, static_cast<void(QCheckBox::*)(bool)>(&QCheckBox::toggled),
|
||||
[=](bool checked = false)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
clearLabel->hide();
|
||||
indexLabel->hide();
|
||||
fullLabel->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
clearLabel->show();
|
||||
indexLabel->show();
|
||||
fullLabel->hide();
|
||||
}
|
||||
}
|
||||
);
|
||||
QtHelpButton* button = new QtHelpButton(
|
||||
"Run only the C/C++ preprocessor on the files. This will quickly show include errors and help fix problems "
|
||||
"in the project setup faster.\n\nThe files will not be indexed and show up as incomplete.");
|
||||
button->setColor(Qt::white);
|
||||
|
||||
m_checkBox->setChecked(!forceRefresh);
|
||||
m_checkBox->setChecked(forceRefresh);
|
||||
QHBoxLayout* subLayout = new QHBoxLayout();
|
||||
subLayout->addStretch();
|
||||
subLayout->addWidget(m_preprocessorOnlyCheckBox);
|
||||
subLayout->addSpacing(10);
|
||||
subLayout->addWidget(button);
|
||||
|
||||
layout->addWidget(m_checkBox, 0, Qt::AlignRight);
|
||||
layout->addSpacing(30);
|
||||
layout->addLayout(subLayout);
|
||||
}
|
||||
|
||||
if (m_fullRefreshCheckBox || m_preprocessorOnlyCheckBox)
|
||||
{
|
||||
layout->addSpacing(20);
|
||||
}
|
||||
|
||||
addButtons(layout);
|
||||
updateNextButton("Start");
|
||||
updateCloseButton("Cancel");
|
||||
|
||||
m_sizeHint = QSize(350, 250);
|
||||
m_sizeHint = QSize(350, 270);
|
||||
m_callback = callback;
|
||||
|
||||
finishSetup();
|
||||
@@ -277,7 +297,11 @@ void QtIndexingDialog::handleNext()
|
||||
{
|
||||
if (m_type == DIALOG_MESSAGE)
|
||||
{
|
||||
m_callback(true, !m_checkBox || m_checkBox->isChecked());
|
||||
DialogView::IndexingOptions options;
|
||||
options.startIndexing = true;
|
||||
options.fullRefresh = m_fullRefreshCheckBox && m_fullRefreshCheckBox->isChecked();
|
||||
options.preprocessorOnly = m_preprocessorOnlyCheckBox && m_preprocessorOnlyCheckBox->isChecked();
|
||||
m_callback(options);
|
||||
}
|
||||
|
||||
QtWindow::handleNext();
|
||||
@@ -287,7 +311,8 @@ void QtIndexingDialog::handleClose()
|
||||
{
|
||||
if (m_type == DIALOG_MESSAGE)
|
||||
{
|
||||
m_callback(false, false);
|
||||
DialogView::IndexingOptions options;
|
||||
m_callback(options);
|
||||
}
|
||||
|
||||
if (m_type == DIALOG_INDEXING)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "component/view/DialogView.h"
|
||||
#include "qt/window/QtWindow.h"
|
||||
|
||||
class QCheckBox;
|
||||
@@ -29,7 +30,7 @@ public:
|
||||
DialogType getType() const;
|
||||
|
||||
void setupStart(size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount,
|
||||
bool forceRefresh, bool needsFullRefresh, std::function<void(bool, bool)> callback);
|
||||
DialogView::IndexingOptions options, std::function<void(DialogView::IndexingOptions)> callback);
|
||||
void setupIndexing();
|
||||
void setupReport(
|
||||
size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount, float time);
|
||||
@@ -77,11 +78,14 @@ private:
|
||||
QLabel* m_messageLabel;
|
||||
QLabel* m_filePathLabel;
|
||||
QPushButton* m_errorLabel;
|
||||
QCheckBox* m_checkBox;
|
||||
|
||||
// start indexing
|
||||
QCheckBox* m_fullRefreshCheckBox;
|
||||
QCheckBox* m_preprocessorOnlyCheckBox;
|
||||
|
||||
QSize m_sizeHint;
|
||||
|
||||
std::function<void(bool, bool)> m_callback;
|
||||
std::function<void(DialogView::IndexingOptions)> m_callback;
|
||||
QString m_sourcePath;
|
||||
};
|
||||
|
||||
|
||||
@@ -2,41 +2,9 @@
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "qt/window/QtTextEditDialog.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
QtHelpButton::QtHelpButton(const QString& helpText, QWidget* parent)
|
||||
: QtIconButton(
|
||||
(ResourcePaths::getGuiPath() + "window/help.png").c_str(),
|
||||
(ResourcePaths::getGuiPath() + "window/help_hover.png").c_str(),
|
||||
parent)
|
||||
, m_helpText(helpText)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
setMouseTracking(true);
|
||||
|
||||
setToolTip("help");
|
||||
|
||||
leaveEvent(nullptr);
|
||||
|
||||
connect(this, SIGNAL(clicked()), this, SLOT(handleHelpPress()));
|
||||
}
|
||||
|
||||
void QtHelpButton::handleHelpPress()
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("Help");
|
||||
msgBox.setInformativeText(m_helpText);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
|
||||
QtProjectWizzardContent::QtProjectWizzardContent(QtProjectWizzardWindow* window)
|
||||
: QWidget(window)
|
||||
, m_window(window)
|
||||
|
||||
@@ -6,29 +6,13 @@
|
||||
#include <QToolButton>
|
||||
#include <QWidget>
|
||||
|
||||
#include "qt/element/QtIconButton.h"
|
||||
#include "qt/element/QtHelpButton.h"
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardWindow.h"
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
class QtTextEditDialog;
|
||||
|
||||
class QtHelpButton
|
||||
: public QtIconButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtHelpButton(const QString& helpText, QWidget* parent = nullptr);
|
||||
|
||||
private slots:
|
||||
void handleHelpPress();
|
||||
|
||||
private:
|
||||
QString m_helpText;
|
||||
};
|
||||
|
||||
|
||||
class QtProjectWizzardContent
|
||||
: public QWidget
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user