compilerset toolbar ok

This commit is contained in:
royqh1979@gmail.com 2021-04-18 11:41:41 +08:00
parent fbb86a78e6
commit 4c4fd9fb2b
5 changed files with 47 additions and 4 deletions

View File

@ -6,6 +6,7 @@
#include "settings.h"
#include <QCloseEvent>
#include <QComboBox>
#include <QFileDialog>
#include <QLabel>
@ -19,8 +20,8 @@ MainWindow::MainWindow(QWidget *parent)
{
ui->setupUi(this);
// status bar
mFileInfoStatus=new QLabel(this);
mFileEncodingStatus = new QLabel(this);
mFileInfoStatus=new QLabel();
mFileEncodingStatus = new QLabel();
mFileInfoStatus->setStyleSheet("margin-left:10px; margin-right:10px");
mFileEncodingStatus->setStyleSheet("margin-left:10px; margin-right:10px");
ui->statusbar->addWidget(mFileInfoStatus);
@ -31,6 +32,12 @@ MainWindow::MainWindow(QWidget *parent)
ui->EditorPanel);
setupActions();
ui->EditorTabsRight->setVisible(false);
mCompilerSet = new QComboBox();
ui->toolbarCompilerSet->addWidget(mCompilerSet);
connect(mCompilerSet,QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &MainWindow::onCompilerSetChanged);
updateCompilerSet();
}
MainWindow::~MainWindow()
@ -84,6 +91,19 @@ void MainWindow::setupActions() {
}
void MainWindow::updateCompilerSet()
{
mCompilerSet->clear();
int index=pSettings->compilerSets().defaultIndex();
for (int i=0;i<pSettings->compilerSets().list().size();i++) {
mCompilerSet->addItem(pSettings->compilerSets().list()[i]->name());
}
if (index < 0 || index>=mCompilerSet->count()) {
index = 0;
}
mCompilerSet->setCurrentIndex(index);
}
void MainWindow::on_actionNew_triggered()
{
@ -139,3 +159,11 @@ void MainWindow::on_actionOptions_triggered()
SettingsDialog settingsDialog;
settingsDialog.exec();
}
void MainWindow::onCompilerSetChanged(int index)
{
if (index<0)
return;
pSettings->compilerSets().setDefaultIndex(index);
pSettings->compilerSets().saveDefaultIndex();
}

View File

@ -9,6 +9,7 @@ QT_END_NAMESPACE
class EditorList;
class QLabel;
class QComboBox;
class MainWindow : public QMainWindow
{
@ -37,14 +38,20 @@ private slots:
void on_actionOptions_triggered();
// qt will auto bind slots with the prefix "on_"
void onCompilerSetChanged(int index);
private:
void setupActions();
void updateCompilerSet();
private:
Ui::MainWindow *ui;
EditorList* mEditorList;
QLabel* mFileInfoStatus;
QLabel* mFileEncodingStatus;
QComboBox* mCompilerSet;
// QWidget interface
protected:

View File

@ -205,7 +205,7 @@
<addaction name="menuTools"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar">
<widget class="QToolBar" name="toolbarMain">
<property name="windowTitle">
<string>toolBar</string>
</property>
@ -220,7 +220,7 @@
<addaction name="actionSave"/>
<addaction name="actionSaveAll"/>
</widget>
<widget class="QToolBar" name="toolBar_2">
<widget class="QToolBar" name="toolbarCompilerSet">
<property name="windowTitle">
<string>toolBar_2</string>
</property>

View File

@ -1021,6 +1021,13 @@ void Settings::CompilerSets::loadSets()
}
}
void Settings::CompilerSets::saveDefaultIndex()
{
mSettings->mSettings.beginGroup(SETTING_COMPILTER_SETS);
mSettings->mSettings.setValue(SETTING_COMPILTER_SETS_DEFAULT_INDEX,mDefaultIndex);
mSettings->mSettings.endGroup();
}
void Settings::CompilerSets::deleteSet(int index)
{
// Erase all sections at and above from disk

View File

@ -206,6 +206,7 @@ public:
void findSets();
void saveSets();
void loadSets();
void saveDefaultIndex();
void deleteSet(int index);
//properties
CompilerSetList& list();