45 #include "plugindialog.h"
56 #include <QStyleFactory>
68 #include <QtCore/QDebug>
69 #include <QtCore/QFileInfo>
70 #include <QtCore/QSettings>
71 #include <QtCore/QTimer>
72 #include <QtCore/QtPlugin>
73 #include <QtCore/QUrl>
75 #include <QApplication>
76 #include <QCloseEvent>
82 #include <QToolButton>
83 #include <QMessageBox>
84 #include <QDesktopServices>
88 #include <QNetworkProxy>
92 using namespace Core::Internal;
94 static const char *uriListMimeFormatC =
"text/uri-list";
103 , m_additionalContexts(m_globalContext)
104 , m_dontSaveSettings(false)
106 , m_modeManager(nullptr)
107 , m_connectionManager(nullptr)
108 , m_boardManager(nullptr)
109 , m_versionDialog(nullptr)
110 , m_authorsDialog(nullptr)
111 , m_activeContext(nullptr)
115 , m_focusToEditor(nullptr)
116 , m_newAction(nullptr)
117 , m_openAction(nullptr)
118 , m_openWithAction(nullptr)
119 , m_saveAllAction(nullptr)
120 , m_exitAction(nullptr)
121 , m_optionsAction(nullptr)
128 m_toggleFullScreenAction(nullptr)
131 m_settings =
new QSettings(QDir::tempPath() + QDir::separator() + GCS_PROJECT_BRANDING
132 + QDir::separator() +
"config_autosave",
143 QStringList keys = originalSettings.allKeys();
144 for (QStringList::iterator
i = keys.begin();
i != keys.end();
i++) {
145 m_settings->setValue(*
i, originalSettings.value(*
i));
148 if (!originalSettings.isWritable()) {
149 QMessageBox msgBox(QMessageBox::Warning, tr(
"Settings Not Saved"),
150 tr(
"Your settings file (%0) is not writable! "
151 "All GCS configuration changes will be lost!")
153 QMessageBox::Ok,
this);
164 QCoreApplication::setOrganizationDomain(QLatin1String(GCS_PROJECT_BRANDING_HELP));
166 QString baseName = QApplication::style()->objectName();
168 qDebug() << baseName;
170 if (baseName == QLatin1String(
"windows")) {
172 if (QStyleFactory::keys().contains(QLatin1String(
"Fusion"))) {
173 baseName = QLatin1String(
"fusion");
176 QByteArray desktopEnvironment = qgetenv(
"DESKTOP_SESSION");
177 if (desktopEnvironment ==
"kde")
178 baseName = QLatin1String(
"plastique");
180 baseName = QLatin1String(
"cleanlooks");
184 qApp->setStyle(QStyleFactory::create(baseName));
186 setDockNestingEnabled(
true);
188 setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
189 setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea);
191 registerDefaultContainers();
192 registerDefaultActions();
194 QGridLayout *gridLayout =
new QGridLayout();
195 gridLayout->setSizeConstraint(QLayout::SetNoConstraint);
197 m_contentFrame =
new QFrame(
this);
198 m_contentFrame->setObjectName(QString(
"MainContentFrame"));
199 m_contentFrame->setLayout(gridLayout);
202 m_modeStack->setIconSize(QSize(24, 24));
203 m_modeStack->setTabPosition(QTabWidget::South);
204 m_modeStack->setMovable(
false);
205 m_modeStack->setMinimumWidth(512);
206 m_modeStack->setMinimumHeight(384);
207 m_modeStack->setMaximumWidth(16777215);
208 m_modeStack->setMaximumHeight(16777215);
209 m_modeStack->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
210 m_modeStack->setElideMode(Qt::ElideRight);
212 gridLayout->addWidget(m_modeStack, 0, 0);
213 gridLayout->setContentsMargins(0, 0, 0, 0);
217 m_modeManager =
new ModeManager(
this, m_modeStack);
223 setCentralWidget(m_contentFrame);
225 connect(QApplication::instance(), SIGNAL(focusChanged(QWidget *, QWidget *)),
this,
226 SLOT(updateFocusWidget(QWidget *, QWidget *)));
227 connect(m_workspaceSettings, SIGNAL(tabBarSettingsApplied(QTabWidget::TabPosition,
bool)),
this,
228 SLOT(applyTabBarSettings(QTabWidget::TabPosition,
bool)));
229 connect(m_modeManager, SIGNAL(newModeOrder(QVector<IMode *>)), m_workspaceSettings,
230 SLOT(newModeOrder(QVector<IMode *>)));
231 statusBar()->setProperty(
"p_styled",
true);
232 setAcceptDrops(
true);
237 if (m_connectionManager) {
245 if (m_uavGadgetManagers.count() > 0) {
247 pm->removeObject(mode);
252 pm->removeObject(m_shortcutSettings);
253 pm->removeObject(m_generalSettings);
254 pm->removeObject(m_workspaceSettings);
255 delete m_globalMessaging;
256 m_globalMessaging =
nullptr;
257 delete m_shortcutSettings;
258 m_shortcutSettings =
nullptr;
259 delete m_generalSettings;
260 m_generalSettings =
nullptr;
261 delete m_workspaceSettings;
262 m_workspaceSettings =
nullptr;
272 originalSettings.clear();
273 QStringList keys = m_settings->allKeys();
274 for (QStringList::iterator
i = keys.begin();
i != keys.end();
i++) {
275 originalSettings.setValue(*
i, m_settings->value(*
i));
278 originalSettings.sync();
279 if (originalSettings.status() != QSettings::NoError)
280 qWarning() <<
"Failed to saved GCS settings!"
285 m_settings =
nullptr;
286 delete m_uniqueIDManager;
287 m_uniqueIDManager =
nullptr;
289 pm->removeObject(m_coreImpl);
291 m_coreImpl =
nullptr;
293 delete m_modeManager;
294 m_modeManager =
nullptr;
299 Q_UNUSED(errorMessage)
302 pm->addObject(m_coreImpl);
303 m_modeManager->
init();
304 m_connectionManager->
init();
305 m_boardManager->
init();
307 pm->addObject(m_generalSettings);
308 pm->addObject(m_shortcutSettings);
309 pm->addObject(m_workspaceSettings);
321 QSettings *qs = m_settings;
324 if (!qs->allKeys().count()) {
325 foreach (QString str, qApp->arguments()) {
326 if (str.contains(
"configfile")) {
328 commandLine = str.split(
"=").at(1);
329 qDebug() << commandLine;
332 QDir directory(QCoreApplication::applicationDirPath());
335 directory.cd(
"Resources");
338 directory.cd(
"share");
340 directory.cd(
"default_configurations");
342 qDebug() <<
"Looking for default config files in: " + directory.absolutePath();
343 bool showDialog =
true;
345 if (!commandLine.isEmpty()) {
346 if (QFile::exists(directory.absolutePath() + QDir::separator() + commandLine)) {
347 filename = directory.absolutePath() + QDir::separator() + commandLine;
348 emit
splashMessages(tr(
"Loading configuration from command line"));
349 qDebug() <<
"Load configuration from command line";
360 dialog->
loadFiles(directory.absolutePath());
370 emit
splashMessages(QString(tr(
"Loading default configuration from %1")).arg(filename));
371 qDebug() <<
"Load default config from resource " << filename;
373 qs->beginGroup(
"General");
374 m_config_description = qs->value(
"Description",
"none").toString();
375 m_config_details = qs->value(
"Details",
"none").toString();
379 connect(m_uavGadgetInstanceManager, SIGNAL(
splashMessages(QString)),
this,
387 QString currentPath = QDir::currentPath();
389 if ((currentPath.length() < 4) || currentPath.contains(
".app", Qt::CaseInsensitive)
390 || currentPath.contains(
"Program Files", Qt::CaseInsensitive)
391 || !QDir(currentPath).exists()) {
392 QDir::setCurrent(QDir::homePath());
400 void MainWindow::readStyleSheet(QFile *
file, QString name, QString *style)
403 if (file->open(QFile::ReadOnly)) {
405 QTextStream styleIn(file);
407 tmp = styleIn.readAll();
410 emit
splashMessages(QString(tr(
"Loading stylesheet %1")).arg(name));
411 qDebug() <<
"Loaded stylesheet:" << name;
413 qDebug() <<
"Failed to openstylesheet file" << name;
417 void MainWindow::loadStyleSheet()
420 QDir directory(QCoreApplication::applicationDirPath());
423 directory.cd(
"Resources");
426 directory.cd(
"share");
428 directory.cd(
"stylesheets");
429 QFile global(directory.absolutePath() + QDir::separator() +
"global.qss");
431 QFile
data(directory.absolutePath() + QDir::separator() +
"macos.qss");
432 #elif defined(Q_OS_LINUX)
433 QFile
data(directory.absolutePath() + QDir::separator() +
"linux.qss");
435 QFile
data(directory.absolutePath() + QDir::separator() +
"windows.qss");
440 readStyleSheet(&global,
"Global", &style);
441 readStyleSheet(&
data,
"OS", &style);
443 if (style.length() > 0) {
444 qApp->setStyleSheet(style);
446 qDebug() <<
"No stylesheets loaded.";
453 m_dontSaveSettings =
true;
455 if (!m_dontSaveSettings) {
460 ExtensionSystem::PluginManager::instance()->getObjects<
ICoreListener>();
470 if (!m_dontSaveSettings) {
479 static bool isDesktopFileManagerDrop(
const QMimeData *d, QStringList *files =
nullptr)
484 if (!d->hasFormat(QLatin1String(uriListMimeFormatC)))
490 bool hasFiles =
false;
493 const QString fileName = it->toLocalFile();
494 if (!fileName.isEmpty()) {
497 files->push_back(fileName);
508 if (isDesktopFileManagerDrop(event->mimeData())) {
518 if (isDesktopFileManagerDrop(event->mimeData(), &files)) {
528 return m_activeContext;
536 return new QStatusBar();
539 void MainWindow::registerDefaultContainers()
545 #ifndef Q_OS_MAC // System menu bar on Mac
546 setMenuBar(menubar->
menuBar());
558 filemenu->
menu()->setTitle(tr(
"&File"));
565 connect(filemenu->
menu(), SIGNAL(aboutToShow()),
this, SLOT(aboutToShowRecentFiles()));
570 medit->menu()->setTitle(tr(
"&Edit"));
581 ac->
menu()->setTitle(tr(
"&Tools"));
586 mwindow->
menu()->setTitle(tr(
"&Window"));
597 ac->
menu()->setTitle(tr(
"&Help"));
605 QAction *tmpaction =
new QAction(parent);
606 tmpaction->setSeparator(
true);
611 void MainWindow::registerDefaultActions()
622 createSeparator(am,
this, QLatin1String(
"QtCreator.File.Sep.Save"), m_globalContext);
625 cmd = createSeparator(am,
this, QLatin1String(
"QtCreator.File.Sep.Close"), m_globalContext);
628 cmd = createSeparator(am,
this, QLatin1String(
"QtCreator.File.Sep.Other"), m_globalContext);
632 cmd = createSeparator(am,
this, QLatin1String(
"QtCreator.Edit.Sep.CopyPaste"), m_globalContext);
635 cmd = createSeparator(am,
this, QLatin1String(
"QtCreator.Edit.Sep.SelectAll"), m_globalContext);
638 cmd = createSeparator(am,
this, QLatin1String(
"QtCreator.Edit.Sep.Find"), m_globalContext);
641 cmd = createSeparator(am,
this, QLatin1String(
"QtCreator.Edit.Sep.Advanced"), m_globalContext);
645 cmd = createSeparator(am,
this, QLatin1String(
"QtCreator.Tools.Sep.Options"), m_globalContext);
652 m_focusToEditor =
new QShortcut(
this);
655 connect(m_focusToEditor, SIGNAL(activated()),
this, SLOT(setFocusToEditor()));
658 m_saveAllAction =
new QAction(tr(
"Save &GCS Default Settings"),
this);
664 connect(m_saveAllAction, SIGNAL(triggered()),
this, SLOT(saveAll()));
671 connect(m_exitAction, SIGNAL(triggered()),
this, SLOT(
exit()));
680 tmpaction->setEnabled(
false);
689 tmpaction->setEnabled(
false);
696 tmpaction->setEnabled(
false);
703 tmpaction->setEnabled(
false);
710 tmpaction->setEnabled(
false);
713 tmpaction =
new QAction(tr(
"&Select All"),
this);
717 tmpaction->setEnabled(
false);
724 cmd->
action()->setMenuRole(QAction::PreferencesRole);
731 m_minimizeAction =
new QAction(tr(
"Minimize"),
this);
735 connect(m_minimizeAction, SIGNAL(triggered()),
this, SLOT(showMinimized()));
738 m_zoomAction =
new QAction(tr(
"Zoom"),
this);
741 connect(m_zoomAction, SIGNAL(triggered()),
this, SLOT(showMaximized()));
744 cmd = createSeparator(am,
this, QLatin1String(
"QtCreator.Window.Sep.Size"), m_globalContext);
750 m_toggleFullScreenAction =
new QAction(tr(
"Full Screen"),
this);
751 m_toggleFullScreenAction->setCheckable(
true);
756 connect(m_toggleFullScreenAction, SIGNAL(triggered(
bool)),
this, SLOT(
setFullScreen(
bool)));
765 QAction *tmpaction1 =
new QAction(
this);
766 tmpaction1->setSeparator(
true);
767 cmd = am->
registerAction(tmpaction1, QLatin1String(
"GCS.Window.Sep.Split"),
768 uavGadgetManagerContext);
771 m_showToolbarsAction =
new QAction(tr(
"Edit Gadgets Mode"),
this);
772 m_showToolbarsAction->setCheckable(
true);
779 QAction *tmpaction2 =
new QAction(
this);
780 tmpaction2->setSeparator(
true);
781 cmd = am->
registerAction(tmpaction2, QLatin1String(
"GCS.Window.Sep.Split2"),
782 uavGadgetManagerContext);
786 QString prefix = tr(
"Meta+Shift");
788 QString prefix = tr(
"Ctrl+Shift");
791 m_splitAction =
new QAction(tr(
"Split"),
this);
796 m_splitSideBySideAction =
new QAction(tr(
"Split Side by Side"),
this);
798 uavGadgetManagerContext);
802 m_removeCurrentSplitAction =
new QAction(tr(
"Close Current View"),
this);
804 uavGadgetManagerContext);
808 m_removeAllSplitsAction =
new QAction(tr(
"Close All Other Views"),
this);
810 uavGadgetManagerContext);
814 m_gotoOtherSplitAction =
new QAction(tr(
"Goto Next View"),
this);
816 uavGadgetManagerContext);
824 tmpaction->setEnabled(
true);
825 connect(tmpaction, SIGNAL(triggered()),
this, SLOT(showHelp()));
828 #ifndef Q_OS_MAC // doesn't have the "About" actions in the Help menu
829 tmpaction =
new QAction(
this);
830 tmpaction->setSeparator(
true);
831 cmd = am->
registerAction(tmpaction, QLatin1String(
"QtCreator.Help.Sep.About"), m_globalContext);
839 tmpaction->setEnabled(
true);
841 cmd->
action()->setMenuRole(QAction::ApplicationSpecificRole);
843 connect(tmpaction, SIGNAL(triggered()),
this, SLOT(aboutPlugins()));
854 tmpaction->setEnabled(
true);
856 cmd->
action()->setMenuRole(QAction::ApplicationSpecificRole);
858 connect(tmpaction, SIGNAL(triggered()),
this, SLOT(aboutGCS()));
864 tmpaction->setEnabled(
true);
866 cmd->
action()->setMenuRole(QAction::ApplicationSpecificRole);
868 connect(tmpaction, SIGNAL(triggered()),
this, SLOT(aboutAuthors()));
875 void MainWindow::openFile()
879 void MainWindow::setFocusToEditor()
892 void MainWindow::saveAll()
894 if (m_dontSaveSettings)
908 QTimer::singleShot(0,
this, SLOT(close()));
915 void MainWindow::applyTabBarSettings(QTabWidget::TabPosition pos,
bool movable)
917 if (m_modeStack->tabPosition() != pos)
918 m_modeStack->setTabPosition(pos);
919 m_modeStack->setMovable(movable);
922 void MainWindow::showHelp()
929 return m_actionManager;
934 return m_uniqueIDManager;
939 return m_globalMessaging;
944 if (scope == QSettings::UserScope)
947 return m_globalSettings;
952 return m_connectionManager;
957 return m_boardManager;
962 return m_uavGadgetManagers;
967 return m_uavGadgetInstanceManager;
972 return m_modeManager;
977 return m_generalSettings;
982 return m_contextWidgets.value(widget);
989 QWidget *widget = context->
widget();
990 if (m_contextWidgets.contains(widget))
993 m_contextWidgets.insert(widget, context);
1001 QWidget *widget = context->
widget();
1002 if (!m_contextWidgets.contains(widget))
1005 m_contextWidgets.remove(widget);
1006 if (m_activeContext == context)
1007 updateContextObject(
nullptr);
1012 QMainWindow::changeEvent(e);
1013 if (e->type() == QEvent::ActivationChange) {
1014 if (isActiveWindow()) {
1016 qDebug() <<
"main window activated";
1019 }
else if (e->type() == QEvent::WindowStateChange) {
1021 bool minimized = isMinimized();
1023 qDebug() <<
"main window state changed to minimized=" << minimized;
1024 m_minimizeAction->setEnabled(!minimized);
1025 m_zoomAction->setEnabled(!minimized);
1027 bool isFullScreen = (windowState() & Qt::WindowFullScreen) != 0;
1028 m_toggleFullScreenAction->setChecked(isFullScreen);
1033 void MainWindow::updateFocusWidget(QWidget *old, QWidget *now)
1038 if (qobject_cast<QMenuBar *>(now))
1042 if (focusWidget()) {
1044 QWidget *p = focusWidget();
1046 context = m_contextWidgets.value(p);
1048 newContext = context;
1051 p = p->parentWidget();
1054 updateContextObject(newContext);
1057 void MainWindow::updateContextObject(
IContext *context)
1059 if (context == m_activeContext)
1061 IContext *oldContext = m_activeContext;
1062 m_activeContext = context;
1063 if (!context || oldContext != m_activeContext) {
1067 qDebug() <<
"new context object =" << context << (context ? context->
widget() :
nullptr)
1068 << (context ? context->
widget()->metaObject()->className() :
nullptr);
1075 updateContextObject(
nullptr);
1080 disconnect(QApplication::instance(), SIGNAL(focusChanged(QWidget *, QWidget *)),
this,
1081 SLOT(updateFocusWidget(QWidget *, QWidget *)));
1082 m_activeContext =
nullptr;
1090 void MainWindow::showUavGadgetMenus(
bool show,
bool hasSplitter)
1092 m_showToolbarsAction->setChecked(show);
1093 m_splitAction->setEnabled(show);
1094 m_splitSideBySideAction->setEnabled(show);
1095 m_removeCurrentSplitAction->setEnabled(show && hasSplitter);
1096 m_removeAllSplitsAction->setEnabled(show && hasSplitter);
1097 m_gotoOtherSplitAction->setEnabled(show && hasSplitter);
1104 int prio = m_uavGadgetManagers.at(0)->priority();
1105 for (
int i = 0;
i < m_uavGadgetManagers.count();
i++) {
1106 int prio2 = m_uavGadgetManagers.at(
i)->priority();
1115 void MainWindow::createWorkspaces(QSettings *qs,
bool diffOnly)
1125 int toRemoveFirst = m_uavGadgetManagers.count();
1127 if (diffOnly && m_uavGadgetManagers.count() > newWorkspacesNo)
1128 toRemoveFirst = m_uavGadgetManagers.count() - newWorkspacesNo;
1134 while (!m_uavGadgetManagers.isEmpty() && (toRemoveFirst > removed)) {
1136 uavGadgetManager = m_uavGadgetManagers.takeAt(index);
1138 pm->removeObject(uavGadgetManager);
1139 delete uavGadgetManager;
1145 start = m_uavGadgetManagers.count();
1147 m_uavGadgetManagers.clear();
1149 for (
int i = start;
i < newWorkspacesNo; ++
i) {
1151 const QString name = m_workspaceSettings->
name(
i);
1152 const QString iconName = m_workspaceSettings->
iconName(
i);
1153 const QString modeName = m_workspaceSettings->
modeName(
i);
1155 90 -
i + 1, modeName,
this);
1157 connect(uavGadgetManager, SIGNAL(showUavGadgetMenus(
bool,
bool)),
this,
1158 SLOT(showUavGadgetMenus(
bool,
bool)));
1160 connect(m_showToolbarsAction, SIGNAL(triggered(
bool)), uavGadgetManager,
1161 SLOT(showToolbars(
bool)));
1162 connect(m_splitAction, SIGNAL(triggered()), uavGadgetManager, SLOT(split()));
1163 connect(m_splitSideBySideAction, SIGNAL(triggered()), uavGadgetManager,
1164 SLOT(splitSideBySide()));
1165 connect(m_removeCurrentSplitAction, SIGNAL(triggered()), uavGadgetManager,
1166 SLOT(removeCurrentSplit()));
1167 connect(m_removeAllSplitsAction, SIGNAL(triggered()), uavGadgetManager,
1168 SLOT(removeAllSplits()));
1169 connect(m_gotoOtherSplitAction, SIGNAL(triggered()), uavGadgetManager,
1170 SLOT(gotoOtherSplit()));
1172 pm->addObject(uavGadgetManager);
1173 m_uavGadgetManagers.append(uavGadgetManager);
1178 static const char *settingsGroup =
"MainWindow";
1179 static const char *geometryKey =
"Geometry";
1180 static const char *maxKey =
"Maximized";
1181 static const char *fullScreenKey =
"FullScreen";
1182 static const char *modePriorities =
"ModePriorities";
1190 if (workspaceDiffOnly) {
1191 createWorkspaces(qs, workspaceDiffOnly);
1196 QNetworkProxy::setApplicationProxy(m_generalSettings->
getNetworkProxy());
1199 qs->beginGroup(QLatin1String(settingsGroup));
1201 const QVariant geom = qs->value(QLatin1String(geometryKey));
1202 if (geom.isValid()) {
1203 setGeometry(geom.toRect());
1207 if (qs->value(QLatin1String(maxKey),
false).toBool())
1208 setWindowState(Qt::WindowMaximized);
1209 setFullScreen(qs->value(QLatin1String(fullScreenKey),
false).toBool());
1215 createWorkspaces(qs);
1218 qs->beginGroup(QLatin1String(modePriorities));
1219 QStringList modeNames = qs->childKeys();
1220 QMap<QString, int> map;
1221 foreach (QString modeName, modeNames) {
1222 map.insert(modeName, qs->value(modeName).toInt());
1231 if (m_dontSaveSettings)
1240 qs->beginGroup(QLatin1String(settingsGroup));
1242 if (windowState() & (Qt::WindowMaximized | Qt::WindowFullScreen)) {
1243 qs->setValue(QLatin1String(maxKey), (
bool)(windowState() & Qt::WindowMaximized));
1244 qs->setValue(QLatin1String(fullScreenKey), (
bool)(windowState() & Qt::WindowFullScreen));
1246 qs->setValue(QLatin1String(maxKey),
false);
1247 qs->setValue(QLatin1String(fullScreenKey),
false);
1248 qs->setValue(QLatin1String(geometryKey), geometry());
1254 qs->beginGroup(QLatin1String(modePriorities));
1255 QVector<IMode *> modes = m_modeManager->
modes();
1256 foreach (
IMode *mode, modes) {
1267 qs->beginGroup(
"General");
1268 qs->setValue(
"Description", m_config_description);
1269 qs->setValue(
"Details", m_config_details);
1280 QObject *qo =
reinterpret_cast<QObject *
>(plugin);
1281 QString configName = qo->metaObject()->className();
1283 qs->beginGroup(
"Plugins");
1284 qs->beginGroup(configName);
1285 configInfo.
read(qs);
1287 qs->beginGroup(
"data");
1297 if (m_dontSaveSettings)
1304 QString configName = plugin->metaObject()->className();
1306 qs->beginGroup(
"Plugins");
1307 qs->beginGroup(configName);
1308 qs->beginGroup(
"data");
1311 configInfo.
save(qs);
1319 m_settings->clear();
1325 originalSettings.clear();
1326 originalSettings.sync();
1329 m_dontSaveSettings =
true;
1337 if (!m_additionalContexts.contains(context))
1338 m_additionalContexts.prepend(context);
1346 int index = m_additionalContexts.indexOf(context);
1348 m_additionalContexts.removeAt(index);
1360 if (m_activeContext)
1361 contexts += m_activeContext->
context();
1363 contexts += m_additionalContexts;
1366 for (
int i = 0;
i < contexts.size(); ++
i) {
1367 const int c = contexts.at(
i);
1368 if (!uniquecontexts.contains(c))
1369 uniquecontexts << c;
1375 void MainWindow::aboutToShowRecentFiles()
1379 aci->
menu()->clear();
1381 bool hasRecentFiles =
false;
1383 aci->
menu()->setEnabled(hasRecentFiles);
1387 void MainWindow::openRecentFile()
1389 QAction *action = qobject_cast<QAction *>(sender());
1392 QString fileName = action->data().toString();
1393 if (!fileName.isEmpty()) {
1397 void MainWindow::aboutGCS()
1399 if (!m_versionDialog) {
1401 connect(m_versionDialog, SIGNAL(finished(
int)),
this, SLOT(destroyVersionDialog()));
1403 m_versionDialog->show();
1406 void MainWindow::destroyVersionDialog()
1408 if (m_versionDialog) {
1409 m_versionDialog->deleteLater();
1410 m_versionDialog =
nullptr;
1414 void MainWindow::aboutAuthors()
1416 if (!m_authorsDialog) {
1418 connect(m_authorsDialog, SIGNAL(finished(
int)),
this, SLOT(destroyAuthorsDialog()));
1420 m_authorsDialog->show();
1423 void MainWindow::destroyAuthorsDialog()
1425 if (m_authorsDialog) {
1426 m_authorsDialog->deleteLater();
1427 m_authorsDialog =
nullptr;
1431 void MainWindow::aboutPlugins()
1439 if (
bool(windowState() & Qt::WindowFullScreen) == on)
1443 setWindowState(windowState() | Qt::WindowFullScreen);
1447 setWindowState(windowState() & ~Qt::WindowFullScreen);
const char *const MINIMIZE_WINDOW
const char *const G_FILE_OPEN
virtual bool coreAboutToClose()
const char *const G_EDIT_UNDOREDO
const char *const M_WINDOW
void setFullScreen(bool on)
int uniqueIdentifier(const QString &id)
const char *const ICON_PASTE
const char *const GCS_HELP
virtual QMenuBar * menuBar() const =0
QString getSettingsFilename()
Command * registerShortcut(QShortcut *shortcut, const QString &id, const QList< int > &context)
Makes a shortcut known to the system under the specified string id.
const char *const ICON_CUT
const char *const G_WINDOW_HIDE_TOOLBAR
const char *const G_TOOLS
ActionContainer * createMenuBar(const QString &id)
Creates a new menu bar with the given string id.
virtual int priority() const =0
virtual QAction * action() const =0
Core::GlobalMessaging * globalMessaging() const
QString modeName(int i) const
bool hasContext(int context) const
const char *const OPTIONS
virtual void setAttribute(CommandAttribute attr)=0
virtual Command * registerAction(QAction *action, const QString &id, const QList< int > &context)=0
Makes an action known to the system under the specified string id.
const char *const G_WINDOW
void contextChanged(Core::IContext *context)
Sent just after a new context became the current context (meaning that its widget got focus)...
const char *const GOTO_OTHER_SPLIT
const char *const M_TOOLS
const char *const ICON_OPTIONS
Core plugin system that manages the plugins, their life cycle and their registered objects...
bool saveSettingsOnExit() const
const char *const G_WINDOW_OTHER
const char *const SPLIT_SIDE_BY_SIDE
const char *const G_EDIT_ADVANCED
void addAdditionalContext(int context)
const char *const MENU_BAR
const char *const G_HELP_HELP
void optionsDialogRequested()
Signal that allows plugins to perform actions just before the {Tools|Options} dialog is shown...
bool hasContext(int context) const
void readSettings(QSettings *qs)
const char *const SAVEALL
const char *const REMOVE_ALL_SPLITS
IContext * currentContextObject() const
const char *const G_FILE_CLOSE
const char *const ICON_HELP
const char *const G_EDIT_OTHER
const char *const G_FILE_PROJECT
const char *const GCS_AUTHOR
const char *const G_FILE_SAVE
IContext * contextObject(QWidget *widget)
void saveSettings(QSettings *qs=nullptr)
const char *const ABOUT_AUTHORS
void readSettings(QSettings *settings)
virtual const char * uniqueModeName() const =0
const char *const G_EDIT_FIND
virtual void dropEvent(QDropEvent *event)
void readSettings(QSettings *qs)
int takeLeastPriorityUavGadgetManager(const QList< Core::UAVGadgetManager * > m_uavGadgetManagers)
Core::ModeManager * modeManager() const
void saveSettings(QSettings *qs)
virtual void setDefaultText(const QString &text)=0
QVector< IMode * > modes() const
const char *const M_FILE_RECENTFILES
QString name(int i) const
virtual QMenu * menu() const =0
void saveSettings(QSettings *qs)
UAVGadgetInstanceManager * uavGadgetInstanceManager() const
void readSettings(QSettings *qs)
virtual void dragEnterEvent(QDragEnterEvent *event)
const char *const G_WINDOW_PANES
static bool isAnyUnixHost()
void saveSettings(QSettings *qs)
void extensionsInitialized()
const char *const G_WINDOW_SPLIT
const char *const G_EDIT_SELECTALL
const char *const GCS_VERSION_LONG
QStatusBar * statusBar() const
void saveSettings(QSettings *qs)
static ICore * instance()
const char *const G_FILE_OTHER
const char *const ICON_GCS
int numberOfWorkspaces() const
Core::BoardManager * boardManager() const
void saveSettings(QSettings *settings)
const char *const ICON_COPY
Command * registerAction(QAction *action, const QString &id, const QList< int > &context)
Makes an action known to the system under the specified string id.
const char *const G_WINDOW_NAVIGATE
virtual void appendGroup(const QString &group)=0
virtual void readConfig(QSettings *qSettings, UAVConfigInfo *configInfo)=0
const char *const ICON_UNDO
virtual void closeEvent(QCloseEvent *event)
const char *const ICON_EXIT
void setContext(const QList< int > &context)
void coreAboutToClose()
Plugins can do some pre-end-of-life actions when they get this signal.
virtual void addAction(Core::Command *action, const QString &group=QString())=0
const char *const TOGGLE_FULLSCREEN
QString iconName(int i) const
const char *const HIDE_TOOLBARS
bool showOptionsDialog(const QString &category=QString(), const QString &page=QString(), QWidget *parent=nullptr)
void coreOpened()
Emitted after all plugins have been loaded and the main window shown.
virtual void setDefaultKeySequence(const QKeySequence &key)=0
const char *const S_RETURNTOEDITOR
Core::ConnectionManager * connectionManager() const
Provides a hook for plugins to veto on certain events emitted from the core plugin.
virtual void saveConfig(QSettings *qSettings, Core::UAVConfigInfo *configInfo)=0
void splashMessages(QString)
const char *const GCS_NAME
void readSettings(QSettings *qs=nullptr, bool workspaceDiffOnly=false)
const char *const G_FILE_NEW
The Config Info is a helper-class to handle version changes in GCS configuration files.
ActionContainer * createMenu(const QString &id)
Creates a new menu with the given string id.
The action manager is responsible for registration of menus and menu items and keyboard shortcuts...
const char *const G_WINDOW_SIZE
const char *const C_UAVGADGETMANAGER
virtual QList< int > context() const =0
static const QSettings::Format XmlSettingsFormat
void saveSettingsRequested()
Emitted to signal that the user has requested that the global settings should be saved to disk...
void readSettings(QSettings *qs)
ActionContainer * actionContainer(int uid) const
void setNameOfConfigurable(const QString nameOfConfigurable)
const char *const ABOUT_GCS
Internal::GeneralSettings * generalSettings() const
const char *const ICON_REDO
void loadFiles(QString path)
QNetworkProxy getNetworkProxy()
QSettings * settings(QSettings::Scope scope) const
virtual void addMenu(Core::ActionContainer *menu, const QString &group=QString())=0
virtual UniqueIDManager * uniqueIDManager() const =0
Returns the application's id manager.
Core::UniqueIDManager * uniqueIDManager() const
const char *const G_EDIT_COPYPASTE
virtual QWidget * widget()=0
bool init(QString *errorMessage)
void reorderModes(QMap< QString, int > priorities)
const char *const ZOOM_WINDOW
void addContextObject(IContext *contex)
void removeContextObject(IContext *contex)
void contextAboutToChange(Core::IContext *context)
Sent just before a new context becomes the current context (meaning that its widget got focus)...
const char *const REMOVE_CURRENT_SPLIT
The class Command represents an action like a menu item, tool button, or shortcut. You don't create Command objects directly, instead use {ActionManager::registerAction()} to register an action and retrieve a Command. The Command object represents the user visible action and its properties. If multiple actions are registered with the same ID (but different contexts) the returned Command is the shared one between these actions.
QList< UAVGadgetManager * > uavGadgetManagers() const
const char *const G_HELP_ABOUT
const char *const ICON_PLUGIN
virtual void changeEvent(QEvent *e)
void removeAdditionalContext(int context)
const char *const ABOUT_PLUGINS
Core::ActionManager * actionManager() const
const char *const SELECTALL
const char *const G_DEFAULT_THREE