qt/LedOK/wProgramManager/wEditProgram/wmaintoolbar.cpp
2022-01-20 10:08:17 +08:00

149 lines
7.0 KiB
C++

#include "wmaintoolbar.h"
#include <wProgramManager/wEditProgram/wElement/eobject.h>
wMainToolBar::wMainToolBar(QWidget *parent) : QToolBar(parent)
{
setAttribute(Qt::WA_DeleteOnClose);
setFloatable(false);
setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
setIconSize(QSize(46, 40));
setProperty("ssType", "progEditor");
setProperty("ssName", "elementCreator");
setStyleSheet("margin-top: 9px; ");
// setFloatable(true);
// setMovable(true);
//QAction *spacer = new QAction();
QAction *actSave = new QAction(QIcon(":/res/ProgramManager/EditProgram/Save.png"), tr("save"));
QAction *actSaveAs = new QAction(QIcon(":/res/ProgramManager/EditProgram/SaveAs.png"), tr("Save as"));
QAction *actSetting = new QAction(QIcon(":/res/ProgramManager/EditProgram/Setting.png"), tr("Setting"));
QAction *actText = new QAction(QIcon(":/res/ProgramManager/EditProgram/Text.png"), tr("Text"));
QAction *actPhoto = new QAction(QIcon(":/res/ProgramManager/EditProgram/Photo.png"), tr("Photo"));
QAction *actMovie = new QAction(QIcon(":/res/ProgramManager/EditProgram/Movie.png"), tr("Video"));
QAction *actGif = new QAction(QIcon(":/res/ProgramManager/EditProgram/Gif.png"), tr("Gif"));
QAction *actDClock = new QAction(QIcon(":/res/ProgramManager/EditProgram/DClock.png"), tr("Clock"));
QAction *actAClock = new QAction(QIcon(":/res/ProgramManager/EditProgram/AClock.png"), tr("Analog Clock"));
QAction *actAudio = new QAction(QIcon(":/res/ProgramManager/EditProgram/Audio.png"), tr("Audio"));
// QAction *actOffice = new QAction(QIcon(":/res/ProgramManager/EditProgram/Office.png"), tr("Office"));
QAction *actTemp = new QAction(QIcon(":/res/ProgramManager/EditProgram/Temp.png"), tr("Environment"));
// QAction *actWeather = new QAction(QIcon(":/res/ProgramManager/EditProgram/Weather.png"), tr("Weather"));
// QAction *actRss = new QAction(QIcon(":/res/ProgramManager/EditProgram/Rss.png"), tr("Rss"));
// QAction *actTimer = new QAction(QIcon(":/res/ProgramManager/EditProgram/Timer.png"), tr("Timer"));
// QAction *actColorText = new QAction(QIcon(":/res/ProgramManager/EditProgram/ColorText.png"), tr("Colorful Word"));
QAction *actWindow = new QAction(QIcon(":/res/ProgramManager/EditProgram/Window.png"), tr("MuliContentWindow"));
actWindow->setToolTip(tr("In this window, a plurality of different program materials can be added and played according to the order of joining the list;"));
QAction *actPreview = new QAction(QIcon(":/res/ProgramManager/EditProgram/preview.png"), tr("Preview"));
QAction *actSend = new QAction(QIcon(":/res/ProgramManager/EditProgram/Send.png"), tr("Publish"));
actSave -> setProperty("action-type", "tool");
actSaveAs -> setProperty("action-type", "tool");
actSetting -> setProperty("action-type", "tool");
actPreview -> setProperty("action-type", "tool");
actSend -> setProperty("action-type", "tool");
actPreview -> setProperty("action-type", "tool");
actSave -> setObjectName("Save");
actSaveAs -> setObjectName("SaveAs");
actSetting -> setObjectName("Setting");
actSend -> setObjectName("Send");
actPreview -> setObjectName("Preview");
actText -> setProperty("action-type", "element");
actPhoto -> setProperty("action-type", "element");
actMovie -> setProperty("action-type", "element");
actGif -> setProperty("action-type", "element");
actDClock -> setProperty("action-type", "element");
actAClock -> setProperty("action-type", "element");
actAudio -> setProperty("action-type", "element");
// actOffice -> setProperty("action-type", "element");
actTemp -> setProperty("action-type", "element");
// actWeather -> setProperty("action-type", "element");
// actRss -> setProperty("action-type", "element");
// actTimer -> setProperty("action-type", "element");
// actColorText -> setProperty("action-type", "element");
actWindow -> setProperty("action-type", "element");
actText -> setData(QVariant(eObject::Text));
actPhoto -> setData(QVariant(eObject::Photo));
actMovie -> setData(QVariant(eObject::Movie));
actGif -> setData(QVariant(eObject::Gif));
actDClock -> setData(QVariant(eObject::DClock));
actAClock -> setData(QVariant(eObject::AClock));
actAudio -> setData(QVariant(eObject::Audio));
// actOffice -> setData(QVariant(eObject::Office));
actTemp -> setData(QVariant(eObject::Temp));
// actWeather -> setData(QVariant(eObject::Weather));
// actRss -> setData(QVariant(eObject::Rss));
// actTimer -> setData(QVariant(eObject::Timer));
// actColorText -> setData(QVariant(eObject::ColorText));
actWindow -> setData(QVariant(eObject::Window));
// addAction(spacer);
addAction(actSave);
addAction(actSaveAs);
addAction(actSetting);
addSeparator();
addAction(actWindow);
addSeparator();
addAction(actText);
addAction(actPhoto);
addAction(actMovie);
addAction(actGif);
addAction(actDClock);
addAction(actAClock);
// addAction(actAudio);
// addAction(actOffice);
addAction(actTemp);
// addAction(actWeather);
// addAction(actRss);
// addAction(actTimer);
// addAction(actColorText);
addSeparator();
// QString strAppPath = QApplication::applicationDirPath();
// strAppPath.replace(MACRO_DANYINFANXIEGAN, MACRO_DANYINXIEGAN);
// QFileInfo javeFile(strAppPath+"/prog_player/bin/java.exe");
// if(javeFile.exists()) {
addAction(actPreview);
addAction(actSend);
connect(this, SIGNAL(actionTriggered(QAction*)), this, SLOT(onActionTriggered(QAction*)));
}
void wMainToolBar::onActionTriggered(QAction *act)
{
if(act->property("action-type").toString() == "element") {
emit sigCreateElement(act->data().toInt());
} else if (act->objectName() == "Save") {
emit sigSave();
} else if (act->objectName() == "SaveAs") {
emit sigSaveAs();
} else if (act->objectName() == "Setting") {
emit sigSetting();
} else if (act->objectName() == "Preview") {
if(m_flagPreviewing==0)
{
emit sigPreview(0);
m_flagPreviewing=1;
act->setIcon(QIcon(":/res/ProgramManager/EditProgram/previewStop.png"));
act->setText(tr("Stop preview"));
}
else {
emit sigPreview(1);
m_flagPreviewing=0;
act->setIcon(QIcon(":/res/ProgramManager/EditProgram/preview.png"));
act->setText(tr("Preview"));
}
}else if (act->objectName() == "Send") {
emit sigSend();
}
}
void wMainToolBar::OnProgPlayerQuit()
{
m_flagPreviewing=0;
QAction *act=this->actions().takeAt(14);
act->setIcon(QIcon(":/res/ProgramManager/EditProgram/preview.png"));
act->setText(tr("Preview"));
}