diff --git a/src/maininterface.cpp b/src/maininterface.cpp index e28d937..c2fb16a 100644 --- a/src/maininterface.cpp +++ b/src/maininterface.cpp @@ -132,20 +132,22 @@ void MainInterface::init() m_belowwidget->setLayout(m_layout); - connect(m_list, &QListView::clicked, this, [=](const QModelIndex &index){ - QString type = index.data().toString(); - if("GlobalTheme" == type){ - m_themestackedwidget->setCurrentIndex(0); - }else if("IconTheme" == type){ - m_themestackedwidget->setCurrentIndex(1); - }else if("CursorTheme" == type){ - m_themestackedwidget->setCurrentIndex(2); - }else if("PlymouthTheme" == type){ - m_themestackedwidget->setCurrentIndex(3); - this->startShowPlymouth(); - }else if("GrubTheme" == type){ - m_themestackedwidget->setCurrentIndex(4); - } + connect(m_globalbtn,&TypeButton::clicked,m_themestackedwidget,[=](){ + m_themestackedwidget->setCurrentIndex(0); + }); + connect(m_iconbtn,&TypeButton::clicked,m_themestackedwidget,[=](){ + m_themestackedwidget->setCurrentIndex(1); + }); + connect(m_cursorbtn,&TypeButton::clicked,m_themestackedwidget,[=](){ + m_themestackedwidget->setCurrentIndex(2); + }); + connect(m_plymouthbtn,&TypeButton::clicked,m_themestackedwidget,[=](){ + m_themestackedwidget->setCurrentIndex(3); + this->startShowPlymouth(); + }); + connect(m_grubbtn,&TypeButton::clicked,m_themestackedwidget,[=](){ + m_themestackedwidget->setCurrentIndex(4); + m_grubbtn->setChecked(true); }); connect(m_buildbtn,&QPushButton::clicked,this,[=](){ m_info = new InfoCreateWidget(nullptr,"create"); @@ -160,8 +162,8 @@ void MainInterface::init() delete m_info; }); }); -//// connect() -// qDebug()<contentsMargins(); +// connect() + qDebug()<contentsMargins(); } /** @@ -173,121 +175,120 @@ void MainInterface::init() */ void MainInterface::initLeftBar() { - m_navigationwidget = new QWidget(m_belowwidget); + m_navigationwidget = new BaseLeftWidget(m_belowwidget); m_navigationwidget->setMinimumSize(200,620); m_navigationwidget->setMaximumWidth(200); - m_navigation = new kdk::KNavigationBar(m_navigationwidget); - QVBoxLayout *leftLayout = new QVBoxLayout(m_navigationwidget); - m_globalbtn = new QStandardItem("GlobalTheme"); + QButtonGroup *buttonGroup = new QButtonGroup(m_navigationwidget); + buttonGroup->setExclusive(true); +// QButtonGroup *bootbuttonGroup = new QButtonGroup(m_navigationwidget); + + m_globalbtn = new TypeButton(m_navigationwidget); m_globalbtn->setText(tr("GlobalTheme")); - m_iconbtn = new QStandardItem("IconTheme"); + m_iconbtn = new TypeButton(m_navigationwidget); m_iconbtn->setText(tr("IconTheme")); - m_cursorbtn = new QStandardItem("CursorTheme"); + m_cursorbtn = new TypeButton(m_navigationwidget); m_cursorbtn->setText(tr("CursorTheme")); - m_plymouthbtn = new QStandardItem("PlymouthTheme"); + m_plymouthbtn = new TypeButton(m_navigationwidget); m_plymouthbtn->setText(tr("PlymouthTheme")); - m_grubbtn = new QStandardItem("GrubTheme"); + m_grubbtn = new TypeButton(m_navigationwidget); m_grubbtn->setText(tr("GrubTheme")); - m_model = m_navigation->model(); - m_list = m_navigation->listview(); - - m_model->appendRow(m_globalbtn); - m_model->appendRow(m_iconbtn); - m_model->appendRow(m_cursorbtn); - m_model->appendRow(m_plymouthbtn); - m_model->appendRow(m_grubbtn); - m_list->setModel(m_model); - m_list->setMaximumWidth(200); - m_buildbtn = new QPushButton(m_navigationwidget); m_buildbtn->setFont(QFont("Arial" , 12)); + buttonGroup->addButton(m_globalbtn); + buttonGroup->addButton(m_iconbtn); + buttonGroup->addButton(m_cursorbtn); + buttonGroup->addButton(m_plymouthbtn); + buttonGroup->addButton(m_grubbtn); - leftLayout->addWidget(m_navigation); + m_globalbtn->setCheckable(true); + m_iconbtn->setCheckable(true); + m_cursorbtn->setCheckable(true); + m_plymouthbtn->setCheckable(true); + m_grubbtn->setCheckable(true); + + m_globalbtn->setFlat(true); + m_iconbtn->setFlat(true); + m_cursorbtn->setFlat(true); + m_plymouthbtn->setFlat(true); + m_grubbtn->setFlat(true); + + leftLayout->addWidget(m_globalbtn); + leftLayout->addWidget(m_iconbtn); + leftLayout->addWidget(m_cursorbtn); + leftLayout->addWidget(m_plymouthbtn); + leftLayout->addWidget(m_grubbtn); leftLayout->addStretch(); leftLayout->addWidget(m_buildbtn); } void MainInterface::setGlobalTheme() { + m_themestackedwidget->setCurrentIndex(0); + m_globalbtn->setHidden(false); + m_globalbtn->setChecked(true); + m_globalbtn->setHidden(false); + m_iconbtn->setHidden(false); + m_cursorbtn->setHidden(false); + m_plymouthbtn->setHidden(false); + m_grubbtn->setHidden(false); m_buildbtn->setText(tr("Start Global Theme Building")); FileProcess::g_createThemeType = "globalTheme"; - m_themestackedwidget->setCurrentIndex(0); - - m_list->setRowHidden(0,false); - m_list->setRowHidden(1,false); - m_list->setRowHidden(2,false); - m_list->setRowHidden(3,false); - m_list->setRowHidden(4,false); - QModelIndex index = m_model->index(0, 0); - m_list->setCurrentIndex(index); - } void MainInterface::setIconTheme() { + m_themestackedwidget->setCurrentIndex(1); + m_globalbtn->setHidden(true); + m_iconbtn->setHidden(false); + m_iconbtn->setChecked(true); + m_cursorbtn->setHidden(true); + m_plymouthbtn->setHidden(true); + m_grubbtn->setHidden(true); m_buildbtn->setText(tr("Start Icon Theme Building")); FileProcess::g_createThemeType = "iconTheme"; - m_themestackedwidget->setCurrentIndex(1); - - m_list->setRowHidden(0,true); - m_list->setRowHidden(1,false); - m_list->setRowHidden(2,true); - m_list->setRowHidden(3,true); - m_list->setRowHidden(4,true); - QModelIndex index = m_model->index(1, 0); - m_list->setCurrentIndex(index); - } void MainInterface::setCursorTheme() { + m_themestackedwidget->setCurrentIndex(2); + m_globalbtn->setHidden(true); + m_iconbtn->setHidden(true); + m_cursorbtn->setHidden(false); + m_cursorbtn->setChecked(true); + m_plymouthbtn->setHidden(true); + m_grubbtn->setHidden(true); m_buildbtn->setText(tr("Start Cursor Theme Building")); FileProcess::g_createThemeType = "cursorTheme"; - m_themestackedwidget->setCurrentIndex(2); - - m_list->setRowHidden(0,true); - m_list->setRowHidden(1,true); - m_list->setRowHidden(2,false); - m_list->setRowHidden(3,true); - m_list->setRowHidden(4,true); - QModelIndex index = m_model->index(2, 0); - m_list->setCurrentIndex(index); } void MainInterface::setPlymouthTheme() { + m_themestackedwidget->setCurrentIndex(3); + m_globalbtn->setHidden(true); + m_iconbtn->setHidden(true); + m_cursorbtn->setHidden(true); + m_plymouthbtn->setHidden(false); + m_plymouthbtn->setChecked(true); + m_grubbtn->setHidden(true); m_buildbtn->setText(tr("Start Plymouth Theme Building")); FileProcess::g_createThemeType = "plymouthTheme"; - m_themestackedwidget->setCurrentIndex(3); - - m_list->setRowHidden(0,true); - m_list->setRowHidden(1,true); - m_list->setRowHidden(2,true); - m_list->setRowHidden(3,false); - m_list->setRowHidden(4,true); - QModelIndex index = m_model->index(3, 0); - m_list->setCurrentIndex(index); - } void MainInterface::setGrubTheme() { + m_themestackedwidget->setCurrentIndex(4); + m_globalbtn->setHidden(true); + m_iconbtn->setHidden(true); + m_cursorbtn->setHidden(true); + m_plymouthbtn->setHidden(true); + m_grubbtn->setHidden(false); + m_grubbtn->setChecked(true); m_buildbtn->setText(tr("Start Grub Theme Building")); FileProcess::g_createThemeType = "grubTheme"; - m_themestackedwidget->setCurrentIndex(4); - - m_list->setRowHidden(0,true); - m_list->setRowHidden(1,true); - m_list->setRowHidden(2,true); - m_list->setRowHidden(3,true); - m_list->setRowHidden(4,false); - QModelIndex index = m_model->index(4, 0); - m_list->setCurrentIndex(index); - } void MainInterface::getThemeInfo(const HistoryInfo &InfoData) @@ -372,17 +373,17 @@ void MainInterface::refresh(QString themeType) void MainInterface::updateButtonGroup(bool isGlobalTheme) { if(isGlobalTheme){ -// m_plymouthbtn->setVisible(false); -// m_grubbtn->setVisible(false); -// m_globalbtn->setVisible(true); -// m_iconbtn->setVisible(true); -// m_cursorbtn->setVisible(true); + m_plymouthbtn->setVisible(false); + m_grubbtn->setVisible(false); + m_globalbtn->setVisible(true); + m_iconbtn->setVisible(true); + m_cursorbtn->setVisible(true); }else{ -// m_globalbtn->setVisible(false); -// m_iconbtn->setVisible(false); -// m_cursorbtn->setVisible(false); -// m_plymouthbtn->setVisible(true); -// m_grubbtn->setVisible(true); + m_globalbtn->setVisible(false); + m_iconbtn->setVisible(false); + m_cursorbtn->setVisible(false); + m_plymouthbtn->setVisible(true); + m_grubbtn->setVisible(true); } } diff --git a/src/maininterface.h b/src/maininterface.h index 9bbfb41..4b97066 100644 --- a/src/maininterface.h +++ b/src/maininterface.h @@ -25,7 +25,7 @@ #include #include #include -#include + class MainInterface : public QWidget { @@ -89,18 +89,13 @@ private: InfoCreateWidget *m_info; QHBoxLayout *m_layout; - QWidget *m_navigationwidget; - kdk::KNavigationBar *m_navigation; - QStandardItem *m_globalbtn; - QStandardItem *m_iconbtn; - QStandardItem *m_cursorbtn; - QStandardItem *m_plymouthbtn; - QStandardItem *m_grubbtn; - - QStandardItemModel*m_model; - QListView* m_list; - + BaseLeftWidget *m_navigationwidget; + TypeButton *m_globalbtn; + TypeButton *m_iconbtn; + TypeButton *m_cursorbtn; + TypeButton *m_plymouthbtn; + TypeButton *m_grubbtn; QPushButton *m_buildbtn; QWidget *m_belowwidget;