Ejemplo n.º 1
0
propertiesDialog::propertiesDialog(threadParam *p ,QIcon *icon,QWidget *parent) :
    QDialog(parent),
    ui(new Ui::propertiesDialog)
{
    ui->setupUi(this);
    setFixedSize(size());
    param=p;
    if (p->files.size()>1){
        ui->nameLabel->setText(trUtf8("(несколько элементов)"));
        ui->label_6->setText(trUtf8("Размещение: "));
        ui->pathLabel->setText(p->source);

        ui->label_8->setText(trUtf8("Кол-во элементов: "));
        ui->typeLabel->setText(trUtf8("файлов: ") + QString().number(p->count_files)+
                               trUtf8(" папок: ")+QString().number(p->count_dirs));
        ui->sizeLabel->setText(filesize(p->total_size));
        ui->time1Label->setText(trUtf8("(несколько элементов)"));
        ui->time2Label->setText(trUtf8("(несколько элементов)"));
    } else {


        ui->nameLabel->setText(p->files.first().fileName());
        ui->pathLabel->setText(p->files.first().absolutePath());
        if (p->files.first().isDir()) ui->sizeLabel->setText(filesize(p->total_size)+trUtf8(", папок: ")+
                                                             QString().number(p->count_dirs)+trUtf8(" файлов: ")+
                                                             QString().number(p->count_files));
        else ui->sizeLabel->setText(filesize(p->total_size));

        if (p->files.first().isSymLink()){
            ui->typeLabel->setText(QFileIconProvider().type(p->files.first())+trUtf8(" (ссылка)"));
            ui->label_12->setText(trUtf8("Ссылка на: "));
            ui->linkLabel->setText(param->files.first().symLinkTarget());
        }
        else{
            ui->typeLabel->setText(QFileIconProvider().type(p->files.first())) ;

        }

        ui->time1Label->setText(p->files.first().lastModified().toString("hh:mm:ss, dd MMM yyyy"));
        ui->time2Label->setText(p->files.first().lastRead().toString("hh:mm:ss, dd MMM yyyy"));

        showPermissions();
        ui->label_11->setPixmap(icon->pixmap(48,48));
    }

    connect(ui->u_read,SIGNAL(stateChanged(int)),this,SLOT(changged()));
    connect(ui->u_write,SIGNAL(stateChanged(int)),this,SLOT(changged()));
    connect(ui->u_exec,SIGNAL(stateChanged(int)),this,SLOT(changged()));

    connect(ui->g_read,SIGNAL(stateChanged(int)),this,SLOT(changged()));
    connect(ui->g_write,SIGNAL(stateChanged(int)),this,SLOT(changged()));
    connect(ui->g_exec,SIGNAL(stateChanged(int)),this,SLOT(changged()));

    connect(ui->o_read,SIGNAL(stateChanged(int)),this,SLOT(changged()));
    connect(ui->o_write,SIGNAL(stateChanged(int)),this,SLOT(changged()));
    connect(ui->o_exec,SIGNAL(stateChanged(int)),this,SLOT(changged()));

}
Ejemplo n.º 2
0
TransferDialog::TransferDialog(Transfer *transfer, QWidget *parent) : Dialog(parent),
	m_transfer(transfer),
	m_ui(new Ui::TransferDialog)
{
	const QString iconName(transfer->getMimeType().iconName());
	const QPixmap icon(QIcon::fromTheme(iconName, QFileIconProvider().icon(iconName)).pixmap(16, 16));
	QString fileName(transfer->getSuggestedFileName());

	if (fileName.isEmpty())
	{
		fileName = tr("unknown file");
	}

	m_ui->setupUi(this);

	if (icon.isNull())
	{
		m_ui->iconLabel->hide();
	}
	else
	{
		m_ui->iconLabel->setPixmap(icon);
	}

	m_ui->nameTextLabelWidget->setText(fileName);
	m_ui->typeTextLabelWidget->setText(transfer->getMimeType().comment());
	m_ui->fromTextLabelWidget->setText(Utils::extractHost(transfer->getSource()));
	m_ui->openWithComboBoxWidget->setMimeType(transfer->getMimeType());

	setProgress(m_transfer->getBytesReceived(), m_transfer->getBytesTotal());
	setWindowTitle(tr("Opening %1").arg(fileName));

	connect(transfer, &Transfer::progressChanged, this, &TransferDialog::setProgress);
	connect(m_ui->buttonBox, &QDialogButtonBox::clicked, this, &TransferDialog::handleButtonClicked);
}
void WindowsPlatformIntegration::getApplicationInformation(ApplicationInformation &information)
{
	const QString rootPath(information.command.left(information.command.indexOf(QLatin1String("\\"))).remove(QLatin1Char('%')));

	if (m_environment.contains(rootPath))
	{
		information.command.replace(QLatin1Char('%') + rootPath + QLatin1Char('%'), m_environment.value(rootPath));
	}

	const QString fullApplicationPath(information.command.left(information.command.indexOf(QLatin1String(".exe"), 0, Qt::CaseInsensitive) + 4));
	const QFileInfo fileInformation(fullApplicationPath);
	HKEY key = NULL;
	TCHAR readBuffer[128];
	DWORD bufferSize = sizeof(readBuffer);

	if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Classes\\Local Settings\\Software\\Microsoft\\Windows\\Shell\\MuiCache"), 0, KEY_QUERY_VALUE, &key) == ERROR_SUCCESS)
	{
		if (RegQueryValueEx(key, fullApplicationPath.toStdWString().c_str(), NULL, NULL, (LPBYTE)readBuffer, &bufferSize) == ERROR_SUCCESS)
		{
			information.name = QString::fromWCharArray(readBuffer);
		}

		RegCloseKey(key);
	}

	if (information.name.isEmpty())
	{
		information.name = fileInformation.baseName();
	}

	information.icon = QFileIconProvider().icon(fileInformation);
}
Ejemplo n.º 4
0
/** Insert a row with a checkbox with folder's name and the number of files in this folder. */
void QuickStart::insertRow(const QFileInfo &fileInfo, const int & musicFileNumber)
{
	// A subfolder is displayed with its number of files on the right
	QTableWidgetItem *checkBox = new QTableWidgetItem;
	checkBox->setFlags(checkBox->flags() | Qt::ItemIsUserCheckable);
	checkBox->setCheckState(Qt::Checked);

	QTableWidgetItem *musicSubFolderName = new QTableWidgetItem(QFileIconProvider().icon(fileInfo), fileInfo.baseName());
	musicSubFolderName->setData(Qt::UserRole, fileInfo.absoluteFilePath());

	QTableWidgetItem *musicSubFolderCount;
	if (musicFileNumber == 0) {
		musicSubFolderCount = new QTableWidgetItem(tr("empty folder"));
		checkBox->setCheckState(Qt::Unchecked);
	} else {
		musicSubFolderCount = new QTableWidgetItem(tr("%n elements", "", musicFileNumber));
	}
	musicSubFolderCount->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);

	int rowCount = quickStartTableWidget->rowCount();
	quickStartTableWidget->insertRow(rowCount);
	quickStartTableWidget->setItem(rowCount, 0, checkBox);
	quickStartTableWidget->setItem(rowCount, 1, musicSubFolderName);
	quickStartTableWidget->setItem(rowCount, 2, musicSubFolderCount);

	_totalMusicFiles += musicFileNumber;
}
NewFileDialog::NewFileDialog(const QString &title,
const QString &name, const QString &defaultDir, QWidget *parent) :
QDialog(parent), m_ui(new Ui::NewFileDialog)
{
    m_ui->setupUi(this); setWindowTitle(title); setObjectName(title);

    setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint |
    Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint | Qt::Dialog);

    m_ui->button->setIcon(QFileIconProvider().icon(QFileIconProvider::Folder));

    connect(m_ui->button, SIGNAL(clicked()),
            this, SLOT(pick()));

    connect(m_ui->nameEdit, SIGNAL(textChanged(QString)),
            this, SLOT(textChanged(QString)));

    connect(m_ui->nameEdit, SIGNAL(textChanged(QString)),
            this, SLOT(userInterfaceChanged()));

    connect(m_ui->edit, SIGNAL(textChanged(QString)),
            this, SLOT(textChanged(QString)));

    connect(m_ui->edit, SIGNAL(textChanged(QString)),
            this, SLOT(userInterfaceChanged()));

    setName(name);
    setDefaultDir(defaultDir);
}
Ejemplo n.º 6
0
QuickStart::QuickStart(QWidget *parent) :
	QWidget(parent), _totalMusicFiles(0), _worker(NULL), _qsse(NULL)
{
	setupUi(this);

	QStringList musicLocations = QStandardPaths::standardLocations(QStandardPaths::MusicLocation);
	if (musicLocations.isEmpty()) {
		defaultFolderGroupBox->setVisible(false);
		orLabel->setVisible(false);
	} else {
		defaultFolderTableWidget->setItemDelegate(new NoFocusItemDelegate(this));

		defaultFolderTableWidget->insertRow(0);
		QTableWidgetItem *checkBox = new QTableWidgetItem;
		checkBox->setFlags(checkBox->flags() | Qt::ItemIsUserCheckable);
		defaultFolderTableWidget->setItem(0, 0, checkBox);
		QString musicLocation = musicLocations.first();
		defaultFolderTableWidget->setItem(0, 1, new QTableWidgetItem(QFileIconProvider().icon(musicLocation), QDir::toNativeSeparators(musicLocation)));

		connect(defaultFolderTableWidget, &QTableWidget::itemClicked, this, [=](QTableWidgetItem *i) {
			if (i->column() != 0) {
				if (defaultFolderTableWidget->item(0, 0)->checkState() == Qt::Checked) {
					defaultFolderTableWidget->item(0, 0)->setCheckState(Qt::Unchecked);
				} else {
					defaultFolderTableWidget->item(0, 0)->setCheckState(Qt::Checked);
				}
			}
			defaultFolderApplyButton->setEnabled(defaultFolderTableWidget->item(0, 0)->checkState() == Qt::Checked);
		});
	}
	quickStartTableWidget->setItemDelegate(new NoFocusItemDelegate(this));

	connect(quickStartTableWidget, &QTableWidget::itemClicked, this, &QuickStart::checkRow);
	this->installEventFilter(this);
}
Ejemplo n.º 7
0
OPFModel::OPFModel(QObject *parent)
    :
    QStandardItemModel(parent),
    m_RefreshInProgress(false),
    m_Book(NULL),
    m_TextFolderItem(new QStandardItem("Text")),
    m_StylesFolderItem(new QStandardItem("Styles")),
    m_ImagesFolderItem(new QStandardItem("Images")),
    m_FontsFolderItem(new QStandardItem("Fonts")),
    m_MiscFolderItem(new QStandardItem("Misc")),
    m_AudioFolderItem(new QStandardItem("Audio")),
    m_VideoFolderItem(new QStandardItem("Video"))
{
    connect(this, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
            this, SLOT(RowsRemovedHandler(const QModelIndex &, int, int)));
    connect(this, SIGNAL(itemChanged(QStandardItem *)),
            this, SLOT(ItemChangedHandler(QStandardItem *)));
    QList<QStandardItem *> items;
    items.append(m_TextFolderItem);
    items.append(m_StylesFolderItem);
    items.append(m_ImagesFolderItem);
    items.append(m_FontsFolderItem);
    items.append(m_AudioFolderItem);
    items.append(m_VideoFolderItem);
    items.append(m_MiscFolderItem);
    QIcon folder_icon = QFileIconProvider().icon(QFileIconProvider::Folder);
    foreach(QStandardItem * item, items) {
        item->setIcon(folder_icon);
        item->setEditable(false);
        item->setDragEnabled(false);
        item->setDropEnabled(false);
        appendRow(item);
    }
Ejemplo n.º 8
0
void ConfigWindow::modifyCustomFF7Path()
{
	QTreeWidgetItem *item = listFF7->currentItem();
	QString currentPath;
	if(item) {
		Data::FF7Version id = Data::FF7Version(item->data(0, Qt::UserRole).toInt());
		if(id == Data::Custom) {
			// Modify
			QString path = QFileDialog::getOpenFileName(this, tr("Chercher ff7.exe"), item->text(0), tr("Fichiers EXE (*.exe)"));
			if(!path.isNull()) {
				Config::setValue("customFF7Path", path);
				item->setText(0, QDir::toNativeSeparators(path));
			}
			return;
		}
		currentPath = item->text(0);
	}
	// Add
	QString path = QFileDialog::getOpenFileName(this, tr("Chercher ff7.exe"), currentPath, tr("Fichiers EXE (*.exe)"));
	if(!path.isNull()) {
		Config::setValue("customFF7Path", path);
		QTreeWidgetItem *item = new QTreeWidgetItem(QStringList(QDir::toNativeSeparators(path)));
		item->setData(0, Qt::UserRole, int(Data::Custom));
		item->setIcon(0, QFileIconProvider().icon(QFileInfo(path)));
		listFF7->addTopLevelItem(item);
		listFF7->setCurrentItem(item);
	}
}
Ejemplo n.º 9
0
QVariant FilteringModel::data(const QModelIndex &index, int role) const
{
    if(role == Qt::DecorationRole && index.column() == 0)
    {
        QModelIndex typeIndex = this->index(index.row(), 1, index.parent());
        QString type = QSortFilterProxyModel::data(typeIndex, Qt::DisplayRole).toString();
        return m_icons.value(type, QFileIconProvider().icon(QFileIconProvider::File));
    }
    else
        return QSortFilterProxyModel::data(index, role);
}
Ejemplo n.º 10
0
const QIcon& CIconProvider::iconForFilesystemObject( const CFileSystemObject& object )
{
	if (_iconForObject.count(object.properties().hash) == 0)
	{
		const QIcon icon = QFileIconProvider().icon(object.absoluteFilePath());
		const quint64 iconHash = icon.cacheKey();
		if (_iconCache.count(iconHash) == 0)
			_iconCache[iconHash] = icon;

		_iconForObject[object.properties().hash] = iconHash;
		return _iconCache[iconHash];
	}

	return _iconCache[_iconForObject[object.properties().hash]];
}
Ejemplo n.º 11
0
void QxFileBrowser::cwdSet(const QString& newPath)
{
	QString path = newPath;
	if ((path.length() > 0) && (path.at(path.length() - 1) == QDir::separator()))
		path = path.left(path.length() - 1);
	QModelIndex root = cwdModel_->setRootPath(path);
	dirView_->setRootIndex(root);
	// updateStatusDisplay();
	QPixmap folderIcon = QFileIconProvider().icon(QFileInfo(newPath)).pixmap(QSize(16, 16));
	QString dirName = QDir(path).dirName();
	gotoButton_->visual()->setText(dirName);
	gotoButton_->visual()->setLeadingIcon(folderIcon);
	// dirView_->setCurrentIndex(cwdModel_->index(0, 0));
	QDir::setCurrent(path);
	emit cwdChanged(QDir::currentPath());
	updateGotoMenu();
	update();
}
Ejemplo n.º 12
0
QVariant DirModel::data(const QModelIndex &index, int role) const
{
//its not for QML
#if defined(REGRESSION_TEST_FOLDERLISTMODEL)
    if (!index.isValid() ||
        (role != Qt::DisplayRole && role != Qt::DecorationRole && role != Qt::BackgroundRole)
       )
    {
        return QVariant();
    }
    if (role == Qt::DecorationRole && index.column() == 0)
    {
        QIcon icon;
        QMimeType mime = mDirectoryContents.at(index.row()).mimeType();
        if (mime.isValid())
        {
            if (QIcon::hasThemeIcon(mime.iconName()) ) {
               icon = QIcon::fromTheme(mime.iconName());
            }
            else if (QIcon::hasThemeIcon(mime.genericIconName())) {
               icon = QIcon::fromTheme(mime.genericIconName());
            }
        }
        if (icon.isNull())
        {
            if (mDirectoryContents.at(index.row()).isLocal())
            {
                icon =  QFileIconProvider().icon(mDirectoryContents.at(index.row()).diskFileInfo());
            }
            else
            if (mDirectoryContents.at(index.row()).isDir())
            {
                icon =  QFileIconProvider().icon(QFileIconProvider::Folder);
            }
            else
            {
                icon =  QFileIconProvider().icon(QFileIconProvider::File);
            }
        }
        return icon;
    }
    if (role == Qt::BackgroundRole && index.column() == 0)
    {
        if (mDirectoryContents.at(index.row()).isSelected())
        {
           //TODO it'd better to get some style or other default
           //     background color
           return QBrush(Qt::lightGray);
        }
        return QVariant();
    }
    role = FileNameRole + index.column();
#else
    if (role < FileNameRole || role > TrackCoverRole) {
        qWarning() << Q_FUNC_INFO << this << "Got an out of range role: " << role;
        return QVariant();
    }

    if (index.row() < 0 || index.row() >= mDirectoryContents.count()) {
        qWarning() << "Attempted to access out of range row: " << index.row();
        return QVariant();
    }

    if (index.column() != 0)
        return QVariant();
#endif

    const DirItemInfo &fi = mDirectoryContents.at(index.row());

    switch (role) {
        case FileNameRole:
            return fi.fileName();
        case AccessedDateRole:
            return fi.lastRead();
        case CreationDateRole:
            return fi.created();
        case ModifiedDateRole:
            return fi.lastModified();
        case FileSizeRole: {
             if (fi.isDir() && fi.isLocal())
             {
                return dirItems(fi.diskFileInfo());
             }
             return fileSize(fi.size());
        }
        case IconSourceRole: {
            const QString &fileName = fi.fileName();

            if (fi.isDir())
                return QLatin1String("image://theme/icon-m-common-directory");

            if (fileName.endsWith(QLatin1String(".jpg"), Qt::CaseInsensitive) ||
                fileName.endsWith(QLatin1String(".png"), Qt::CaseInsensitive)) {
                return QLatin1String("image://nemoThumbnail/") + fi.filePath();
            }

            return "image://theme/icon-m-content-document";
        }
        case FilePathRole:
            return fi.filePath();
        case MimeTypeRole:
            return fi.mimeType().name();
        case MimeTypeDescriptionRole:
            return fi.mimeType().comment();
        case IsDirRole:
            return fi.isDir();
        case IsFileRole:
            return !fi.isDir();
        case IsReadableRole:
            return fi.isReadable();
        case IsWritableRole:
            return fi.isWritable();
        case IsExecutableRole:
            return fi.isExecutable();
        case IsSelectedRole:
            return fi.isSelected();
#ifndef DO_NOT_USE_TAG_LIB
        case TrackTitleRole:
        case TrackArtistRole:
        case TrackAlbumRole:
        case TrackYearRole:
        case TrackNumberRole:
        case TrackGenreRole:
        case TrackLengthRole:
        case TrackCoverRole:
             if (mReadsMediaMetadata && fi.isLocal())
             {
                 return getAudioMetaData(fi.diskFileInfo(), role);
             }
             break;
#endif
        default:
#if !defined(REGRESSION_TEST_FOLDERLISTMODEL)
            // this should not happen, ever
            Q_ASSERT(false);
            qWarning() << Q_FUNC_INFO << this << "Got an unknown role: " << role;
#endif
            break;
    }

    return QVariant();
}
Ejemplo n.º 13
0
QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid())
        return QVariant();

    if (role == Qt::EditRole)
        return QVariant();

    switch(classify(index)) {
    case AddButton: {
        if (role == FolderStatusDelegate::AddButton) {
            return QVariant(true);
        } else if (role == Qt::ToolTipRole) {
            if (!_accountState->isConnected()) {
                return tr("You need to be connected to add a folder");
            } if (_folders.count() == 1) {
                auto remotePath = _folders.at(0)._folder->remotePath();
                if (remotePath.isEmpty() || remotePath == QLatin1String("/")) {
                    // Syncing the entire owncloud: disable the add folder button (#3438)
                    return tr("Adding folder is disabled because you are already syncing all your files. "
                            "If you want to sync multiple folders, please remove the currently "
                            "configured root folder.");
                }
            }
            return tr("Click this button to add a folder to synchronize.");
        }
        return QVariant();
    }
    case SubFolder:
    {
        const auto &x = static_cast<SubFolderInfo *>(index.internalPointer())->_subs[index.row()];
        switch (role) {
        case Qt::ToolTipRole:
        case Qt::DisplayRole:
            return tr("%1 (%2)").arg(x._name, Utility::octetsToString(x._size));
        case Qt::CheckStateRole:
            return x._checked;
        case Qt::DecorationRole:
            return QFileIconProvider().icon(QFileIconProvider::Folder);
        case Qt::ForegroundRole:
            if (x._isUndecided) {
                return QColor(Qt::red);
            }
            break;
        }
    }
        return QVariant();
    case FetchLabel:
    {
        const auto x = static_cast<SubFolderInfo *>(index.internalPointer());
        switch(role) {
            case Qt::DisplayRole:
                if (x->_hasError) {
                    return tr("Error while loading the list of folders from the server.");
                } else {
                    return tr("Fetching folder list from server...");
                }
                break;
            default: return QVariant();
        }
    }
    case RootFolder:
        break;
    }

    const SubFolderInfo & folderInfo = _folders.at(index.row());
    auto f = folderInfo._folder;
    if (!f)
        return QVariant();

    const SubFolderInfo::Progress & progress = folderInfo._progress;
    const bool accountConnected = _accountState->isConnected();

    switch (role) {
    case FolderStatusDelegate::FolderPathRole         : return  f->shortGuiPath();
    case FolderStatusDelegate::FolderSecondPathRole   : return  f->remotePath();
    case FolderStatusDelegate::HeaderRole             : return  f->aliasGui();
    case FolderStatusDelegate::FolderAliasRole        : return  f->alias();
    case FolderStatusDelegate::FolderSyncPaused       : return  f->syncPaused();
    case FolderStatusDelegate::FolderAccountConnected : return  accountConnected;
    case Qt::ToolTipRole:
        if ( accountConnected )
            return Theme::instance()->statusHeaderText(f->syncResult().status());
        else
            return tr("Signed out");
    case FolderStatusDelegate::FolderStatusIconRole:
        if ( accountConnected ) {
            auto theme = Theme::instance();
            auto status = f->syncResult().status();
            if( f->syncPaused() ) {
                return theme->folderDisabledIcon( );
            } else {
                if( status == SyncResult::SyncPrepare ) {
                    return theme->syncStateIcon(SyncResult::SyncRunning);
                } else if( status == SyncResult::Undefined ) {
                    return theme->syncStateIcon( SyncResult::SyncRunning);
                } else {
                    // keep the previous icon for the prepare phase.
                    if( status == SyncResult::Problem) {
                        return theme->syncStateIcon( SyncResult::Success);
                    } else {
                        return theme->syncStateIcon( status );
                    }
                }
            }
        } else {
            return Theme::instance()->folderOfflineIcon();
        }
    case FolderStatusDelegate::SyncProgressItemString:
        return progress._progressString;
    case FolderStatusDelegate::WarningCount:
        return progress._warningCount;
    case FolderStatusDelegate::SyncProgressOverallPercent:
        return progress._overallPercent;
    case FolderStatusDelegate::SyncProgressOverallString:
        return progress._overallSyncString;
    }
    return QVariant();
}
Ejemplo n.º 14
0
QxFileBrowser::QxFileBrowser(QWidget* parent)
	: QWidget(parent),
	  gotoMenu_(0),
	  recentMenu_(0),
	  showHidden_(false),
	  showDetails_(true),
	  createFileDialog_(0),
	  createDirDialog_(0),
	  renameDialog_(0)
{
	//--------------------------------------------------------------------------
	// setup primary model and view
	
	cwdModel_ = new QFileSystemModel(this);
	cwdModel_->setReadOnly(false);
	QModelIndex root = cwdModel_->setRootPath(QDir::currentPath());
	connect( cwdModel_, SIGNAL(fileRenamed(const QString&, const QString&, const QString&)),
	         this, SLOT(fileRenamed(const QString&, const QString&, const QString&)) );
	
	dirView_ = new QxFileSystemView(this);
	dirView_->setModel(cwdModel_);
	dirView_->header()->hide();
	dirView_->setRootIndex(root);
	dirView_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	dirView_->setDragDropMode(QAbstractItemView::DragOnly);
	connect(dirView_, SIGNAL(activated(const QModelIndex&)), this, SLOT(cwdSet(const QModelIndex&)));
	connect(dirView_, SIGNAL(escape()), this, SIGNAL(escape()));
	connect(dirView_, SIGNAL(cdUp()), this, SLOT(cdUp()));
	connect(cwdModel_, SIGNAL(layoutChanged()), dirView_, SLOT(resizeColumnsToContents()));
	
	setFocusProxy(dirView_);
	
	// dirView_->setTextElideMode(Qt::ElideMiddle);
	dirView_->setFrameStyle(QFrame::NoFrame);
	// dirView_->setIndentation(18); // together with a branch pixmap could improve branch alignment
	dirView_->setLineWidth(0);
	dirView_->setMidLineWidth(0);
	#ifdef Q_WS_MAC
	dirView_->setStyleSheet(
		"QTreeView {"
		"  font-size: 12px;"
		"}"
		"QTreeView::item {"
		"  padding-top: 1px;"
		"}"
	);
	#endif
	{
		QPalette pal = dirView_->palette();
		pal.setColor(QPalette::Base, styleManager()->color("fileBrowserDirViewBgColor"));
		dirView_->setPalette(pal);
	}
	
	//--------------------------------------------------------------------------
	// setup navigation bar / panel head
	
	gotoButton_ = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserGotoButton")));
	gotoButton_->setMode(QxControl::MenuMode);
	gotoButton_->visual()->setText(QDir::current().dirName());
	gotoButton_->setMinimumWidth(10); // design HACK
	gotoButton_->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
	{
		QPixmap folderIcon = QFileIconProvider().icon(QFileInfo(QDir::currentPath())).pixmap(QSize(16, 16));
		gotoButton_->visual()->setLeadingIcon(folderIcon);
	}
	#ifdef Q_WS_MAC
	#ifdef QT_MAC_USE_COCOA
	connect(gotoButton_, SIGNAL(toggled(bool)), this, SLOT(blockFloating(bool)));
	#endif // QT_MAC_USE_COCOA
	#endif // Q_WS_MAC
	
	updateGotoMenu();
	
	class QxCdUpButton: public QxControl {
	public:
		QxCdUpButton(QWidget* parent)
			: QxControl(parent, new QxVisual(styleManager()->style("fileBrowserCdUpButton")))
		{}
	private:
		// workaround HACK, prevent undocking, map double click event to single click
		virtual void mouseDoubleClickEvent(QMouseEvent* event) { press(); event->accept(); }
	};
	QxControl* cdUpButton = new QxCdUpButton(this);
	cdUpButton->setMode(QxControl::TouchMode);
	connect(cdUpButton, SIGNAL(pressed()), this, SLOT(cdUp()));
	
	//--------------------------------------------------------------------------
	// define context actions
	
	contextMenu_ = new QMenu(this);
	
	// QxDesignHack::beautify(contextMenu_);
	openDefaultAction_ = new QAction(tr("Open in Default App."), this);
	openDefaultAction_->setShortcut(tr("Ctrl+D"));
	openDefaultAction_->setShortcutContext(Qt::WidgetShortcut);
	openFileAction_ = new QAction(tr("Open in %1").arg(qApp->applicationName()), this);
	
	createFileAction_ = contextMenu_->addAction(tr("New File"));
	createDirAction_ = contextMenu_->addAction(tr("New Folder"));
	contextMenu_->addSeparator();
	contextMenu_->addAction(openFileAction_);
	contextMenu_->addAction(openDefaultAction_);
	contextMenu_->addSeparator();
	renameAction_ = contextMenu_->addAction(tr("Rename"));
	deleteAction_ = contextMenu_->addAction(tr("Move To Trash"));
	contextMenu_->addSeparator();
	bookmarkAction_ = contextMenu_->addAction(tr("Bookmark"));
	contextMenu_->addSeparator();
	showHiddenAction_ = contextMenu_->addAction(tr("Show Hidden"));
	showDetailsAction_ = contextMenu_->addAction(tr("Show Details"));
	
	connect(createFileAction_, SIGNAL(triggered()), this, SLOT(createFile()));
	connect(createDirAction_, SIGNAL(triggered()), this, SLOT(createDir()));
	connect(openDefaultAction_, SIGNAL(triggered()), this, SLOT(openDefault()));
	connect(openFileAction_, SIGNAL(triggered()), this, SLOT(openFile()));
	connect(renameAction_, SIGNAL(triggered()), this, SLOT(rename()));
	connect(deleteAction_, SIGNAL(triggered()), this, SLOT(delete_()));
	connect(dirView_, SIGNAL(delKeyPressed()), this, SLOT(delete_()));
	connect(showHiddenAction_, SIGNAL(toggled(bool)), this, SLOT(showHidden(bool)));
	connect(showDetailsAction_, SIGNAL(toggled(bool)), this, SLOT(showDetails(bool)));
	connect(bookmarkAction_, SIGNAL(triggered()), this, SLOT(bookmark()));
	
	showHiddenAction_->setCheckable(true);
	showDetailsAction_->setCheckable(true);
	showHiddenAction_->setChecked(false);
	showDetailsAction_->setChecked(false);
	
	//--------------------------------------------------------------------------
	// setup toolbar
	
	QxControl* plusButton = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserPlusButton")));
	plusButton->setMode(QxControl::TouchMode);
	connect(plusButton, SIGNAL(pressed()), this, SLOT(createFile()));
	
	QxControl* wheelButton = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserWheelButton")));
	wheelButton->setMenu(contextMenu_);
	wheelButton->setMenuPopupMode(QxControl::DownsideMenuPopup|QxControl::UpsideMenuPopup|QxControl::PreferUpsideMenuPopup);
	
	QxControl* recentButton = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserRecentButton")));
	recentButton->setMode(QxControl::TouchMode);
	connect(recentButton, SIGNAL(pressed()), this, SLOT(recentShowOrHide()));
	
	QxControl* bookmarksButton = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserBookmarksButton")));
	bookmarksButton->setMode(QxControl::TouchMode);
	connect(bookmarksButton, SIGNAL(pressed()), this, SLOT(bookmarksShowOrHide()));
	
	statusBar_ = new QxStatusBar(this);
	
	showHidden(false);
	showDetails(false);
	
	//--------------------------------------------------------------------------
	// setup bottom views
	
	recentModel_ = new QxUrlListModel(this);
	
	recentView_ = new QxUrlListView(this);
	// recentView_->header()->hide();
	// recentView_->setViewMode(QListView::IconMode);
	// recentView_->setIconSize(QSize(16, 16));
	recentView_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	recentView_->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
	recentView_->setTextElideMode(Qt::ElideLeft);
	recentView_->setFrameStyle(QFrame::NoFrame);
	recentView_->setLineWidth(0);
	recentView_->setMidLineWidth(0);
	recentView_->setStyleSheet(
		"QListView::item {"
		"  padding-top: 1px;"
		"}"
	);
	// recentView_->setAlternatingRowColors(true);
	recentView_->setModel(recentModel_);
	connect(recentView_, SIGNAL(activated(const QModelIndex&)), this, SLOT(gotoRecent(const QModelIndex&)));
	
	recentContextMenu_ = new QMenu(this);
	recentContextMenu_->addAction(tr("Goto"), this, SLOT(gotoRecent()));
	recentContextMenu_->addAction(tr("Add To Bookmarks"), this, SLOT(recentAddToBookmarks()));
	
	bookmarksModel_ = new QxUrlListModel(this);
	bookmarksModel_->setPathReduction(1);
	
	bookmarksView_ = new QxUrlListView(this);
	bookmarksView_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	bookmarksView_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	bookmarksView_->setTextElideMode(Qt::ElideLeft);
	bookmarksView_->setFrameStyle(QFrame::NoFrame);
	bookmarksView_->setLineWidth(0);
	bookmarksView_->setMidLineWidth(0);
	bookmarksView_->setStyleSheet(
		"QListView::item {"
		"  padding-top: 1px;"
		"}"
	);
	bookmarksView_->setModel(bookmarksModel_);
	bookmarksView_->setDragDropMode(QAbstractItemView::InternalMove);
	bookmarksView_->setDragEnabled(true);
	bookmarksView_->setAcceptDrops(true);
	bookmarksView_->setDropIndicatorShown(true);
	connect(bookmarksView_, SIGNAL(activated(const QModelIndex&)), this, SLOT(gotoBookmark(const QModelIndex&)));
	
	bookmarksContextMenu_ = new QMenu(this);
	bookmarksContextMenu_->addAction(tr("Add Current Directory"), this, SLOT(cwdAddToBookmark()));
	bookmarksContextMenu_->addAction(tr("Add Other Directory"), this, SLOT(addDirBookmark()));
	bookmarksContextMenu_->addSeparator();
	bookmarksContextMenu_->addAction(tr("Goto Here"), this, SLOT(gotoBookmark()));
	bookmarksContextMenu_->addAction(tr("Remove From List"), this, SLOT(removeBookmark()));
	bookmarksContextMenu_->addSeparator();
	bookmarksShowFullPathAction_ = bookmarksContextMenu_->addAction(tr("Show Full Path"));
	bookmarksShowFullPathAction_->setCheckable(true);
	bookmarksShowFullPathAction_->setChecked(bookmarksModel_->pathReduction() == -1);
	connect(bookmarksShowFullPathAction_, SIGNAL(toggled(bool)), this, SLOT(bookmarksShowFullPath(bool)));
	
	#ifdef Q_WS_MAC
	{
		QProxyStyle* proxyStyle = qobject_cast<QProxyStyle*>(style());
		QMacStyle* macStyle = qobject_cast<QMacStyle*>((proxyStyle) ? proxyStyle->baseStyle() : style());
		if (macStyle) {
			macStyle->setFocusRectPolicy(dirView_, QMacStyle::FocusDisabled);
			macStyle->setFocusRectPolicy(recentView_, QMacStyle::FocusDisabled);
			macStyle->setFocusRectPolicy(dirView_, QMacStyle::FocusDisabled);
			macStyle->setFocusRectPolicy(bookmarksView_, QMacStyle::FocusDisabled);
		}
	}
	#endif
	
	//--------------------------------------------------------------------------
	// layout widgets
	
	handle_ = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserSplitter")));
	handle_->visual()->setText("");
	handleTextRecent_ = tr("Recent Places");
	handleTextBookmarks_ = tr("Bookmarks");
	
	bottomStack_ = new QxControl(this);
	bottomStackLayout_ = new QStackedLayout;
	bottomStackLayout_->addWidget(recentView_);
	bottomStackLayout_->addWidget(bookmarksView_);
	bottomStack_->setLayout(bottomStackLayout_);
	bottomStack_->setVisible(false);
	
	splitter_ = new QxSplitter(this);
	splitter_->setOrientation(Qt::Vertical);
	splitter_->setHandle(1, handle_);
	splitter_->setHandleWidth(styleManager()->constant("fileBrowserSplitterWidth"));
	splitter_->addWidget(dirView_);
	/*{
		QxControl* carrier = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserDirView")));
		QGridLayout* layout = new QGridLayout;
		layout->setSpacing(0);
		layout->setMargin(0);
		layout->addWidget(dirView_);
		carrier->setLayout(layout);
		splitter_->addWidget(carrier);
	}*/
	splitter_->addWidget(bottomStack_);
	
	// make dirView_ grow/shrink dynamically, while bottomStack_ keeps user-defined size
	splitter_->setStretchFactor(0, 1);
	splitter_->setStretchFactor(1, 0);
	
	QDockWidget* dock = qobject_cast<QDockWidget*>(parent);
	if (dock) {
		dock->setWidget(this);
		// connect(dock, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(adaptToDockLocation(Qt::DockWidgetArea)));
	}
	
	QVBoxLayout* col = new QVBoxLayout;
	col->setSpacing(0);
	col->setMargin(0);
	{
		QxControl* carrier = new QxControl(parent, new QxVisual(styleManager()->style("fileBrowserNavCarrier")));
		QHBoxLayout* row = new QHBoxLayout;
		row->setSpacing(0);
		row->setMargin(0);
		row->addWidget(gotoButton_);
		row->addStretch();
		row->addWidget(cdUpButton);
		carrier->setLayout(row);
		
		if (dock)
			dock->setTitleBarWidget(carrier);
		else
			col->addWidget(carrier);
	}
	col->addWidget(splitter_);
	col->addWidget(styleManager()->hl(this));
	{
		QBoxLayout* row = new QBoxLayout(QBoxLayout::LeftToRight);
		row->setSpacing(0);
		row->setMargin(0);
		row->addWidget(plusButton);
		row->addWidget(styleManager()->vl(this));
		row->addWidget(wheelButton);
		row->addWidget(styleManager()->vl(this));
		row->addWidget(recentButton);
		row->addWidget(styleManager()->vl(this));
		row->addWidget(bookmarksButton);
		row->addWidget(styleManager()->vl(this));
		row->addWidget(statusBar_);
		col->addLayout(row);
		
		bottomToolLayout_ = row;
	}
	setLayout(col);
}
Ejemplo n.º 15
0
QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid())
        return QVariant();

    if (role == Qt::EditRole)
        return QVariant();

    switch (classify(index)) {
    case AddButton: {
        if (role == FolderStatusDelegate::AddButton) {
            return QVariant(true);
        } else if (role == Qt::ToolTipRole) {
            if (!_accountState->isConnected()) {
                return tr("You need to be connected to add a folder");
            }
            return tr("Click this button to add a folder to synchronize.");
        }
        return QVariant();
    }
    case SubFolder: {
        const auto &x = static_cast<SubFolderInfo *>(index.internalPointer())->_subs[index.row()];
        switch (role) {
        case Qt::DisplayRole:
            //: Example text: "File.txt (23KB)"
            return x._size < 0 ? x._name : tr("%1 (%2)").arg(x._name, Utility::octetsToString(x._size));
        case Qt::ToolTipRole:
            return QString(QLatin1String("<qt>") + Utility::escape(x._size < 0 ? x._name : tr("%1 (%2)").arg(x._name, Utility::octetsToString(x._size))) + QLatin1String("</qt>"));
        case Qt::CheckStateRole:
            return x._checked;
        case Qt::DecorationRole:
            return QFileIconProvider().icon(x._isExternal ? QFileIconProvider::Network : QFileIconProvider::Folder);
        case Qt::ForegroundRole:
            if (x._isUndecided) {
                return QColor(Qt::red);
            }
            break;
        case FolderStatusDelegate::FolderPathRole: {
            auto f = x._folder;
            if (!f)
                return QVariant();
            return QVariant(f->path() + x._path);
        }
        }
    }
        return QVariant();
    case FetchLabel: {
        const auto x = static_cast<SubFolderInfo *>(index.internalPointer());
        switch (role) {
        case Qt::DisplayRole:
            if (x->_hasError) {
                return QVariant(tr("Error while loading the list of folders from the server.")
                    + QString("\n") + x->_lastErrorString);
            } else {
                return tr("Fetching folder list from server...");
            }
            break;
        default:
            return QVariant();
        }
    }
    case RootFolder:
        break;
    }

    const SubFolderInfo &folderInfo = _folders.at(index.row());
    auto f = folderInfo._folder;
    if (!f)
        return QVariant();

    const SubFolderInfo::Progress &progress = folderInfo._progress;
    const bool accountConnected = _accountState->isConnected();

    switch (role) {
    case FolderStatusDelegate::FolderPathRole:
        return f->shortGuiLocalPath();
    case FolderStatusDelegate::FolderSecondPathRole:
        return f->remotePath();
    case FolderStatusDelegate::FolderConflictMsg:
        return (f->syncResult().hasUnresolvedConflicts())
            ? QStringList(tr("There are unresolved conflicts. Click for details."))
            : QStringList();
    case FolderStatusDelegate::FolderErrorMsg:
        return f->syncResult().errorStrings();
    case FolderStatusDelegate::FolderInfoMsg:
        return f->useVirtualFiles()
            ? QStringList(tr("New files are being created as virtual files."))
            : QStringList();
    case FolderStatusDelegate::SyncRunning:
        return f->syncResult().status() == SyncResult::SyncRunning;
    case FolderStatusDelegate::HeaderRole:
        return f->shortGuiRemotePathOrAppName();
    case FolderStatusDelegate::FolderAliasRole:
        return f->alias();
    case FolderStatusDelegate::FolderSyncPaused:
        return f->syncPaused();
    case FolderStatusDelegate::FolderAccountConnected:
        return accountConnected;
    case Qt::ToolTipRole: {
        QString toolTip;
        if (!progress.isNull()) {
            return progress._progressString;
        }
        if (accountConnected)
            toolTip = Theme::instance()->statusHeaderText(f->syncResult().status());
        else
            toolTip = tr("Signed out");
        toolTip += "\n";
        toolTip += folderInfo._folder->path();
        return toolTip;
    }
    case FolderStatusDelegate::FolderStatusIconRole:
        if (accountConnected) {
            auto theme = Theme::instance();
            auto status = f->syncResult().status();
            if (f->syncPaused()) {
                return theme->folderDisabledIcon();
            } else {
                if (status == SyncResult::SyncPrepare) {
                    return theme->syncStateIcon(SyncResult::SyncRunning);
                } else if (status == SyncResult::Undefined) {
                    return theme->syncStateIcon(SyncResult::SyncRunning);
                } else {
                    // The "Problem" *result* just means some files weren't
                    // synced, so we show "Success" in these cases. But we
                    // do use the "Problem" *icon* for unresolved conflicts.
                    if (status == SyncResult::Success || status == SyncResult::Problem) {
                        if (f->syncResult().hasUnresolvedConflicts()) {
                            return theme->syncStateIcon(SyncResult::Problem);
                        } else {
                            return theme->syncStateIcon(SyncResult::Success);
                        }
                    } else {
                        return theme->syncStateIcon(status);
                    }
                }
            }
        } else {
            return Theme::instance()->folderOfflineIcon();
        }
    case FolderStatusDelegate::SyncProgressItemString:
        return progress._progressString;
    case FolderStatusDelegate::WarningCount:
        return progress._warningCount;
    case FolderStatusDelegate::SyncProgressOverallPercent:
        return progress._overallPercent;
    case FolderStatusDelegate::SyncProgressOverallString:
        return progress._overallSyncString;
    }
    return QVariant();
}
Ejemplo n.º 16
0
QIcon Resource::Icon() const
{
    return QFileIconProvider().icon(QFileInfo(m_FullFilePath));
}
Ejemplo n.º 17
0
/** Redefined. */
void AddressBarButton::paintEvent(QPaintEvent *)
{
	QStylePainter p(this);
	QRect r = rect().adjusted(0, 1, -1, -(1 + extra));
	static const int arrowWidth = r.height();

	QPalette palette = QApplication::palette();
	QLinearGradient g(rect().topLeft(), rect().bottomLeft());
	g.setColorAt(0, palette.base().color());
	g.setColorAt(1, palette.window().color());
	p.fillRect(r, g);

	// Compute size of rectangles to display text and right arrow
	if (_atLeastOneSubDir) {
		if (isLeftToRight()) {
			_arrowRect = QRect(r.width() - arrowWidth, r.y(), arrowWidth, r.height());
			_textRect = QRect(r.x(), r.y(), r.width() - arrowWidth, r.height());
		} else {
			_arrowRect = QRect(r.x(), r.y(), arrowWidth, r.height());
			_textRect = QRect(r.x() + arrowWidth, r.y(), r.width() - arrowWidth, r.height());
		}
	} else {
		_textRect = r.adjusted(0, 0, -5, 0);
	}

	// Highlight button if mouse is over
	QPoint pos = mapFromGlobal(QCursor::pos());
	p.save();
	QBrush brush;
	if (_addressBar->isDown()) {
		brush = palette.highlight().color().lighter();
	} else {
		brush = palette.highlight().color().lighter(lighterValue);
	}

	if (_highlighted) {
		p.setPen(palette.highlight().color());
		p.setBrush(brush);
		p.drawRect(_textRect);
		if (_atLeastOneSubDir) {
			p.drawRect(_arrowRect);
		}
	} else {
		if (_atLeastOneSubDir) {
			if (_textRect.contains(pos) || _arrowRect.contains(pos)) {
				p.setPen(palette.highlight().color());
				p.setBrush(brush);
				p.drawRect(_textRect);
				p.drawRect(_arrowRect);
			} else {
				p.setPen(Qt::NoPen);
				p.setBrush(Qt::NoBrush);
				p.drawRect(_textRect);
				p.drawRect(_arrowRect);
			}
		} else {
			if (_textRect.contains(pos)) {
				p.setPen(palette.highlight().color());
				p.setBrush(brush);
				p.drawRect(_textRect);
			}
		}
	}
	p.restore();

	// Draw folder's name
	QColor lighterBG = palette.highlight().color().lighter();
	QColor highlightedText = palette.highlightedText().color();

	if (rect().contains(pos) && SettingsPrivate::instance()->isCustomTextColorOverriden()) {
		p.setPen(palette.highlightedText().color());
	} else if (qAbs(lighterBG.value() - highlightedText.value()) > 128 && _highlighted) {
		p.setPen(highlightedText);
	} else {
		p.setPen(palette.text().color());
	}

	// Special case for root and drives
	bool root = false;
	if (_path.isRoot()) {
		QPixmap pixmap = QFileIconProvider().icon(QFileIconProvider::Computer).pixmap(20, 20);
		QString drive;
		if (_isAbsoluteRoot) {
			pixmap = QFileIconProvider().icon(QFileIconProvider::Computer).pixmap(20, 20);
			if (isLeftToRight()) {
				p.drawPixmap(2, 3, 20, 20, pixmap);
			} else {
				p.drawPixmap(18, 3, 20, 20, pixmap);
			}
		} else {
			drive = AddressBar::getVolumeInfo(_path.absolutePath());
			if (!_isAbsoluteRoot && !drive.isEmpty()) {
				// Add a small offset to simulate a pressed button
				if (_highlighted) {
					p.translate(1, 1);
				}
				p.drawText(_textRect.adjusted(5, 0, 0, 0), Qt::AlignCenter, drive);
			}
			pixmap = QFileIconProvider().icon(QFileIconProvider::Drive).pixmap(20, 20);
		}
	} else {
		if (!_path.dirName().isEmpty()) {
			// Add a small offset to simulate a pressed button
			if (_highlighted) {
				p.translate(1, 1);
			}
			p.drawText(_textRect.adjusted(0, 0, 0, 0), Qt::AlignCenter, _path.dirName());
		}
	}

	if (_atLeastOneSubDir) {
		QStyleOptionButton o;
		o.initFrom(this);
		p.save();
		p.setPen(Qt::NoPen);
		p.setBrush(o.palette.mid());
		if (root && _addressBar->hasHiddenFolders()) {
			/// Right To Left
			QPoint p1(o.rect.x() + 32, o.rect.y() + 11),
					p2(o.rect.x() + 29, o.rect.y() + 14),
					p2b(o.rect.x() + 29, o.rect.y() + 13),
					p3(o.rect.x() + 32, o.rect.y() + 16);
			p.save();
			p.setPen(Qt::black);
			p.setRenderHint(QPainter::Antialiasing);
			p.drawLine(p1, p2);
			p.drawLine(p2b, p3);
			p.translate(4, 0);
			p.drawLine(p1, p2);
			p.drawLine(p2b, p3);
			p.restore();
		} else {
			int w = _arrowRect.width() / 3;
			int h = this->rect().height() / 3;
			QRect indicatorArrow(_arrowRect.x() + w + 1, _arrowRect.y() + h, w, h);

			o.rect = indicatorArrow;
			p.setRenderHint(QPainter::Antialiasing);

			p.save();
			QPen pen(palette.mid().color());
			pen.setWidthF(1.5);
			pen.setJoinStyle(Qt::MiterJoin);
			p.setPen(pen);
			QPolygon pol;
			QPoint p1, p2, p3;
			if (_highlighted) {
				p.translate(0, -1);
				p1 = QPoint(o.rect.x(), o.rect.y() + o.rect.height() / 2);
				p2 = QPoint(o.rect.x() + o.rect.width(), o.rect.y() + o.rect.height() / 2);
				p3 = QPoint(o.rect.x() + o.rect.width() / 2, o.rect.y() + o.rect.height());
			} else if (isLeftToRight()) {
				p1 = QPoint(o.rect.x(), o.rect.y());
				p2 = QPoint(o.rect.x(), o.rect.y() + o.rect.height());
				p3 = QPoint(o.rect.x() + o.rect.width(), o.rect.y() + o.rect.height() / 2);
			} else {
				p1 = QPoint(o.rect.x() + o.rect.width(), o.rect.y());
				p2 = QPoint(o.rect.x() + o.rect.width(), o.rect.y() + o.rect.height());
				p3 = QPoint(o.rect.x(), o.rect.y() + o.rect.height() / 2);
			}
			pol.append(p1);
			pol.append(p2);
			pol.append(p3);
			p.drawPolygon(pol);
			p.restore();
			p.setRenderHint(QPainter::Antialiasing, false);
		}
		p.restore();
	}
}
Ejemplo n.º 18
0
void ConfigWindow::fillConfig()
{
	QString kernel_path = Config::value("kernel2Path").toString();
	QString window_path = Config::value("windowBinPath").toString();
	QString char_path = Config::value("charPath").toString();
	QMap<Data::FF7Version, QString> ff7PathList = Data::ff7AppPathList();

	listFF7->clear();
	QTreeWidgetItem *selectedItem = 0;
	QMapIterator<Data::FF7Version, QString> it(ff7PathList);

	while(it.hasNext()) {
		it.next();

		const QString &ff7Path = it.value();

		QTreeWidgetItem *item = new QTreeWidgetItem(QStringList(QDir::toNativeSeparators(ff7Path)));
		if(ff7Path.compare(Data::ff7AppPath(), Qt::CaseInsensitive) == 0) {
			selectedItem = item;
		}
		item->setData(0, Qt::UserRole, int(it.key()));
		listFF7->addTopLevelItem(item);
	}
	if(selectedItem)	listFF7->setCurrentItem(selectedItem);

	if(kernel_path.isEmpty()) {
		kernel_path = Data::ff7KernelPath() % "/kernel2.bin";
		kernelAutoChange(false);
	} else {
		kernelAuto->setChecked(true);
	}

	if(window_path.isEmpty()) {
		window_path = Data::ff7KernelPath() % "/window.bin";
		windowAutoChange(false);
	} else {
		windowAuto->setChecked(true);
	}

	if(char_path.isEmpty()) {
		char_path = Data::ff7DataPath() % "/field/char.lgp";
		charAutoChange(false);
	} else {
		charAuto->setChecked(true);
	}

	disableOGL->setChecked(!Config::value("OpenGL", true).toBool());

	kernelPath->setText(QDir::toNativeSeparators(QDir::cleanPath(kernel_path)));
	windowPath->setText(QDir::toNativeSeparators(QDir::cleanPath(window_path)));
	charPath->setText(QDir::toNativeSeparators(QDir::cleanPath(char_path)));

	windowColorTopLeft = Config::value("windowColorTopLeft", qRgb(0,88,176)).toInt();
	windowColorTopRight = Config::value("windowColorTopRight", qRgb(0,0,80)).toInt();
	windowColorBottomLeft = Config::value("windowColorBottomLeft", qRgb(0,0,128)).toInt();
	windowColorBottomRight = Config::value("windowColorBottomRight", qRgb(0,0,32)).toInt();

	optiText->setChecked(!Config::value("dontOptimizeTexts", false).toBool());
	japEnc->setChecked(Config::value("jp_txt", false).toBool());
	expandedByDefault->setChecked(Config::value("scriptItemExpandedByDefault", false).toBool());
	lzsNotCheck->setChecked(Config::value("lzsNotCheck", false).toBool());

	setWindowColors();

	for(int charId=0 ; charId<9; ++charId) {
		customNames << Config::value(QString("customCharName%1").arg(charId), Data::char_names.at(charId)).toString();
	}

	fillCharNameEdit();

	autoSizeMarginEdit->setValue(Config::value("autoSizeMarginRight", 14).toInt());
	spacedCharactersWidthEdit->setValue(Config::value("spacedCharactersWidth", 13).toInt());

	for(int j=0 ; j<listFF7->topLevelItemCount() ; ++j) {
		QCoreApplication::processEvents();
		QTreeWidgetItem *item = listFF7->topLevelItem(j);
		if(item == NULL)	break;
		item->setIcon(0, QFileIconProvider().icon(QFileInfo(item->text(0))));
	}
}