GreatWindow::GreatWindow(int monitor, bool main, QWidget *parent) : QMainWindow(parent), m_jumping(false), m_monitor(monitor), ui(new Ui::GreatWindow), m_bMainWindow(main) { ui->setupUi(this); if(!main) { ui->menuBar->hide(); } else { m_recentFileActions[0] = ui->actionFile1; m_recentFileActions[1] = ui->actionFile2; m_recentFileActions[2] = ui->actionFile3; m_recentFileActions[3] = ui->actionFile4; m_recentFileActions[4] = ui->actionFile5; for(int i=0; i<5; i++){ connect(m_recentFileActions[i], SIGNAL(triggered()), this, SLOT(openRecentFile())); } ContentMgr.loadRecentFiles(); } ui->mainToolBar->hide(); updateRecent(); m_canvas = new CCanvas(ui->center); this->setCentralWidget(m_canvas); setupStatusBar(); updateZoom(); }
void PanelKMenu::clearRecentMenuItems() { RecentlyLaunchedApps::self().clearRecentApps(); RecentlyLaunchedApps::self().save(); RecentlyLaunchedApps::self().m_bNeedToUpdate = true; updateRecent(); }
MainWindow::MainWindow(): QMainWindow(), bModified(false), pAboutDial(new AboutDialog(this)), timer(new QTimer(this)), iTimerCount(0), smMapper(new QSignalMapper(this)), dDuration(0.0) { setupUi(this); updateDisplay(); timer->setInterval(100); timer->setSingleShot(false); connect(timer,SIGNAL(timeout()),this,SLOT(onTimer_timeout())); connect(treeMusic,SIGNAL(fileToPlay(std::string,double)),this,SLOT(playMusic(std::string,double))); connect(treeFX,SIGNAL(fileToPlay(std::string,double)),this,SLOT(playSound(std::string))); connect(smMapper,SIGNAL(mapped(int)),this,SLOT(loadRecent(int))); // setting widgets treeFX->setSizeLimited(true); // loading settings QSettings settings; settings.beginGroup("directories"); QDir::setCurrent(settings.value("work").toString()); settings.endGroup(); settings.beginGroup("mainWindow"); resize(settings.value("size",size()).toSize()); if (settings.value("maximized",false).toBool()) { setWindowState(windowState() | Qt::WindowMaximized); } settings.endGroup(); settings.beginGroup("files"); slRecent = settings.value("recent").toStringList(); // display the recently opened games in the menu actionR_ecent->setMenu(new QMenu); addRecent(""); sFileName = settings.value("last").toString(); if (!sFileName.isEmpty()) { // we load the game opened when GMA was closed on_action_Reload_triggered(); setWindowTitle(QString("GM-Assistant - ")+QFileInfo(sFileName).fileName()); } settings.endGroup(); // recently opened files update connect(actionR_ecent->menu(),SIGNAL(aboutToShow()),this,SLOT(updateRecent())); }
void MainWindow::open() { if(this->isHidden()) this->show(); sdprinting = false; QString filename; QDir home; if(lastDir == "") { filename = QFileDialog::getOpenFileName(this, tr("Open GCODE"), home.home().absolutePath(), "GCODE (*.g *.gco *.gcode *.nc)"); } else { filename = QFileDialog::getOpenFileName(this, tr("Open GCODE"), lastDir, "GCODE (*.g *.gco *.gcode *.nc)"); } if(filename.isEmpty() || filename.isNull()) return; //Remember the last folder lastDir.clear(); lastDir.append(filename); int filenameChars = 0; for(int i = filename.count()-1; filename.at(i) != QDir::separator(); i--) { filenameChars++; //Count how many characters are in the filename } lastDir.remove(lastDir.count()-filenameChars, filenameChars);//remove filename gfile.setFileName(filename); if(!recentFiles.contains(filename)) { recentFiles.prepend(filename); if(recentFiles.size() >= 10) recentFiles.removeLast(); } updateRecent(); parseFile(filename); }
void PanelKMenu::initialize() { // kDebug(1210) << "PanelKMenu::initialize()"; updateRecent(); if (initialized()) { return; } if (loadSidePixmap()) { // in case we've been through here before, let's disconnect disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), this, SLOT(paletteChanged())); connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), this, SLOT(paletteChanged())); } else { sidePixmap = sideTilePixmap = QPixmap(); } // add services PanelServiceMenu::initialize(); /* FIXME: no more insertTitle! now what? if (KickerSettings::showMenuTitles()) { int id; id = insertTitle(i18n("All Applications"), -1, 0); setItemEnabled( id, false ); id = insertTitle(i18n("Actions"), -1 , -1); setItemEnabled( id, false ); } */ // create recent menu section createRecentMenuItems(); bool need_separator = false; // insert bookmarks if (KickerSettings::useBookmarks() && KAuthorized::authorizeKAction("bookmarks")) { // Need to create a new popup each time, it's deleted by subMenus.clear() KMenu * bookmarkParent = new KMenu(this); bookmarkParent->setObjectName("bookmarks" ); delete bookmarkMenu; // can't reuse old one, the popup has been deleted bookmarkMenu = new KBookmarkMenu( KBookmarkManager::userBookmarksManager(), 0, bookmarkParent, actionCollection ); insertItem(Plasma::menuIconSet("bookmark"), i18n("Bookmarks"), bookmarkParent); subMenus.append(bookmarkParent); need_separator = true; } // insert quickbrowser if (KickerSettings::useBrowser()) { PanelQuickBrowser *browserMnu = new PanelQuickBrowser(this); browserMnu->initialize(); insertItem(Plasma::menuIconSet("kdisknav"), i18n("Quick Browser"), Plasma::reduceMenu(browserMnu)); subMenus.append(browserMnu); need_separator = true; } // insert dynamic menus QStringList menu_ext = KickerSettings::menuExtensions(); if (!menu_ext.isEmpty()) { for (QStringList::ConstIterator it=menu_ext.begin(); it!=menu_ext.end(); ++it) { MenuInfo info(*it); if (!info.isValid()) continue; KPanelMenu *menu = info.load(); if (menu) { insertItem(Plasma::menuIconSet(info.icon()), info.name(), menu); dynamicSubMenus.append(menu); need_separator = true; } } } if (need_separator) addSeparator(); // run command if (KAuthorized::authorizeKAction("run_command")) { insertItem(Plasma::menuIconSet("system-run"), i18n("Run Command..."), this, SLOT( slotRunCommand())); addSeparator(); } if (KDisplayManager().isSwitchable() && KAuthorized::authorizeKAction("switch_user")) { sessionsMenu = new QMenu( this ); insertItem(Plasma::menuIconSet("switchuser"), i18n("Switch User"), sessionsMenu); connect( sessionsMenu, SIGNAL(aboutToShow()), SLOT(slotPopulateSessions()) ); connect( sessionsMenu, SIGNAL(activated(int)), SLOT(slotSessionActivated(int)) ); } /* If the user configured ksmserver to */ KConfig ksmserver("ksmserverrc", KConfig::CascadeConfig); if (ksmserver.group("General").readEntry( "loginMode" ) == "restoreSavedSession") { insertItem(Plasma::menuIconSet("document-save"), i18n("Save Session"), this, SLOT(slotSaveSession())); } if (KAuthorized::authorizeKAction("lock_screen")) { insertItem(Plasma::menuIconSet("system-lock-screen"), i18n("Lock Session"), this, SLOT(slotLock())); } if (KAuthorized::authorizeKAction("logout")) { insertItem(Plasma::menuIconSet("application-exit"), i18n("Log Out..."), this, SLOT(slotLogout())); } #if 0 // WABA: tear off handles don't work together with dynamically updated // menus. We can't update the menu while torn off, and we don't know // when it is torn off. if (KGlobalSettings::insertTearOffHandle()) insertTearOffHandle(); #endif setInitialized(true); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); //Set parents settings.setParent(this); gfile.setParent(this); //Setup the UI ui->fileBox->setDisabled(true); ui->sendBtn->setDisabled(true); ui->pauseBtn->setDisabled(true); ui->progressBar->setValue(0); ui->controlBox->setDisabled(true); ui->consoleGroup->setDisabled(true); ui->pauseBtn->setDisabled(true); ui->actionPrint_from_SD->setDisabled(true); ui->actionSet_SD_printing_mode->setDisabled(true); ui->actionEEPROM_editor->setDisabled(true); ui->statusGroup->setDisabled(true); ui->extruderlcd->setPalette(Qt::red); ui->bedlcd->setPalette(Qt::red); ui->sendtext->installEventFilter(this); ui->etmpspin->installEventFilter(this); ui->btmpspin->installEventFilter(this); recentMenu = new QMenu(this); //Note about tray icon - possible bug with Qt 5.4 trayIcon = new QSystemTrayIcon(this); trayIcon->setIcon(QIcon(":icons/repraptor.png")); trayIconMenu = new QMenu(this); trayIconMenu->addAction(ui->actionOpen); trayIconMenu->addAction(ui->actionExit); trayIcon->setToolTip(tr("RepRaptor running in the background")); trayIcon->setContextMenu(trayIconMenu); recentMenu->setTitle("Recent files"); ui->menuFile->insertMenu(ui->actionSettings, recentMenu); ui->menuFile->insertSeparator(ui->actionSettings); //Init baudrate combobox ui->baudbox->addItem(QString::number(4800)); ui->baudbox->addItem(QString::number(9600)); ui->baudbox->addItem(QString::number(115200)); ui->baudbox->addItem(QString::number(128000)); ui->baudbox->addItem(QString::number(230400)); ui->baudbox->addItem(QString::number(250000)); ui->baudbox->addItem(QString::number(460800)); ui->baudbox->addItem(QString::number(500000)); //Create objects //Timers need parent to be set up //in order to be tied to its thread //and stop right statusTimer = new QTimer(this); progressSDTimer = new QTimer(this); //QElapsedTimers have no parents sinceLastTemp = new QElapsedTimer(); sinceLastSDStatus = new QElapsedTimer(); //Workers would be moved to ther thread, //so we should not set their parents. Instead, //we should connect QThread's finished() to //worker's deleteLater() parserWorker = new Parser(); senderWorker = new Sender(); //Setting the parent of QThread lets //threads to stop right, and also makes //them inherit parent's priority parserThread = new QThread(this); senderThread = new QThread(this); //Restore settings firstrun = !settings.value("core/firstrun").toBool(); //firstrun is inverted! ui->baudbox->setCurrentIndex(settings.value("printer/baudrateindex", 2).toInt()); checkingTemperature = settings.value("core/checktemperature", 0).toBool(); ui->checktemp->setChecked(checkingTemperature); ui->etmpspin->setValue(settings.value("user/extrudertemp", 210).toInt()); ui->btmpspin->setValue(settings.value("user/bedtemp", 60).toInt()); ui->stepspin->setValue(settings.value("user/step", 1).toInt()); ui->estepspin->setValue(settings.value("user/estep", 1).toInt()); echo = settings.value("core/echo", 0).toBool(); autolock = settings.value("core/lockcontrols", 0).toBool(); chekingSDStatus = settings.value("core/checksdstatus", 1).toBool(); firmware = settings.value("printer/firmware", OtherFirmware).toInt(); statusTimer->setInterval(settings.value("core/statusinterval", 3000).toInt()); feedrate = settings.value("feedrate", 1500).toInt(); extruderFeedrate = settings.value("extruderfeedrate", 200).toInt(); trayIconEnabled = settings.value("core/trayiconenabled", 1).toBool(); supressWait = settings.value("user/supresswait", 0).toBool(); lastDir.append(settings.value("user/lastdir", "").toString()); int size = settings.beginReadArray("user/recentfiles"); for(int i = 0; i < size; ++i) { settings.setArrayIndex(i); recentFiles.append(settings.value("user/file").toString()); } settings.endArray(); //Init values sending = false; paused = false; sdprinting = false; opened = false; sdBytes = 0; userHistoryPos = -1; //Register all the types qRegisterMetaType<TemperatureReadings>("TemperatureReadings"); qRegisterMetaType<SDProgress>("SDProgress"); qRegisterMetaType<QSerialPortInfo>("QSerialPortInfo"); qRegisterMetaType< QVector<QString> >("QVector<QString>"); qRegisterMetaType<FileProgress>("FileProgress"); qRegisterMetaType<QSerialPort::SerialPortError>("QSerialPort::SerialPortError"); //Internal signal-slots connect(statusTimer, &QTimer::timeout, this, &MainWindow::checkStatus); connect(progressSDTimer, &QTimer::timeout, this, &MainWindow::checkSDStatus); connect(trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::trayIconClicked); //Parser thread signal-slots and init parserWorker->moveToThread(parserThread); connect(parserThread, &QThread::finished, parserWorker, &QObject::deleteLater); connect(this, &MainWindow::startedReadingEEPROM, parserWorker, &Parser::setEEPROMReadingMode); connect(parserWorker, &Parser::receivedTemperature, this, &MainWindow::updateTemperature); connect(parserWorker, &Parser::receivedSDFilesList, this, &MainWindow::initSDprinting); connect(parserWorker, &Parser::receivedEEPROMLine, this, &MainWindow::EEPROMSettingReceived); connect(parserWorker, &Parser::recievingEEPROMDone, this, &MainWindow::openEEPROMeditor); connect(parserWorker, &Parser::receivedError, this, &MainWindow::receivedError); connect(parserWorker, &Parser::receivedSDDone, this, &MainWindow::receivedSDDone); connect(parserWorker, &Parser::receivedSDUpdate, this, &MainWindow::updateSDStatus); connect(parserWorker, &Parser::receivedNotSDPrinting, this, &MainWindow::receivedNotSDPrinting); parserThread->start(); parserThread->setPriority(QThread::HighestPriority); //Sender thread signal-slots and init senderWorker->moveToThread(senderThread); connect(senderThread, &QThread::finished, senderWorker, &QObject::deleteLater); connect(parserWorker, &Parser::receivedOkNum, senderWorker, &Sender::receivedOkNum); connect(parserWorker, &Parser::receivedOkWait, senderWorker, &Sender::receivedOkWait); connect(parserWorker, &Parser::receivedResend, senderWorker, &Sender::receivedResend); connect(parserWorker, &Parser::receivedStart, senderWorker, &Sender::receivedStart); connect(senderWorker, &Sender::errorReceived, this, &MainWindow::serialError); connect(senderWorker, &Sender::dataReceived, parserWorker, &Parser::parse); connect(senderWorker, &Sender::dataReceived, this, &MainWindow::readSerial); connect(senderWorker, &Sender::reportProgress, this, &MainWindow::updateFileProgress); connect(senderWorker, &Sender::baudrateSetFailed, this, &MainWindow::baudrateSetFailed); connect(this, &MainWindow::setFile, senderWorker, &Sender::setFile); connect(this, &MainWindow::startPrinting, senderWorker, &Sender::startPrinting); connect(this, &MainWindow::stopPrinting, senderWorker, &Sender::stopPrinting); connect(this, &MainWindow::pause, senderWorker, &Sender::pause); connect(this, &MainWindow::setBaudrate, senderWorker, &Sender::setBaudrate); connect(this, &MainWindow::openPort, senderWorker, &Sender::openPort); connect(this, &MainWindow::closePort, senderWorker, &Sender::closePort); connect(this, &MainWindow::injectCommand, senderWorker, &Sender::injectCommand); connect(this, &MainWindow::flushInjectionBuffer, senderWorker, &Sender::flushInjectionBuffer); senderThread->start(); senderThread->setPriority(QThread::TimeCriticalPriority); //Timers init statusTimer->start(); progressSDTimer->setInterval(2500); if(chekingSDStatus) progressSDTimer->start(); sinceLastTemp->start(); sinceLastSDStatus->start(); //Update serial ports serialupdate(); //Update recent files list updateRecent(); //Update icon if(trayIconEnabled) trayIcon->show(); else trayIcon->hide(); }
void PanelKMenu::initialize() { // kdDebug(1210) << "PanelKMenu::initialize()" << endl; updateRecent(); if (initialized()) { return; } if (loadSidePixmap()) { // in case we've been through here before, let's disconnect disconnect(kapp, SIGNAL(kdisplayPaletteChanged()), this, SLOT(paletteChanged())); connect(kapp, SIGNAL(kdisplayPaletteChanged()), this, SLOT(paletteChanged())); } else { sidePixmap = sideTilePixmap = QPixmap(); } // add services PanelServiceMenu::initialize(); if (KickerSettings::showMenuTitles()) { int id; id = insertItem(new PopupMenuTitle(i18n("All Applications"), font()), -1 /* id */, 0); setItemEnabled( id, false ); id = insertItem(new PopupMenuTitle(i18n("Actions"), font()), -1 /* id */, -1); setItemEnabled( id, false ); } // create recent menu section createRecentMenuItems(); bool need_separator = false; // insert bookmarks if (KickerSettings::useBookmarks() && kapp->authorizeKAction("bookmarks")) { // Need to create a new popup each time, it's deleted by subMenus.clear() KPopupMenu * bookmarkParent = new KPopupMenu( this, "bookmarks" ); if(!bookmarkOwner) bookmarkOwner = new KBookmarkOwner; delete bookmarkMenu; // can't reuse old one, the popup has been deleted bookmarkMenu = new KBookmarkMenu( KonqBookmarkManager::self(), bookmarkOwner, bookmarkParent, actionCollection, true, false ); insertItem(KickerLib::menuIconSet("bookmark"), i18n("Bookmarks"), bookmarkParent); subMenus.append(bookmarkParent); need_separator = true; } // insert quickbrowser if (KickerSettings::useBrowser()) { PanelQuickBrowser *browserMnu = new PanelQuickBrowser(this); browserMnu->initialize(); insertItem(KickerLib::menuIconSet("kdisknav"), i18n("Quick Browser"), KickerLib::reduceMenu(browserMnu)); subMenus.append(browserMnu); need_separator = true; } // insert dynamic menus QStringList menu_ext = KickerSettings::menuExtensions(); if (!menu_ext.isEmpty()) { for (QStringList::ConstIterator it=menu_ext.begin(); it!=menu_ext.end(); ++it) { MenuInfo info(*it); if (!info.isValid()) continue; KPanelMenu *menu = info.load(); if (menu) { insertItem(KickerLib::menuIconSet(info.icon()), info.name(), menu); dynamicSubMenus.append(menu); need_separator = true; } } } if (need_separator) insertSeparator(); // insert client menus, if any if (clients.count() > 0) { QIntDictIterator<KickerClientMenu> it(clients); while (it){ if (it.current()->text.at(0) != '.') insertItem( it.current()->icon, it.current()->text, it.current(), it.currentKey() ); ++it; } insertSeparator(); } // run command if (kapp->authorize("run_command")) { insertItem(KickerLib::menuIconSet("run"), i18n("Run Command..."), this, SLOT( slotRunCommand())); insertSeparator(); } if (DM().isSwitchable() && kapp->authorize("switch_user")) { sessionsMenu = new QPopupMenu( this ); insertItem(KickerLib::menuIconSet("switchuser"), i18n("Switch User"), sessionsMenu); connect( sessionsMenu, SIGNAL(aboutToShow()), SLOT(slotPopulateSessions()) ); connect( sessionsMenu, SIGNAL(activated(int)), SLOT(slotSessionActivated(int)) ); } /* If the user configured ksmserver to */ KConfig ksmserver("ksmserverrc", false, false); ksmserver.setGroup("General"); if (ksmserver.readEntry( "loginMode" ) == "restoreSavedSession") { insertItem(KickerLib::menuIconSet("filesave"), i18n("Save Session"), this, SLOT(slotSaveSession())); } if (kapp->authorize("lock_screen")) { insertItem(KickerLib::menuIconSet("lock"), i18n("Lock Session"), this, SLOT(slotLock())); } if (kapp->authorize("logout")) { insertItem(KickerLib::menuIconSet("exit"), i18n("Log Out..."), this, SLOT(slotLogout())); } #if 0 // WABA: tear off handles don't work together with dynamically updated // menus. We can't update the menu while torn off, and we don't know // when it is torn off. if (KGlobalSettings::insertTearOffHandle()) insertTearOffHandle(); #endif setInitialized(true); }