Пример #1
0
CommandDlg::CommandDlg(dwt::Widget* parent, int type_, int ctx_, const tstring& name_, const tstring& command_, const tstring& hub_) :
	WidgetFactory<dwt::ModalDialog>(parent),
	separator(0),
	raw(0),
	chat(0),
	PM(0),
	hubMenu(0),
	userMenu(0),
	searchMenu(0),
	fileListMenu(0),
	nameBox(0),
	commandBox(0),
	hubBox(0),
	nick(0),
	once(0),
	result(0),
	openHelp(0),
	type(type_),
	ctx(ctx_),
	name(name_),
	command(command_),
	hub(hub_)
{
	onInitDialog(std::tr1::bind(&CommandDlg::handleInitDialog, this));
	onFocus(std::tr1::bind(&CommandDlg::handleFocus, this));
	onHelp(std::tr1::bind(&WinUtil::help, _1, _2));
}
Пример #2
0
GKGotoCellDialog::GKGotoCellDialog(QWidget *parent)
    : QDialog(parent), ui(new Ui::GKGoToCellDialog)
{
    ui->setupUi(this);

    adjustSize();
    setFixedSize(size());

    ui->label->setBuddy(ui->lineEdit);

    QRegExp regExp("[A-Za-z][1-9][0-9]{0,2}");
    ui->lineEdit->setValidator(new QRegExpValidator(regExp, this));

    connect(ui->btnOK, SIGNAL(clicked()), this, SLOT(accept()));
    connect(ui->btnCancel, SIGNAL(clicked()), this, SLOT(reject()));
    connect(ui->btnHelp, SIGNAL(clicked()), this, SLOT(onHelp()));
    connect(ui->lineEdit, SIGNAL(textChanged(QString)), this, SLOT(handleTextChanged()));
}
Пример #3
0
MainWindow::MainWindow(QWidget *parent)
	: QDialog(parent)
{
	ui.setupUi(this);

	DataTree *tree = this->findChild<DataTree *>(tr("treeWidget"));

	QStringList headers;
	headers << tr("title"); 
	tree->setHeaderLabels(headers);

	tree->setHeaderHidden(true);


	auto exportButton = this->findChild<QPushButton *>(tr("pushButton_exportData"));
	if (exportButton)
	{
		this->connect(exportButton, SIGNAL(clicked()), this, SLOT(onExportData()));
	}

	auto setExportPathButton = this->findChild<QPushButton *>(tr("pushButton_setExportPath"));
	if (setExportPathButton)
	{
		this->connect(setExportPathButton, SIGNAL(clicked()), this, SLOT(onSetExportPath()));
	}

	auto helpButton = this->findChild<QPushButton *>(tr("pushButton_help"));
	if (helpButton)
	{
		this->connect(helpButton, SIGNAL(clicked()), this, SLOT(onHelp()));
	}

	this->setAcceptDrops(true);

	loadOpenedFileList();

	//QString filename = QObject::tr("D:\\dev\\project\\misc\\qt\\DataExporter\\data\\test.xlsx");
	//tree->loadData(filename);
}
Пример #4
0
BOOL CALLBACK CalcOptions::wndProc(UINT msg,WPARAM wParam,LPARAM lParam)
{
	switch (msg)
	{
		case WM_INITDIALOG:
			return onInitDialog();

		case WM_DRAWITEM:
			return onDrawItem((LPDRAWITEMSTRUCT)lParam);

		case WM_COMMAND:

			switch(wParam)
			{
				case IDC_EXPR_FONT:
				case IDC_RESULT_FONT:
				case IDC_ERROR_FONT:
					onFont(wParam);
					break;

				case ID_SET_DEFAULTS:
					onSetDefaults();
					break;

				case ID_HELP_HELPTOPICS:
					onHelp();
					break;

				case IDOK:
				case IDCANCEL:					
					return onCloseDialog(wParam);
			}
			return TRUE;
	}
	return FALSE;
}
Пример #5
0
/** The text entered in the command textfield is sent (enter key pressed)
  *
  *
  * \param o A parameter used for FOX callbacks
  * \param s A parameter used for FOX callbacks
  * \param v The text comming from the command textfield
  *
  * \return Always 1
  *
  */
long RainbruRPG::Gui::FtpClientWindow::
treatNewCommand(FXObject* o,FXSelector s,void* v){
  FXString str;
  str=(FX::FXchar*)v;

  FXString filename=(FX::FXchar*)v;

  // If the entered text is not empty
  if (!str.empty()){

    fxText->appendText( "> " );
    fxText->appendText( str );
    fxText->appendText( "\n" );
    
    FXTextField* a=(FXTextField*)o;
    a->setText("");


    str=str.upper();
    if (str.contains("HELP")!=0){
      if (str.contains("USER")!=0){
	showHelpUser();
      }
      else if (str.contains("PASS")!=0){
	showHelpPass();
      }
      else if (str.contains("PASV")!=0){
	showHelpPasv();
      }
      else if (str.contains("PWD")!=0){
	showHelpPwd();
      }
      else if (str.contains("LIST")!=0){
	showHelpList();
      }
      else if (str.contains("SYST")!=0){
	showHelpSyst();
      }
      else if (str.contains("BINARY")!=0){
	showHelpBinary();
      }
      else if (str.contains("ASCII")!=0){
	showHelpAscii();
      }
      else if (str.contains("STOR")!=0){
	showHelpStore();
      }
      else if (str.contains("RETR")!=0){
	showHelpRetrieve();
      }
      else{
	onHelp(NULL,0,NULL);

      }
    }
    else if (str.contains("LIST")!=0){
      string s=ftpClient->commandLIST();
      FXString str=s.c_str();
      str.substitute('\r', ' ', true );
      logMessage(str);
    }
    else if (str.contains("PASV")!=0){
      ftpClient->toggleTransferMode();
      string s=ftpClient->waitControlResponse();
      logMessage(s.c_str());
    }
    else if (str.contains("PWD")!=0){
      string s=ftpClient->commandPWD();
      logMessage(s.c_str());
    }
    else if (str.contains("SYST")!=0){
      string s=ftpClient->commandSYST();
      logMessage(s.c_str());
    }
    else if (str.contains("BINARY")!=0){
      string s=ftpClient->commandBINARY();
      logMessage(s.c_str());
    }
    else if (str.contains("ASCII")!=0){
      string s=ftpClient->commandASCII();
      logMessage(s.c_str());
    }
    else if (str.contains("STOR")!=0){
      // because str is in UPPER case
      // I get the no-upper string
      int pos = str.find("STOR", 0);
      filename.erase( pos, 5 );

      LOGCATS("Filename :");
      LOGCATS(filename.text());
      LOGCAT();

      std::string fn(filename.text());

      // Get filename
      int filesize=ftpClient->getFilesize(fn);
      labTrPb->setTotal(filesize);

      // Change transfer information
      labTransName->setText(filename);
      labTransOrie->setText("Out");
      labTransSize->setText(filesizeToString(filesize));

      string s=ftpClient->commandSTOR(fn);
      logMessage(s.c_str());
    }
    else if (str.contains("RETR")!=0){
      // because str is in UPPER case
      // I get the no-upper string
      int pos = str.find("RETR", 0);
      filename.erase( pos, 5 );

      LOGCATS("Filename :");
      LOGCATS(filename.text());
      LOGCAT();

      std::string fn(filename.text());

      // Change transfer information
      labTransName->setText(filename);
      labTransOrie->setText("In");

      string s=ftpClient->commandRETR(fn);
      logMessage(s.c_str());
    }
    else{
      logMessage("Unknown command");
    }
  }

  scrollDown();
  return 1;
}
Пример #6
0
void QmitkExtWorkbenchWindowAdvisor::PostWindowCreate()
{
 QmitkCommonWorkbenchWindowAdvisor::PostWindowCreate();
 // very bad hack...
 berry::IWorkbenchWindow::Pointer window =
  this->GetWindowConfigurer()->GetWindow();
 QMainWindow* mainWindow =
  static_cast<QMainWindow*> (window->GetShell()->GetControl());

 if (!windowIcon.empty())
 {
  mainWindow->setWindowIcon(QIcon(QString::fromStdString(windowIcon)));
 }
 mainWindow->setContextMenuPolicy(Qt::PreventContextMenu);

 /*mainWindow->setStyleSheet("color: white;"
 "background-color: #808080;"
 "selection-color: #659EC7;"
 "selection-background-color: #808080;"
 " QMenuBar {"
 "background-color: #808080; }");*/

 // ==== Application menu ============================
 QMenuBar* menuBar = mainWindow->menuBar();
 menuBar->setContextMenuPolicy(Qt::PreventContextMenu);

 QMenu* fileMenu = menuBar->addMenu("&File");
 fileMenu->setObjectName("FileMenu");

 QAction* fileOpenAction = new QmitkExtFileOpenAction(QIcon(":/org.mitk.gui.qt.ext/Load_48.png"), window);
 fileMenu->addAction(fileOpenAction);
 fileSaveProjectAction = new QmitkExtFileSaveProjectAction(window);
 fileSaveProjectAction->setIcon(QIcon(":/org.mitk.gui.qt.ext/Save_48.png"));
 fileMenu->addAction(fileSaveProjectAction);
 closeProjectAction = new QmitkCloseProjectAction(window);
 closeProjectAction->setIcon(QIcon(":/org.mitk.gui.qt.ext/Remove_48.png"));
 fileMenu->addAction(closeProjectAction);
 fileMenu->addSeparator();
 QAction* fileExitAction = new QmitkFileExitAction(window);
 fileExitAction->setObjectName("QmitkFileExitAction");
 fileMenu->addAction(fileExitAction);

 berry::IViewRegistry* viewRegistry =
  berry::PlatformUI::GetWorkbench()->GetViewRegistry();
 const std::vector<berry::IViewDescriptor::Pointer>& viewDescriptors =
  viewRegistry->GetViews();

 // another bad hack to get an edit/undo menu...
 QMenu* editMenu = menuBar->addMenu("&Edit");
 undoAction = editMenu->addAction(QIcon(":/org.mitk.gui.qt.ext/Undo_48.png"),
  "&Undo",
  QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onUndo()),
  QKeySequence("CTRL+Z"));
 undoAction->setToolTip("Undo the last action (not supported by all modules)");
 redoAction = editMenu->addAction(QIcon(":/org.mitk.gui.qt.ext/Redo_48.png")
  , "&Redo",
  QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onRedo()),
  QKeySequence("CTRL+Y"));
 redoAction->setToolTip("execute the last action that was undone again (not supported by all modules)");

 imageNavigatorAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/Slider.png"), "&Image Navigator", NULL);
 bool imageNavigatorViewFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.imagenavigator");
 if (imageNavigatorViewFound)
 {
   QObject::connect(imageNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onImageNavigator()));
   imageNavigatorAction->setCheckable(true);

   // add part listener for image navigator
   imageNavigatorPartListener = new PartListenerForImageNavigator(imageNavigatorAction);
   window->GetPartService()->AddPartListener(imageNavigatorPartListener);
   berry::IViewPart::Pointer imageNavigatorView =
       window->GetActivePage()->FindView("org.mitk.views.imagenavigator");
   imageNavigatorAction->setChecked(false);
   if (imageNavigatorView)
   {
     bool isImageNavigatorVisible = window->GetActivePage()->IsPartVisible(imageNavigatorView);
     if (isImageNavigatorVisible)
       imageNavigatorAction->setChecked(true);
   }
   imageNavigatorAction->setToolTip("Open image navigator for navigating through image");
 }

 // toolbar for showing file open, undo, redo and other main actions
 QToolBar* mainActionsToolBar = new QToolBar;
 mainActionsToolBar->setContextMenuPolicy(Qt::PreventContextMenu);
#ifdef __APPLE__
 mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextUnderIcon );
#else
 mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextBesideIcon );
#endif

 mainActionsToolBar->addAction(fileOpenAction);
 mainActionsToolBar->addAction(fileSaveProjectAction);
 mainActionsToolBar->addAction(closeProjectAction);
 mainActionsToolBar->addAction(undoAction);
 mainActionsToolBar->addAction(redoAction);
 if (imageNavigatorViewFound)
 {
   mainActionsToolBar->addAction(imageNavigatorAction);
 }
 mainWindow->addToolBar(mainActionsToolBar);

#ifdef __APPLE__
 mainWindow->setUnifiedTitleAndToolBarOnMac(true);
#endif

 // ==== Window Menu ==========================
 QMenu* windowMenu = menuBar->addMenu("Window");
 if (showNewWindowMenuItem)
 {
   windowMenu->addAction("&New Window", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onNewWindow()));
   windowMenu->addSeparator();
 }

 QMenu* perspMenu = windowMenu->addMenu("&Open Perspective");

 QMenu* viewMenu;
 if (showViewMenuItem)
 {
   viewMenu = windowMenu->addMenu("Show &View");
   viewMenu->setObjectName("Show View");
 }
 windowMenu->addSeparator();
 resetPerspAction = windowMenu->addAction("&Reset Perspective",
  QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onResetPerspective()));

 if(showClosePerspectiveMenuItem)
  closePerspAction = windowMenu->addAction("&Close Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onClosePerspective()));

 windowMenu->addSeparator();
 windowMenu->addAction("&Preferences...",
  QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onEditPreferences()),
  QKeySequence("CTRL+P"));

 // fill perspective menu
 berry::IPerspectiveRegistry* perspRegistry =
  window->GetWorkbench()->GetPerspectiveRegistry();
 QActionGroup* perspGroup = new QActionGroup(menuBar);

 std::vector<berry::IPerspectiveDescriptor::Pointer> perspectives(
  perspRegistry->GetPerspectives());

    bool skip = false;
    for (std::vector<berry::IPerspectiveDescriptor::Pointer>::iterator perspIt =
      perspectives.begin(); perspIt != perspectives.end(); ++perspIt)
    {

      // if perspectiveExcludeList is set, it contains the id-strings of perspectives, which
      // should not appear as an menu-entry in the perspective menu
      if (perspectiveExcludeList.size() > 0)
      {
        for (unsigned int i=0; i<perspectiveExcludeList.size(); i++)
        {
          if (perspectiveExcludeList.at(i) == (*perspIt)->GetId())
          {
            skip = true;
            break;
          }
        }
        if (skip)
        {
          skip = false;
          continue;
        }
      }

      QAction* perspAction = new berry::QtOpenPerspectiveAction(window,
        *perspIt, perspGroup);
      mapPerspIdToAction.insert(std::make_pair((*perspIt)->GetId(), perspAction));
    }
 perspMenu->addActions(perspGroup->actions());

 // sort elements (converting vector to map...)
 std::vector<berry::IViewDescriptor::Pointer>::const_iterator iter;
 std::map<std::string, berry::IViewDescriptor::Pointer> VDMap;

 skip = false;
 for (iter = viewDescriptors.begin(); iter != viewDescriptors.end(); ++iter)
 {

   // if viewExcludeList is set, it contains the id-strings of view, which
   // should not appear as an menu-entry in the menu
   if (viewExcludeList.size() > 0)
   {
     for (unsigned int i=0; i<viewExcludeList.size(); i++)
     {
       if (viewExcludeList.at(i) == (*iter)->GetId())
       {
         skip = true;
         break;
       }
     }
     if (skip)
     {
       skip = false;
       continue;
     }
   }

  if ((*iter)->GetId() == "org.blueberry.ui.internal.introview")
   continue;
  if ((*iter)->GetId() == "org.mitk.views.imagenavigator")
   continue;

  std::pair<std::string, berry::IViewDescriptor::Pointer> p(
   (*iter)->GetLabel(), (*iter));
  VDMap.insert(p);
 }
 // ==================================================

  // ==== Perspective Toolbar ==================================
 QToolBar* qPerspectiveToolbar = new QToolBar;

 if (showPerspectiveToolbar)
 {
  qPerspectiveToolbar->addActions(perspGroup->actions());
  mainWindow->addToolBar(qPerspectiveToolbar);
 }
 else
  delete qPerspectiveToolbar;

 // ==== View Toolbar ==================================
 QToolBar* qToolbar = new QToolBar;

 std::map<std::string, berry::IViewDescriptor::Pointer>::const_iterator
  MapIter;
 for (MapIter = VDMap.begin(); MapIter != VDMap.end(); ++MapIter)
 {
  berry::QtShowViewAction* viewAction = new berry::QtShowViewAction(window,
   (*MapIter).second);
  viewActions.push_back(viewAction);
  if(showViewMenuItem)
    viewMenu->addAction(viewAction);
  if (showViewToolbar)
  {
   qToolbar->addAction(viewAction);
  }
 }

 if (showViewToolbar)
 {
  mainWindow->addToolBar(qToolbar);
 }
 else
  delete qToolbar;

 QSettings settings(GetQSettingsFile(), QSettings::IniFormat);
 mainWindow->restoreState(settings.value("ToolbarPosition").toByteArray());


 // ====================================================

 // ===== Help menu ====================================
 QMenu* helpMenu = menuBar->addMenu("Help");
 helpMenu->addAction("&Welcome",this, SLOT(onIntro()));
  helpMenu->addAction("&Help Contents",this, SLOT(onHelp()),  QKeySequence("F1"));
 helpMenu->addAction("&About",this, SLOT(onAbout()));
 // =====================================================


 QStatusBar* qStatusBar = new QStatusBar();

 //creating a QmitkStatusBar for Output on the QStatusBar and connecting it with the MainStatusBar
 QmitkStatusBar *statusBar = new QmitkStatusBar(qStatusBar);
 //disabling the SizeGrip in the lower right corner
 statusBar->SetSizeGripEnabled(false);



 QmitkProgressBar *progBar = new QmitkProgressBar();

 qStatusBar->addPermanentWidget(progBar, 0);
 progBar->hide();
// progBar->AddStepsToDo(2);
// progBar->Progress(1);

 mainWindow->setStatusBar(qStatusBar);

 QmitkMemoryUsageIndicatorView* memoryIndicator =
  new QmitkMemoryUsageIndicatorView();
 qStatusBar->addPermanentWidget(memoryIndicator, 0);
}
Пример #7
0
ThreadRunnerDlgImpl::ThreadRunnerDlgImpl(QWidget* pParent, Qt::WFlags flags, PausableThread* pThread, bool bShowCounter, TruncatePos eTruncatePos, bool bShowPauseAbort /* = true*/) :
    QDialog(pParent, flags),
    Ui::ThreadRunnerDlg(),

    m_pThread(pThread),
    m_nCounter(0),
    m_bShowCounter(bShowCounter),
    //m_nLastKey(0),

    m_tRealBegin(time(0)),
    m_tRunningBegin(time(0)),
    m_bShowPauseAbort(bShowPauseAbort),
    m_bFirstTime(true),
    m_eTruncatePos(eTruncatePos)
{
    setupUi(this);

    if (!bShowPauseAbort)
    {
        m_pPauseResumeB->hide();
        m_pAbortB->hide();
    }

    pThread->setParent(this);

    connect(m_pThread, SIGNAL(stepChanged(const StrList&, int)), this, SLOT(onStepChanged(const StrList&, int)));
    connect(m_pThread, SIGNAL(completed(bool)), this, SLOT(onThreadCompleted(bool)));
    connect(&m_closeTimer, SIGNAL(timeout()), this, SLOT(onCloseTimer()));
    connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(onUpdateTimer()));

    { QAction* p (new QAction(this)); p->setShortcut(QKeySequence(Qt::Key_Escape)); connect(p, SIGNAL(triggered()), this, SLOT(on_m_pAbortB_clicked())); addAction(p); } // !!! make ESC call on_m_pAbortB_clicked() instead of closing the dialog

    m_pCurrentL->setText("");

    pThread->start();
    m_updateTimer.start(500); // 0.5 sec

    { QAction* p (new QAction(this)); p->setShortcut(QKeySequence("F1")); connect(p, SIGNAL(triggered()), this, SLOT(onHelp())); addAction(p); }
}
int guMainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: abortInspectProcess(); break;
        case 1: show(); break;
        case 2: onGetSoapResponse(); break;
        case 3: testWebService(); break;
        case 4: loadCover((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 5: onCopyMD5ToClipboard(); break;
        case 6: onOpenCurrentEbook(); break;
        case 7: onSetLibraryForAllBooks(); break;
        case 8: onSetLibraryIssueForAllBooks(); break;
        case 9: onSetPeriodicalForAllBooks(); break;
        case 10: onSetTitleForAllBooks(); break;
        case 11: onSetAuthorsForAllBooks(); break;
        case 12: onSetSeriesForAllBooks(); break;
        case 13: onSetPublisherForAllBooks(); break;
        case 14: onSetSityForAllBooks(); break;
        case 15: onSetUdcForAllBooks(); break;
        case 16: onSetPubYearForAllBooks(); break;
        case 17: onSetBbcForAllBooks(); break;
        case 18: onSetLanguageForAllBooks(); break;
        case 19: onSetOrientationForAllBooks(); break;
        case 20: onSetScanDpiForAllBooks(); break;
        case 21: onSetColorScanForAllBooks(); break;
        case 22: onSetCleanScanForAllBooks(); break;
        case 23: { QString _r = getParamValue((*reinterpret_cast< QDomDocument*(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 24: onSetCategoryForAllBooks(); break;
        case 25: onSetCommentaryForAllBooks(); break;
        case 26: onAbortInspectProcess(); break;
        case 27: onAllEbooksUploaded(); break;
        case 28: onShowAbout(); break;
        case 29: onHelp(); break;
        case 30: initBaseSettings(); break;
        case 31: initSearchFilesSettings(); break;
        case 32: processCheckDublicateReply((*reinterpret_cast< QNetworkReply*(*)>(_a[1]))); break;
        case 33: processFillBibliographyReply((*reinterpret_cast< QNetworkReply*(*)>(_a[1]))); break;
        case 34: processLoadCoverReply((*reinterpret_cast< QNetworkReply*(*)>(_a[1]))); break;
        case 35: onCurrentFileChanged((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< QTreeWidgetItem*(*)>(_a[2]))); break;
        case 36: onFilesTreeDoubleClicked((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 37: onAddNewEbook((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< ebook(*)>(_a[2]))); break;
        case 38: onDublicateFinded(); break;
        case 39: onInspectFinished(); break;
        case 40: onStartProcess(); break;
        case 41: onEndProcess(); break;
        case 42: onTimerTimeout(); break;
        case 43: onCurrentCategoryChanged((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< QTreeWidgetItem*(*)>(_a[2]))); break;
        case 44: onCurrentCategoryChangedFillStr((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< QTreeWidgetItem*(*)>(_a[2]))); break;
        case 45: clearEditFields(); break;
        case 46: onInspectFolder(); break;
        case 47: onGetBiblioInfo(); break;
        case 48: onUploadToServer(); break;
        case 49: onFileListRight(); break;
        case 50: onFileListLeft(); break;
        case 51: onGetBiblioForCurrentEbook(); break;
        case 52: setGuiEditForCurrentItem(); break;
        case 53: onSaveChangesForBook(); break;
        case 54: onUploadEbookProgress((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 55: onUploadEbookFinished((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 56: onShowSettingsDialog(); break;
        case 57: onIsbnFieldChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 58: onIsbnsListItemActivated(); break;
        case 59: onAddIsbn(); break;
        case 60: onRemoveIsbn(); break;
        case 61: onAddIsbnToEbook((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 62: onRemoveIsbnFromEbook((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 63: onCommentaryTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 64: onTitleTextChanged((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 65: onAuthorsTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 66: onSeriesTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 67: onPublisherTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 68: onUdcTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 69: onBbcTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 70: onPubYearTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 71: onPageNumTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 72: onIssueTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 73: onVolumeTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 74: onLanguageTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 75: onDescriptionTextChanged(); break;
        case 76: onSityTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 77: onPeriodicalTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 78: onCategoryTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 79: onOrientationIndexChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 80: onBiblioTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 81: onDpiTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 82: onDvdNumTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 83: onColorScanStateChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 84: onClearScanStateChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 85: onSelectAllToUploadToogled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 86: onSubjectIndexChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 87: onToogleShowDublicates((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 88: onToogleShowUploaded((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 89: onToogleShowWithISBN((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 90: onToogleShowWithBibliography((*reinterpret_cast< bool(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 91;
    }
    return _id;
}
void QmitkExtWorkbenchWindowAdvisor::PostWindowCreate()
{
  // very bad hack...
  berry::IWorkbenchWindow::Pointer window =
    this->GetWindowConfigurer()->GetWindow();
  QMainWindow* mainWindow =
    qobject_cast<QMainWindow*> (window->GetShell()->GetControl());

  if (!windowIcon.isEmpty())
  {
    mainWindow->setWindowIcon(QIcon(windowIcon));
  }
  mainWindow->setContextMenuPolicy(Qt::PreventContextMenu);

  /*mainWindow->setStyleSheet("color: white;"
  "background-color: #808080;"
  "selection-color: #659EC7;"
  "selection-background-color: #808080;"
  " QMenuBar {"
  "background-color: #808080; }");*/

  // Load selected icon theme

  QStringList searchPaths = QIcon::themeSearchPaths();
  searchPaths.push_front( QString(":/org_mitk_icons/icons/") );
  QIcon::setThemeSearchPaths( searchPaths );

  berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService();
  berry::IPreferences::Pointer stylePref = prefService->GetSystemPreferences()->Node(berry::QtPreferences::QT_STYLES_NODE);
  QString iconTheme = stylePref->Get(berry::QtPreferences::QT_ICON_THEME, "<<default>>");
  if( iconTheme == QString( "<<default>>" ) )
  {
    iconTheme = QString( "tango" );
  }
  QIcon::setThemeName( iconTheme );

  // ==== Application menu ============================

  QMenuBar* menuBar = mainWindow->menuBar();
  menuBar->setContextMenuPolicy(Qt::PreventContextMenu);

#ifdef __APPLE__
  menuBar->setNativeMenuBar(true);
#else
  menuBar->setNativeMenuBar(false);
#endif

  QAction* fileOpenAction = new QmitkFileOpenAction(QIcon::fromTheme("document-open",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/document-open.svg")), window);
  fileOpenAction->setShortcut(QKeySequence::Open);
  QAction* fileSaveAction = new QmitkFileSaveAction(QIcon(":/org.mitk.gui.qt.ext/Save_48.png"), window);
  fileSaveAction->setShortcut(QKeySequence::Save);
  fileSaveProjectAction = new QmitkExtFileSaveProjectAction(window);
  fileSaveProjectAction->setIcon(QIcon::fromTheme("document-save",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/document-save.svg")));
  closeProjectAction = new QmitkCloseProjectAction(window);
  closeProjectAction->setIcon(QIcon::fromTheme("edit-delete",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-delete.svg")));

  auto   perspGroup = new QActionGroup(menuBar);
  std::map<QString, berry::IViewDescriptor::Pointer> VDMap;

  // sort elements (converting vector to map...)
  QList<berry::IViewDescriptor::Pointer>::const_iterator iter;

  berry::IViewRegistry* viewRegistry =
    berry::PlatformUI::GetWorkbench()->GetViewRegistry();
  const QList<berry::IViewDescriptor::Pointer> viewDescriptors = viewRegistry->GetViews();

  bool skip = false;
  for (iter = viewDescriptors.begin(); iter != viewDescriptors.end(); ++iter)
  {
    // if viewExcludeList is set, it contains the id-strings of view, which
    // should not appear as an menu-entry in the menu
    if (viewExcludeList.size() > 0)
    {
      for (int i=0; i<viewExcludeList.size(); i++)
      {
        if (viewExcludeList.at(i) == (*iter)->GetId())
        {
          skip = true;
          break;
        }
      }
      if (skip)
      {
        skip = false;
        continue;
      }
    }

    if ((*iter)->GetId() == "org.blueberry.ui.internal.introview")
      continue;
    if ((*iter)->GetId() == "org.mitk.views.imagenavigator")
      continue;
    if ((*iter)->GetId() == "org.mitk.views.viewnavigatorview")
      continue;

    std::pair<QString, berry::IViewDescriptor::Pointer> p(
      (*iter)->GetLabel(), (*iter));
    VDMap.insert(p);
  }

  std::map<QString, berry::IViewDescriptor::Pointer>::const_iterator
    MapIter;
  for (MapIter = VDMap.begin(); MapIter != VDMap.end(); ++MapIter)
  {
    berry::QtShowViewAction* viewAction = new berry::QtShowViewAction(window,
      (*MapIter).second);
    viewActions.push_back(viewAction);
  }

  if (!USE_EXPERIMENTAL_COMMAND_CONTRIBUTIONS)
  {
    QMenu* fileMenu = menuBar->addMenu("&File");
    fileMenu->setObjectName("FileMenu");
    fileMenu->addAction(fileOpenAction);
    fileMenu->addAction(fileSaveAction);
    fileMenu->addAction(fileSaveProjectAction);
    fileMenu->addAction(closeProjectAction);
    fileMenu->addSeparator();

    QAction* fileExitAction = new QmitkFileExitAction(window);
    fileExitAction->setIcon(QIcon::fromTheme("system-log-out",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/system-log-out.svg")));
    fileExitAction->setShortcut(QKeySequence::Quit);
    fileExitAction->setObjectName("QmitkFileExitAction");
    fileMenu->addAction(fileExitAction);

    // another bad hack to get an edit/undo menu...
    QMenu* editMenu = menuBar->addMenu("&Edit");
    undoAction = editMenu->addAction(QIcon::fromTheme("edit-undo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-undo.svg")),
      "&Undo",
      QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onUndo()),
      QKeySequence("CTRL+Z"));
    undoAction->setToolTip("Undo the last action (not supported by all modules)");
    redoAction = editMenu->addAction(QIcon::fromTheme("edit-redo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-redo.svg"))
      , "&Redo",
      QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onRedo()),
      QKeySequence("CTRL+Y"));
    redoAction->setToolTip("execute the last action that was undone again (not supported by all modules)");

    // ==== Window Menu ==========================
    QMenu* windowMenu = menuBar->addMenu("Window");
    if (showNewWindowMenuItem)
    {
      windowMenu->addAction("&New Window", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onNewWindow()));
      windowMenu->addSeparator();
    }

    QMenu* perspMenu = windowMenu->addMenu("&Open Perspective");

    QMenu* viewMenu;
    if (showViewMenuItem)
    {
      viewMenu = windowMenu->addMenu("Show &View");
      viewMenu->setObjectName("Show View");
    }
    windowMenu->addSeparator();
    resetPerspAction = windowMenu->addAction("&Reset Perspective",
      QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onResetPerspective()));

    if(showClosePerspectiveMenuItem)
      closePerspAction = windowMenu->addAction("&Close Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onClosePerspective()));

    windowMenu->addSeparator();
    windowMenu->addAction("&Preferences...",
      QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onEditPreferences()),
      QKeySequence("CTRL+P"));

    // fill perspective menu
    berry::IPerspectiveRegistry* perspRegistry =
      window->GetWorkbench()->GetPerspectiveRegistry();

    QList<berry::IPerspectiveDescriptor::Pointer> perspectives(
      perspRegistry->GetPerspectives());

    skip = false;
    for (QList<berry::IPerspectiveDescriptor::Pointer>::iterator perspIt =
      perspectives.begin(); perspIt != perspectives.end(); ++perspIt)
    {
      // if perspectiveExcludeList is set, it contains the id-strings of perspectives, which
      // should not appear as an menu-entry in the perspective menu
      if (perspectiveExcludeList.size() > 0)
      {
        for (int i=0; i<perspectiveExcludeList.size(); i++)
        {
          if (perspectiveExcludeList.at(i) == (*perspIt)->GetId())
          {
            skip = true;
            break;
          }
        }
        if (skip)
        {
          skip = false;
          continue;
        }
      }

      QAction* perspAction = new berry::QtOpenPerspectiveAction(window,
        *perspIt, perspGroup);
      mapPerspIdToAction.insert((*perspIt)->GetId(), perspAction);
    }
    perspMenu->addActions(perspGroup->actions());

    if (showViewMenuItem)
    {
      for (auto viewAction : viewActions)
      {
        viewMenu->addAction(viewAction);
      }
    }

    // ===== Help menu ====================================
    QMenu* helpMenu = menuBar->addMenu("&Help");
    helpMenu->addAction("&Welcome",this, SLOT(onIntro()));
    helpMenu->addAction("&Open Help Perspective", this, SLOT(onHelpOpenHelpPerspective()));
    helpMenu->addAction("&Context Help",this, SLOT(onHelp()),  QKeySequence("F1"));
    helpMenu->addAction("&About",this, SLOT(onAbout()));
    // =====================================================
  }
  else
  {
    //undoAction = new QAction(QIcon::fromTheme("edit-undo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-undo.svg")),
    //  "&Undo", nullptr);
    undoAction = new QmitkUndoAction(QIcon::fromTheme("edit-undo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-undo.svg")), nullptr);
    undoAction->setShortcut(QKeySequence::Undo);
    redoAction = new QmitkRedoAction(QIcon::fromTheme("edit-redo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-redo.svg")), nullptr);
    redoAction->setShortcut(QKeySequence::Redo);
  }

  // toolbar for showing file open, undo, redo and other main actions
  auto   mainActionsToolBar = new QToolBar;
  mainActionsToolBar->setObjectName("mainActionsToolBar");
  mainActionsToolBar->setContextMenuPolicy(Qt::PreventContextMenu);
#ifdef __APPLE__
  mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextUnderIcon );
#else
  mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextBesideIcon );
#endif

  imageNavigatorAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/Slider.png"), "&Image Navigator", nullptr);
  bool imageNavigatorViewFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.imagenavigator");

  if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor"))
  {
    openDicomEditorAction = new QmitkOpenDicomEditorAction(QIcon(":/org.mitk.gui.qt.ext/dcm-icon.png"),window);
  }

  if (imageNavigatorViewFound)
  {
    QObject::connect(imageNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onImageNavigator()));
    imageNavigatorAction->setCheckable(true);

    // add part listener for image navigator
    imageNavigatorPartListener.reset(new PartListenerForImageNavigator(imageNavigatorAction));
    window->GetPartService()->AddPartListener(imageNavigatorPartListener.data());
    berry::IViewPart::Pointer imageNavigatorView =
      window->GetActivePage()->FindView("org.mitk.views.imagenavigator");
    imageNavigatorAction->setChecked(false);
    if (imageNavigatorView)
    {
      bool isImageNavigatorVisible = window->GetActivePage()->IsPartVisible(imageNavigatorView);
      if (isImageNavigatorVisible)
        imageNavigatorAction->setChecked(true);
    }
    imageNavigatorAction->setToolTip("Toggle image navigator for navigating through image");
  }

  viewNavigatorAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/view-manager_48.png"),"&View Navigator", nullptr);
  viewNavigatorFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.viewnavigatorview");
  if (viewNavigatorFound)
  {
    QObject::connect(viewNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onViewNavigator()));
    viewNavigatorAction->setCheckable(true);

    // add part listener for view navigator
    viewNavigatorPartListener.reset(new PartListenerForViewNavigator(viewNavigatorAction));
    window->GetPartService()->AddPartListener(viewNavigatorPartListener.data());
    berry::IViewPart::Pointer viewnavigatorview =
      window->GetActivePage()->FindView("org.mitk.views.viewnavigatorview");
    viewNavigatorAction->setChecked(false);
    if (viewnavigatorview)
    {
      bool isViewNavigatorVisible = window->GetActivePage()->IsPartVisible(viewnavigatorview);
      if (isViewNavigatorVisible)
        viewNavigatorAction->setChecked(true);
    }
    viewNavigatorAction->setToolTip("Toggle View Navigator");
  }

  mainActionsToolBar->addAction(fileOpenAction);
  mainActionsToolBar->addAction(fileSaveProjectAction);
  mainActionsToolBar->addAction(closeProjectAction);
  mainActionsToolBar->addAction(undoAction);
  mainActionsToolBar->addAction(redoAction);
  if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor"))
  {
    mainActionsToolBar->addAction(openDicomEditorAction);
  }
  if (imageNavigatorViewFound)
  {
    mainActionsToolBar->addAction(imageNavigatorAction);
  }
  if (viewNavigatorFound)
  {
    mainActionsToolBar->addAction(viewNavigatorAction);
  }
  mainWindow->addToolBar(mainActionsToolBar);

  // ==== Perspective Toolbar ==================================
  auto   qPerspectiveToolbar = new QToolBar;
  qPerspectiveToolbar->setObjectName("perspectiveToolBar");

  if (showPerspectiveToolbar)
  {
    qPerspectiveToolbar->addActions(perspGroup->actions());
    mainWindow->addToolBar(qPerspectiveToolbar);
  }
  else
    delete qPerspectiveToolbar;

  // ==== View Toolbar ==================================
  auto   qToolbar = new QToolBar;
  qToolbar->setObjectName("viewToolBar");

  if (showViewToolbar)
  {
    mainWindow->addToolBar(qToolbar);

    for (auto viewAction : viewActions)
    {
      qToolbar->addAction(viewAction);
    }
  }
  else
    delete qToolbar;

  QSettings settings(GetQSettingsFile(), QSettings::IniFormat);
  mainWindow->restoreState(settings.value("ToolbarPosition").toByteArray());

  auto   qStatusBar = new QStatusBar();

  //creating a QmitkStatusBar for Output on the QStatusBar and connecting it with the MainStatusBar
  auto  statusBar = new QmitkStatusBar(qStatusBar);
  //disabling the SizeGrip in the lower right corner
  statusBar->SetSizeGripEnabled(false);

  auto  progBar = new QmitkProgressBar();

  qStatusBar->addPermanentWidget(progBar, 0);
  progBar->hide();
  // progBar->AddStepsToDo(2);
  // progBar->Progress(1);

  mainWindow->setStatusBar(qStatusBar);

  if (showMemoryIndicator)
  {
    auto   memoryIndicator = new QmitkMemoryUsageIndicatorView();
    qStatusBar->addPermanentWidget(memoryIndicator, 0);
  }
}
Пример #10
0
MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags)
    : QMainWindow(parent, flags), loginWindow_(NULL), connectWindow_(NULL), serverListWindow_(0),
      timer_(NULL), settingsMenu_(0), connected_(0), getServers_(NULL)
{
	QCoreApplication::setOrganizationName("CPPP");
    QCoreApplication::setApplicationName("VPNht");

	ui.setupUi(this);
    setWindowTitle("VPN.ht " + QString(VERSION));

    g_openVPNConnection = new OpenVPNConnectorQt(this);
    if (!g_openVPNConnection->installHelper(SERVICE_NAME))
    {
        QMessageBox::information(this,
                                 "VPNht", "Failed to install helper for program. Please contact support.");
        QTimer::singleShot(1, this, SLOT(close()));
        return;
    }

#if defined Q_OS_MAC
    //setAttribute(Qt::WA_QuitOnClose, false);
#endif

    trayIcon_ = new QSystemTrayIcon(this);       

    trayMenu_ = new QMenu(this);
    actConnect_ = new QAction("Connect", this);
    actDisconnect_ = new QAction("Disconnect", this);
    actHelp_ = new QAction("Help", this);
    actLiveChat_ = new QAction("Live chat", this);
    actExit_ = new QAction("Quit", this);
    trayMenu_->addAction(actConnect_);
    trayMenu_->addAction(actDisconnect_);
    trayMenu_->addSeparator();
    trayMenu_->addAction(actHelp_);
    trayMenu_->addAction(actLiveChat_);
    trayMenu_->addAction(actExit_);
    trayIcon_->setContextMenu(trayMenu_);
    trayIcon_->hide();    

    setTrayStatusDisconnected(false);

    settingsMenu_ = new QMenu(this);
    settingsMenu_->addAction("Settings", this, SLOT(onSettings()));
    settingsMenu_->addAction("Status", this, SLOT(onStatus()));
    settingsMenu_->addAction("Help", this, SLOT(onHelp()));
    settingsMenu_->addAction("Proxy", this, SLOT(onProxy()));
    settingsMenu_->addAction("Show logs", this, SLOT(onShowLogs()));
    settingsMenu_->addAction("Logout", this, SLOT(onReturnToSignUp()));
    settingsMenu_->setStyleSheet(ctxMenuStyle);    

    loginWindow_ = new LoginWindow(this);
	ui.verticalLayout->addWidget(loginWindow_);
	loginWindow_->loadSettings();
    loginWindow_->hide();
	connect(loginWindow_, SIGNAL(signedIn(QString, QString)), SLOT(onSignIn(QString, QString)));

    waitWindow_ = new WaitWindow(this);
    ui.verticalLayout->addWidget(waitWindow_);

    settingsWindow_ = new SettingsWindow(settingsMenu_, this);
    connect(settingsWindow_, SIGNAL(back()), SLOT(onBack()));
	ui.verticalLayout->addWidget(settingsWindow_);
    settingsWindow_->hide();

    connectWindow_ = new ConnectWindow(settingsMenu_, this);
    connect(connectWindow_, SIGNAL(serverList()), SLOT(onServerList()));
    connect(connectWindow_, SIGNAL(connected()), SLOT(onConnected()));
        ui.verticalLayout->addWidget(connectWindow_);

    ui.verticalLayout->addWidget(connectWindow_);
	connectWindow_->hide();

    serverListWindow_ = new ServerListWindow(this);
    connect(serverListWindow_, SIGNAL(serverSelected(const QString &)),
            this, SLOT( onChangeServer(const QString &) ));
    ui.verticalLayout->addWidget(serverListWindow_);
    serverListWindow_->hide();

    proxySettingsWindow_ = new ProxySettingsWindow(settingsMenu_, this);
    connect(proxySettingsWindow_, SIGNAL(back()), SLOT(onBack()));
    ui.verticalLayout->addWidget(proxySettingsWindow_);
    proxySettingsWindow_->hide();


    // tray action
    connect(actConnect_, SIGNAL(triggered()), connectWindow_, SLOT(onClickConnect()));
    connect(actDisconnect_, SIGNAL(triggered()), connectWindow_, SLOT(onClickConnect()));
    connect(actHelp_, SIGNAL(triggered()), SLOT(onActHelp()));
    connect(actLiveChat_, SIGNAL(triggered()), SLOT(onLiveChat()));
    connect(actExit_, SIGNAL(triggered()), SLOT(onExit()));


#if defined Q_OS_WIN
    connect(trayIcon_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
            SLOT( onTrayActivated(QSystemTrayIcon::ActivationReason) ));
#endif

    QSettings settings;
    if (settings.value("savePass", "true").toString() == "true")
    {
		QString username = settings.value("login", "").toString();
		QString password = settings.value("password", "").toString();
		if (!username.isEmpty() && !password.isEmpty())
        {
            adjustSize();
            setFixedSize(size());
            skipLoginScreen(username, password);
		}
		else
		{
            waitWindow_->hide();
            loginWindow_->show();
            adjustSize();
            setFixedSize(size());
		}
    }
    else
    {
        waitWindow_->hide();
        loginWindow_->show();
        adjustSize();
        setFixedSize(size());
    }
}
Пример #11
0
SettingsDialog::SettingsDialog(dwt::Widget* parent) : WidgetFactory<dwt::ModalDialog>(parent), currentPage(0) {
	onInitDialog(std::tr1::bind(&SettingsDialog::initDialog, this));
	onHelp(std::tr1::bind(&SettingsDialog::handleHelp, this, _1, _2));
}
IntelligentSecurity::IntelligentSecurity(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::IntelligentSecurity)
{
    ui->setupUi(this);

#ifdef __linux__
    struct stat st = {0};

    if (stat(INSTALL_PATH.toStdString().c_str(), &st) == -1) {
        mkdir(INSTALL_PATH.toStdString().c_str(), 0744);
    }

    st = {0};

    if (stat(QString(INSTALL_PATH+QString("/data")).toStdString().c_str(),&st) == -1){
         mkdir(QString(INSTALL_PATH+QString("/data")).toStdString().c_str(),0744);
}
#else

#endif


    /*************************************************/
    /***** CREATING MENU FOR APP INDICATOR ***********/
    a_updateModel = new QAction(tr("&Update"),this);
    connect(a_updateModel, SIGNAL(triggered()), this, SLOT(onUpdateModel()));

    a_showConfiguration = new QAction(tr("&Configure"), this);
    connect(a_showConfiguration, SIGNAL(triggered()), this, SLOT(onShowConfiguration()));

    a_showAccessAttempts = new QAction(tr("&Show access attempts"), this);
    connect(a_showAccessAttempts, SIGNAL(triggered()), this, SLOT(onShowAccessAttempts()));

    a_showhideRecognizerWindows = new QAction(tr("&Show recognizer window"),this);
    connect(a_showhideRecognizerWindows, SIGNAL(triggered()), this, SLOT(onShowHideRecognizerWindows()));

    a_help = new QAction(tr("&Help"), this);
    connect(a_help, SIGNAL(triggered()), this, SLOT(onHelp()));

    a_quit = new QAction(tr("&Quit"), this);
    connect(a_quit, SIGNAL(triggered()), this, SLOT(onQuit()));


    trayIconMenu = new QMenu(this);
    trayIconMenu->addAction(a_updateModel);
    trayIconMenu->addAction(a_showConfiguration);
    trayIconMenu->addAction(a_showAccessAttempts);
    trayIconMenu->addAction(a_showhideRecognizerWindows);
    trayIconMenu->addAction(a_help);
    trayIconMenu->addAction(a_quit);

    trayIcon = new QSystemTrayIcon(QIcon(DEFAULT_PATH("IS_Indicator.png")), this);
    trayIcon->setContextMenu(trayIconMenu);
    trayIcon->show();
    /*************************************************/
    /*************************************************/

    faceRecognizer = new FaceRecognizer();
    faceRecognizer->Init();
    faceRecognizer->OpenVideoCapture(CV_CAP_ANY);

    QFile check(USER_PATH("IntelligentSecurity.cvs"));
    if(!check.open(QIODevice::ReadOnly | QIODevice::Text)) {
       this->onShowHideRecognizerWindows();
       faceRecognizer->showWindows();
       faceRecognizer->Train(1);
       faceRecognizer->SaveModel(USER_PATH("IntelligentSecurity.cvs"));
       cvDestroyAllWindows();
    } else {
        faceRecognizer->LoadModel(USER_PATH("IntelligentSecurity.cvs"));
    }


    if(!this->readConfiguration()) {
        string msg = "Now enter your details for customization and press OK.";
        NotificationManager::showNotification("Setting up", msg.c_str(),"/usr/share/icons/HighContrast/256x256/status/dialog-information.png");
        this->show();
        pVoice.Speak(msg);

    } else {
        timer = new QTimer(this);
        connect(timer, SIGNAL(timeout()), this, SLOT(runFaceRecognizer()));
        timer->start(10);
    }

    pVoice.Init();
    workstation_locked = false;
    faceRecognizer->hideWindows();
}
Пример #13
0
INT_PTR TffdshowPageBase::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg) {
        case WM_DESTROY: {
            for (ThtiPages::const_iterator htiPage = htiPages.begin(); htiPage != htiPages.end(); htiPage++) {
                delete *htiPage;
            }
            htiPages.clear();
            page = NULL;
            if (arrowsFont) {
                DeleteObject(arrowsFont);
            }
            arrowsFont = NULL;
            if (hil) {
                ImageList_Destroy(hil);
            }
            hil = NULL;
            for (int i = 0; i < countof(bmp1); i++) {
                DeleteObject(bmp1[i]);
                DeleteObject(bmp2[i]);
            }
            break;
        }
        case WM_FFONCHANGE:
            DPRINTF(_l("onChangeParam"));
            if (wParam == IDFF_alwaysOnTop && IsWindow(dlg)) {
                SetWindowPos(dlg, lParam ? HWND_TOPMOST : HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
            }
            if (wParam != 0) {
                setChange();
            }
            return TRUE;
        case WM_FFONFRAME: {
            MSG msg;
            if (PeekMessage(&msg, m_hwnd, WM_FFONFRAME, WM_FFONFRAME, PM_NOREMOVE)) {
                return TRUE;    // drop msg when next WM_FFONFRAME is already in the message queue.
            }
            for (ThtiPages::const_iterator hp = htiPages.begin(); hp != htiPages.end(); hp++)
                for (TconfPages::const_iterator i = (*hp)->begin(); i != (*hp)->end(); i++)
                    if ((*i)->m_hwnd) {
                        (*i)->onFrame();
                    }
            return TRUE;
        }
        case WM_COMMAND:
            switch (LOWORD(wParam)) {
                case IDC_BT_HELP:
                    if (HIWORD(wParam) == BN_CLICKED) {
                        onHelp();
                        return TRUE;
                    }
                    break;
            }
            break;
        case WM_CONTEXTMENU:
            if (translateTV()) {
                return TRUE;
            }
            break;
        case WM_NOTIFY: {
            NMHDR *nmhdr = LPNMHDR(lParam);
            if (nmhdr->hwndFrom == htv && nmhdr->idFrom == IDC_TV_TREE)
                switch (nmhdr->code) {
                    case TVN_SELCHANGED: {
                        NMTREEVIEW *nmtv = LPNMTREEVIEW(lParam);
                        if (nmtv->itemNew.hItem) {
                            selectPage(hti2page(nmtv->itemNew.hItem));
                            return TRUE;
                        }
                        break;
                    }
                    case TVN_ITEMEXPANDING: {
                        NMTREEVIEW *nmtv = LPNMTREEVIEW(lParam);
                        if (nmtv->action == TVE_COLLAPSE) {
                            setDlgResult(TRUE);
                        }
                        return TRUE;
                    }
                }
            break;
        }
    }
    return Twindow::msgProc(uMsg, wParam, lParam);
}