42 #include <QApplication>
43 #include <QCloseEvent>
44 #include <QDesktopWidget>
46 #include <QFileDialog>
47 #include <QInputDialog>
48 #include <QMessageBox>
49 #include <QPushButton>
52 #include <QStringList>
53 #include <QtConcurrent>
108 mStackedWidget->
addWidget(mPluginManager);
134 mStackedWidget->
addWidget(mWelcomeScreen);
136 mStackedWidget->
addWidget(mGateLibraryManager);
142 mActionImportNetlist =
new Action(
this);
143 mActionExportProject =
new Action(
this);
144 mActionImportProject =
new Action(
this);
145 mActionGateLibraryManager =
new Action(
this);
146 mActionAbout =
new Action(
this);
148 mActionStartRecording =
new Action(
this);
149 mActionStopRecording =
new Action(
this);
150 mActionPlayMacro =
new Action(
this);
151 mActionUndo =
new Action(
this);
153 mActionSettings =
new Action(
this);
154 mActionPluginManager =
new Action(
this);
155 mActionQuit =
new Action(
this);
189 mMenuFile =
new QMenu(mMenuBar);
190 mMenuEdit =
new QMenu(mMenuBar);
191 mMenuMacro =
new QMenu(mMenuBar);
192 mMenuUtilities =
new QMenu(mMenuBar);
193 mMenuPlugins =
new QMenu(mMenuBar);
194 mMenuHelp =
new QMenu(mMenuBar);
208 QMenu* menuImport =
new QMenu(
"Import …",
this);
209 menuImport->
addAction(mActionImportNetlist);
210 menuImport->
addAction(mActionImportProject);
212 QMenu* menuExport =
new QMenu(
"Export …",
this);
213 bool hasExporter =
false;
216 if (it.second.empty())
continue;
226 for (std::string ex : it.second)
237 menuExport->
addAction(mActionExportProject);
239 mMenuFile->
addMenu(menuImport);
240 mMenuFile->
addMenu(menuExport);
248 "eXpert Settings:Debug",
249 "Specifies whether each netlist event gets dumped to event log. Might generate a lot of output thus slowing down hal system."
257 mMenuMacro->
addAction(mActionStartRecording);
258 mMenuMacro->
addAction(mActionStopRecording);
262 mMenuUtilities->
addAction(mActionPluginManager);
263 mMenuUtilities->
addAction(mActionGateLibraryManager);
270 mRightToolBar->
addAction(mActionPluginManager);
271 mRightToolBar->
addAction(mActionGateLibraryManager);
272 mRightToolBar->
addAction(mActionSettings);
274 mActionStartRecording->
setText(
"Start recording");
275 mActionStopRecording->
setText(
"Stop recording");
276 mActionPlayMacro->
setText(
"Play macro");
283 mActionImportNetlist->
setText(
"Import Netlist");
284 mActionImportProject->
setText(
"Import Project");
285 mActionExportProject->
setText(
"Export Project");
286 mActionGateLibraryManager->
setText(
"Gate Library Manager");
288 mActionAbout->
setText(
"About");
289 mActionSettings->
setText(
"Settings");
290 mActionPluginManager->
setText(
"Plugin Manager");
295 mMenuUtilities->
setTitle(
"Utilities");
304 mSettingUndoLast =
new SettingsItemKeybind(
"Undo Last Action",
"keybinds/action_undo",
QKeySequence(
"Ctrl+Z"),
"Keybindings:Global",
"Keybind for having last user interaction undone.");
341 case StyleSheetOption::Dark:
342 styleSheetToOpen =
":/style/dark";
344 case StyleSheetOption::Light:
345 styleSheetToOpen =
":/style/light";
350 QFile stylesheet(styleSheetToOpen);
362 return mHalIconStyle;
367 return mOpenFileIconPath;
372 return mOpenFileIconStyle;
377 return mQuitIconPath;
382 return mQuitIconStyle;
387 return mSettingsIconPath;
392 return mSettingsIconStyle;
397 return mPluginsIconPath;
402 return mPluginsIconStyle;
407 return mUndoIconPath;
412 return mUndoIconStyle;
417 return mNeGateIconPath;
421 return mNeGateIconStyle;
426 return mDisabledIconStyle;
436 mHalIconStyle =
style;
441 mOpenFileIconPath = path;
446 mOpenFileIconStyle =
style;
451 mQuitIconPath = path;
456 mQuitIconStyle =
style;
461 mSettingsIconPath = path;
466 mSettingsIconStyle =
style;
471 mPluginsIconPath = path;
476 mPluginsIconStyle =
style;
481 mUndoIconPath = path;
486 mUndoIconStyle =
style;
491 mNeGateIconPath = path;
495 mNeGateIconStyle =
style;
500 mDisabledIconStyle =
style;
516 mLayoutArea->
clear();
519 void MainWindow::handleEventLogEnabled(
bool enable)
561 mFileActions->
setup();
581 mFileActions->
setup(
nullptr, mPluginManager);
591 mMenuPlugins->
clear();
596 mFileActions->
setup();
604 msgBox.
setText(
"Error: New Project");
622 msgBox.
setText(
"Error: Open Project");
634 for (
int inx = 0; inx < projects.
size(); ++inx)
638 QMessageBox::warning(
this,
"Bad project directory",
"HAL project directories must not have suffix (." +
653 msgBox.
setText(
"Error: Import Netlist");
662 QString title =
"Import Netlist";
701 mWelcomeScreen->
close();
705 mMenuPlugins->
clear();
727 newBtn->
setToolTip(
"Create new gate library");
729 openBtn->
setToolTip(
"Open existing gate library");
734 optBox.
setText(
"Gate Library Manager");
736 auto btn = optBox.
exec();
742 mFileActions->
setup(mGateLibraryManager);
755 mFileActions->
setup(mGateLibraryManager);
759 void MainWindow::handleImportProjectTriggered()
764 if (ipd.importProject())
767 ipd.extractedProjectAbsolutePath());
772 "Import Project Failed",
773 "Failed to extract a HAL project from selected archive file.\n"
774 "You might want to uncompress the archive manually and try to fetchGateLibrary the project.");
778 void MainWindow::handleExportProjectTriggered()
781 if (pm->get_project_status() == ProjectManager::ProjectStatus::NONE)
return;
785 "You might want to save the changes\n"
786 "before exporting the project.",
788 "Export without save",
797 ExportProjectDialog epd(
this);
806 QString filename = saveHandler();
816 saveHandler(projectDir);
824 QString saveProjectDir(projectDir);
828 if (saveProjectDir.isEmpty())
830 QString title =
"Save Project";
831 QString filter =
"HAL Directory Folder (*)";
835 if (saveProjectDir.isEmpty())
return QString();
839 if (!finfo.suffix().isEmpty())
841 QMessageBox::warning(
this,
"Save Error",
"selected project directory name must not have suffix ." + finfo.suffix());
868 fm->watchFile(qNetlistPath);
869 fm->emitProjectSaved(saveProjectDir, qNetlistPath);
886 bool trySaveMacro =
true;
887 while (trySaveMacro) {
902 trySaveMacro =
false;
931 QString iconStyle =
enable ? mUndoIconStyle : mDisabledIconStyle;
951 if (tryToCloseFile())
964 bool MainWindow::tryToCloseFile()
969 msgBox.setStyleSheet(
"QLabel{min-width: 600px;}");
972 msgBox.setDefaultButton(cancelButton);
973 msgBox.setInformativeText(
"Are you sure you want to close the application ?");
975 msgBox.setText(
"There are unsaved modifications.");
976 QString detailed_text =
"The following modifications have not been saved yet:\n";
978 detailed_text.
append(
" -> modified Gate Library\n");
980 detailed_text.
append(
" -> " + s +
"\n");
982 msgBox.setDetailedText(detailed_text);
984 for (
const auto& button : msgBox.buttons())
996 if (msgBox.clickedButton() == cancelButton)
1003 geif->netlist_about_to_close(
gNetlist);
1027 mMenuPlugins->
clear();
1034 void MainWindow::restoreState()
1044 void MainWindow::saveState()
A dialog that displays the Qt version and our open source license.
Provides an interface for triggerable functionality that can be inserted into widgets and also connec...
void setText(const QString &text)
Manages the layout of all ContentWidgets.
void initSplitterSize(const QSize &size)
void addContent(ContentWidget *widget, int index, ContentLayout::Position anchor)
Manages all ContentWidgets.
void setWindowTitle(const QString &filename)
Abstract class for Widgets within HAL's ContentArea.
void setup(GateLibraryManager *glcw=nullptr, GuiPluginManager *plmgr=nullptr)
static FileManager * get_instance()
void projectOpened(QString projectDir, QString fileName)
void fileOpened(const QString &fileName)
QList< QString > getUnsavedChangeDescriptors() const
bool modifiedFilesExisting() const
bool isGatelibModified() const
bool initialize(GateLibrary *gateLibrary=nullptr, bool readOnly=false)
bool callUnsavedChangesWindow()
void handleCreateAction()
void addPluginActions(QMenu *menu) const
static QMap< QString, GuiExtensionInterface * > getGuiExtensions()
SupportedFileFormats listFacFeature(FacExtensionInterface::Feature ft) const
void loadFeature(FacExtensionInterface::Feature ft, const QString &extension=QString())
The top-level widget that displays all settings.
bool handleAboutToClose()
void closeGateLibraryManager()
void handleActionImportNetlist()
void handleActionOpenProject()
void setUndoIconStyle(const QString &style)
QString neGateIconStyle() const
QString pluginsIconStyle() const
void handleActionGatelibraryManager()
void setHalIconPath(const QString &path)
void handleSaveAsTriggered()
void closePluginManager()
void handleActionCloseFile()
void reloadStylsheet(int istyle)
QString halIconPath() const
void handleActionStopRecording()
void setNeGateIconStyle(const QString &style)
void setSettingsIconStyle(const QString &style)
QString undoIconPath() const
ContentLayoutArea * layoutArea() const
QString disabledIconStyle() const
QString quitIconStyle() const
void setOpenFileIconPath(const QString &path)
void handleActionStartRecording()
void enableUndo(bool enable=true)
void handleProjectOpened(const QString &projDir, const QString &fileName)
void addContent(ContentWidget *widget, int index, ContentLayout::Position anchor)
void setNeGateIconPath(const QString &path)
void setOpenFileIconStyle(const QString &style)
QString quitIconPath() const
void setUndoIconPath(const QString &path)
void handleActionPlayMacro()
void onActionQuitTriggered()
void handleFileOpened(const QString &fileName)
void setSettingsIconPath(const QString &path)
MainWindow(QWidget *parent=nullptr)
void removeContent(ContentWidget *widget)
void setQuitIconPath(const QString &path)
QString settingsIconPath() const
void setHalIconStyle(const QString &style)
QString openFileIconStyle() const
void onActionCloseDocumentTriggered()
void handleSaveTriggered()
QString undoIconStyle() const
QString halIconStyle() const
void setQuitIconStyle(const QString &style)
QString neGateIconPath() const
void handleActionExport()
static SettingsItemDropdown * sSettingStyle
QString openFileIconPath() const
void setDisabledIconStyle(const QString &style)
void setPluginsIconStyle(const QString &style)
void setPluginsIconPath(const QString &path)
QString pluginsIconPath() const
QString settingsIconStyle() const
GuiPluginTable * mGuiPluginTable
std::filesystem::path get_default_filename(const std::string &extension=std::string()) const
static ProjectManager * instance()
bool create_project_directory(const std::string &path)
bool serialize_project(Netlist *netlist, bool shadow=false)
ProjectStatus get_project_status() const
const ProjectDirectory & get_project_directory() const
void abortThreadAndWait()
A SettingsItem representing a Checkbox.
virtual QVariant value() const override
A SettingsItem that represents a dropdown menu.
void intChanged(int value)
A SettingsItem to modify keybinds.
void keySequenceChanged(QKeySequence value)
virtual QVariant value() const override
void mainWindowSaveGeometry(const QPoint &pos, const QSize &size)
static SettingsManager * instance()
QSize mainWindowSize() const
QPoint mainWindowPosition() const
Handles and manages user actions related proccesses.
void canUndoLastAction(bool yesWeCan)
static UserActionManager * instance()
void playMacro(const QString ¯oFilename)
QMessageBox::StandardButton setStopRecording(const QString ¯oFilename)
#define log_warning(channel,...)
void enable_event_log(bool enable)
QIcon getStyledSvgIcon(const QString &from_to_colors_enabled, const QString &svg_path, QString from_to_colors_disabled=QString())
const std::unordered_map< std::string, std::vector< std::string > > & get_writer_extensions()
Retrieve the extensions for which extensions have been registered.
const char * MSG_PROJECT_ALREADY_OPEN
PythonContext * gPythonContext
ContentManager * gContentManager
PluginRelay * gPluginRelay
FileStatusManager * gFileStatusManager
void runMain(const QString fileName, const QList< QString > plugins)
GraphContextManager * gGraphContextManager
SelectionRelay * gSelectionRelay
CommentManager * gCommentManager
NetlistRelay * gNetlistRelay
This file contains various functions to create and load netlists.
QVariant data() const const
void setIcon(const QIcon &icon)
void setData(const QVariant &userData)
void triggered(bool checked)
void addLayout(QLayout *layout, int stretch)
void setSpacing(int spacing)
virtual bool open(QIODevice::OpenMode mode) override
QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
QStringList selectedFiles() const const
QString suffix() const const
void setContentsMargins(int left, int top, int right, int bottom)
void append(const T &value)
const T & at(int i) const const
virtual int exec() override
void setInformativeText(const QString &text)
void setWindowTitle(const QString &title)
void setText(const QString &text)
QMessageBox::StandardButton warning(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void setObjectName(const QString &name)
QObject * sender() const const
QString cap(int nth) const const
int indexIn(const QString &str, int offset, QRegExp::CaretMode caretMode) const const
bool contains(const QString &key) const const
void setValue(const QString &key, const QVariant &value)
QVariant value(const QString &key, const QVariant &defaultValue) const const
void setKey(const QKeySequence &key)
QString & append(QChar ch)
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
QString fromStdString(const std::string &str)
bool isEmpty() const const
bool isNull() const const
QString & remove(int position, int n)
std::string toStdString() const const
bool isNull() const const
bool toBool() const const
QString toString() const const
QStringList toStringList() const const