ui: Moved color scheme selection to preferences
* removed 'Switch Color Scheme' action from View menu * added dropdown with all fetched color schemes to preferences bug id = 114
This commit is contained in:
+12
-1
@@ -71,7 +71,12 @@ void Application::loadSettings()
|
||||
{
|
||||
ApplicationSettings::getInstance()->load(FilePath(UserPaths::getAppSettingsPath()));
|
||||
|
||||
ColorScheme::getInstance()->load(ApplicationSettings::getInstance()->getColorSchemePath());
|
||||
loadStyle(ApplicationSettings::getInstance()->getColorSchemePath());
|
||||
}
|
||||
|
||||
void Application::loadStyle(const FilePath& colorSchemePath)
|
||||
{
|
||||
ColorScheme::getInstance()->load(colorSchemePath);
|
||||
GraphViewStyle::loadStyleSettings();
|
||||
}
|
||||
|
||||
@@ -323,6 +328,12 @@ void Application::handleMessage(MessageRefresh* message)
|
||||
}
|
||||
}
|
||||
|
||||
void Application::handleMessage(MessageSwitchColorScheme* message)
|
||||
{
|
||||
loadStyle(message->colorSchemePath);
|
||||
m_componentManager->refreshViews();
|
||||
}
|
||||
|
||||
void Application::startMessagingAndScheduling()
|
||||
{
|
||||
TaskScheduler::getInstance()->startSchedulerLoopThreaded();
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
#include "utility/messaging/type/MessageSwitchColorScheme.h"
|
||||
|
||||
class IDECommunicationController;
|
||||
class NetworkFactory;
|
||||
@@ -23,11 +24,13 @@ class Application
|
||||
, public MessageListener<MessageFinishedParsing>
|
||||
, public MessageListener<MessageLoadProject>
|
||||
, public MessageListener<MessageRefresh>
|
||||
, public MessageListener<MessageSwitchColorScheme>
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<Application> create(const Version& version, ViewFactory* viewFactory, NetworkFactory* networkFactory);
|
||||
static std::shared_ptr<Application> create(const Version& version);
|
||||
static void loadSettings();
|
||||
static void loadStyle(const FilePath& colorSchemePath);
|
||||
|
||||
~Application();
|
||||
|
||||
@@ -43,6 +46,7 @@ private:
|
||||
virtual void handleMessage(MessageFinishedParsing* message);
|
||||
virtual void handleMessage(MessageLoadProject* message);
|
||||
virtual void handleMessage(MessageRefresh* message);
|
||||
virtual void handleMessage(MessageSwitchColorScheme* message);
|
||||
|
||||
void startMessagingAndScheduling();
|
||||
|
||||
|
||||
@@ -196,15 +196,6 @@ void FeatureController::handleMessage(MessageResetZoom* message)
|
||||
MessageStatus("Zoom: 100%").dispatch();
|
||||
}
|
||||
|
||||
void FeatureController::handleMessage(MessageSwitchColorScheme* message)
|
||||
{
|
||||
ApplicationSettings* settings = ApplicationSettings::getInstance().get();
|
||||
settings->setColorSchemePath(message->colorSchemeFilePath);
|
||||
settings->save();
|
||||
|
||||
MessageRefresh().refreshUiOnly().dispatch();
|
||||
}
|
||||
|
||||
void FeatureController::handleMessage(MessageZoom* message)
|
||||
{
|
||||
bool zoomIn = message->zoomIn;
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "utility/messaging/type/MessageActivateTokenLocations.h"
|
||||
#include "utility/messaging/type/MessageResetZoom.h"
|
||||
#include "utility/messaging/type/MessageSearch.h"
|
||||
#include "utility/messaging/type/MessageSwitchColorScheme.h"
|
||||
#include "utility/messaging/type/MessageZoom.h"
|
||||
|
||||
class StorageAccess;
|
||||
@@ -27,7 +26,6 @@ class FeatureController
|
||||
, public MessageListener<MessageActivateTokenLocations>
|
||||
, public MessageListener<MessageResetZoom>
|
||||
, public MessageListener<MessageSearch>
|
||||
, public MessageListener<MessageSwitchColorScheme>
|
||||
, public MessageListener<MessageZoom>
|
||||
{
|
||||
public:
|
||||
@@ -44,7 +42,6 @@ private:
|
||||
virtual void handleMessage(MessageActivateTokenIds* message);
|
||||
virtual void handleMessage(MessageActivateTokenLocations* message);
|
||||
virtual void handleMessage(MessageResetZoom* message);
|
||||
virtual void handleMessage(MessageSwitchColorScheme* message);
|
||||
virtual void handleMessage(MessageZoom* message);
|
||||
|
||||
StorageAccess* m_storageAccess;
|
||||
|
||||
@@ -95,12 +95,12 @@ void ApplicationSettings::setFontSize(int fontSize)
|
||||
setValue<int>("application/font_size", fontSize);
|
||||
}
|
||||
|
||||
std::string ApplicationSettings::getColorSchemePath() const
|
||||
FilePath ApplicationSettings::getColorSchemePath() const
|
||||
{
|
||||
std::string defaultPath = ResourcePaths::getColorSchemesPath() + "bright.xml";
|
||||
std::string path = getValue<std::string>("application/color_scheme", defaultPath);
|
||||
FilePath defaultPath(ResourcePaths::getColorSchemesPath() + "bright.xml");
|
||||
FilePath path(getValue<std::string>("application/color_scheme", defaultPath.str()));
|
||||
|
||||
if (path != defaultPath && !FilePath(path).exists())
|
||||
if (path != defaultPath && !path.exists())
|
||||
{
|
||||
return defaultPath;
|
||||
}
|
||||
@@ -108,9 +108,9 @@ std::string ApplicationSettings::getColorSchemePath() const
|
||||
return path;
|
||||
}
|
||||
|
||||
void ApplicationSettings::setColorSchemePath(const std::string& colorSchemePath)
|
||||
void ApplicationSettings::setColorSchemePath(const FilePath& colorSchemePath)
|
||||
{
|
||||
setValue<std::string>("application/color_scheme", colorSchemePath);
|
||||
setValue<std::string>("application/color_scheme", colorSchemePath.str());
|
||||
}
|
||||
|
||||
int ApplicationSettings::getFontSizeMax() const
|
||||
|
||||
@@ -35,8 +35,8 @@ public:
|
||||
int getFontSize() const;
|
||||
void setFontSize(int fontSize);
|
||||
|
||||
std::string getColorSchemePath() const;
|
||||
void setColorSchemePath(const std::string& colorSchemePath);
|
||||
FilePath getColorSchemePath() const;
|
||||
void setColorSchemePath(const FilePath& colorSchemePath);
|
||||
|
||||
int getFontSizeMax() const;
|
||||
void setFontSizeMax(const int fontSizeMax);
|
||||
|
||||
@@ -7,8 +7,8 @@ class MessageSwitchColorScheme
|
||||
: public Message<MessageSwitchColorScheme>
|
||||
{
|
||||
public:
|
||||
MessageSwitchColorScheme(const std::string& filePath)
|
||||
: colorSchemeFilePath(filePath)
|
||||
MessageSwitchColorScheme(const FilePath& filePath)
|
||||
: colorSchemePath(filePath)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ public:
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << colorSchemeFilePath;
|
||||
os << colorSchemePath.str();
|
||||
}
|
||||
|
||||
const std::string colorSchemeFilePath;
|
||||
const FilePath colorSchemePath;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SWITCH_COLOR_SCHEME_H
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
#include "utility/messaging/type/MessageResetZoom.h"
|
||||
#include "utility/messaging/type/MessageSearch.h"
|
||||
#include "utility/messaging/type/MessageSwitchColorScheme.h"
|
||||
#include "utility/messaging/type/MessageUndo.h"
|
||||
#include "utility/messaging/type/MessageWindowFocus.h"
|
||||
#include "utility/messaging/type/MessageZoom.h"
|
||||
@@ -474,16 +473,6 @@ void QtMainWindow::resetZoom()
|
||||
MessageResetZoom().dispatch();
|
||||
}
|
||||
|
||||
void QtMainWindow::switchColorScheme()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), (ResourcePaths::getColorSchemesPath()).c_str(), "XML Files (*.xml)");
|
||||
|
||||
if (!fileName.isEmpty())
|
||||
{
|
||||
MessageSwitchColorScheme(fileName.toStdString()).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
void QtMainWindow::toggleView(View* view, bool fromMenu)
|
||||
{
|
||||
DockWidget* dock = getDockWidgetForView(view);
|
||||
@@ -624,10 +613,6 @@ void QtMainWindow::setupViewMenu()
|
||||
menu->addAction(tr("Smaller font"), this, SLOT(zoomOut()), QKeySequence::ZoomOut);
|
||||
menu->addAction(tr("Reset font size"), this, SLOT(resetZoom()), QKeySequence(Qt::CTRL + Qt::Key_0));
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
menu->addAction(tr("Switch Color Scheme..."), this, SLOT(switchColorScheme()));
|
||||
|
||||
m_viewMenu = menu;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,6 @@ public slots:
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
void resetZoom();
|
||||
void switchColorScheme();
|
||||
|
||||
void toggleView(View* view, bool fromMenu);
|
||||
|
||||
|
||||
@@ -1,12 +1,30 @@
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentPreferences.h"
|
||||
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/messaging/type/MessageSwitchColorScheme.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
QtProjectWizzardContentPreferences::QtProjectWizzardContentPreferences(
|
||||
ProjectSettings* settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContent(settings, window)
|
||||
, m_oldColorSchemeIndex(-1)
|
||||
{
|
||||
std::vector<std::string> colorSchemePaths =
|
||||
FileSystem::getFileNamesFromDirectory(ResourcePaths::getColorSchemesPath(), std::vector<std::string>(1, ".xml"));
|
||||
for (const std::string& colorScheme : colorSchemePaths)
|
||||
{
|
||||
m_colorSchemePaths.push_back(FilePath(colorScheme));
|
||||
}
|
||||
}
|
||||
|
||||
QtProjectWizzardContentPreferences::~QtProjectWizzardContentPreferences()
|
||||
{
|
||||
if (m_oldColorSchemeIndex != -1)
|
||||
{
|
||||
colorSchemeChanged(m_oldColorSchemeIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPreferences::populateWindow(QGridLayout* layout)
|
||||
@@ -24,41 +42,49 @@ void QtProjectWizzardContentPreferences::populateForm(QGridLayout* layout, int&
|
||||
row++;
|
||||
|
||||
// font face
|
||||
QLabel* fontLabel = createFormLabel("Font face");
|
||||
m_fontFace = new QLineEdit();
|
||||
m_fontFace->setObjectName("name");
|
||||
m_fontFace->setAttribute(Qt::WA_MacShowFocusRect, 0);
|
||||
|
||||
layout->addWidget(fontLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
||||
layout->addWidget(createFormLabel("Font face"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
||||
layout->addWidget(m_fontFace, row, QtProjectWizzardWindow::BACK_COL);
|
||||
row++;
|
||||
|
||||
// font size
|
||||
QLabel* sizeLabel = createFormLabel("Font size");
|
||||
|
||||
m_fontSize = new QComboBox();
|
||||
for (int i = appSettings->getFontSizeMin(); i <= appSettings->getFontSizeMax(); i++)
|
||||
{
|
||||
m_fontSize->insertItem(i, QString::number(i));
|
||||
}
|
||||
|
||||
layout->addWidget(sizeLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
||||
layout->addWidget(createFormLabel("Font size"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
||||
layout->addWidget(m_fontSize, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
|
||||
row++;
|
||||
|
||||
// tab width
|
||||
QLabel* tabLabel = createFormLabel("Tab width");
|
||||
|
||||
m_tabWidth = new QComboBox();
|
||||
for (int i = 1; i < 17; i++)
|
||||
{
|
||||
m_tabWidth->insertItem(i, QString::number(i));
|
||||
}
|
||||
|
||||
layout->addWidget(tabLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
||||
layout->addWidget(createFormLabel("Tab width"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
||||
layout->addWidget(m_tabWidth, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
|
||||
row++;
|
||||
|
||||
// color scheme
|
||||
m_colorSchemes = new QComboBox();
|
||||
for (size_t i = 0; i < m_colorSchemePaths.size(); i++)
|
||||
{
|
||||
m_colorSchemes->insertItem(i, m_colorSchemePaths[i].withoutExtension().fileName().c_str());
|
||||
}
|
||||
|
||||
connect(m_colorSchemes, SIGNAL(activated(int)), this, SLOT(colorSchemeChanged(int)));
|
||||
|
||||
layout->addWidget(createFormLabel("Color scheme"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
||||
layout->addWidget(m_colorSchemes, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
|
||||
row++;
|
||||
|
||||
layout->setRowMinimumHeight(row++, 20);
|
||||
|
||||
|
||||
@@ -67,15 +93,13 @@ void QtProjectWizzardContentPreferences::populateForm(QGridLayout* layout, int&
|
||||
row++;
|
||||
|
||||
// indexer threads
|
||||
QLabel* threadsLabel = createFormLabel("Indexer threads");
|
||||
|
||||
m_threads = new QComboBox();
|
||||
for (int i = 1; i <= 24; i++)
|
||||
{
|
||||
m_threads->insertItem(i, QString::number(i));
|
||||
}
|
||||
|
||||
layout->addWidget(threadsLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
||||
layout->addWidget(createFormLabel("Indexer threads"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
||||
layout->addWidget(m_threads, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
|
||||
|
||||
addHelpButton(
|
||||
@@ -86,11 +110,9 @@ void QtProjectWizzardContentPreferences::populateForm(QGridLayout* layout, int&
|
||||
row++;
|
||||
|
||||
// ignore non-fatal errors in non-indexed files
|
||||
QLabel* errorsLabel = createFormLabel("Non-Fatal Errors");
|
||||
|
||||
m_fatalErrors = new QCheckBox("Display non-fatal errors in unindexed files", this);
|
||||
|
||||
layout->addWidget(errorsLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
||||
layout->addWidget(createFormLabel("Non-Fatal Errors"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
||||
layout->addWidget(m_fatalErrors, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
|
||||
|
||||
addHelpButton(
|
||||
@@ -110,6 +132,17 @@ void QtProjectWizzardContentPreferences::load()
|
||||
m_fontSize->setCurrentIndex(appSettings->getFontSize() - appSettings->getFontSizeMin());
|
||||
m_tabWidth->setCurrentIndex(appSettings->getCodeTabWidth() - 1);
|
||||
|
||||
FilePath colorSchemePath = appSettings->getColorSchemePath();
|
||||
for (size_t i = 0; i < m_colorSchemePaths.size(); i++)
|
||||
{
|
||||
if (colorSchemePath == m_colorSchemePaths[i])
|
||||
{
|
||||
m_colorSchemes->setCurrentIndex(i);
|
||||
m_oldColorSchemeIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_threads->setCurrentIndex(appSettings->getIndexerThreadCount() - 1);
|
||||
m_fatalErrors->setChecked(appSettings->getShowExternalNonFatalErrors());
|
||||
}
|
||||
@@ -123,6 +156,9 @@ void QtProjectWizzardContentPreferences::save()
|
||||
appSettings->setFontSize(m_fontSize->currentIndex() + appSettings->getFontSizeMin());
|
||||
appSettings->setCodeTabWidth(m_tabWidth->currentIndex() + 1);
|
||||
|
||||
appSettings->setColorSchemePath(m_colorSchemePaths[m_colorSchemes->currentIndex()]);
|
||||
m_oldColorSchemeIndex = -1;
|
||||
|
||||
appSettings->setIndexerThreadCount(m_threads->currentIndex() + 1);
|
||||
appSettings->setShowExternalNonFatalErrors(m_fatalErrors->isChecked());
|
||||
}
|
||||
@@ -131,3 +167,8 @@ bool QtProjectWizzardContentPreferences::check()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPreferences::colorSchemeChanged(int index)
|
||||
{
|
||||
MessageSwitchColorScheme(m_colorSchemePaths[index]).dispatch();
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ class QtProjectWizzardContentPreferences
|
||||
|
||||
public:
|
||||
QtProjectWizzardContentPreferences(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
~QtProjectWizzardContentPreferences();
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual void populateWindow(QGridLayout* layout) override;
|
||||
@@ -23,12 +24,20 @@ public:
|
||||
virtual void save() override;
|
||||
virtual bool check() override;
|
||||
|
||||
private slots:
|
||||
void colorSchemeChanged(int index);
|
||||
|
||||
private:
|
||||
QLineEdit* m_fontFace;
|
||||
QComboBox* m_fontSize;
|
||||
QComboBox* m_tabWidth;
|
||||
QComboBox* m_colorSchemes;
|
||||
|
||||
QComboBox* m_threads;
|
||||
QCheckBox* m_fatalErrors;
|
||||
|
||||
std::vector<FilePath> m_colorSchemePaths;
|
||||
int m_oldColorSchemeIndex;
|
||||
};
|
||||
|
||||
#endif // QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H
|
||||
|
||||
Reference in New Issue
Block a user