Skip to content

Commit

Permalink
[stylesheet]:修改 QHeaderView和QComboBox样式;
Browse files Browse the repository at this point in the history
  • Loading branch information
RealChuan committed May 7, 2024
1 parent 4d823fe commit 7042732
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
22 changes: 12 additions & 10 deletions src/plugins/coreplugin/configwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@
class ConfigWidget::ConfigWidgetPrivate
{
public:
ConfigWidgetPrivate(ConfigWidget *q)
explicit ConfigWidgetPrivate(ConfigWidget *q)
: q_ptr(q)
{
languageBox = new QComboBox(q_ptr);
languageBox->addItem(tr("Chinese"), Utils::LanguageConfig::Language::Chinese);
languageBox->addItem(tr("English"), Utils::LanguageConfig::Language::English);
languageBox->setView(new QListView(languageBox));
languageBox->addItem("", Utils::LanguageConfig::Language::Chinese);
languageBox->addItem("", Utils::LanguageConfig::Language::English);
}

void setupUI()
{
auto fromLayout = new QFormLayout(q_ptr);
auto *fromLayout = new QFormLayout(q_ptr);
fromLayout->addRow(tr("Language(Requires Restart): "), languageBox);
}

void setData()
void setData() const
{
languageBox->setCurrentIndex(Utils::LanguageConfig::instance()->currentLanguage());
}
Expand All @@ -39,20 +40,21 @@ ConfigWidget::ConfigWidget(QWidget *parent)
buildConnect();
Utils::setMacComboBoxStyle(this);
d_ptr->setData();
setTr();
}

ConfigWidget::~ConfigWidget() {}
ConfigWidget::~ConfigWidget() = default;

void ConfigWidget::onReloadLanguage(int)
void ConfigWidget::onReloadLanguage(int /*unused*/)
{
Utils::LanguageConfig::instance()->loadLanguage(
Utils::LanguageConfig::Language(d_ptr->languageBox->currentData().toInt()));
}

void ConfigWidget::changeEvent(QEvent *e)
void ConfigWidget::changeEvent(QEvent *event)
{
QWidget::changeEvent(e);
switch (e->type()) {
QWidget::changeEvent(event);
switch (event->type()) {
case QEvent::LanguageChange: setTr(); break;
default: break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/coreplugin/configwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private slots:
void onReloadLanguage(int index);

protected:
void changeEvent(QEvent *e) override;
void changeEvent(QEvent *event) override;

private:
void buildConnect();
Expand Down
3 changes: 2 additions & 1 deletion src/resource/qss/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ QStackedWidget {
*****************************************************************************/

QHeaderView::section {
background: rgb(45, 45, 45);
background: rgb(54, 62, 78);
color: white;
border: 1px soild white;
}
Expand Down Expand Up @@ -359,6 +359,7 @@ QComboBox {
color: #495060;
background: #fff;
padding: 0 4px;
combobox-popup: 0;
}

QComboBox:!editable{
Expand Down
9 changes: 4 additions & 5 deletions src/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,25 +412,24 @@ auto Utils::crashPath() -> QString
{
const auto path = configLocation() + "/crash";
generateDirectorys(path);
return QDir::toNativeSeparators(path);
return path;
}

auto Utils::logPath() -> QString
{
const auto path = configLocation() + "/log";
generateDirectorys(path);
return QDir::toNativeSeparators(path);
return path;
}

auto Utils::configPath() -> QString
{
const auto path = configLocation() + "/config";
generateDirectorys(path);
return QDir::toNativeSeparators(path);
return path;
}

auto Utils::configFilePath() -> QString
{
const auto path = configPath() + "/config.ini";
return QDir::toNativeSeparators(path);
return (configPath() + "/config.ini");
}

0 comments on commit 7042732

Please sign in to comment.