mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-20 03:18:51 +00:00
Save and load the layout of the Functions widget (#2844)
This commit is contained in:
parent
22cb8e7594
commit
cff49fa2a2
@ -21,17 +21,16 @@
|
|||||||
* and for light - only light ones.
|
* and for light - only light ones.
|
||||||
*/
|
*/
|
||||||
const QHash<QString, ColorFlags> Configuration::relevantThemes = {
|
const QHash<QString, ColorFlags> Configuration::relevantThemes = {
|
||||||
{ "ayu", DarkFlag }, { "basic", DarkFlag }, { "behelit", DarkFlag },
|
{ "ayu", DarkFlag }, { "basic", DarkFlag }, { "behelit", DarkFlag },
|
||||||
{ "bold", DarkFlag }, { "bright", DarkFlag }, { "consonance", DarkFlag },
|
{ "bold", DarkFlag }, { "bright", DarkFlag }, { "consonance", DarkFlag },
|
||||||
{ "darkda", DarkFlag }, { "defragger", DarkFlag }, { "focus", DarkFlag },
|
{ "darkda", DarkFlag }, { "defragger", DarkFlag }, { "focus", DarkFlag },
|
||||||
{ "gentoo", DarkFlag }, { "lima", DarkFlag }, { "monokai", DarkFlag },
|
{ "gentoo", DarkFlag }, { "lima", DarkFlag }, { "monokai", DarkFlag },
|
||||||
{ "ogray", DarkFlag }, { "onedark", DarkFlag }, { "pink", DarkFlag },
|
{ "ogray", DarkFlag }, { "onedark", DarkFlag }, { "pink", DarkFlag },
|
||||||
{ "rasta", DarkFlag }, { "sepia", DarkFlag }, { "smyck", DarkFlag },
|
{ "rasta", DarkFlag }, { "sepia", DarkFlag }, { "smyck", DarkFlag },
|
||||||
{ "solarized", DarkFlag }, { "twilight", DarkFlag }, { "white2", DarkFlag },
|
{ "solarized", DarkFlag }, { "twilight", DarkFlag }, { "white2", DarkFlag },
|
||||||
{ "xvilka", DarkFlag }, { "zenburn", DarkFlag },
|
{ "xvilka", DarkFlag }, { "zenburn", DarkFlag }, { "cga", LightFlag },
|
||||||
{ "cga", LightFlag }, { "cutter", LightFlag }, { "dark", LightFlag },
|
{ "cutter", LightFlag }, { "dark", LightFlag }, { "gb", LightFlag },
|
||||||
{ "gb", LightFlag }, { "matrix", LightFlag }, { "tango", LightFlag },
|
{ "matrix", LightFlag }, { "tango", LightFlag }, { "white", LightFlag }
|
||||||
{ "white", LightFlag }
|
|
||||||
};
|
};
|
||||||
static const QString DEFAULT_LIGHT_COLOR_THEME = "cutter";
|
static const QString DEFAULT_LIGHT_COLOR_THEME = "cutter";
|
||||||
static const QString DEFAULT_DARK_COLOR_THEME = "ayu";
|
static const QString DEFAULT_DARK_COLOR_THEME = "ayu";
|
||||||
@ -251,8 +250,8 @@ bool Configuration::setLocaleByName(const QString &language)
|
|||||||
QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry);
|
QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry);
|
||||||
|
|
||||||
for (auto &it : allLocales) {
|
for (auto &it : allLocales) {
|
||||||
if (QString::compare(it.nativeLanguageName(), language, Qt::CaseInsensitive) == 0 ||
|
if (QString::compare(it.nativeLanguageName(), language, Qt::CaseInsensitive) == 0
|
||||||
it.name() == language) {
|
|| it.name() == language) {
|
||||||
setLocale(it);
|
setLocale(it);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -289,7 +288,8 @@ void Configuration::loadNativeStylesheet()
|
|||||||
QTextStream ts(&f);
|
QTextStream ts(&f);
|
||||||
QString stylesheet = ts.readAll();
|
QString stylesheet = ts.readAll();
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
QFile mf(nativeWindowIsDark() ? ":native/native-macos-dark.qss" : ":native/native-macos-light.qss");
|
QFile mf(nativeWindowIsDark() ? ":native/native-macos-dark.qss"
|
||||||
|
: ":native/native-macos-light.qss");
|
||||||
if (mf.exists()) {
|
if (mf.exists()) {
|
||||||
mf.open(QFile::ReadOnly | QFile::Text);
|
mf.open(QFile::ReadOnly | QFile::Text);
|
||||||
QTextStream mts(&mf);
|
QTextStream mts(&mf);
|
||||||
@ -667,11 +667,13 @@ QStringList Configuration::getAvailableTranslations()
|
|||||||
|
|
||||||
for (auto i : fileNames) {
|
for (auto i : fileNames) {
|
||||||
QString localeName = i.mid(sizeof("cutter_") - 1, 2); // TODO:#2321 don't asume 2 characters
|
QString localeName = i.mid(sizeof("cutter_") - 1, 2); // TODO:#2321 don't asume 2 characters
|
||||||
// language code is sometimes 3 characters, and there could also be language_COUNTRY. Qt supports that.
|
// language code is sometimes 3 characters, and there could also be language_COUNTRY. Qt
|
||||||
|
// supports that.
|
||||||
QLocale locale(localeName);
|
QLocale locale(localeName);
|
||||||
if (locale.language() != QLocale::C) {
|
if (locale.language() != QLocale::C) {
|
||||||
currLanguageName = locale.nativeLanguageName();
|
currLanguageName = locale.nativeLanguageName();
|
||||||
if (currLanguageName.isEmpty()) { // Qt doesn't have native language name for some languages
|
if (currLanguageName
|
||||||
|
.isEmpty()) { // Qt doesn't have native language name for some languages
|
||||||
currLanguageName = QLocale::languageToString(locale.language());
|
currLanguageName = QLocale::languageToString(locale.language());
|
||||||
}
|
}
|
||||||
if (!currLanguageName.isEmpty()) {
|
if (!currLanguageName.isEmpty()) {
|
||||||
@ -774,7 +776,7 @@ bool Configuration::getOutputRedirectionEnabled() const
|
|||||||
return outputRedirectEnabled;
|
return outputRedirectEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Configuration::setPreviewValue( bool checked )
|
void Configuration::setPreviewValue(bool checked)
|
||||||
{
|
{
|
||||||
s.setValue("asm.preview", checked);
|
s.setValue("asm.preview", checked);
|
||||||
}
|
}
|
||||||
@ -821,3 +823,13 @@ void Configuration::addRecentProject(QString file)
|
|||||||
files.prepend(file);
|
files.prepend(file);
|
||||||
setRecentProjects(files);
|
setRecentProjects(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Configuration::getFunctionsWidgetLayout()
|
||||||
|
{
|
||||||
|
return s.value("functionsWidgetLayout").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Configuration::setFunctionsWidgetLayout(const QString &layout)
|
||||||
|
{
|
||||||
|
s.setValue("functionsWidgetLayout", layout);
|
||||||
|
}
|
||||||
|
@ -228,6 +228,19 @@ public:
|
|||||||
void setRecentProjects(const QStringList &list);
|
void setRecentProjects(const QStringList &list);
|
||||||
void addRecentProject(QString file);
|
void addRecentProject(QString file);
|
||||||
|
|
||||||
|
// Functions Widget Layout
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the layout of the Functions widget.
|
||||||
|
* @return The layout.
|
||||||
|
*/
|
||||||
|
QString getFunctionsWidgetLayout();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the layout of the Functions widget
|
||||||
|
* @param layout The layout of the Functions widget, either horizontal or vertical.
|
||||||
|
*/
|
||||||
|
void setFunctionsWidgetLayout(const QString &layout);
|
||||||
public slots:
|
public slots:
|
||||||
void refreshFont();
|
void refreshFont();
|
||||||
signals:
|
signals:
|
||||||
|
@ -526,7 +526,11 @@ FunctionsWidget::FunctionsWidget(MainWindow *main)
|
|||||||
addActions(itemConextMenu->actions());
|
addActions(itemConextMenu->actions());
|
||||||
|
|
||||||
// Use a custom context menu on the dock title bar
|
// Use a custom context menu on the dock title bar
|
||||||
actionHorizontal.setChecked(true);
|
if (Config()->getFunctionsWidgetLayout() == "horizontal") {
|
||||||
|
actionHorizontal.setChecked(true);
|
||||||
|
} else {
|
||||||
|
actionVertical.setChecked(true);
|
||||||
|
}
|
||||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(this, &QWidget::customContextMenuRequested, this,
|
connect(this, &QWidget::customContextMenuRequested, this,
|
||||||
&FunctionsWidget::showTitleContextMenu);
|
&FunctionsWidget::showTitleContextMenu);
|
||||||
@ -617,6 +621,7 @@ void FunctionsWidget::showTitleContextMenu(const QPoint &pt)
|
|||||||
void FunctionsWidget::onActionHorizontalToggled(bool enable)
|
void FunctionsWidget::onActionHorizontalToggled(bool enable)
|
||||||
{
|
{
|
||||||
if (enable) {
|
if (enable) {
|
||||||
|
Config()->setFunctionsWidgetLayout("horizontal");
|
||||||
functionModel->setNested(false);
|
functionModel->setNested(false);
|
||||||
ui->treeView->setIndentation(8);
|
ui->treeView->setIndentation(8);
|
||||||
}
|
}
|
||||||
@ -625,6 +630,7 @@ void FunctionsWidget::onActionHorizontalToggled(bool enable)
|
|||||||
void FunctionsWidget::onActionVerticalToggled(bool enable)
|
void FunctionsWidget::onActionVerticalToggled(bool enable)
|
||||||
{
|
{
|
||||||
if (enable) {
|
if (enable) {
|
||||||
|
Config()->setFunctionsWidgetLayout("vertical");
|
||||||
functionModel->setNested(true);
|
functionModel->setNested(true);
|
||||||
ui->treeView->setIndentation(20);
|
ui->treeView->setIndentation(20);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user