MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags flags ) : QMainWindow( parent, flags ), ui(new Ui::MainWindow) { qDebug( "Home Path : %s" ,QDir::homePath().toLatin1().constData()); qDebug( "Current Path : %s" ,QDir::currentPath ().toLatin1().constData()); ui->setupUi(this); this->setAttribute( Qt::WA_DeleteOnClose ); //hide by default setWindowTitle(QString(PACKAGE) + " " + QString(VERSION)); // loads the settings loadSettings(); // connecting the Go server tab buttons and signals // connecting the new game button connect( ui->actionOpen, SIGNAL(triggered()), SLOT(slot_fileOpen()) ); connect(ui->actionNew,SIGNAL(triggered()),SLOT(slot_fileNew())); connect(ui->cancelButtonPrefs,SIGNAL(pressed()),SLOT(slot_cancelPressed())); connect(ui->cancelButtonServer,SIGNAL(pressed()),SLOT(slot_cancelPressed())); connect(ui->stackedWidget, SIGNAL(currentChanged ( int )), SLOT(slot_currentChanged(int ))); //coneects the preference buttons connect( ui->gobanPathButton, SIGNAL( clicked() ), this, SLOT( slot_getGobanPath() ) ); connect( ui->tablePathButton, SIGNAL( clicked() ), this, SLOT( slot_getTablePath() ) ); connect(ui->comboBox_language, SIGNAL(currentIndexChanged ( int )), SLOT(slot_languageChanged(int ))); //sound connectSound = new Sound("static.wav"); logindialog = new LoginDialog(this); connect( ui->actionConnect, SIGNAL(triggered()), SLOT(openConnectDialog()) ); engineTableModel = new EngineTableModel(this); ui->engineTableView->setModel(engineTableModel); ui->engineTableView->setColumnWidth ( EngineTableModel::ENGINE_DEFAULT, 60 ); ui->engineTableView->setColumnWidth ( EngineTableModel::ENGINE_PATH, 300 ); connect(ui->engineAddButton, &QPushButton::pressed, this, &MainWindow::addEngine); connect(ui->engineRemoveButton, &QPushButton::pressed, this, &MainWindow::removeEngine); }
void ZGui::CreateWindow ( QWidget * ) { ///Set title window setMainWidgetTitle ( "zTextEdit" ); ///load lenguage ProgDir = getProgramDir(); lng->ProgDir = ProgDir; lng->autoLoadLng(); ///Load settings ZConfig cfg(ProgDir+"/zTextEdit.cfg"); cfg_fontSize = cfg.readNumEntry(QString("GUI"), QString("FontSize"), 15); cfg_underline = cfg.readBoolEntry(QString("GUI"), QString("Underline"), true); cfg_autoOpen = cfg.readBoolEntry(QString("GUI"), QString("AutoOpen"), false); cfg_menuCopy = cfg.readBoolEntry(QString("GUI"), QString("MenuCopyOnDial"), false); #ifdef MDI curDlg=0; countDlg=1; #endif if (cfg_autoOpen) { sFileName = cfg.readEntry(QString("LastFile"), QString("FileName"), ""); sFilePath = cfg.readEntry(QString("LastFile"), QString("FilePath"), ""); } cfg_chineseCodeDetect = cfg.readBoolEntry(QString("Enginea"), QString("ChineseCodeDetect"), false); #ifdef SELECT_CUR_LINE cfg_selCurLine = cfg.readBoolEntry(QString("GUI"), QString("SelCurLine"), false); #endif /* #if !( defined(EZX_ZN5) || defined(EZX_U9) || defined(EZX_Z6W) ) cfg_infoBar = cfg.readBoolEntry(QString("GUI"), QString("InfoBar"), false); //Create info bar if ( cfg_infoBar ) { ZAppInfoArea *pAIA = new ZAppInfoArea(this); #if defined(EZX_Z6) || defined(EZX_V8) pAIA->setActArea( ZAppInfoArea::no_progress_meter ); #else pAIA->setActArea( ZAppInfoArea::NO_PROGRESS_METER ); #endif pAIA->setInputArea(); setAppInfoArea( pAIA ); } #endif */ ///Create main widget on window #ifndef MDI edit = new ZMultiLineEdit( this, false, 1, "ZMultiLineEdit" ); CHECK_PTR(edit); setSettingToEdit(edit); setContentWidget(edit); edit->setGeometry( ZGlobal::getContentR( false ) ); #else wStack = new QWidgetStack(this); curDlg=0; zmeEditList[curDlg] = new ZMultiLineEdit( this, false, 1, "ZMultiLineEdit" ); dlgCapList[curDlg] = "New"; CHECK_PTR(zmeEditList[curDlg]); setSettingToEdit(zmeEditList[curDlg]); wStack->addWidget(zmeEditList[curDlg], curDlg); setContentWidget(wStack); wStack->raiseWidget(curDlg); #endif textCode=0; ///Create SoftKey and Menu ZSoftKey *softKey = new ZSoftKey ( NULL , this , this ); QPixmap* pm = new QPixmap(); QRect rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); MainMenu = new ZOptionsMenu ( rect, softKey, NULL, 0 ); MainMenu->setItemSpacing(10); ///File Menu FileMenu = new ZOptionsMenu ( rect, softKey, NULL, 0 ); FileMenu->setItemSpacing(10); pm->load(ProgDir+ "/img/new.png"); FileMenu->insertItem ( MENU_FIX+lng->getString("NEW"), NULL, pm, true, 0, 0 ); pm->load(ProgDir+ "/img/open.png"); FileMenu->insertItem ( MENU_FIX+lng->getString("OPEN"), NULL, pm, true, 1, 1 ); pm->load(ProgDir+ "/img/save.png"); FileMenu->insertItem ( MENU_FIX+lng->getString("SAVE"), NULL, pm, true, 2, 2 ); pm->load(ProgDir+ "/img/fake.png"); FileMenu->insertItem ( MENU_FIX+lng->getString("SAVEAS"), NULL, pm, true, 3, 3 ); FileMenu->connectItem ( 0, this, SLOT ( slot_fileNew() ) ); FileMenu->connectItem ( 1, this, SLOT ( slot_fileOpen() ) ); FileMenu->connectItem ( 2, this, SLOT ( slot_fileSave() ) ); FileMenu->connectItem ( 3, this, SLOT ( slot_fileSaveAs() ) ); pm->load(ProgDir+ "/img/new.png"); MainMenu->insertItem ( MENU_FIX+lng->getString("FILE"), FileMenu, pm , true , 1, 1 ); ///Edit Menu EditMenu = new ZOptionsMenu ( rect, softKey, NULL, 0 ); EditMenu->setItemSpacing(10); pm->load(ProgDir+ "/img/copy.png"); EditMenu->insertItem ( MENU_FIX+lng->getString("COPY"), NULL, pm, true, 0, 0); pm->load(ProgDir+ "/img/cut.png"); EditMenu->insertItem ( MENU_FIX+lng->getString("CUT"), NULL, pm, true, 1, 1); pm->load(ProgDir+ "/img/paste.png"); EditMenu->insertItem ( MENU_FIX+lng->getString("PASTE"), NULL, pm, true, 2, 2); pm->load(ProgDir+ "/img/select_all.png"); EditMenu->insertItem ( MENU_FIX+lng->getString("SELECT_ALL"), NULL, pm, true, 3, 3); pm->load(ProgDir+ "/img/fake.png"); EditMenu->insertItem ( MENU_FIX+lng->getString("SELECT_BLOCK"), NULL, pm, true, 4, 4); EditMenu->connectItem ( 0, this, SLOT ( slot_editCopy() ) ); EditMenu->connectItem ( 1, this, SLOT ( slot_editCut() ) ); EditMenu->connectItem ( 2, this, SLOT ( slot_editPaste() ) ); EditMenu->connectItem ( 3, this, SLOT ( slot_editSelAll() ) ); EditMenu->connectItem ( 4, this, SLOT ( slot_editSelectBlock() ) ); pm->load(ProgDir+ "/img/edit.png"); MainMenu->insertItem ( MENU_FIX+lng->getString("EDIT"), EditMenu, pm , true , 2, 2 ); CodeMenu = new ZOptionsMenu ( rect, softKey, NULL, 0 ); CodeMenu->setItemSpacing(10); #if !(defined(EZX_Z6) || defined(EZX_V8)) CodeMenu->insertItem ( "UTF-8", NULL, NULL, true, 0, 0, false, true, true ); CodeMenu->insertItem ( "Win1251", NULL, NULL, true, 1, 1, false, true ); CodeMenu->insertItem ( "KOI8-R", NULL, NULL, true, 2, 2, false, true ); CodeMenu->insertItem ( "ISO8859-1", NULL, NULL, true, 3, 3, false, true ); CodeMenu->insertItem ( "ISO8859-2", NULL, NULL, true, 4, 4, false, true ); CodeMenu->insertItem ( "ISO8859-5", NULL, NULL, true, 5, 5, false, true ); CodeMenu->insertItem ( "KOI8-U", NULL, NULL, true, 6, 6, false, true ); CodeMenu->insertItem ( "Big5", NULL, NULL, true, 7, 7, false, true ); CodeMenu->insertItem ( "GBK", NULL, NULL, true, 8, 8, false, true ); #else CodeMenu->insertItem ( "UTF-8", NULL, NULL, NULL, true, true, true, 0, 0 ); CodeMenu->insertItem ( "Win1251", NULL, NULL, NULL, true, true, false, 1, 1 ); CodeMenu->insertItem ( "KOI8-R", NULL, NULL, NULL, true, true, false, 2, 2 ); CodeMenu->insertItem ( "ISO8859-1", NULL, NULL, NULL, true, true, false, 3, 3 ); CodeMenu->insertItem ( "ISO8859-2", NULL, NULL, NULL, true, true, false, 4, 4 ); CodeMenu->insertItem ( "ISO8859-5", NULL, NULL, NULL, true, true, false, 5, 5 ); CodeMenu->insertItem ( "KOI8-U", NULL, NULL, NULL, true, true, false, 6, 6 ); CodeMenu->insertItem ( "Big5", NULL, NULL, NULL, true, true, false, 7, 7 ); CodeMenu->insertItem ( "GBK", NULL, NULL, NULL, true, true, false, 8, 8 ); #endif #define CODEC_COUNT 9 connect( CodeMenu, SIGNAL( activated( int ) ), this, SLOT( slot_codecChenged( int ) ) ); pm->load(ProgDir+ "/img/fake.png"); MainMenu->insertItem ( MENU_FIX+lng->getString("CODE"), CodeMenu, pm, true , 3, 3 ); #ifdef MDI DlgMenu = new ZOptionsMenu ( rect, softKey, NULL, 0 ); DlgMenu->setItemSpacing(10); connect( DlgMenu, SIGNAL( activated( int ) ), this, SLOT( slot_dlgChenged( int ) ) ); pm->load(ProgDir+ "/img/document.png"); MainMenu->insertItem ( MENU_FIX+lng->getString("DLG"), DlgMenu, pm, true , 3, 3 ); buildDlgMenu(); #endif pm->load(ProgDir+ "/img/find.png"); MainMenu->insertItem ( MENU_FIX+lng->getString("SEARCH"), NULL, pm, true, 4, 4 ); pm->load(ProgDir+ "/img/options.png"); MainMenu->insertItem ( MENU_FIX+lng->getString("OPTION"), NULL, pm, true, 5, 5 ); pm->load(ProgDir+ "/img/about.png"); MainMenu->insertItem ( MENU_FIX+lng->getString("ABOUT"), NULL, pm, true, 6, 6 ); pm->load(ProgDir+ "/img/exit.png"); MainMenu->insertItem ( MENU_FIX+lng->getString("EXIT"), NULL, pm, true, 7, 7 ); MainMenu->connectItem ( 4, this, SLOT ( slot_fileFind() ) ); MainMenu->connectItem ( 5, this, SLOT ( slot_settings() ) ); MainMenu->connectItem ( 6, this, SLOT ( slot_about() ) ); MainMenu->connectItem ( 7, this, SLOT ( slot_exit() ) ); softKey->setTextForOptMenuHide(lng->getString("FILE")); softKey->setText ( ZSoftKey::LEFT, lng->getString("FILE"), ( ZSoftKey::TEXT_PRIORITY ) 0 ); softKey->setText ( ZSoftKey::RIGHT, lng->getString("EXIT"), ( ZSoftKey::TEXT_PRIORITY ) 0 ); softKey->setOptMenu ( ZSoftKey::LEFT, MainMenu ); softKey->setClickedSlot ( ZSoftKey::RIGHT, this, SLOT ( slot_exit() ) ); #if defined(EZX_ZN5) || defined(EZX_U9) || defined(EZX_Z6W) edit->setFixedHeight( SCREEN_HEIGHT - headerSize().height() - softKey->height()); #endif setSoftKey ( softKey ); ///Connect std signal #ifndef EZX_VE66 connect( qApp, SIGNAL(signalRaise()), this, SLOT(slot_Raise()) ); connect( qApp, SIGNAL(askReturnToIdle(int)), this, SLOT(slot_ReturnToIdle(int)) ); #endif ///init peremen textCode = 0; pos = NULL; isMarck = false; ///load file if need if ( !cfg_autoOpen ) sFileName = ""; QFile file; if ( qApp->argc() > 1 ) { sFileName = ""; if ( file.exists(QString::fromUtf8(qApp->argv()[1])) ) sFileName = QString::fromUtf8(qApp->argv()[1]); else if ( qApp->argc() > 2 ) if ( file.exists(QString::fromUtf8(qApp->argv()[2])) ) sFileName = QString::fromUtf8(qApp->argv()[2]); sFilePath = getFilePath(sFileName); sFileName = getFileName(sFileName); } if ( sFileName.isEmpty() || sFilePath.isEmpty() ) slot_fileNew(); else load(sFilePath+sFileName); }