Esempio n. 1
0
//--------------------------------------------------------------------------
MainWindow::MainWindow() :
    settings(new Settings(this)),
    scanner(new Scanner(this)),
    engine(new SearchEngine(this)),
    mainMenu(new MainMenu(this)),
    status(new StatusBar(this)),
    stack(new QStackedWidget(this)),
    settingsDialog(new SettingsDialog(this))
{
    // Set up window widgets
    setWindowTitle(tr("Vaultaire"));
    setWindowIcon(QIcon(":/vaultaire.svg"));
    setMenuBar(mainMenu);
    setStatusBar(status);
    setCentralWidget(stack);

    // Connect signals to show scanning in-progress in status bar
    connect(scanner, SIGNAL(started()),
            status, SLOT(startBusyIndicator()));
    connect(scanner, SIGNAL(started()),
            this, SLOT(showScanningMessage()));
    connect(scanner, SIGNAL(finished(Scanner::ScanResult)),
            status, SLOT(stopBusyIndicator()));
    connect(scanner, SIGNAL(finished(Scanner::ScanResult)),
            status, SLOT(clearMessage()));

    // Connect signals to show search in-progress in status bar
    connect(engine, SIGNAL(started()),
            status, SLOT(startBusyIndicator()));
    connect(engine, SIGNAL(finished(QStringList)),
            status, SLOT(stopBusyIndicator()));

    // Create application widgets
    scanView = new ScanView(scanner, this);
    browser = new LibraryBrowser(this);
    search = new SearchView(engine, this);
    stack->addWidget(scanView);
    stack->addWidget(browser);
    stack->addWidget(search);

    // Connect menu signals
    connect(mainMenu, SIGNAL(scanNewFile()), this, SLOT(showScanForm()));
    connect(mainMenu, SIGNAL(browseFiles()), this, SLOT(showFileBrowser()));
    connect(mainMenu, SIGNAL(findFile()), this, SLOT(showSearchForm()));
    connect(mainMenu, SIGNAL(showAboutInfo()), this, SLOT(about()));
    connect(mainMenu, SIGNAL(quit()), this, SLOT(close()));
    connect(mainMenu, SIGNAL(editSettings()), settingsDialog, SLOT(show()));

    readSettings();
}
void MainWindow::initiateWindowWidgets() {
	okButton->setEnabledPixmap(QPixmap("images/button/ok.png"));
	okButton->setDisabledPixmap(QPixmap("images/button/ok-disabled.png"));
	connect(okButton, SIGNAL(clicked()), this, SLOT(okClicked()));

	cancelButton->setEnabledPixmap(QPixmap("images/button/cancel.png"));
	cancelButton->setDisabledPixmap(
			QPixmap("images/button/cancel-disabled.png"));
	connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelClicked()));

	abandonButton->setEnabledPixmap(QPixmap("images/button/discard.png"));
	abandonButton->setDisabledPixmap(
			QPixmap("images/button/discard-disabled.png"));
	connect(abandonButton, SIGNAL(clicked()), this, SLOT(abandonClicked()));

	quitButton->setEnabledPixmap(QPixmap("images/button/close.png"));
	quitButton->setDisabledPixmap(QPixmap("images/button/close.png"));
	quitButton->setPressedPixmap(QPixmap("images/button/close-pressed.png"));
	connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));

	aboutButton->setEnabledPixmap(QPixmap("images/button/enabled-big.png"));
	aboutButton->setDisabledPixmap(QPixmap("images/button/disabled-big.png"));
	aboutButton->setPressedPixmap(QPixmap("images/button/pressed-big.png"));

	bigPauseButton->setEnabledPixmap(
			QPixmap("images/button/enabled-large.png"));
	bigPauseButton->setDisabledPixmap(
			QPixmap("images/button/disabled-large.png"));
	bigPauseButton->setPressedPixmap(
			QPixmap("images/button/pressed-large.png"));
	connect(bigPauseButton, SIGNAL(clicked()), pauseButton, SLOT(click()));

	helpButton->setEnabledPixmap(QPixmap("images/button/enabled-large.png"));
	helpButton->setDisabledPixmap(QPixmap("images/button/disabled-large.png"));
	helpButton->setPressedPixmap(QPixmap("images/button/pressed-large.png"));

	tipBox = new MessageBox(this);
	tipBox->hide();
	pauseBox = new MessageBox(this);
	pauseBox->hide();
	cardContainer = new CardContainer(this);
	cardContainer->hide();
	wujiangChooseBox = new WujiangChooseBox(this);
	wujiangChooseBox->hide();
	guanxingBox = new GuanxingBox(this);
	guanxingBox->hide();

	zhuangbeiLabel = new ZhuangbeiLabel(this);
	zhuangbeiLabel->hide();

	aboutFrame = new AboutFrame(this);
	aboutFrame->hide();
	connect(aboutButton, SIGNAL(clicked()), aboutFrame, SLOT(showAboutInfo()));

	helpBox = new HelpBox(this);
	helpBox->hide();
	connect(helpButton, SIGNAL(clicked()), helpBox, SLOT(displayHelp()));

	wugufengdengBox = new WugufengdengBox(this);
	wugufengdengBox->hide();

	fanjianBox = new FanjianBox(this);
	fanjianBox->hide();

	cardViewer = new CardViewer(this);
	cardViewer->hide();

	gameOverBox = new GameOverBox(this);
	gameOverBox->hide();

	cardDeckLabel->hide();

	blockingFrameMovingAnimation = new QPropertyAnimation(this);
	blockingFrameMovingAnimation->setPropertyName("pos");
	blockingFrameMovingAnimation->setDuration(
			GUIStaticData::blockingFrameMovingDuration);

	debugCheckBox->hide();
	debugTabWidget->hide();
	testWidget->hide();
	connect(pauseButton, SIGNAL(clicked()), this, SLOT(pauseClicked()));

	checkButtons();
}
Esempio n. 3
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
    QApplication::setApplicationVersion(VER);

    // Setup UI
    ui->setupUi(this);

    // Configure settings
    readWindowSettings();

    // Setup session
    session = new Session(this);
    session->readFromSettings();
    connect(session, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int)));
    connect(session, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(rowsInserted(QModelIndex, int, int)));
    connect(session, SIGNAL(messageReceived(Server*,Channel*,QString,QStringList,Channel::MessageType)), this, SLOT(handleMessage(Server*,Channel*,QString,QStringList,Channel::MessageType)));
    connect(session, SIGNAL(serverDisconnected(Server*)), this, SLOT(showDisconnectedMessage(Server*)));

    // Setup tree view
    connect(ui->treeView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(treeItemClicked(const QModelIndex&)));
    ui->treeView->setModel(session);
    ui->treeView->setFocusPolicy(Qt::NoFocus);
    ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(ui->treeView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(generateContextMenu(const QPoint &)));

    // Setup sending text
    connect(ui->sendText, SIGNAL(returnPressed()), this, SLOT(sendMessage()));
    connect(ui->sendText, SIGNAL(channelCycle(bool)), this, SLOT(cycleChannel(bool)));
    ui->sendText->setFocus();

    // Setup user list
    ui->userList->setFocusPolicy(Qt::NoFocus);

    // Setup the main text area
    document = new QTextDocument(ui->mainText);
    document->setDefaultStyleSheet(this->readFile(this->mainCssFileName));
    ui->mainText->setDocument(document);
    connect(ui->mainText, SIGNAL(anchorClicked(QUrl)), this, SLOT(anchorClicked(QUrl)));

    // Set focus on first server
    QModelIndex modelIndex = session->index(0, 0);
    this->selectItem(modelIndex);

    // Setup command parser
    commandParser = new CommandParser(this);

    // Setup network manager
    networkAccessManager = new QNetworkAccessManager(this);
    connect(networkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(imageDownloaded(QNetworkReply*)));
    updateCheckerNetworkAccessManager = new QNetworkAccessManager(this);
    connect(updateCheckerNetworkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(versionFileDownloaded(QNetworkReply*)));

    // Setup web view for checking oembed
    webView = new QWebView(this);
    QWebSettings::globalSettings()->setAttribute(QWebSettings::AutoLoadImages, false);
    QWebSettings::globalSettings()->setAttribute(QWebSettings::JavascriptEnabled, false);
    webView->hide();
    connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(webLoadFinished(bool)));

    // Let's get some styles up in here
    QString controlStyles = "QListView, QTreeView, QLineEdit, QPlainTextEdit, QTextBrowser { background:#333;font-family:\"Lucida Console\",Monaco,monospace;font-size:11px;color:#fff; }";
    ui->userList->setStyleSheet(controlStyles);
    ui->treeView->setStyleSheet(controlStyles);
    ui->mainText->setStyleSheet(controlStyles);
    ui->sendText->setStyleSheet(controlStyles + "QLineEdit { padding:5px; }, QPlainTextEdit { padding:2px; }");
    ui->userList->setAttribute(Qt::WA_MacShowFocusRect, 0);
    ui->treeView->setAttribute(Qt::WA_MacShowFocusRect, 0);
    ui->sendText->setAttribute(Qt::WA_MacShowFocusRect, 0);

    // Setup menu items
    connect(ui->actionPreferences, SIGNAL(triggered()), this, SLOT(openPreferences()));
    connect(ui->actionNewServer, SIGNAL(triggered()), this, SLOT(newServerWindow()));
    connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(showAboutInfo()));

    //Check For Updates
    checkForUpdates();
}