simplified Icon allocation

This commit is contained in:
Miodrag Milanovic 2018-07-14 17:58:58 +02:00
parent 0b1ae3ce8d
commit f339f796a1
3 changed files with 50 additions and 83 deletions

View File

@ -42,7 +42,7 @@ BaseMainWindow::BaseMainWindow(std::unique_ptr<Context> context, QWidget *parent
log_files.clear(); log_files.clear();
log_streams.clear(); log_streams.clear();
setObjectName(QStringLiteral("BaseMainWindow")); setObjectName("BaseMainWindow");
resize(1024, 768); resize(1024, 768);
createMenusAndBars(); createMenusAndBars();
@ -93,34 +93,26 @@ void BaseMainWindow::writeInfo(std::string text) { console->info(text); }
void BaseMainWindow::createMenusAndBars() void BaseMainWindow::createMenusAndBars()
{ {
actionNew = new QAction("New", this); actionNew = new QAction("New", this);
QIcon iconNew; actionNew->setIcon(QIcon(":/icons/resources/new.png"));
iconNew.addFile(QStringLiteral(":/icons/resources/new.png"));
actionNew->setIcon(iconNew);
actionNew->setShortcuts(QKeySequence::New); actionNew->setShortcuts(QKeySequence::New);
actionNew->setStatusTip("New project file"); actionNew->setStatusTip("New project file");
connect(actionNew, SIGNAL(triggered()), this, SLOT(new_proj())); connect(actionNew, SIGNAL(triggered()), this, SLOT(new_proj()));
actionOpen = new QAction("Open", this); actionOpen = new QAction("Open", this);
QIcon iconOpen; actionOpen->setIcon(QIcon(":/icons/resources/open.png"));
iconOpen.addFile(QStringLiteral(":/icons/resources/open.png"));
actionOpen->setIcon(iconOpen);
actionOpen->setShortcuts(QKeySequence::Open); actionOpen->setShortcuts(QKeySequence::Open);
actionOpen->setStatusTip("Open an existing project file"); actionOpen->setStatusTip("Open an existing project file");
connect(actionOpen, SIGNAL(triggered()), this, SLOT(open_proj())); connect(actionOpen, SIGNAL(triggered()), this, SLOT(open_proj()));
QAction *actionSave = new QAction("Save", this); QAction *actionSave = new QAction("Save", this);
QIcon iconSave; actionSave->setIcon(QIcon(":/icons/resources/save.png"));
iconSave.addFile(QStringLiteral(":/icons/resources/save.png"));
actionSave->setIcon(iconSave);
actionSave->setShortcuts(QKeySequence::Save); actionSave->setShortcuts(QKeySequence::Save);
actionSave->setStatusTip("Save existing project to disk"); actionSave->setStatusTip("Save existing project to disk");
connect(actionSave, SIGNAL(triggered()), this, SLOT(save_proj()));
actionSave->setEnabled(false); actionSave->setEnabled(false);
connect(actionSave, SIGNAL(triggered()), this, SLOT(save_proj()));
QAction *actionExit = new QAction("Exit", this); QAction *actionExit = new QAction("Exit", this);
QIcon iconExit; actionExit->setIcon(QIcon(":/icons/resources/exit.png"));
iconExit.addFile(QStringLiteral(":/icons/resources/exit.png"));
actionExit->setIcon(iconExit);
actionExit->setShortcuts(QKeySequence::Quit); actionExit->setShortcuts(QKeySequence::Quit);
actionExit->setStatusTip("Exit the application"); actionExit->setStatusTip("Exit the application");
connect(actionExit, SIGNAL(triggered()), this, SLOT(close())); connect(actionExit, SIGNAL(triggered()), this, SLOT(close()));

View File

@ -90,30 +90,25 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), net
propertyEditor->show(); propertyEditor->show();
const QIcon searchIcon(":/icons/resources/zoom.png");
QLineEdit *lineEdit = new QLineEdit(); QLineEdit *lineEdit = new QLineEdit();
lineEdit->setClearButtonEnabled(true); lineEdit->setClearButtonEnabled(true);
lineEdit->addAction(searchIcon, QLineEdit::LeadingPosition); lineEdit->addAction(QIcon(":/icons/resources/zoom.png"), QLineEdit::LeadingPosition);
lineEdit->setPlaceholderText("Search..."); lineEdit->setPlaceholderText("Search...");
actionFirst = new QAction("", this); actionFirst = new QAction("", this);
QIcon iconFirst(QStringLiteral(":/icons/resources/resultset_first.png")); actionFirst->setIcon(QIcon(":/icons/resources/resultset_first.png"));
actionFirst->setIcon(iconFirst);
actionFirst->setEnabled(false); actionFirst->setEnabled(false);
actionPrev = new QAction("", this); actionPrev = new QAction("", this);
QIcon iconPrev(QStringLiteral(":/icons/resources/resultset_previous.png")); actionPrev->setIcon(QIcon(":/icons/resources/resultset_previous.png"));
actionPrev->setIcon(iconPrev);
actionPrev->setEnabled(false); actionPrev->setEnabled(false);
actionNext = new QAction("", this); actionNext = new QAction("", this);
QIcon iconNext(QStringLiteral(":/icons/resources/resultset_next.png")); actionNext->setIcon(QIcon(":/icons/resources/resultset_next.png"));
actionNext->setIcon(iconNext);
actionNext->setEnabled(false); actionNext->setEnabled(false);
actionLast = new QAction("", this); actionLast = new QAction("", this);
QIcon iconLast(QStringLiteral(":/icons/resources/resultset_last.png")); actionLast->setIcon(QIcon(":/icons/resources/resultset_last.png"));
actionLast->setIcon(iconLast);
actionLast->setEnabled(false); actionLast->setEnabled(false);
QToolBar *toolbar = new QToolBar(); QToolBar *toolbar = new QToolBar();

View File

@ -72,60 +72,46 @@ void MainWindow::createMenu()
menuBar->addAction(menu_Design->menuAction()); menuBar->addAction(menu_Design->menuAction());
actionLoadJSON = new QAction("Open JSON", this); actionLoadJSON = new QAction("Open JSON", this);
QIcon iconLoadJSON; actionLoadJSON->setIcon(QIcon(":/icons/resources/open_json.png"));
iconLoadJSON.addFile(QStringLiteral(":/icons/resources/open_json.png"));
actionLoadJSON->setIcon(iconLoadJSON);
actionLoadJSON->setStatusTip("Open an existing JSON file"); actionLoadJSON->setStatusTip("Open an existing JSON file");
connect(actionLoadJSON, SIGNAL(triggered()), this, SLOT(open_json()));
actionLoadJSON->setEnabled(true); actionLoadJSON->setEnabled(true);
connect(actionLoadJSON, SIGNAL(triggered()), this, SLOT(open_json()));
actionLoadPCF = new QAction("Open PCF", this); actionLoadPCF = new QAction("Open PCF", this);
QIcon iconLoadPCF; actionLoadPCF->setIcon(QIcon(":/icons/resources/open_pcf.png"));
iconLoadPCF.addFile(QStringLiteral(":/icons/resources/open_pcf.png"));
actionLoadPCF->setIcon(iconLoadPCF);
actionLoadPCF->setStatusTip("Open PCF file"); actionLoadPCF->setStatusTip("Open PCF file");
connect(actionLoadPCF, SIGNAL(triggered()), this, SLOT(open_pcf()));
actionLoadPCF->setEnabled(false); actionLoadPCF->setEnabled(false);
connect(actionLoadPCF, SIGNAL(triggered()), this, SLOT(open_pcf()));
actionPack = new QAction("Pack", this); actionPack = new QAction("Pack", this);
QIcon iconPack; actionPack->setIcon(QIcon(":/icons/resources/pack.png"));
iconPack.addFile(QStringLiteral(":/icons/resources/pack.png"));
actionPack->setIcon(iconPack);
actionPack->setStatusTip("Pack current design"); actionPack->setStatusTip("Pack current design");
connect(actionPack, SIGNAL(triggered()), task, SIGNAL(pack()));
actionPack->setEnabled(false); actionPack->setEnabled(false);
connect(actionPack, SIGNAL(triggered()), task, SIGNAL(pack()));
actionAssignBudget = new QAction("Assign Budget", this); actionAssignBudget = new QAction("Assign Budget", this);
QIcon iconAssignBudget; actionAssignBudget->setIcon(QIcon(":/icons/resources/time_add.png"));
iconAssignBudget.addFile(QStringLiteral(":/icons/resources/time_add.png"));
actionAssignBudget->setIcon(iconAssignBudget);
actionAssignBudget->setStatusTip("Assign time budget for current design"); actionAssignBudget->setStatusTip("Assign time budget for current design");
connect(actionAssignBudget, SIGNAL(triggered()), this, SLOT(budget()));
actionAssignBudget->setEnabled(false); actionAssignBudget->setEnabled(false);
connect(actionAssignBudget, SIGNAL(triggered()), this, SLOT(budget()));
actionPlace = new QAction("Place", this); actionPlace = new QAction("Place", this);
QIcon iconPlace; actionPlace->setIcon(QIcon(":/icons/resources/place.png"));
iconPlace.addFile(QStringLiteral(":/icons/resources/place.png"));
actionPlace->setIcon(iconPlace);
actionPlace->setStatusTip("Place current design"); actionPlace->setStatusTip("Place current design");
connect(actionPlace, SIGNAL(triggered()), this, SLOT(place()));
actionPlace->setEnabled(false); actionPlace->setEnabled(false);
connect(actionPlace, SIGNAL(triggered()), this, SLOT(place()));
actionRoute = new QAction("Route", this); actionRoute = new QAction("Route", this);
QIcon iconRoute; actionRoute->setIcon(QIcon(":/icons/resources/route.png"));
iconRoute.addFile(QStringLiteral(":/icons/resources/route.png"));
actionRoute->setIcon(iconRoute);
actionRoute->setStatusTip("Route current design"); actionRoute->setStatusTip("Route current design");
connect(actionRoute, SIGNAL(triggered()), task, SIGNAL(route()));
actionRoute->setEnabled(false); actionRoute->setEnabled(false);
connect(actionRoute, SIGNAL(triggered()), task, SIGNAL(route()));
actionSaveAsc = new QAction("Save ASC", this); actionSaveAsc = new QAction("Save ASC", this);
QIcon iconSaveAsc; actionSaveAsc->setIcon(QIcon(":/icons/resources/save_asc.png"));
iconSaveAsc.addFile(QStringLiteral(":/icons/resources/save_asc.png"));
actionSaveAsc->setIcon(iconSaveAsc);
actionSaveAsc->setStatusTip("Save ASC file"); actionSaveAsc->setStatusTip("Save ASC file");
connect(actionSaveAsc, SIGNAL(triggered()), this, SLOT(save_asc()));
actionSaveAsc->setEnabled(false); actionSaveAsc->setEnabled(false);
connect(actionSaveAsc, SIGNAL(triggered()), this, SLOT(save_asc()));
QToolBar *taskFPGABar = new QToolBar(); QToolBar *taskFPGABar = new QToolBar();
addToolBar(Qt::TopToolBarArea, taskFPGABar); addToolBar(Qt::TopToolBarArea, taskFPGABar);
@ -147,28 +133,22 @@ void MainWindow::createMenu()
menu_Design->addAction(actionSaveAsc); menu_Design->addAction(actionSaveAsc);
actionPlay = new QAction("Play", this); actionPlay = new QAction("Play", this);
QIcon iconPlay; actionPlay->setIcon(QIcon(":/icons/resources/control_play.png"));
iconPlay.addFile(QStringLiteral(":/icons/resources/control_play.png"));
actionPlay->setIcon(iconPlay);
actionPlay->setStatusTip("Continue running task"); actionPlay->setStatusTip("Continue running task");
connect(actionPlay, SIGNAL(triggered()), task, SLOT(continue_thread()));
actionPlay->setEnabled(false); actionPlay->setEnabled(false);
connect(actionPlay, SIGNAL(triggered()), task, SLOT(continue_thread()));
actionPause = new QAction("Pause", this); actionPause = new QAction("Pause", this);
QIcon iconPause; actionPause->setIcon(QIcon(":/icons/resources/control_pause.png"));
iconPause.addFile(QStringLiteral(":/icons/resources/control_pause.png"));
actionPause->setIcon(iconPause);
actionPause->setStatusTip("Pause running task"); actionPause->setStatusTip("Pause running task");
connect(actionPause, SIGNAL(triggered()), task, SLOT(pause_thread()));
actionPause->setEnabled(false); actionPause->setEnabled(false);
connect(actionPause, SIGNAL(triggered()), task, SLOT(pause_thread()));
actionStop = new QAction("Stop", this); actionStop = new QAction("Stop", this);
QIcon iconStop; actionStop->setIcon(QIcon(":/icons/resources/control_stop.png"));
iconStop.addFile(QStringLiteral(":/icons/resources/control_stop.png"));
actionStop->setIcon(iconStop);
actionStop->setStatusTip("Stop running task"); actionStop->setStatusTip("Stop running task");
connect(actionStop, SIGNAL(triggered()), task, SLOT(terminate_thread()));
actionStop->setEnabled(false); actionStop->setEnabled(false);
connect(actionStop, SIGNAL(triggered()), task, SLOT(terminate_thread()));
QToolBar *taskToolBar = new QToolBar(); QToolBar *taskToolBar = new QToolBar();
addToolBar(Qt::TopToolBarArea, taskToolBar); addToolBar(Qt::TopToolBarArea, taskToolBar);