code format
This commit is contained in:
@@ -1,27 +1,29 @@
|
||||
#include "edockwidget.h"
|
||||
#include "cdpultwindow.h"
|
||||
|
||||
#include "cdutils_core.h"
|
||||
#include "cdutils_k.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "cdutils_m.h"
|
||||
#include "qcd_core.h"
|
||||
#include "qcd_view.h"
|
||||
#include "qcd_model.h"
|
||||
#include "qcd_modedialog.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "chunkstream.h"
|
||||
#include "qvariantedit.h"
|
||||
#include "edockwidget.h"
|
||||
#include "piqt.h"
|
||||
#include "piqt_highlighter.h"
|
||||
#include "qcd_core.h"
|
||||
#include "qcd_modedialog.h"
|
||||
#include "qcd_model.h"
|
||||
#include "qcd_view.h"
|
||||
#include "qcodeedit.h"
|
||||
#include "qvariantedit.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QScrollBar>
|
||||
#include <QImageReader>
|
||||
#include <QMessageBox>
|
||||
#include <QScrollBar>
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
|
||||
CDPultWindow::CDPultWindow(QWidget *parent) : EMainWindow(parent), Ui::CDPultWindow() {
|
||||
CDPultWindow::CDPultWindow(QWidget * parent): EMainWindow(parent), Ui::CDPultWindow() {
|
||||
setupUi(this);
|
||||
centralWidget()->hide();
|
||||
setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
|
||||
@@ -48,24 +50,22 @@ CDPultWindow::CDPultWindow(QWidget *parent) : EMainWindow(parent), Ui::CDPultWin
|
||||
session.addEntry(ribbon->tabWidget());
|
||||
session.load();
|
||||
reset();
|
||||
connect(widgetK, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString)));
|
||||
connect(widgetX, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString)));
|
||||
connect(widgetC, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString)));
|
||||
connect(widgetM, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString)));
|
||||
connect(widgetK, SIGNAL(addToLog(CDViewWidget::LogIcon, QString)), this, SLOT(addToLog(CDViewWidget::LogIcon, QString)));
|
||||
connect(widgetX, SIGNAL(addToLog(CDViewWidget::LogIcon, QString)), this, SLOT(addToLog(CDViewWidget::LogIcon, QString)));
|
||||
connect(widgetC, SIGNAL(addToLog(CDViewWidget::LogIcon, QString)), this, SLOT(addToLog(CDViewWidget::LogIcon, QString)));
|
||||
connect(widgetM, SIGNAL(addToLog(CDViewWidget::LogIcon, QString)), this, SLOT(addToLog(CDViewWidget::LogIcon, QString)));
|
||||
connect(widgetK->view, SIGNAL(changedGlobal()), widgetDirectK, SLOT(changedGlobal()));
|
||||
connect(widgetX->view, SIGNAL(changedGlobal()), widgetGraphics, SLOT(changedGlobal()));
|
||||
connect(widgetX->view, SIGNAL(receivedX()), widgetGraphics, SLOT(receivedX()));
|
||||
connect(widgetM->view, SIGNAL(messageReceived(QString,int,QString)), this, SLOT(messageReceived(QString,int,QString)));
|
||||
connect(widgetM->view, SIGNAL(messageReceived(QString, int, QString)), this, SLOT(messageReceived(QString, int, QString)));
|
||||
QCDCore::instance()->bindWidget(widgetK->view);
|
||||
QCDCore::instance()->setDirectKEnabled(true);
|
||||
X.start();
|
||||
if (windowState() == Qt::WindowMinimized)
|
||||
setWindowState(Qt::WindowNoState);
|
||||
if (windowState() == Qt::WindowMinimized) setWindowState(Qt::WindowNoState);
|
||||
}
|
||||
|
||||
|
||||
CDPultWindow::~CDPultWindow() {
|
||||
}
|
||||
CDPultWindow::~CDPultWindow() {}
|
||||
|
||||
|
||||
void CDPultWindow::loadFile(const QString & fp) {
|
||||
@@ -87,14 +87,13 @@ void CDPultWindow::apply(bool sessions) {
|
||||
if (sessions) {
|
||||
widgetGraphics->load(session_gr);
|
||||
widgetDirectK->load(session_dk);
|
||||
if (!session_mw.isEmpty())
|
||||
restoreState(session_mw);
|
||||
if (!session_mw.isEmpty()) restoreState(session_mw);
|
||||
X.lock();
|
||||
PIVector<PIDeque<int> > x_list = X.enabledList();
|
||||
PIVector<PIDeque<int>> x_list = X.enabledList();
|
||||
X.unlock();
|
||||
piForeachC (PIDeque<int> & p, x_list)
|
||||
piForeachC(PIDeque<int> & p, x_list)
|
||||
X.enable(X[p]);
|
||||
((CDItemModel*)widgetX->view->model())->updateModel();
|
||||
((CDItemModel *)widgetX->view->model())->updateModel();
|
||||
widgetX->view->expandAll();
|
||||
}
|
||||
dockCDKView->setVisible(checkHasK->isChecked());
|
||||
@@ -105,10 +104,9 @@ void CDPultWindow::apply(bool sessions) {
|
||||
}
|
||||
|
||||
|
||||
void CDPultWindow::closeEvent(QCloseEvent *e) {
|
||||
void CDPultWindow::closeEvent(QCloseEvent * e) {
|
||||
EMainWindow::closeEvent(e);
|
||||
if (!e->isAccepted())
|
||||
return;
|
||||
if (!e->isAccepted()) return;
|
||||
QApplication::closeAllWindows();
|
||||
session.save();
|
||||
session.setFile(QString());
|
||||
@@ -141,8 +139,7 @@ bool CDPultWindow::load(const QString & path) {
|
||||
checkHasM->setChecked(conf.getValue("has_m").toBool());
|
||||
checkDefaultConfig->setChecked(conf.getValue("default_config").toBool());
|
||||
codeConfig->setText(QByteArray2QString(conf.getValue("config").toByteArray()));
|
||||
if (codeConfig->text().isEmpty())
|
||||
codeConfig->setText(def_config);
|
||||
if (codeConfig->text().isEmpty()) codeConfig->setText(def_config);
|
||||
session_gr = conf.getValue("session_gr").toByteArray();
|
||||
session_dk = conf.getValue("session_dk").toByteArray();
|
||||
session_mw = conf.getValue("session_mw").toByteArray();
|
||||
@@ -180,8 +177,8 @@ bool CDPultWindow::save(const QString & path) {
|
||||
file_name = path;
|
||||
return true;
|
||||
|
||||
//widgetK->setFile(path);
|
||||
//widgetK->save();
|
||||
// widgetK->setFile(path);
|
||||
// widgetK->save();
|
||||
}
|
||||
|
||||
|
||||
@@ -201,7 +198,7 @@ QByteArray CDPultWindow::appIcon() const {
|
||||
QBuffer buff(&ret);
|
||||
buff.open(QIODevice::WriteOnly);
|
||||
icon.save(&buff, "png");
|
||||
//qDebug() << "s" << ret.size();
|
||||
// qDebug() << "s" << ret.size();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -212,16 +209,16 @@ void CDPultWindow::setAppIcon(QByteArray ba) {
|
||||
setWindowIcon(QIcon());
|
||||
return;
|
||||
}
|
||||
//qDebug() << "l" << ba.size();
|
||||
// qDebug() << "l" << ba.size();
|
||||
icon = QImage::fromData(ba);
|
||||
setWindowIcon(QIcon(QPixmap::fromImage(icon)));
|
||||
//qDebug() << QApplication::windowIcon().availableSizes();
|
||||
// qDebug() << QApplication::windowIcon().availableSizes();
|
||||
}
|
||||
|
||||
|
||||
void CDPultWindow::addToLog(CDViewWidget::LogIcon icon, const QString & msg) {
|
||||
QListWidgetItem * ni = new QListWidgetItem(log_icons[icon], "(" + QTime::currentTime().toString() + ") " + msg);
|
||||
bool s = listLog->verticalScrollBar()->value() == listLog->verticalScrollBar()->maximum();
|
||||
bool s = listLog->verticalScrollBar()->value() == listLog->verticalScrollBar()->maximum();
|
||||
listLog->addItem(ni);
|
||||
if (s) listLog->scrollToBottom();
|
||||
}
|
||||
@@ -231,8 +228,7 @@ void CDPultWindow::messageReceived(QString path, int type, QString msg) {
|
||||
MessageType mt = (MessageType)type;
|
||||
const CDType & t(M.root()[CDCore::stringToPath(Q2PIString(path))]);
|
||||
if (t.cd_type() != CDType::cdM) return;
|
||||
if (mt == MessageBox)
|
||||
QMessageBox::information(this, windowTitle(), QString("[%1]\n%2").arg(PI2QString(t.name()), msg));
|
||||
if (mt == MessageBox) QMessageBox::information(this, windowTitle(), QString("[%1]\n%2").arg(PI2QString(t.name()), msg));
|
||||
}
|
||||
|
||||
|
||||
@@ -262,13 +258,15 @@ void CDPultWindow::on_editFileK_valueChanged(const QVariant & p) {
|
||||
}
|
||||
if (!fi.path().isEmpty() && fi.path() != ".") {
|
||||
dir = fi.path();
|
||||
if (!dir.endsWith("/"))
|
||||
dir += "/";
|
||||
if (!dir.endsWith("/")) dir += "/";
|
||||
}
|
||||
QAD::File f = editFileK->value().value<QAD::File>();
|
||||
f.file = dir + xn + dot + ext; editFileX->setValue(QVariant::fromValue(f));
|
||||
f.file = dir + cn + dot + ext; editFileC->setValue(QVariant::fromValue(f));
|
||||
f.file = dir + mn + dot + ext; editFileM->setValue(QVariant::fromValue(f));
|
||||
f.file = dir + xn + dot + ext;
|
||||
editFileX->setValue(QVariant::fromValue(f));
|
||||
f.file = dir + cn + dot + ext;
|
||||
editFileC->setValue(QVariant::fromValue(f));
|
||||
f.file = dir + mn + dot + ext;
|
||||
editFileM->setValue(QVariant::fromValue(f));
|
||||
}
|
||||
|
||||
|
||||
@@ -284,10 +282,12 @@ void CDPultWindow::on_lineSessionName_textChanged(const QString & t) {
|
||||
|
||||
void CDPultWindow::on_buttonIcon_clicked() {
|
||||
QList<QByteArray> ifl = QImageReader::supportedImageFormats();
|
||||
QStringList sfl; foreach (QByteArray s, ifl) sfl << ("*." + QString(s).toLower());
|
||||
QStringList sfl;
|
||||
foreach(QByteArray s, ifl)
|
||||
sfl << ("*." + QString(s).toLower());
|
||||
QString f = QFileDialog::getOpenFileName(this, tr("Select icon"), last_icon, tr("Images") + " (" + sfl.join(" ") + ")");
|
||||
if (f.isEmpty()) return;
|
||||
last_icon = f;
|
||||
icon = QImage(last_icon);
|
||||
icon = QImage(last_icon);
|
||||
setWindowIcon(QIcon(QPixmap::fromImage(icon)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user