コード例 #1
0
ファイル: MainWindow.cpp プロジェクト: mk219533/tesseract-gui
MainWindow::MainWindow()
{
  tabWidget = new QTabWidget;

  #if QT_VERSION >= 0x040500
  tabWidget->setTabsClosable(true);
  tabWidget->setMovable(true);
  #endif

  connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(handleClose(int)));
  connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateMenus()));
  connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateCommandActions()));
  connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateSaveAction()));

  setCentralWidget(tabWidget);

  windowMapper = new QSignalMapper(this);
  connect(windowMapper, SIGNAL(mapped(int)), tabWidget, SLOT(setCurrentIndex(int)));

  createActions();
  createMenus();
  createToolBars();
  updateMenus();
  updateCommandActions();
  updateSaveAction();
  readSettings();
  setUnifiedTitleAndToolBarOnMac(true);
}
コード例 #2
0
ファイル: MainWindow.cpp プロジェクト: ecraven/qt-box-editor
void MainWindow::addChild(const QString& imageFileName) {
  if (!imageFileName.isEmpty()) {
    QString canonicalImageFileName =
      QFileInfo(imageFileName).canonicalFilePath();
    for (int i = 0; i < tabWidget->count(); ++i) {
      ChildWidget* child = qobject_cast<ChildWidget*> (tabWidget->widget(i));
      if (canonicalImageFileName == child->canonicalImageFileName()) {
        tabWidget->setCurrentIndex(i);
        return;
      }
    }

    ChildWidget* child = new ChildWidget(this);
    if (child->loadImage(imageFileName)) {
      statusBar()->showMessage(tr("File loaded"), 2000);
      tabWidget->setCurrentIndex(tabWidget->addTab(child,
                                 child->userFriendlyCurrentFile()));
      tabWidget->setTabToolTip(tabWidget->currentIndex(), imageFileName);
      connect(child, SIGNAL(boxChanged()), this, SLOT(updateCommandActions()));
      connect(child, SIGNAL(modifiedChanged()), this, SLOT(updateTabTitle()));
      connect(child, SIGNAL(modifiedChanged()), this, SLOT(updateSaveAction()));
      connect(child, SIGNAL(zoomRatioChanged(qreal)), this,
              SLOT(zoomRatioChanged(qreal)));
      connect(child, SIGNAL(statusBarMessage(QString)), this,
              SLOT(statusBarMessage(QString)));
      connect(child, SIGNAL(drawRectangleChoosen()), this, SLOT(updateCommandActions()));
      child->setZoomStatus();
      // save path of open image file
      QSettings settings(QSettings::IniFormat, QSettings::UserScope,
                         SETTING_ORGANIZATION, SETTING_APPLICATION);
      QString filePath = QFileInfo(imageFileName).absolutePath();
      settings.setValue("last_path", filePath);

      QStringList files = settings.value("recentFileList").toStringList();
      files.removeAll(imageFileName);
      files.prepend(imageFileName);
      while (files.size() > MaxRecentFiles)
        files.removeLast();

      settings.setValue("recentFileList", files);

      foreach(QWidget * widget, QApplication::topLevelWidgets()) {
        MainWindow* mainWin = qobject_cast<MainWindow*>(widget);
        if (mainWin)
          mainWin->updateRecentFileActions();
      }
コード例 #3
0
ファイル: MainWindow.cpp プロジェクト: ecraven/qt-box-editor
MainWindow::MainWindow() {
  tabWidget = new QTabWidget;

#if QT_VERSION >= 0x040500
  tabWidget->setTabsClosable(true);
  tabWidget->setMovable(true);
#endif

  connect(tabWidget, SIGNAL(tabCloseRequested(int)), this,
          SLOT(handleClose(int)));
  connect(tabWidget, SIGNAL(currentChanged(int)), this,
          SLOT(updateMenus()));
  connect(tabWidget, SIGNAL(currentChanged(int)), this,
          SLOT(updateCommandActions()));
  connect(tabWidget, SIGNAL(currentChanged(int)), this,
          SLOT(updateSaveAction()));

  setCentralWidget(tabWidget);

  windowMapper = new QSignalMapper(this);
  connect(windowMapper, SIGNAL(mapped(int)), tabWidget,
          SLOT(setCurrentIndex(int)));

  shortCutsDialog = 0;
  setAcceptDrops(true);
  tabWidget->setAcceptDrops(true);
  createActions();
  createMenus();
  createToolBars();
  createStatusBar();
  updateMenus();
  updateCommandActions();
  updateSaveAction();
  readSettings(true);
  setUnifiedTitleAndToolBarOnMac(true);
  setWindowIcon(QIcon(":/icons/qbe.png"));
  setWindowTitle(tr("%1 - v%2").arg(SETTING_APPLICATION).arg(VERSION));
}
コード例 #4
0
ファイル: MainWindow.cpp プロジェクト: mk219533/tesseract-gui
void MainWindow::addChild(const QString &imageFileName)
{
  if (!imageFileName.isEmpty()) {
    QString canonicalImageFileName = QFileInfo(imageFileName).canonicalFilePath();
    for (int i = 0; i < tabWidget->count(); ++i) {
      ChildWidget *child = qobject_cast<ChildWidget *> (tabWidget->widget(i));
      if (canonicalImageFileName == child->canonicalImageFileName()) {
        tabWidget->setCurrentIndex(i);
        return;
      }
    }

    ChildWidget *child = new ChildWidget;
    if (child->loadImage(imageFileName)) {
      statusBar()->showMessage(tr("File loaded"), 2000);
      tabWidget->setCurrentIndex(tabWidget->addTab(child, child->userFriendlyCurrentFile()));
      connect(child, SIGNAL(boxChanged()), this, SLOT(updateCommandActions()));
      connect(child, SIGNAL(modifiedChanged()), this, SLOT(updateTabTitle()));
      connect(child, SIGNAL(modifiedChanged()), this, SLOT(updateSaveAction()));
    } else {
      child->close();
    }
  }
}