Logo Search packages:      
Sourcecode: ultracopier version File versions  Download package

Main_window::Main_window (  )

For create the copy or moving window It link action, create menu, connect signal and slot. Initialise the widget and the default settings.

Todo:

start, stop, pause the copy

copy error management

See also:
~Main_window()

Definition at line 24 of file Mwindow.cpp.

References abstractLayerGetSpeed(), abstractLayerUpdateSpeedType(), actionaddFile, actionaddFolder, actionPause, actionQuit, actionRestore, addDirDropFrame, addEntryToDirList(), addFile(), addFolder(), AddFolderDetectAreSame(), AddingFolderThread, addToList(), aErrorHasOccurred, autoIncrementId, cancel_copy_window(), CatchAction(), changePriority(), changeShowStatusBar(), CopyThread, copyThreadError(), fileTot, getOldProgression, ListingIsFinish(), MainDestination, MainSource, MaxSpeedValueInt, menu, movingMode, numberOfFilePutAtTheEnd, PauseButton(), pixmapBottom, pixmapTop, Playlist_management_del(), Playlist_management_putSelectedFileDown(), Playlist_management_putSelectedFileOnBottom(), Playlist_management_putSelectedFileOnTop(), Playlist_management_putSelectedFileUp(), resizeMore(), RestoreTheWindow(), searchShortcut, searchShortcut2, copyThread::setBlockSize(), setDefaultOptions(), copyThread::setKeepDate(), copyThread::setPreallocateFileSize(), setPreallocateFileSize(), copyThread::setRightCopy(), shouldBeClosed, showingDrop, sizeCur, sizeTot, SkipButton(), sysTrayIcon, systrayMenu, TimerForCopySpeedUpdate, TimerForCopyUpdate, TimerForSearch, TimerForTimeRemainingUpdate, updateBlockSize(), updatePlayPauseSkipButton(), UpdateStyle(), and updateTheCopyStat().

{
      DEBUGCONSOLE(90,"Main_window::Main_window","start");
      
      //setup the interface
      setupUi(this);
      this->setWindowFlags(((this->windowFlags()|Qt::WindowMinMaxButtonsHint)&(0xffffffff^Qt::WindowContextHelpButtonHint)));
      setAcceptDrops(true);
      tabWidget->setCurrentIndex(0);
      CopyList->setColumnWidth(1,60);
      treeWidgetListError->setColumnWidth(1,60);
      tabWidget->hide();
      progressBar_file->hide();
      current_file->hide();
      skipButton->hide();
      currentSpeed->hide();
      progressBar_all->setTextVisible(false);
      this->setMaximumHeight(50);
      this->adjustSize();
      closeTheSearchBox();
      TimerForSearch    = new QTimer(this);
      TimerForSearch->setInterval(500);
      TimerForSearch->setSingleShot(true);
      searchShortcut    = new QShortcut(QKeySequence("Ctrl+F"),this);
      searchShortcut2 = new QShortcut(QKeySequence("F3"),this);

      qRegisterMetaType<QDir>("QDir");
      qRegisterMetaType<QFileInfo>("QFileInfo");
      
      //connect the button for do the action
      connect(moreButton,           SIGNAL(toggled(bool)),              this, SLOT(resizeMore(bool)));
      connect(del,                  SIGNAL(clicked(bool)),              this, SLOT(Playlist_management_del()));
      connect(pauseButton,          SIGNAL(clicked(bool)),              this, SLOT(PauseButton()));
      connect(cancelButton,         SIGNAL(clicked(bool)),              this, SLOT(cancel_copy_window()));
      connect(skipButton,           SIGNAL(clicked()),                  this, SLOT(SkipButton()));
      connect(SetDefaultOptions,    SIGNAL(clicked()),                  this, SLOT(setDefaultOptions()));
      
      connect(putOnTop,       SIGNAL(clicked()),                  this, SLOT(Playlist_management_putSelectedFileOnTop()));
      connect(pushUp,               SIGNAL(clicked()),                  this, SLOT(Playlist_management_putSelectedFileUp()));
      connect(pushDown,       SIGNAL(clicked()),                  this, SLOT(Playlist_management_putSelectedFileDown()));
      connect(putOnBottom,          SIGNAL(clicked()),                  this, SLOT(Playlist_management_putSelectedFileOnBottom()));
      
      //connect for speed
      connect(limitSpeed,           SIGNAL(valueChanged(int)),          this, SLOT(abstractLayerGetSpeed()));
      connect(checkBox_limitSpeed,  SIGNAL(stateChanged(int)),          this, SLOT(abstractLayerGetSpeed()));
      connect(SliderSpeed,          SIGNAL(valueChanged(int)),          this, SLOT(abstractLayerGetSpeed()));
      connect(spinBoxBlock,         SIGNAL(valueChanged(int)),          this, SLOT(updateBlockSize(int)));
      connect(comboBox_TypeSpeedMax,      SIGNAL(currentIndexChanged(int)),   this, SLOT(abstractLayerUpdateSpeedType()));
      
      //connect other
      connect(comboBox_Priority,    SIGNAL(currentIndexChanged(int)),   this, SLOT(changePriority()));
      connect(TimerForSearch,       SIGNAL(timeout()),                  this, SLOT(hilightTheSearch()));
      connect(searchShortcut,       SIGNAL(activated()),                this, SLOT(searchBoxShortcut()));
      connect(searchShortcut2,      SIGNAL(activated()),                this, SLOT(on_pushButtonSearchNext_clicked()));
      connect(pushButtonCloseSearch,      SIGNAL(clicked()),                  this, SLOT(closeTheSearchBox()));
      
      actionaddFile = new QAction(tr("Open f&ile(s)"), this);
      connect(actionaddFile,        SIGNAL(triggered()),                this, SLOT(addFile()));
      actionaddFolder = new QAction(tr("Open f&older"), this);
      connect(actionaddFolder,      SIGNAL(triggered()),                this, SLOT(addFolder()));
      
      menu = new QMenu("menu", this);
      menu->addAction(actionaddFile);
      menu->addAction(actionaddFolder);
      add->setPopupMode(QToolButton::InstantPopup);
      add->setMenu(menu);
      
      AddingFolderThread = new AddFolderThread(this);
      connect(AddingFolderThread,   SIGNAL(putToDirList(QDir)),         this, SLOT(addEntryToDirList(QDir)));
      connect(AddingFolderThread,   SIGNAL(addToCopyList(QFileInfo,QFileInfo)), this,     SLOT(addToList(QFileInfo,QFileInfo)));
      connect(AddingFolderThread,   SIGNAL(FolderSourceAndDestAreSame(QString)), this,    SLOT(AddFolderDetectAreSame(QString)));
      connect(AddingFolderThread,   SIGNAL(started()),                  this, SLOT(updateProgressBarAllMode()));
      connect(AddingFolderThread,   SIGNAL(finished()),                 this, SLOT(ListingIsFinish()));
      connect(AddingFolderThread,   SIGNAL(finished()),                 this, SLOT(updateProgressBarAllMode()));
      connect(AddingFolderThread,   SIGNAL(ErrorInListing(QString,QString)),this,   SLOT(ErrorInListing(QString,QString)));
      
      //setup the copy thread
      CopyThread = new copyThread(this);
      connect(AddingFolderThread, SIGNAL(putToDirDestinationEmptyList(QDir)), CopyThread, SLOT(addEntryToEmptyDestinationDirList(QDir)));
      //error management here
      connect(CopyThread,           SIGNAL(errorOnFile(int,QString,QString,quint64)), this, SLOT(copyThreadError(int,QString,QString,quint64)));
      connect(CopyThread,           SIGNAL(fileIsSame(QString)),        this, SLOT(copyThreadFileIsSame(QString)));
      connect(CopyThread,           SIGNAL(fileIsExists(QString,QString)),    this, SLOT(copyThreadFileIsExists(QString,QString)));
      connect(CopyThread,           SIGNAL(started()),                  this, SLOT(updateTheCopyStat()));
      connect(CopyThread,           SIGNAL(started()),                  this, SLOT(updatePlayPauseSkipButton()));
      connect(CopyThread,           SIGNAL(started()),                  this, SLOT(updateProgressBarAllMode()));
      connect(CopyThread,           SIGNAL(finished()),                 this, SLOT(updateTheCopyStat()));
      connect(CopyThread,           SIGNAL(finished()),                 this, SLOT(updatePlayPauseSkipButton()));
      connect(CopyThread,           SIGNAL(finished()),                 this, SLOT(updateProgressBarAllMode()));
      connect(CopyThread,           SIGNAL(finished()),                 this, SLOT(copyThreadIsFinish()));
      connect(CopyThread,           SIGNAL(allThreadIsFinishNow()),           this, SLOT(copyThreadOrWriteThread()));
      connect(CopyThread,           SIGNAL(isInPauseOrNot()),           this, SLOT(updatePlayPauseSkipButton()));

      connect(checkBoxRightCopy,    SIGNAL(stateChanged(int)),          CopyThread, SLOT(setRightCopy(int)));
      connect(checkBoxPreallocate,  SIGNAL(stateChanged(int)),          this,       SLOT(setPreallocateFileSize(int)));
      connect(checkBoxKeepDate,     SIGNAL(stateChanged(int)),          CopyThread, SLOT(setKeepDate(int)));
      connect(checkWriteThread,     SIGNAL(stateChanged(int)),          CopyThread, SLOT(setThreadWrite(int)));
      connect(spinBoxBlock,         SIGNAL(valueChanged(int)),          CopyThread, SLOT(setBlockSize()));
      connect(comboBox_statusBar,   SIGNAL(currentIndexChanged(int)),   this,       SLOT(changeShowStatusBar()));
      
      TimerForCopyUpdate = new QTimer();
      TimerForCopyUpdate->setInterval(UPDATEINTERVAL);
      connect(TimerForCopyUpdate,   SIGNAL(timeout()), this, SLOT(updateTheCopyStat()));

      TimerForCopySpeedUpdate = new QTimer();
      TimerForCopySpeedUpdate->setInterval(UPDATEINTERVAL);
      connect(TimerForCopySpeedUpdate,SIGNAL(timeout()), this, SLOT(updateTheCopySpeed()));

      TimerForTimeRemainingUpdate = new QTimer();
      TimerForTimeRemainingUpdate->setInterval(1000);
      connect(CopyThread,           SIGNAL(started()),      TimerForTimeRemainingUpdate,  SLOT(start()));
      connect(CopyThread,           SIGNAL(finished()),     TimerForTimeRemainingUpdate,  SLOT(stop()));
      connect(CopyThread,           SIGNAL(finished()),     this,                   SLOT(updateTheTimeRemaining()));
      connect(TimerForTimeRemainingUpdate, SIGNAL(timeout()), this,                       SLOT(updateTheTimeRemaining()));

      //systray progression icon
      sysTrayIcon = new QSystemTrayIcon(this);
      
      //initialise the variable
      sizeTot                 = 0;
      sizeCur                 = 0;
      fileTot                 = 0;
      MaxSpeedValueInt  = 0;
      aErrorHasOccurred = false;
      movingMode        = false;
      autoIncrementId         = 1;
      MainDestination         = "";
      MainSource        = "";
      shouldBeClosed          = false;
      numberOfFilePutAtTheEnd = 0;

      //start time
      showingDrop.start();
      addDirDropFrame.start();

      //Set range
      progressBar_file->setRange(0,32767);
      progressBar_all->setRange(0,32767);

      //load the default options
      setDefaultOptions();
      
      //After load options set if the right should be copied
      CopyThread->setPreallocateFileSize(checkBoxPreallocate->isChecked());
      CopyThread->setRightCopy(checkBoxRightCopy->isChecked());
      CopyThread->setKeepDate(checkBoxKeepDate->isChecked());
      CopyThread->setBlockSize(spinBoxBlock->value());
      CopyThread->setThreadWrite(checkWriteThread->isChecked());

      //loading the image
      #ifdef Q_OS_WIN32
      pixmapTop         = new QPixmap(loadImagePixmap("systray/top.png"));
      pixmapBottom            = new QPixmap(loadImagePixmap("systray/bottom.png"));
      #else
      pixmapTop         = new QPixmap(loadImagePixmap("systray/top_X11.png"));
      pixmapBottom            = new QPixmap(loadImagePixmap("systray/bottom_X11.png"));
      #endif

      connect(sysTrayIcon,          SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(CatchAction(QSystemTrayIcon::ActivationReason)));
      connect(sysTrayIcon,          SIGNAL(messageClicked()), this, SLOT(RestoreTheWindow()));
      
      //initialise the menu
      actionPause = new QAction(tr("Pause"), this);
      actionPause->setEnabled(false);
      connect(actionPause,          SIGNAL(triggered()), this, SLOT(PauseButton()));
      actionRestore = new QAction(tr("Restore"), this);
      connect(actionRestore,        SIGNAL(triggered()), this, SLOT(RestoreTheWindow()));
      actionQuit = new QAction(tr("Quit"), this);
      connect(actionQuit,           SIGNAL(triggered()), this, SLOT(cancel_copy_window()));
      
      systrayMenu = new QMenu("menu", this);
      systrayMenu->addAction(actionaddFile);
      systrayMenu->addAction(actionaddFolder);
      systrayMenu->addAction(actionPause);
      systrayMenu->addAction(actionRestore);
      systrayMenu->addAction(actionQuit);
      sysTrayIcon->setContextMenu(systrayMenu);
      
      getOldProgression=-1;

      #if (DEBUG_ULTRACOPIER>0)
      connect(&DebugTrackThread,    SIGNAL(timeout()), this, SLOT(DebugCheckThread()));
      DebugTrackThread.setInterval(1000);
      hboxLayoutDebug = new QHBoxLayout();
      Debug_label_copyThread = new QLabel(this);
      Debug_label_copyThread->setText("Init...");
      Debug_label_copyThread->hide();
      Debug_label_writeThread = new QLabel(this);
      Debug_label_writeThread->setText("Init...");
      Debug_label_writeThread->hide();
      Debug_label_waitThread = new QLabel(this);
      Debug_label_waitThread->setText("Init...");
      Debug_label_waitThread->hide();
      Debug_label_waitThread->setStyleSheet("background-color: rgb(255, 255, 0);");
      hboxLayoutDebug->addWidget(Debug_label_copyThread);
      hboxLayoutDebug->addWidget(Debug_label_writeThread);
      hboxLayoutDebug->addWidget(Debug_label_waitThread);
      vboxLayout->addLayout(hboxLayoutDebug);
      #endif

      #ifdef Q_OS_WIN32
      SpecWindowsCurWindow=GetActiveWindow();
      #endif

      DEBUGCONSOLE(30,"Main_window::Main_window","stop");   
      //update the style
      this->UpdateStyle();
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index