1
0
Fork 0

Various attempts at improving startup performance

This commit is contained in:
Duncan Ogilvie 2020-10-31 13:28:23 +01:00
parent 9b40810902
commit 683e16fcdf
6 changed files with 36 additions and 25 deletions

View File

@ -13,7 +13,7 @@ ReferenceView::ReferenceView(bool sourceView, QWidget* parent) : StdSearchListVi
mSearchStartCol = 1;
// Widget container for progress
QWidget* progressWidget = new QWidget();
QWidget* progressWidget = new QWidget(this);
// Create the layout for the progress bars
QHBoxLayout* layoutProgress = new QHBoxLayout();

View File

@ -33,7 +33,7 @@ SearchListView::SearchListView(QWidget* parent, AbstractSearchList* abstractSear
listLayout->addWidget(abstractSearchList->searchList());
// Add list placeholder
QWidget* listPlaceholder = new QWidget();
QWidget* listPlaceholder = new QWidget(this);
listPlaceholder->setLayout(listLayout);
barSplitter->addWidget(listPlaceholder);
@ -68,7 +68,7 @@ SearchListView::SearchListView(QWidget* parent, AbstractSearchList* abstractSear
horzLayout->addWidget(mRegexCheckbox);
// Add searchbar placeholder
QWidget* horzPlaceholder = new QWidget();
QWidget* horzPlaceholder = new QWidget(this);
horzPlaceholder->setLayout(horzLayout);
barSplitter->addWidget(horzPlaceholder);

View File

@ -672,7 +672,7 @@ void Configuration::readColors()
//read config
for(int i = 0; i < Colors.size(); i++)
{
QString id = Colors.keys().at(i);
const QString & id = Colors.keys().at(i);
Colors[id] = colorFromConfig(id);
}
}
@ -682,7 +682,7 @@ void Configuration::writeColors()
//write config
for(int i = 0; i < Colors.size(); i++)
{
QString id = Colors.keys().at(i);
const QString & id = Colors.keys().at(i);
colorToConfig(id, Colors[id]);
}
emit colorsUpdated();
@ -694,11 +694,11 @@ void Configuration::readBools()
//read config
for(int i = 0; i < Bools.size(); i++)
{
QString category = Bools.keys().at(i);
const QString & category = Bools.keys().at(i);
QMap<QString, bool> & currentBool = Bools[category];
for(int j = 0; j < currentBool.size(); j++)
{
QString id = currentBool.keys().at(j);
const QString & id = currentBool.keys().at(j);
currentBool[id] = boolFromConfig(category, id);
}
}
@ -709,11 +709,11 @@ void Configuration::writeBools()
//write config
for(int i = 0; i < Bools.size(); i++)
{
QString category = Bools.keys().at(i);
const QString & category = Bools.keys().at(i);
QMap<QString, bool>* currentBool = &Bools[category];
for(int j = 0; j < currentBool->size(); j++)
{
QString id = (*currentBool).keys().at(j);
const QString & id = (*currentBool).keys().at(j);
boolToConfig(category, id, (*currentBool)[id]);
}
}
@ -725,11 +725,11 @@ void Configuration::readUints()
//read config
for(int i = 0; i < Uints.size(); i++)
{
QString category = Uints.keys().at(i);
const QString & category = Uints.keys().at(i);
QMap<QString, duint> & currentUint = Uints[category];
for(int j = 0; j < currentUint.size(); j++)
{
QString id = currentUint.keys().at(j);
const QString & id = currentUint.keys().at(j);
currentUint[id] = uintFromConfig(category, id);
}
}
@ -743,11 +743,11 @@ void Configuration::writeUints()
//write config
for(int i = 0; i < Uints.size(); i++)
{
QString category = Uints.keys().at(i);
const QString & category = Uints.keys().at(i);
QMap<QString, duint>* currentUint = &Uints[category];
for(int j = 0; j < currentUint->size(); j++)
{
QString id = (*currentUint).keys().at(j);
const QString & id = (*currentUint).keys().at(j);
// Do not save settings to file if saveLoadTabOrder checkbox is Unchecked
if(!bSaveLoadTabOrder && category == "TabOrder" && BridgeSettingGetUint(category.toUtf8().constData(), id.toUtf8().constData(), &setting))
@ -764,7 +764,7 @@ void Configuration::readFonts()
//read config
for(int i = 0; i < Fonts.size(); i++)
{
QString id = Fonts.keys().at(i);
const QString & id = Fonts.keys().at(i);
QFont font = fontFromConfig(id);
QFontInfo fontInfo(font);
if(id == "Application" || fontInfo.fixedPitch())
@ -777,7 +777,7 @@ void Configuration::writeFonts()
//write config
for(int i = 0; i < Fonts.size(); i++)
{
QString id = Fonts.keys().at(i);
const QString & id = Fonts.keys().at(i);
fontToConfig(id, Fonts[id]);
}
emit fontsUpdated();
@ -1136,7 +1136,7 @@ bool Configuration::shortcutToConfig(const QString & id, const QKeySequence shor
void Configuration::registerMenuBuilder(MenuBuilder* menu, size_t count)
{
QString id = menu->getId();
const QString & id = menu->getId();
for(const auto & i : NamedMenuBuilders)
if(i.type == 0 && i.builder->getId() == id)
return; //already exists

View File

@ -33,7 +33,7 @@ public:
bool GlobalShortcut;
Shortcut(QString name = QString(), QString hotkey = QString(), bool global = false)
: Name(name), Hotkey(hotkey), GlobalShortcut(global) { }
: Name(name), Hotkey(hotkey, QKeySequence::PortableText), GlobalShortcut(global) { }
Shortcut(std::initializer_list<QString> names, QString hotkey = QString(), bool global = false)
: Shortcut(QStringList(names).join(" -> "), hotkey, global) { }

View File

@ -7,12 +7,16 @@
#include "ComboBoxDialog.h"
#include "StringUtil.h"
#include "BrowseDialog.h"
#include <thread>
void SetApplicationIcon(WId winId)
{
HICON hIcon = LoadIcon(GetModuleHandleW(0), MAKEINTRESOURCE(100));
SendMessageW((HWND)winId, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
DestroyIcon(hIcon);
std::thread([winId]
{
HICON hIcon = LoadIcon(GetModuleHandleW(0), MAKEINTRESOURCE(100));
SendMessageW((HWND)winId, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
DestroyIcon(hIcon);
}).detach();
}
QByteArray & ByteReverse(QByteArray & array)
@ -39,7 +43,7 @@ QByteArray ByteReverse(QByteArray && array)
return array;
}
bool SimpleInputBox(QWidget* parent, const QString & title, QString defaultValue, QString & output, const QString & placeholderText, QIcon* icon)
bool SimpleInputBox(QWidget* parent, const QString & title, QString defaultValue, QString & output, const QString & placeholderText, const QIcon* icon)
{
LineEditDialog mEdit(parent);
mEdit.setWindowIcon(icon ? *icon : parent->windowIcon());
@ -56,7 +60,7 @@ bool SimpleInputBox(QWidget* parent, const QString & title, QString defaultValue
return false;
}
bool SimpleChoiceBox(QWidget* parent, const QString & title, QString defaultValue, const QStringList & choices, QString & output, bool editable, const QString & placeholderText, QIcon* icon, int minimumContentsLength)
bool SimpleChoiceBox(QWidget* parent, const QString & title, QString defaultValue, const QStringList & choices, QString & output, bool editable, const QString & placeholderText, const QIcon* icon, int minimumContentsLength)
{
ComboBoxDialog mChoice(parent);
mChoice.setWindowIcon(icon ? *icon : parent->windowIcon());

View File

@ -11,8 +11,8 @@ class QByteArray;
void SetApplicationIcon(WId winId);
QByteArray & ByteReverse(QByteArray & array);
QByteArray ByteReverse(QByteArray && array);
bool SimpleInputBox(QWidget* parent, const QString & title, QString defaultValue, QString & output, const QString & placeholderText, QIcon* icon = nullptr);
bool SimpleChoiceBox(QWidget* parent, const QString & title, QString defaultValue, const QStringList & choices, QString & output, bool editable, const QString & placeholderText, QIcon* icon = nullptr, int minimumContentsLength = -1);
bool SimpleInputBox(QWidget* parent, const QString & title, QString defaultValue, QString & output, const QString & placeholderText, const QIcon* icon = nullptr);
bool SimpleChoiceBox(QWidget* parent, const QString & title, QString defaultValue, const QStringList & choices, QString & output, bool editable, const QString & placeholderText, const QIcon* icon = nullptr, int minimumContentsLength = -1);
void SimpleErrorBox(QWidget* parent, const QString & title, const QString & text);
void SimpleWarningBox(QWidget* parent, const QString & title, const QString & text);
void SimpleInfoBox(QWidget* parent, const QString & title, const QString & text);
@ -23,5 +23,12 @@ bool isEaster();
QString couldItBeSeasonal(QString icon);
QIcon getFileIcon(QString file);
#define DIcon(file) QIcon(QString(":/icons/images/").append(couldItBeSeasonal(file)))
template<int>
static const QIcon & DIconHelper(const QString & file)
{
static QIcon icon(QString(":/icons/images/").append(couldItBeSeasonal(file)));
return icon;
}
#define DIcon(file) DIconHelper<__LINE__>(file)
#endif // MISCUTIL_H