git-svn-id: svn://db.shs.com.ru/libs@388 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2018-05-28 11:32:30 +00:00
parent 31557d5e5c
commit f2581cd605
12 changed files with 237 additions and 237 deletions

View File

@@ -14,6 +14,7 @@
#include "qcodeedit.h"
#include <QFileDialog>
#include <QScrollBar>
#include <QImageReader>
using namespace CDUtils;
@@ -22,6 +23,7 @@ CDPultWindow::CDPultWindow(QWidget *parent) : EMainWindow(parent), Ui::CDPultWin
setupUi(this);
centralWidget()->hide();
CDCore::instance()->initPult();
def_config = codeConfig->text();
new ConfigHighlighter(codeConfig->document());
widgetK->setType(CDUtils::CDType::cdK);
widgetX->setType(CDUtils::CDType::cdX);
@@ -82,6 +84,7 @@ void CDPultWindow::apply(bool sessions) {
dockCDKView->setVisible(checkHasK->isChecked());
dockCDXView->setVisible(checkHasX->isChecked());
dockCDCView->setVisible(checkHasC->isChecked());
QMetaObject::invokeMethod(this, "changedDock", Qt::QueuedConnection);
}
@@ -103,6 +106,7 @@ void CDPultWindow::reset(bool full) {
bool CDPultWindow::load(const QString & path) {
qApp->setOverrideCursor(Qt::WaitCursor);
QPIConfig conf(path, QIODevice::ReadOnly);
QAD::File f = editFileK->value().value<QAD::File>();
checkSyncFiles->setChecked(false);
@@ -111,16 +115,21 @@ bool CDPultWindow::load(const QString & path) {
editFileC->setValue(QVariant::fromValue(QAD::File(conf.getValue("file_c").value(), f.filter)));
checkSyncFiles->setChecked(conf.getValue("sync_files"));
lineSessionName->setText(conf.getValue("session_name"));
last_icon = conf.getValue("icon_path", "").value();
setAppIcon(conf.getValue("icon", QByteArray()));
checkHasK->setChecked(conf.getValue("has_k"));
checkHasX->setChecked(conf.getValue("has_x"));
checkHasC->setChecked(conf.getValue("has_c"));
checkDefaultConfig->setChecked(conf.getValue("default_config"));
codeConfig->setText(QByteArray2QString(conf.getValue("config", QByteArray())));
if (codeConfig->text().isEmpty())
codeConfig->setText(def_config);
session_gr = conf.getValue("session_gr", QByteArray());
session_mw = conf.getValue("session_mw", QByteArray());
setChanged(false);
file_name = path;
apply(true);
qApp->restoreOverrideCursor();
return true;
}
@@ -135,6 +144,8 @@ bool CDPultWindow::save(const QString & path) {
conf.setValue("file_c", editFileC->value().value<QAD::File>().file);
conf.setValue("sync_files", checkSyncFiles->isChecked());
conf.setValue("session_name", lineSessionName->text());
conf.setValue("icon_path", last_icon);
conf.setValue("icon", appIcon());
conf.setValue("has_k", checkHasK->isChecked());
conf.setValue("has_x", checkHasX->isChecked());
conf.setValue("has_c", checkHasC->isChecked());
@@ -161,6 +172,30 @@ void CDPultWindow::savingSession(QPIConfig & conf) {
}
QByteArray CDPultWindow::appIcon() const {
QByteArray ret;
if (icon.isNull()) return ret;
QBuffer buff(&ret);
buff.open(QIODevice::WriteOnly);
icon.save(&buff, "png");
//qDebug() << "s" << ret.size();
return ret;
}
void CDPultWindow::setAppIcon(QByteArray ba) {
if (ba.isEmpty()) {
icon = QImage();
setWindowIcon(QIcon());
return;
}
//qDebug() << "l" << ba.size();
icon = QImage::fromData(ba);
setWindowIcon(QIcon(QPixmap::fromImage(icon)));
//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();
@@ -210,3 +245,14 @@ void CDPultWindow::on_buttonSessionApply_clicked() {
void CDPultWindow::on_lineSessionName_textChanged(const QString & t) {
setWindowTitle(QString("CD Pult - %1").arg(t));
}
void CDPultWindow::on_buttonIcon_clicked() {
QList<QByteArray> ifl = QImageReader::supportedImageFormats();
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);
setWindowIcon(QIcon(QPixmap::fromImage(icon)));
}