void PerformAction::DoCommand(string command, string input) { if (command.compare("open") == 0) { OpenProgram(input); } else if (command.compare("store") == 0) { StoreFilePath(input); } else if (command.compare("close") == 0) { } else if (command.compare("goodbye") == 0) { } }
TNMainWindow::TNMainWindow(QObject *parent) : QObject(parent){ #if TARGET_OS_MAC //On mac, get the directory of the bundle (which will be <location>/TermNotify.app/Contents/MacOS) and go up to the folder with the file in QDir BundleDir(QCoreApplication::applicationDirPath()); BundleDir.cdUp(); BundleDir.cdUp(); BundleDir.cdUp(); QString strMacBundlePath = BundleDir.path().append("/"); QSettings stgSettings(QString(strMacBundlePath).append("TermNotify.ini"), QSettings::IniFormat); #else QSettings stgSettings("TermNotify.ini", QSettings::IniFormat); #endif //Load settings gstrExecutable = stgSettings.value("RunFile", #ifdef _WIN32 //Windows "UwTerminalX" #elif TARGET_OS_MAC //Mac "%DIRPATH%/UwTerminalX.app/Contents/MacOS/UwTerminalX" #else //Linux "./UwTerminalX" #endif ).toString(); gstrArgumentList = stgSettings.value("ArgumentList", "ACCEPT COM=%PORT% NOCONNECT").toString(); gintDisplayTime = stgSettings.value("DisplayTime", DefaultDisplayTime).toUInt(); gintScanTime = stgSettings.value("ScanTime", DefaultScanTime).toUInt(); //Set defaults if not found in configuration file if (stgSettings.value("RunFile").isNull()) { stgSettings.setValue("RunFile", gstrExecutable); } if (stgSettings.value("ArgumentList").isNull()) { stgSettings.setValue("ArgumentList", gstrArgumentList); } if (stgSettings.value("DisplayTime").isNull()) { stgSettings.setValue("DisplayTime", gintDisplayTime); } if (stgSettings.value("ScanTime").isNull()) { stgSettings.setValue("ScanTime", gintScanTime); } #ifdef TARGET_OS_MAC //Replaces instances of %DIRPATH% with the folder location that TermNotify is in gstrExecutable.replace("%DIRPATH%", strMacBundlePath); #endif //Create system tray menu gpContextMenu = new QMenu; gpContextMenu->addAction(new QAction("Laird TermNotify", this)); gpContextMenu->addAction(new QAction(TermNotifyVer, this)); gpContextMenu->addSeparator(); gpContextMenu->addAction(new QAction("Edit Configuration", this)); gpContextMenu->addAction(new QAction("Exit", this)); gpContextMenu->actions()[0]->setDisabled(true); gpContextMenu->actions()[1]->setDisabled(true); #ifdef TARGET_OS_MAC //Disabled due to Mac not associating .ini files with text editor gpContextMenu->actions()[2]->setDisabled(true); #endif //Create system tray object #ifdef _WIN32 giUw16Image = QImage(":/images/TermNotify.ico"); #else giUw16Image = QImage(":/images/TermNotify.png"); #endif gpUw16Pixmap = new QPixmap(QPixmap::fromImage(giUw16Image)); gstSysTrayIcon.setIcon(QIcon(*gpUw16Pixmap)); gstSysTrayIcon.setContextMenu(gpContextMenu); gstSysTrayIcon.show(); //Connect up the context menu connect(gpContextMenu, SIGNAL(triggered(QAction*)), this, SLOT(ContextMenuClicked(QAction*))); //Connect balloon meesage clicked event connect(&gstSysTrayIcon, SIGNAL(messageClicked()), this, SLOT(OpenProgram())); //Connect timer connect(>SerialCheckTimer, SIGNAL(timeout()), this, SLOT(SerialCheck())); //Default list glPorts.clear(); gbInitialScan = false; //Start the timer gtSerialCheckTimer.setInterval(gintScanTime); gtSerialCheckTimer.start(); }
glPorts.clear(); gbInitialScan = false; //Start the timer gtSerialCheckTimer.setInterval(gintScanTime); gtSerialCheckTimer.start(); } //============================================================================= //============================================================================= TNMainWindow::~TNMainWindow( ) { //Disconnect events disconnect(this, SLOT(ContextMenuClicked(QAction*))); disconnect(this, SLOT(OpenProgram())); disconnect(this, SLOT(SerialCheck())); //Delete context menu delete gpContextMenu; //Remove system tray icon gstSysTrayIcon.hide(); //Delete pixmap delete gpUw16Pixmap; } //============================================================================= //============================================================================= void