Skip to content

Commit

Permalink
Improve UI
Browse files Browse the repository at this point in the history
Signed-off-by: xiaoming <[email protected]>
  • Loading branch information
QQxiaoming committed Sep 10, 2024
1 parent 2ff6e7b commit d8c5595
Show file tree
Hide file tree
Showing 23 changed files with 319 additions and 189 deletions.
17 changes: 13 additions & 4 deletions src/globaloptions/globaloptionsadvancedwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>449</width>
<height>459</height>
<width>440</width>
<height>500</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>4</number>
Expand Down Expand Up @@ -270,12 +276,15 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>275</height>
<height>0</height>
</size>
</property>
</spacer>
Expand Down
17 changes: 13 additions & 4 deletions src/globaloptions/globaloptionsappearancewidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@
<x>0</x>
<y>0</y>
<width>550</width>
<height>598</height>
<height>538</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>4</number>
Expand Down Expand Up @@ -711,19 +717,22 @@
<number>70</number>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<height>0</height>
</size>
</property>
</spacer>
Expand Down
17 changes: 13 additions & 4 deletions src/globaloptions/globaloptionsgeneralwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>379</width>
<height>412</height>
<width>440</width>
<height>500</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
<number>4</number>
Expand Down Expand Up @@ -291,12 +297,15 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<height>0</height>
</size>
</property>
</spacer>
Expand Down
21 changes: 15 additions & 6 deletions src/globaloptions/globaloptionsterminalwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>434</width>
<height>497</height>
<width>440</width>
<height>518</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_8">
Expand Down Expand Up @@ -90,7 +96,7 @@
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -174,7 +180,7 @@
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
Expand Down Expand Up @@ -211,12 +217,15 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<height>0</height>
</size>
</property>
</spacer>
Expand Down
19 changes: 14 additions & 5 deletions src/globaloptions/globaloptionstransferwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>420</width>
<height>300</height>
<width>440</width>
<height>500</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>4</number>
Expand Down Expand Up @@ -135,7 +141,7 @@
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -173,12 +179,15 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<height>0</height>
</size>
</property>
</spacer>
Expand Down
69 changes: 30 additions & 39 deletions src/globaloptions/globaloptionswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,38 +130,32 @@ GlobalOptionsWindow::GlobalOptionsWindow(QWidget *parent) :
setWindowModality(Qt::ApplicationModal);
setWindowFlags(Qt::Tool);

QSplitter *splitter = new QSplitter(Qt::Horizontal, this);
splitter->setHandleWidth(1);
ui->horizontalLayout->addWidget(splitter);
treeView = new QTreeView(this);
treeView->setHeaderHidden(true);
model = new GlobalOptionsModel(treeView);
ui->splitter->setHandleWidth(1);
ui->treeView->setHeaderHidden(true);
model = new GlobalOptionsModel(ui->treeView);
model->setOnlyName(true);
model->setDistinguishType(false);
treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
splitter->addWidget(treeView);
QWidget *widget = new QWidget(this);
splitter->addWidget(widget);
widget->setLayout(new QVBoxLayout(widget));
widget->layout()->setContentsMargins(0,0,0,0);
splitter->setSizes(QList<int>() << 1 << 100);
splitter->setCollapsible(0,false);
splitter->setCollapsible(1,false);

globalOptionsGeneralWidget = new GlobalOptionsGeneralWidget(widget);
widget->layout()->addWidget(globalOptionsGeneralWidget);
globalOptionsAppearanceWidget = new GlobalOptionsAppearanceWidget(widget);
widget->layout()->addWidget(globalOptionsAppearanceWidget);
globalOptionsTerminalWidget = new GlobalOptionsTerminalWidget(widget);
widget->layout()->addWidget(globalOptionsTerminalWidget);
globalOptionsWindowWidget = new GlobalOptionsWindowWidget(widget);
widget->layout()->addWidget(globalOptionsWindowWidget);
globalOptionsTransferWidget = new GlobalOptionsTransferWidget(widget);
widget->layout()->addWidget(globalOptionsTransferWidget);
globalOptionsAdvancedWidget = new GlobalOptionsAdvancedWidget(widget);
widget->layout()->addWidget(globalOptionsAdvancedWidget);

treeView->setModel(model);
ui->treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
emptyWidget = new QWidget(this);
ui->stackedWidget->addWidget(emptyWidget);
ui->splitter->setSizes(QList<int>() << 1 << 100);
ui->splitter->setCollapsible(0,false);
ui->splitter->setCollapsible(1,false);

globalOptionsGeneralWidget = new GlobalOptionsGeneralWidget(this);
ui->stackedWidget->addWidget(globalOptionsGeneralWidget);
globalOptionsAppearanceWidget = new GlobalOptionsAppearanceWidget(this);
ui->stackedWidget->addWidget(globalOptionsAppearanceWidget);
globalOptionsTerminalWidget = new GlobalOptionsTerminalWidget(this);
ui->stackedWidget->addWidget(globalOptionsTerminalWidget);
globalOptionsWindowWidget = new GlobalOptionsWindowWidget(this);
ui->stackedWidget->addWidget(globalOptionsWindowWidget);
globalOptionsTransferWidget = new GlobalOptionsTransferWidget(this);
ui->stackedWidget->addWidget(globalOptionsTransferWidget);
globalOptionsAdvancedWidget = new GlobalOptionsAdvancedWidget(this);
ui->stackedWidget->addWidget(globalOptionsAdvancedWidget);

ui->treeView->setModel(model);
retranslateUi();
setActiveWidget(globalOptionsGeneralWidget);

Expand All @@ -177,6 +171,7 @@ GlobalOptionsWindow::GlobalOptionsWindow(QWidget *parent) :
QStringList fontFamilies = QFontDatabase::applicationFontFamilies(fontId);
if (fontFamilies.size() > 0) {
font.setFamily(fontFamilies[0]);
qDebug() << fontFamilies[0];
}
globalOptionsAppearanceWidget->ui->pushButtonSelectSeriesFont->setText("Built-in");
if(settings.contains("fontFamily")) {
Expand All @@ -192,6 +187,7 @@ GlobalOptionsWindow::GlobalOptionsWindow(QWidget *parent) :
font.setPointSize(12);
settings.setValue("fontPointSize", font.pointSize());
}
qDebug() << font;
globalOptionsAppearanceWidget->ui->spinBoxFontSize->setValue(font.pointSize());

globalOptionsAppearanceWidget->ui->comBoxColorSchemes->setEditable(true);
Expand Down Expand Up @@ -445,7 +441,7 @@ GlobalOptionsWindow::GlobalOptionsWindow(QWidget *parent) :
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &GlobalOptionsWindow::buttonBoxAccepted);
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &GlobalOptionsWindow::buttonBoxRejected);

connect(treeView, &QTreeView::clicked, [&](const QModelIndex &index) {
connect(ui->treeView, &QTreeView::clicked, [&](const QModelIndex &index) {
QString filePath = model->filePath(index);
QStringList pathList = filePath.split(model->separator());
GlobalOptionsModel::TreeNode node = rootInfo;
Expand Down Expand Up @@ -477,7 +473,7 @@ void GlobalOptionsWindow::retranslateUi()
GlobalOptionsModel::TreeNode advanced(tr("Advanced"),globalOptionsAdvancedWidget);
rootInfo.children << generalNode << appearance << terminal << window << transfer << advanced;
model->setTree(rootInfo);
treeView->setRootIndex(model->setRootPath("/"));
ui->treeView->setRootIndex(model->setRootPath("/"));
ui->retranslateUi(this);
globalOptionsGeneralWidget->ui->retranslateUi(this);
globalOptionsGeneralWidget->ui->retranslateUi(this);
Expand All @@ -490,15 +486,10 @@ void GlobalOptionsWindow::retranslateUi()

void GlobalOptionsWindow::setActiveWidget(QWidget *widget)
{
globalOptionsGeneralWidget->setVisible(false);
globalOptionsAppearanceWidget->setVisible(false);
globalOptionsTerminalWidget->setVisible(false);
globalOptionsWindowWidget->setVisible(false);
globalOptionsTransferWidget->setVisible(false);
globalOptionsAdvancedWidget->setVisible(false);
ui->stackedWidget->setCurrentWidget(emptyWidget);

if(widget)
widget->setVisible(true);
ui->stackedWidget->setCurrentWidget(widget);
}

void GlobalOptionsWindow::setAvailableColorSchemes(QStringList colorSchemes)
Expand Down
4 changes: 3 additions & 1 deletion src/globaloptions/globaloptionswindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <QColor>
#include <QTreeView>
#include <QList>
#include <QStackedWidget>

#include "globaloptionsgeneralwidget.h"
#include "globaloptionsappearancewidget.h"
#include "globaloptionsterminalwidget.h"
Expand Down Expand Up @@ -148,13 +150,13 @@ private slots:

private:
Ui::GlobalOptionsWindow *ui;
QWidget *emptyWidget;
GlobalOptionsGeneralWidget *globalOptionsGeneralWidget;
GlobalOptionsAppearanceWidget *globalOptionsAppearanceWidget;
GlobalOptionsTerminalWidget *globalOptionsTerminalWidget;
GlobalOptionsWindowWidget *globalOptionsWindowWidget;
GlobalOptionsTransferWidget *globalOptionsTransferWidget;
GlobalOptionsAdvancedWidget *globalOptionsAdvancedWidget;
QTreeView *treeView;
GlobalOptionsModel *model;
QFont font;
QString cursorColorStr;
Expand Down
23 changes: 16 additions & 7 deletions src/globaloptions/globaloptionswindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,28 @@
<rect>
<x>0</x>
<y>0</y>
<width>726</width>
<height>299</height>
<width>730</width>
<height>550</height>
</rect>
</property>
<property name="windowTitle">
<string>Global Options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>4</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout"/>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QTreeView" name="treeView"/>
<widget class="QWidget" name="verticalLayoutWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QStackedWidget" name="stackedWidget"/>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
Expand Down
Loading

0 comments on commit d8c5595

Please sign in to comment.